diff options
Diffstat (limited to 'ihl/items_blocks')
| -rw-r--r-- | ihl/items_blocks/FlexibleCableItem.java | 723 | ||||
| -rw-r--r-- | ihl/items_blocks/ItemSubstance.java | 4 |
2 files changed, 312 insertions, 415 deletions
diff --git a/ihl/items_blocks/FlexibleCableItem.java b/ihl/items_blocks/FlexibleCableItem.java index 54710cb..7fd2583 100644 --- a/ihl/items_blocks/FlexibleCableItem.java +++ b/ihl/items_blocks/FlexibleCableItem.java @@ -37,529 +37,428 @@ import ihl.utils.IHLUtils; public class FlexibleCableItem extends Item implements IWire {
@SideOnly(Side.CLIENT)
- IIcon thickCopper,
- thinIron,
- thickIron,
- insulatedCopperRawruber,
- insulatedThickCopperRawruber,
- insulatedIronRawruber,
- insulatedThickIronRawruber,
- insulatedCopperRuber,
- insulatedThickCopperRuber,
- insulatedIronRuber,
- insulatedThickIronRuber;
- public static FlexibleCableItem instance;
+ IIcon thickCopper, thinIron, thickIron, insulatedCopperRawruber, insulatedThickCopperRawruber,
+ insulatedIronRawruber, insulatedThickIronRawruber, insulatedCopperRuber, insulatedThickCopperRuber,
+ insulatedIronRuber, insulatedThickIronRuber;
+ public static FlexibleCableItem instance;
public final Set<String> yellowColoredWires = new HashSet<String>(3);
- public boolean isDataCable=false;
-
- public FlexibleCableItem()
- {
- super();
- yellowColoredWires.add("Gold");
- yellowColoredWires.add("Copper");
- yellowColoredWires.add("Bronze");
+ public boolean isDataCable = false;
+
+ public FlexibleCableItem() {
+ super();
+ yellowColoredWires.add("Gold");
+ yellowColoredWires.add("Copper");
+ yellowColoredWires.add("Bronze");
this.setCreativeTab(IHLCreativeTab.tab);
this.setMaxStackSize(1);
this.setFull3D();
- instance=this;
+ instance = this;
}
@Override
@SideOnly(Side.CLIENT)
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void getSubItems(Item item, CreativeTabs tabs, List itemList)
- {
- itemList.add(IHLUtils.getUninsulatedWire("Copper", 160, 15));
- itemList.add(IHLUtils.getUninsulatedWire("Copper", 160, 240));
- itemList.add(IHLUtils.getUninsulatedWire("Steel", 160, 15));
- itemList.add(IHLUtils.getUninsulatedWire("Steel", 160, 240));
- itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 15,"RawRubber",100));
- itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 240,"RawRubber",100));
- itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 15,"RawRubber",100));
- itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 240,"RawRubber",100));
- itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 15,"Rubber",100));
- itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 240,"Rubber",100));
- itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 15,"Rubber",100));
- itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 240,"Rubber",100));
- }
-
- public static void init()
- {
- GameRegistry.registerItem(new FlexibleCableItem(),"copperWire");
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList) {
+ itemList.add(IHLUtils.getUninsulatedWire("Copper", 160, 15));
+ itemList.add(IHLUtils.getUninsulatedWire("Copper", 160, 240));
+ itemList.add(IHLUtils.getUninsulatedWire("Steel", 160, 15));
+ itemList.add(IHLUtils.getUninsulatedWire("Steel", 160, 240));
+ itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 15, "RawRubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 240, "RawRubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 15, "RawRubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 240, "RawRubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 15, "Rubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 240, "Rubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 15, "Rubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 240, "Rubber", 100));
+ }
+
+ public static void init() {
+ GameRegistry.registerItem(new FlexibleCableItem(), "copperWire");
}
-
- @Override
- public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
- {
- TileEntity t = world.getTileEntity(x, y, z);
- short facing = IHLUtils.getFacingFromPlayerView(player, true);
- if(!world.isRemote && t instanceof IEnergyTile && !(t instanceof IMultiPowerCableHolder) && !(t instanceof ICableHolder))
- {
- ForgeDirection direction = ForgeDirection.getOrientation(facing);
- x+=direction.offsetX;
- y+=direction.offsetY;
- z+=direction.offsetZ;
- t=world.getTileEntity(x, y, z);
- if(IHLUtils.isBlockCanBeReplaced(world, x,y,z))
- {
- world.setBlock(x, y, z, IHLMod.cableAnchorBlock);
- }
- else if(!(t instanceof AnchorTileEntity))
- {
- return false;
- }
- t=world.getTileEntity(x, y, z);
- }
- if(world.isRemote)world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "step.stone", 1.0F, 0.8F);
- if(!world.isRemote && t!=null &&
- ((t instanceof IEnergyNetNode && !isDataCable) ||
- (t instanceof IMultiPowerCableHolder && !isDataCable) ||
- (t instanceof IDataCableHolder && isDataCable)) &&
- stack.stackTagCompound.getInteger("fullLength")>=1)
- {
- double ppx,ppy,ppz;
- ICableHolder te;
- if(t instanceof IMultiPowerCableHolder)
- {
- facing = ((IMultiPowerCableHolder)t).getSide(player);
- if(facing==-1)
- {
- return false;
- }
- else
- {
- te = ((IMultiPowerCableHolder)t).getEnergyNetNode(facing);
- }
- }
- else
- {
- te = (ICableHolder)t;
- }
- ppx=te.getPortPos(player)[0];
- ppy=te.getPortPos(player)[1];
- ppz=te.getPortPos(player)[2];
- if(stack.stackTagCompound.getBoolean("firstConnection"))
- {
- int x1 = stack.stackTagCompound.getInteger("connectorX");
- int y1 = stack.stackTagCompound.getInteger("connectorY");
- int z1 = stack.stackTagCompound.getInteger("connectorZ");
- int l1=stack.stackTagCompound.getInteger("fullLength");
- int l2=stack.stackTagCompound.getInteger("length");
- if(x==x1 && y==y1 && z==z1)
- {
- this.cleanUp(stack.stackTagCompound.getInteger("chainUID"));
- stack.stackTagCompound.setBoolean("firstConnection", false);
- stack.stackTagCompound.setInteger("length", l1);
- return true;
- }
- int t2DimensionId = stack.stackTagCompound.getInteger("connectorDimensionId");
- short facing2 = stack.stackTagCompound.getShort("connectorFacing");
- TileEntity t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x1, y1, z1);
- if(t2==null)
- {
- stack.stackTagCompound.setBoolean("firstConnection", false);
- return false;
- }
- else
- {
- if(t2 instanceof IMultiPowerCableHolder)
- {
- te = ((IMultiPowerCableHolder)t2).getEnergyNetNode(facing);
- }
- else
- {
- te = (ICableHolder)t2;
- }
- te.setCableCheck(true);
- }
- this.connect(t,facing, t2, facing2, stack);
- stack.stackTagCompound.setInteger("fullLength", l2);
- if(l2<=0)
- {
- stack.stackSize--;
- }
- stack.stackTagCompound.setBoolean("firstConnection", false);
- stack.stackTagCompound.setInteger("chainArrangeNumber",stack.stackTagCompound.getInteger("chainArrangeNumber")+1);
- x=x1;
- y=y1;
- z=z1;
- }
- else
- {
- te.setCableCheck(false);
- stack.stackTagCompound.setBoolean("firstConnection", true);
- stack.stackTagCompound.setInteger("connectorX", x);
- stack.stackTagCompound.setInteger("connectorY", y);
- stack.stackTagCompound.setInteger("connectorZ", z);
- stack.stackTagCompound.setShort("connectorFacing", facing);
- stack.stackTagCompound.setInteger("connectorDimensionId", world.provider.dimensionId);
- stack.stackTagCompound.setInteger("prevDimensionId", world.provider.dimensionId);
- stack.stackTagCompound.setInteger("chainArrangeNumber",0);
- stack.stackTagCompound.setInteger("chainUID",world.rand.nextInt());
- stack.stackTagCompound.setDouble("prevNodePosX",ppx);
- stack.stackTagCompound.setDouble("prevNodePosY",ppy);
- stack.stackTagCompound.setDouble("prevNodePosZ",ppz);
- }
- NodeEntity node = newNode(world, player.posX, player.posY, player.posZ, stack, stack.stackTagCompound.getInteger("chainArrangeNumber"),x,y,z);
- node.virtualNodePosX=ppx;
- node.virtualNodePosY=ppy;
- node.virtualNodePosZ=ppz;
- return true;
- }
- else
- {
- return false;
- }
- }
- protected void connect(TileEntity t1,short facing, TileEntity t2, short facing2, ItemStack stack)
- {
- IEnergyNetNode te;
- IEnergyNetNode te1;
- if(t1 instanceof IEnergyNetNode)
- {
- te = (IEnergyNetNode)t1;
- }
- else
- {
- te = ((IMultiPowerCableHolder)t1).getEnergyNetNode(facing);
- }
- if(t2 instanceof IEnergyNetNode)
- {
- te1 = (IEnergyNetNode)t2;
- }
- else
- {
- te1 = ((IMultiPowerCableHolder)t2).getEnergyNetNode(facing2);
- }
- int newGridID=IHLMod.enet.mergeGrids(te.getGridID(),te1.getGridID());
- int l1=stack.stackTagCompound.getInteger("fullLength");
- int l2=stack.stackTagCompound.getInteger("length");
+ @Override
+ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7,
+ float par8, float par9, float par10) {
+ TileEntity t = world.getTileEntity(x, y, z);
+ short facing = IHLUtils.getFacingFromPlayerView(player, true);
+ if (!world.isRemote && t instanceof IEnergyTile && !(t instanceof IMultiPowerCableHolder)
+ && !(t instanceof ICableHolder)) {
+ ForgeDirection direction = ForgeDirection.getOrientation(facing);
+ x += direction.offsetX;
+ y += direction.offsetY;
+ z += direction.offsetZ;
+ t = world.getTileEntity(x, y, z);
+ if (IHLUtils.isBlockCanBeReplaced(world, x, y, z)) {
+ world.setBlock(x, y, z, IHLMod.cableAnchorBlock);
+ } else if (!(t instanceof AnchorTileEntity)) {
+ return false;
+ }
+ t = world.getTileEntity(x, y, z);
+ }
+ if (world.isRemote)
+ world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "step.stone", 1.0F, 0.8F);
+ if (!world.isRemote && t != null
+ && ((t instanceof IEnergyNetNode && !isDataCable)
+ || (t instanceof IMultiPowerCableHolder && !isDataCable)
+ || (t instanceof IDataCableHolder && isDataCable))
+ && stack.stackTagCompound.getInteger("fullLength") >= 1) {
+ double ppx, ppy, ppz;
+ ICableHolder te;
+ if (t instanceof IMultiPowerCableHolder) {
+ facing = ((IMultiPowerCableHolder) t).getSide(player);
+ if (facing == -1) {
+ return false;
+ } else {
+ te = ((IMultiPowerCableHolder) t).getEnergyNetNode(facing);
+ }
+ } else {
+ te = (ICableHolder) t;
+ }
+ ppx = te.getPortPos(player)[0];
+ ppy = te.getPortPos(player)[1];
+ ppz = te.getPortPos(player)[2];
+ if (stack.stackTagCompound.getBoolean("firstConnection")) {
+ int x1 = stack.stackTagCompound.getInteger("connectorX");
+ int y1 = stack.stackTagCompound.getInteger("connectorY");
+ int z1 = stack.stackTagCompound.getInteger("connectorZ");
+ int l1 = stack.stackTagCompound.getInteger("fullLength");
+ int l2 = stack.stackTagCompound.getInteger("length");
+ if (x == x1 && y == y1 && z == z1) {
+ this.cleanUp(stack.stackTagCompound.getInteger("chainUID"));
+ stack.stackTagCompound.setBoolean("firstConnection", false);
+ stack.stackTagCompound.setInteger("length", l1);
+ return true;
+ }
+ int t2DimensionId = stack.stackTagCompound.getInteger("connectorDimensionId");
+ short facing2 = stack.stackTagCompound.getShort("connectorFacing");
+ TileEntity t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x1, y1,
+ z1);
+ if (t2 == null) {
+ stack.stackTagCompound.setBoolean("firstConnection", false);
+ return false;
+ } else {
+ if (t2 instanceof IMultiPowerCableHolder) {
+ te = ((IMultiPowerCableHolder) t2).getEnergyNetNode(facing);
+ } else {
+ te = (ICableHolder) t2;
+ }
+ te.setCableCheck(true);
+ }
+ this.connect(t, facing, t2, facing2, stack);
+ stack.stackTagCompound.setInteger("fullLength", l2);
+ if (l2 <= 0) {
+ stack.stackSize--;
+ }
+ stack.stackTagCompound.setBoolean("firstConnection", false);
+ stack.stackTagCompound.setInteger("chainArrangeNumber",
+ stack.stackTagCompound.getInteger("chainArrangeNumber") + 1);
+ x = x1;
+ y = y1;
+ z = z1;
+ } else {
+ te.setCableCheck(false);
+ stack.stackTagCompound.setBoolean("firstConnection", true);
+ stack.stackTagCompound.setInteger("connectorX", x);
+ stack.stackTagCompound.setInteger("connectorY", y);
+ stack.stackTagCompound.setInteger("connectorZ", z);
+ stack.stackTagCompound.setShort("connectorFacing", facing);
+ stack.stackTagCompound.setInteger("connectorDimensionId", world.provider.dimensionId);
+ stack.stackTagCompound.setInteger("prevDimensionId", world.provider.dimensionId);
+ stack.stackTagCompound.setInteger("chainArrangeNumber", 0);
+ stack.stackTagCompound.setInteger("chainUID", world.rand.nextInt());
+ stack.stackTagCompound.setDouble("prevNodePosX", ppx);
+ stack.stackTagCompound.setDouble("prevNodePosY", ppy);
+ stack.stackTagCompound.setDouble("prevNodePosZ", ppz);
+ }
+ NodeEntity node = newNode(world, player.posX, player.posY, player.posZ, stack,
+ stack.stackTagCompound.getInteger("chainArrangeNumber"), x, y, z);
+ node.virtualNodePosX = ppx;
+ node.virtualNodePosY = ppy;
+ node.virtualNodePosZ = ppz;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ protected void connect(TileEntity t1, short facing, TileEntity t2, short facing2, ItemStack stack) {
+ IEnergyNetNode te;
+ IEnergyNetNode te1;
+ if (t1 instanceof IEnergyNetNode) {
+ te = (IEnergyNetNode) t1;
+ } else {
+ te = ((IMultiPowerCableHolder) t1).getEnergyNetNode(facing);
+ }
+ if (t2 instanceof IEnergyNetNode) {
+ te1 = (IEnergyNetNode) t2;
+ } else {
+ te1 = ((IMultiPowerCableHolder) t2).getEnergyNetNode(facing2);
+ }
+ int newGridID = IHLMod.enet.mergeGrids(te.getGridID(), te1.getGridID());
+ int l1 = stack.stackTagCompound.getInteger("fullLength");
+ int l2 = stack.stackTagCompound.getInteger("length");
NBTTagCompound cable = (NBTTagCompound) stack.stackTagCompound.copy();
- cable.setInteger("length", l1-l2);
+ cable.setInteger("length", l1 - l2);
cable.setBoolean("firstConnection", false);
cable.setInteger("connectorX1", t1.xCoord);
cable.setInteger("connectorY1", t1.yCoord);
cable.setInteger("connectorZ1", t1.zCoord);
cable.setShort("connectorFacing1", facing);
cable.setInteger("connectorDimensionId1", t1.getWorldObj().provider.dimensionId);
- if(te.addCable(cable) && te1.addCable(cable))
- {
- te.setGrid(newGridID);
- te1.setGrid(newGridID);
+ if (te.addCable(cable) && te1.addCable(cable)) {
+ te.setGrid(newGridID);
+ te1.setGrid(newGridID);
}
- }
-
- private int getTransverseSection(ItemStack stack)
- {
- if(stack.stackTagCompound==null)
- {
- stack.stackTagCompound=new NBTTagCompound();
+ }
+
+ private int getTransverseSection(ItemStack stack) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
}
return stack.stackTagCompound.getInteger("transverseSection");
}
- public String getMaterial(ItemStack stack)
- {
- if(stack.stackTagCompound==null)
- {
- stack.stackTagCompound=new NBTTagCompound();
+ public String getMaterial(ItemStack stack) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
}
return stack.stackTagCompound.getString("material");
}
- public int getVoltageLimit(ItemStack stack)
- {
- if(stack.stackTagCompound==null)
- {
- stack.stackTagCompound=new NBTTagCompound();
+ public int getVoltageLimit(ItemStack stack) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
+ }
+ if (stack.stackTagCompound.hasKey("maxVoltage")) {
+ return stack.stackTagCompound.getInteger("maxVoltage");
}
- if(stack.stackTagCompound.hasKey("maxVoltage"))
- {
- return stack.stackTagCompound.getInteger("maxVoltage");
- }
return 0;
}
- private long getResistance(ItemStack stack)
- {
- if(stack.stackTagCompound==null)
- {
- stack.stackTagCompound=new NBTTagCompound();
+ private long getResistance(ItemStack stack) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
}
return IHLUtils.getResistance(stack.stackTagCompound);
}
- private void cleanUp(int uid)
- {
+ private void cleanUp(int uid) {
Set<NodeEntity> cs = IHLMod.proxy.nodeEntityRegistry.get(uid);
- if(cs!=null)
- {
- for(NodeEntity ne:cs)
- {
- if(ne!=null)
- {
+ if (cs != null) {
+ for (NodeEntity ne : cs) {
+ if (ne != null) {
ne.setDead();
}
}
}
}
-
- @Override
- public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem)
- {
- if(!world.isRemote && stack.stackTagCompound!=null)
- {
- if(stack.stackTagCompound.getBoolean("firstConnection"))
- {
- int leight = stack.stackTagCompound.getInteger("length");
- if(leight>0)
- {
- double pnpx = stack.stackTagCompound.getDouble("prevNodePosX");
- double pnpy = stack.stackTagCompound.getDouble("prevNodePosY");
- double pnpz = stack.stackTagCompound.getDouble("prevNodePosZ");
- double ppx=entity.posX;
- double ppy=entity.posY;
- double ppz=entity.posZ;
-
- if(pnpx!=0D && pnpy!=0D && pnpz!=0D)
- {
- double sqd = (ppx - pnpx)*(ppx - pnpx) + (ppy - pnpy)*(ppy - pnpy) + (ppz - pnpz)*(ppz - pnpz);
- if(sqd>2D)
- {
- int can = stack.stackTagCompound.getInteger("chainArrangeNumber")+1;
- int cx = stack.stackTagCompound.getInteger("connectorX");
- int cy = stack.stackTagCompound.getInteger("connectorY");
- int cz = stack.stackTagCompound.getInteger("connectorZ");
- NodeEntity node = newNode(world, ppx, ppy, ppz, stack, can,cx,cy,cz);
- node.shouldFollowPlayer=true;
- node.virtualNodePosX=ppx+(ppx - pnpx)*2;
- node.virtualNodePosY=ppy+(ppy - pnpy)*2;
- node.virtualNodePosZ=ppz+(ppz - pnpz)*2;
- stack.stackTagCompound.setInteger("chainArrangeNumber",can);
- stack.stackTagCompound.setDouble("prevNodePosX",ppx);
- stack.stackTagCompound.setDouble("prevNodePosY",ppy);
- stack.stackTagCompound.setDouble("prevNodePosZ",ppz);
- stack.stackTagCompound.setInteger("length",--leight);
- stack.stackTagCompound.setInteger("prevDimensionId", world.provider.dimensionId);
- }
- }
- }
- }
- }
- }
-
- public void onPlayerTeleport(PlayerChangedDimensionEvent event)
- {
+ @Override
+ public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) {
+ if (!world.isRemote && stack.stackTagCompound != null) {
+ if (stack.stackTagCompound.getBoolean("firstConnection")) {
+ int leight = stack.stackTagCompound.getInteger("length");
+ if (leight > 0) {
+ double pnpx = stack.stackTagCompound.getDouble("prevNodePosX");
+ double pnpy = stack.stackTagCompound.getDouble("prevNodePosY");
+ double pnpz = stack.stackTagCompound.getDouble("prevNodePosZ");
+ double ppx = entity.posX;
+ double ppy = entity.posY;
+ double ppz = entity.posZ;
+
+ if (pnpx != 0D && pnpy != 0D && pnpz != 0D) {
+ double sqd = (ppx - pnpx) * (ppx - pnpx) + (ppy - pnpy) * (ppy - pnpy)
+ + (ppz - pnpz) * (ppz - pnpz);
+ if (sqd > 2D) {
+ int can = stack.stackTagCompound.getInteger("chainArrangeNumber") + 1;
+ int cx = stack.stackTagCompound.getInteger("connectorX");
+ int cy = stack.stackTagCompound.getInteger("connectorY");
+ int cz = stack.stackTagCompound.getInteger("connectorZ");
+ NodeEntity node = newNode(world, ppx, ppy, ppz, stack, can, cx, cy, cz);
+ node.shouldFollowPlayer = true;
+ node.virtualNodePosX = ppx + (ppx - pnpx) * 2;
+ node.virtualNodePosY = ppy + (ppy - pnpy) * 2;
+ node.virtualNodePosZ = ppz + (ppz - pnpz) * 2;
+ stack.stackTagCompound.setInteger("chainArrangeNumber", can);
+ stack.stackTagCompound.setDouble("prevNodePosX", ppx);
+ stack.stackTagCompound.setDouble("prevNodePosY", ppy);
+ stack.stackTagCompound.setDouble("prevNodePosZ", ppz);
+ stack.stackTagCompound.setInteger("length", --leight);
+ stack.stackTagCompound.setInteger("prevDimensionId", world.provider.dimensionId);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void onPlayerTeleport(PlayerChangedDimensionEvent event) {
EntityPlayer player = event.player;
- for(ItemStack stack:player.inventory.mainInventory)
- {
- if(stack!=null && stack.getItem() instanceof FlexibleCableItem)
- {
- if(stack.stackTagCompound.getBoolean("firstConnection"))
- {
+ for (ItemStack stack : player.inventory.mainInventory) {
+ if (stack != null && stack.getItem() instanceof FlexibleCableItem) {
+ if (stack.stackTagCompound.getBoolean("firstConnection")) {
int can = -1;
- Set<NodeEntity> ns = IHLMod.proxy.nodeEntityRegistry.get(stack.stackTagCompound.getInteger("chainUID"));
- if(ns!=null)
- {
+ Set<NodeEntity> ns = IHLMod.proxy.nodeEntityRegistry
+ .get(stack.stackTagCompound.getInteger("chainUID"));
+ if (ns != null) {
NodeEntity lastNode = null;
- for(NodeEntity node:ns)
- {
- node.shouldFollowPlayer=false;
- if(node.chainArrangeNumber>can)
- {
- lastNode=node;
- can=node.chainArrangeNumber;
+ for (NodeEntity node : ns) {
+ node.shouldFollowPlayer = false;
+ if (node.chainArrangeNumber > can) {
+ lastNode = node;
+ can = node.chainArrangeNumber;
}
}
- if(lastNode!=null)
- {
+ if (lastNode != null) {
lastNode.setVirtualNodePosToNearestPortal();
}
}
double[] cc = IHLUtils.tracePlayerView(player);
- can = stack.stackTagCompound.getInteger("chainArrangeNumber")+1;
- int cx = stack.stackTagCompound.getInteger("connectorX");
- int cy = stack.stackTagCompound.getInteger("connectorY");
- int cz = stack.stackTagCompound.getInteger("connectorZ");
- int leight = stack.stackTagCompound.getInteger("length");
- NodeEntity node = newNode(MinecraftServer.getServer().worldServerForDimension(event.toDim), cc[0], player.posY, cc[2], stack, can,cx,cy,cz);
+ can = stack.stackTagCompound.getInteger("chainArrangeNumber") + 1;
+ int cx = stack.stackTagCompound.getInteger("connectorX");
+ int cy = stack.stackTagCompound.getInteger("connectorY");
+ int cz = stack.stackTagCompound.getInteger("connectorZ");
+ int leight = stack.stackTagCompound.getInteger("length");
+ NodeEntity node = newNode(MinecraftServer.getServer().worldServerForDimension(event.toDim), cc[0],
+ player.posY, cc[2], stack, can, cx, cy, cz);
node.setVirtualNodePosToNearestPortal();
- stack.stackTagCompound.setInteger("chainArrangeNumber",can);
- stack.stackTagCompound.setDouble("prevNodePosX",cc[0]);
- stack.stackTagCompound.setDouble("prevNodePosY",cc[1]);
- stack.stackTagCompound.setDouble("prevNodePosZ",cc[2]);
- stack.stackTagCompound.setInteger("length",--leight);
- stack.stackTagCompound.setInteger("prevDimensionId", event.toDim);
+ stack.stackTagCompound.setInteger("chainArrangeNumber", can);
+ stack.stackTagCompound.setDouble("prevNodePosX", cc[0]);
+ stack.stackTagCompound.setDouble("prevNodePosY", cc[1]);
+ stack.stackTagCompound.setDouble("prevNodePosZ", cc[2]);
+ stack.stackTagCompound.setInteger("length", --leight);
+ stack.stackTagCompound.setInteger("prevDimensionId", event.toDim);
}
}
}
}
-
- protected NodeEntity newNode(World world, double ppx, double ppy, double ppz, ItemStack stack, int can, int x, int y, int z)
- {
- PowerCableNodeEntity node = new PowerCableNodeEntity(world);
+ protected NodeEntity newNode(World world, double ppx, double ppy, double ppz, ItemStack stack, int can, int x,
+ int y, int z) {
+ PowerCableNodeEntity node = new PowerCableNodeEntity(world);
node.setPosition(ppx, ppy, ppz);
node.setChainUniqueID(stack.stackTagCompound.getInteger("chainUID"));
short facing = stack.stackTagCompound.getShort("connectorFacing");
int dimensionId = stack.stackTagCompound.getInteger("connectorDimensionId");
- node.setAnchor(x, y, z,facing,dimensionId);
- node.chainArrangeNumber=can;
+ node.setAnchor(x, y, z, facing, dimensionId);
+ node.chainArrangeNumber = can;
node.colorIndex = this.getColor(stack);
node.addCable((NBTTagCompound) stack.stackTagCompound.copy());
- if(stack.stackTagCompound.hasKey("insulationMaterial"))
- {
- node.type=1;
- }
- else
- {
- node.type=0;
+ if (stack.stackTagCompound.hasKey("insulationMaterial")) {
+ node.type = 1;
+ } else {
+ node.type = 0;
}
world.spawnEntityInWorld(node);
return node;
- }
+ }
- private int getColor(ItemStack stack)
- {
- if(!stack.stackTagCompound.hasKey("insulationMaterial"))
- {
- if(yellowColoredWires.contains(this.getMaterial(stack)))
- {
+ private int getColor(ItemStack stack) {
+ if (!stack.stackTagCompound.hasKey("insulationMaterial")) {
+ if (yellowColoredWires.contains(this.getMaterial(stack))) {
return 0xFF9900;
- }
- else
- {
+ } else {
return 0xAAAABB;
}
- }
+ }
return 0xFFFFFF;
}
@Override
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag)
- {
- if(itemStack.stackTagCompound!=null)
- {
- info.add("Length: " + itemStack.stackTagCompound.getInteger("length") +" m");
- info.add("Wire material: " + this.getMaterial(itemStack));
- info.add("Resistivity: " + this.getResistance(itemStack)/1000F + " V^2/(EU*m)");
- info.add("Transverse section: " + this.getTransverseSection(itemStack)/10F + " sq. mm.");
- if(itemStack.stackTagCompound.hasKey("insulationMaterial"))
- {
- info.add("Insulation material: "+this.getInsulationMaterial(itemStack));
- info.add("Insulation thickness: " + this.getInsulationThickness(itemStack)/10f+" mm");
- info.add("Insulation breakdown voltage: "+ this.getVoltageLimit(itemStack)/1000 + " kV");
- }
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) {
+ if (itemStack.stackTagCompound != null) {
+ info.add("Length: " + itemStack.stackTagCompound.getInteger("length") + " m");
+ info.add("Wire material: " + this.getMaterial(itemStack));
+ info.add("Resistivity: " + this.getResistance(itemStack) / 1000F + " V^2/(EU*m)");
+ info.add("Transverse section: " + this.getTransverseSection(itemStack) / 10F + " sq. mm.");
+ if (itemStack.stackTagCompound.hasKey("insulationMaterial")) {
+ info.add("Insulation material: " + this.getInsulationMaterial(itemStack));
+ info.add("Insulation thickness: " + this.getInsulationThickness(itemStack) / 10f + " mm");
+ info.add("Insulation breakdown voltage: " + this.getVoltageLimit(itemStack) / 1000 + " kV");
+ }
- }
- }
+ }
+ }
@Override
- public String getTag()
- {
+ public String getTag() {
return "length";
}
@Override
- public String getTagSecondary()
- {
+ public String getTagSecondary() {
return "fullLength";
}
-
+
@Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(IIconRegister par1IconRegister)
- {
- this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":copperWire");
- this.thickCopper = par1IconRegister.registerIcon(IHLModInfo.MODID + ":copperWire16x");
- this.thinIron = par1IconRegister.registerIcon(IHLModInfo.MODID + ":steelWire");
- this.thickIron = par1IconRegister.registerIcon(IHLModInfo.MODID + ":steelWire16x");
- this.insulatedIronRawruber = par1IconRegister.registerIcon(IHLModInfo.MODID + ":flexibleCableSteel2");
- }
-
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister par1IconRegister) {
+ this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":copperWire");
+ this.thickCopper = par1IconRegister.registerIcon(IHLModInfo.MODID + ":copperWire16x");
+ this.thinIron = par1IconRegister.registerIcon(IHLModInfo.MODID + ":steelWire");
+ this.thickIron = par1IconRegister.registerIcon(IHLModInfo.MODID + ":steelWire16x");
+ this.insulatedIronRawruber = par1IconRegister.registerIcon(IHLModInfo.MODID + ":flexibleCableSteel2");
+ }
+
@Override
@SideOnly(Side.CLIENT)
- public IIcon getIcon(ItemStack stack, int i)
- {
- if(stack.stackTagCompound!=null)
- {
- if(this.getInsulationMaterial(stack).equals("null"))
- {
- if(this.getTransverseSection(stack)>=240)
- {
- if(yellowColoredWires.contains(this.getMaterial(stack)))
- {
+ public IIcon getIcon(ItemStack stack, int i) {
+ if (stack.stackTagCompound != null) {
+ if (this.getInsulationMaterial(stack).equals("null")) {
+ if (this.getTransverseSection(stack) >= 240) {
+ if (yellowColoredWires.contains(this.getMaterial(stack))) {
return this.thickCopper;
- }
- else
- {
+ } else {
return this.thickIron;
}
- }
- else
- {
- if(yellowColoredWires.contains(this.getMaterial(stack)))
- {
+ } else {
+ if (yellowColoredWires.contains(this.getMaterial(stack))) {
return this.itemIcon;
- }
- else
- {
+ } else {
return this.thinIron;
}
}
- }
- else
- {
+ } else {
return this.insulatedIronRawruber;
}
}
return this.itemIcon;
}
-
+
@Override
- public String getUnlocalizedName(ItemStack stack)
- {
- if(stack.stackTagCompound!=null && !this.getInsulationMaterial(stack).equals("null"))
- {
+ public String getUnlocalizedName(ItemStack stack) {
+ if (stack.stackTagCompound != null && !this.getInsulationMaterial(stack).equals("null")) {
return "cable";
}
return "wire";
}
@Override
- public boolean isSameWire(ItemStack stack1,ItemStack stack2)
- {
- if(stack1.getItem()==stack2.getItem() && stack1.getItemDamage()==stack2.getItemDamage())
- {
- if(stack1.stackTagCompound!=null && stack2.stackTagCompound!=null)
- {
- return this.getMaterial(stack1).equals(this.getMaterial(stack2)) &&
- this.getTransverseSection(stack1)==this.getTransverseSection(stack2) &&
- this.getInsulationMaterial(stack1).equals(this.getInsulationMaterial(stack2)) &&
- this.getInsulationThickness(stack1)==this.getInsulationThickness(stack2);
+ public boolean isSameWire(ItemStack stack1, ItemStack stack2) {
+ if (stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage()) {
+ if (stack1.stackTagCompound != null && stack2.stackTagCompound != null) {
+ return this.getMaterial(stack1).equals(this.getMaterial(stack2))
+ && this.getTransverseSection(stack1) == this.getTransverseSection(stack2)
+ && this.getInsulationMaterial(stack1).equals(this.getInsulationMaterial(stack2))
+ && this.getInsulationThickness(stack1) == this.getInsulationThickness(stack2);
}
}
return false;
}
- public String getInsulationMaterial(ItemStack stack)
- {
- if(stack.stackTagCompound.hasKey("insulationMaterial"))
- {
- return stack.stackTagCompound.getString("insulationMaterial");
- }
+ public String getInsulationMaterial(ItemStack stack) {
+ if (stack.stackTagCompound.hasKey("insulationMaterial")) {
+ return stack.stackTagCompound.getString("insulationMaterial");
+ }
return "null";
}
-
- public int getInsulationThickness(ItemStack stack)
- {
- if(stack.stackTagCompound.hasKey("insulationThickness"))
- {
- return stack.stackTagCompound.getInteger("insulationThickness");
- }
+
+ public int getInsulationThickness(ItemStack stack) {
+ if (stack.stackTagCompound.hasKey("insulationThickness")) {
+ return stack.stackTagCompound.getInteger("insulationThickness");
+ }
return 0;
}
}
diff --git a/ihl/items_blocks/ItemSubstance.java b/ihl/items_blocks/ItemSubstance.java index 464878c..d934172 100644 --- a/ihl/items_blocks/ItemSubstance.java +++ b/ihl/items_blocks/ItemSubstance.java @@ -12,10 +12,8 @@ import ihl.utils.IHLUtils; import ihl.worldgen.ores.IHLFluid.IHLFluidType;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -274,7 +272,7 @@ public class ItemSubstance extends Item implements IItemHasMiniGUI{ CrushedPurifiedBauxite(126, "crushedPurifiedBauxite",true,"Al\u2082O\u2083\u00B7H\u2082O"),
CrushedBauxite(125, "crushedBauxite",true,"Al\u2082O\u2083�H\u2082O + SiO\u2082, Fe\u2082O\u2083"),
SodiumSulfide(124,"dustSodiumSulfide",true,"NaS"),
- SodiumSulfate(123,"dustSodiumSulfate",true,"NaSO\u2084"),
+ SodiumSulfate(123,"dustSodiumSulfate",true,"Na\u2082SO\u2084"),
dustWood(122,"dustWood",true),
Kenotron(121,"valveTube1C21P"),
HighVolatgeCapacitor(120,"highVoltageCapacitor"),
|
