diff --git a/src/main/java/techreborn/init/ModParts.java b/src/main/java/techreborn/init/ModParts.java index 8b2c4c42a..64b4ded71 100644 --- a/src/main/java/techreborn/init/ModParts.java +++ b/src/main/java/techreborn/init/ModParts.java @@ -27,11 +27,5 @@ public class ModParts { ModPartRegistry.masterProvider = provider; } } - for (int i = 0; i < 13; i++) { - Item stack = ModPartRegistry.itemParts.get("Cable." + i); - if(stack != null){ - stackCable.put(i, new ItemStack(stack)); - } - } } } diff --git a/src/main/java/techreborn/partSystem/ModPartRegistry.java b/src/main/java/techreborn/partSystem/ModPartRegistry.java index a5fe4575b..460da6056 100644 --- a/src/main/java/techreborn/partSystem/ModPartRegistry.java +++ b/src/main/java/techreborn/partSystem/ModPartRegistry.java @@ -45,6 +45,8 @@ public class ModPartRegistry { itemParts.put(modPart.getName(), part); if(modPart instanceof CablePart){ GameRegistry.addShapelessRecipe(new ItemStack(part), IC2Items.getItem(CablePart.getTextureNameFromType(((CablePart) modPart).type))); + ((CablePart) modPart).stack = new ItemStack(part); + ModParts.stackCable.put(((CablePart) modPart).type, new ItemStack(part)); } } diff --git a/src/main/java/techreborn/partSystem/fmp/FMPModPart.java b/src/main/java/techreborn/partSystem/fmp/FMPModPart.java index 80bffac0e..a3d1501f1 100644 --- a/src/main/java/techreborn/partSystem/fmp/FMPModPart.java +++ b/src/main/java/techreborn/partSystem/fmp/FMPModPart.java @@ -9,12 +9,14 @@ import java.util.List; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import techreborn.lib.Location; import techreborn.lib.vecmath.Vecs3d; import techreborn.lib.vecmath.Vecs3dCube; import techreborn.partSystem.ModPart; +import techreborn.util.LogHelper; import uk.co.qmunity.lib.client.render.RenderHelper; import codechicken.lib.raytracer.IndexedCuboid6; import codechicken.lib.vec.Cuboid6; @@ -178,10 +180,23 @@ public class FMPModPart extends TMultiPart implements TSlottedPart, @Override public boolean renderStatic(Vector3 pos, int pass) { + boolean render; RenderHelper.instance.setRenderCoords(getWorld(), (int) pos.x, (int) pos.y, (int) pos.z); - iModPart.renderStatic(new Vecs3d((int) pos.x, (int) pos.y, (int) pos.z), RenderHelper.instance, pass); + render = iModPart.renderStatic(new Vecs3d((int) pos.x, (int) pos.y, (int) pos.z), RenderHelper.instance, pass); RenderHelper.instance.reset(); - return false; - + return render; } + + @Override + public Iterable getDrops() { + List stackArrayList = new ArrayList(); + if(iModPart.getItem() != null){ + stackArrayList.add(iModPart.getItem()); + } else { + LogHelper.error("Part " + iModPart.getName() + " has a null drop"); + } + return stackArrayList; + } + + } diff --git a/src/main/java/techreborn/partSystem/parts/CablePart.java b/src/main/java/techreborn/partSystem/parts/CablePart.java index baae47fb8..93ae57c08 100644 --- a/src/main/java/techreborn/partSystem/parts/CablePart.java +++ b/src/main/java/techreborn/partSystem/parts/CablePart.java @@ -15,9 +15,8 @@ import java.util.Map; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import ic2.core.network.NetworkManager; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -25,6 +24,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import techreborn.client.render.RenderCablePart; +import techreborn.init.ModParts; import techreborn.lib.Functions; import techreborn.lib.vecmath.Vecs3d; import techreborn.lib.vecmath.Vecs3dCube; @@ -41,6 +41,7 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile protected ForgeDirection[] dirs = ForgeDirection.values(); private boolean[] connections = new boolean[6]; public boolean addedToEnergyNet = false; + public ItemStack stack; public int type = 0;//TODO save this to nbt and not use the constructor. @@ -194,7 +195,7 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile @Override public ItemStack getItem() { - return new ItemStack(ModPartUtils.getItemForPart(getName())); + return ModParts.stackCable.get(type); } public boolean shouldConnectTo(TileEntity entity, ForgeDirection dir) {