Work on fixing cover dectection

This commit is contained in:
modmuss50 2015-04-25 09:21:06 +01:00
parent 60141026ec
commit 0270a917a0
6 changed files with 45 additions and 6 deletions

View file

@ -27,4 +27,6 @@ public interface IPartProvider {
ModPart modPart);
public boolean isTileFromProvider(TileEntity tileEntity);
public IModPart getPartFromWorld(World world, Location location, String name);
}

View file

@ -4,6 +4,7 @@
package techreborn.partSystem;
import me.modmuss50.mods.lib.mod.IMod;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import techreborn.lib.Location;
@ -25,8 +26,7 @@ public class ModPartUtils {
return false;
}
public static boolean checkOcclusion(World world, int x, int y, int z,
Vecs3dCube cube) {
public static boolean checkOcclusion(World world, int x, int y, int z, Vecs3dCube cube) {
return !checkOcclusion(world, new Location(x, y, z), cube);
}
@ -80,4 +80,15 @@ public class ModPartUtils {
}
return null;
}
public static IModPart getPartFromWorld(World world, Location location, String name){
for (IPartProvider partProvider : ModPartRegistry.providers) {
IModPart tempPart = null;
tempPart = partProvider.getPartFromWorld(world, location, name);
if(tempPart != null){
return tempPart;
}
}
return null;
}
}

View file

@ -13,6 +13,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.lib.Location;
import techreborn.lib.vecmath.Vecs3dCube;
import techreborn.partSystem.IModPart;
import techreborn.partSystem.IPartProvider;
import techreborn.partSystem.ModPart;
import techreborn.partSystem.ModPartRegistry;
@ -79,6 +80,17 @@ public class QModPartFactory implements IPartFactory, IPartProvider {
return tileEntity instanceof TileMultipart;
}
@Override
public IModPart getPartFromWorld(World world, Location location, String name) {
IPart part = MultipartCompatibility.getPart(world, location.getX(), location.getY(), location.getZ(), name);
if(part != null){
if(part instanceof QModPart){
return ((QModPart) part).iModPart;
}
}
return null;
}
public String getCreatedPartType(ItemStack item, EntityPlayer player,
World world, MovingObjectPosition mop, ModPart modPart) {
return modPart.getName();

View file

@ -16,6 +16,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.lib.Location;
import techreborn.lib.vecmath.Vecs3dCube;
import techreborn.partSystem.IModPart;
import techreborn.partSystem.IPartProvider;
import techreborn.partSystem.ModPart;
@ -116,4 +117,10 @@ public class WorldProvider implements IPartProvider {
public boolean isTileFromProvider(TileEntity tileEntity) {
return tileEntity instanceof TileEntityModPart;
}
//TODO
@Override
public IModPart getPartFromWorld(World world, Location location, String name) {
return null;
}
}

View file

@ -16,6 +16,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import techreborn.lib.Location;
import techreborn.lib.vecmath.Vecs3dCube;
import techreborn.partSystem.IModPart;
import techreborn.partSystem.IPartProvider;
import techreborn.partSystem.ModPart;
import techreborn.partSystem.ModPartRegistry;
@ -65,6 +66,12 @@ public class FMPFactory implements MultiPartRegistry.IPartFactory,
return tileEntity instanceof TileMultipart;
}
//TODO
@Override
public IModPart getPartFromWorld(World world, Location location, String name) {
return null;
}
@Override
public String modID() {
return "ForgeMultipart";

View file

@ -528,12 +528,12 @@ public class CablePart extends ModPart implements IEnergyConductor {
@Override
public boolean acceptsEnergyFrom(TileEntity tileEntity,
ForgeDirection forgeDirection) {
return true;
return connectedSides.containsKey(forgeDirection);
}
@Override
public boolean emitsEnergyTo(TileEntity tileEntity,
ForgeDirection forgeDirection) {
return true;
return connectedSides.containsKey(forgeDirection);
}
}