From 05c78126859231a68e199dc34613689bd0978e2f Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 11 Apr 2016 19:44:54 +0300 Subject: Initial commit --- ihl/items_blocks/ExplosiveBlock.java | 255 +++++++++ ihl/items_blocks/FiberItem.java | 107 ++++ ihl/items_blocks/FlexibleCableItem.java | 573 +++++++++++++++++++++ ihl/items_blocks/FlexiblePipeItem.java | 128 +++++ ihl/items_blocks/GroundRemoverItem.java | 92 ++++ ihl/items_blocks/IHLFluidBlock.java | 120 +++++ ihl/items_blocks/IHLItemBlock.java | 280 ++++++++++ ihl/items_blocks/IHLTool.java | 431 ++++++++++++++++ ihl/items_blocks/ItemSubstance.java | 392 ++++++++++++++ ihl/items_blocks/MachineBaseBlock.java | 880 ++++++++++++++++++++++++++++++++ ihl/items_blocks/RecipeInputs.java | 25 + 11 files changed, 3283 insertions(+) create mode 100644 ihl/items_blocks/ExplosiveBlock.java create mode 100644 ihl/items_blocks/FiberItem.java create mode 100644 ihl/items_blocks/FlexibleCableItem.java create mode 100644 ihl/items_blocks/FlexiblePipeItem.java create mode 100644 ihl/items_blocks/GroundRemoverItem.java create mode 100644 ihl/items_blocks/IHLFluidBlock.java create mode 100644 ihl/items_blocks/IHLItemBlock.java create mode 100644 ihl/items_blocks/IHLTool.java create mode 100644 ihl/items_blocks/ItemSubstance.java create mode 100644 ihl/items_blocks/MachineBaseBlock.java create mode 100644 ihl/items_blocks/RecipeInputs.java (limited to 'ihl/items_blocks') diff --git a/ihl/items_blocks/ExplosiveBlock.java b/ihl/items_blocks/ExplosiveBlock.java new file mode 100644 index 0000000..225873f --- /dev/null +++ b/ihl/items_blocks/ExplosiveBlock.java @@ -0,0 +1,255 @@ +package ihl.items_blocks; + +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.processing.chemistry.ExplosiveTileEntity; +import ihl.processing.metallurgy.MuffleFurnanceTileEntity; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ExplosiveBlock extends Block implements ITileEntityProvider{ + + @SideOnly(Side.CLIENT) + IIcon textureSide, + textureBack, + textureTop; + + public ExplosiveBlock() + { + super(Material.tnt); + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockName("ihlExplosive"); + this.setHardness(2F); + this.setResistance(1F); + } + + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + { + if(IC2.platform.isSimulating()) + { + } + } + + @Override + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) + { + ItemStack result = new ItemStack(item); + result.stackTagCompound=new NBTTagCompound(); + result.stackTagCompound.setInteger("explosionType", 0);//0 - IC2; 1- IHL + result.stackTagCompound.setInteger("explosionPower", 100000); + //itemList.add(result); + result = new ItemStack(item); + result.stackTagCompound=new NBTTagCompound(); + result.stackTagCompound.setInteger("explosionType", 1);//0 - IC2; 1- IHL + result.stackTagCompound.setInteger("explosionPower", Integer.MAX_VALUE);//31000 + itemList.add(result); + } + + @Override + public void onBlockPreDestroy(World world, int x, int y, int z, int meta) + { + if(!world.isRemote) + { + TileEntity te = world.getTileEntity(x, y, z); + } + super.onBlockPreDestroy(world, x, y, z, meta); + } + + @Override + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.9F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.9F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBoundsForItemRender(); + } + + @Override + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) + { + int facing = 3; + TileEntity te = blockAccess.getTileEntity(x, y, z); + if(te!=null && te instanceof IWrenchable) + { + IWrenchable tebh = (IWrenchable) te; + facing=tebh.getFacing(); + } + super.setBlockBoundsBasedOnState(blockAccess, x, y, z); + } + + public static void init() + { + GameRegistry.registerBlock(new ExplosiveBlock(), IHLItemBlock.class,"ihlExplosive"); + GameRegistry.registerTileEntity(ExplosiveTileEntity.class, "explosiveTileEntity"); + ExplosiveType[] var1 = ExplosiveType.values(); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new ExplosiveTileEntity(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenSide"); + this.textureBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenBack"); + this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenSide"); + this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenTop"); + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z){ + TileEntity te = world.getTileEntity(x,y,z); + if(IC2.platform.isSimulating() && te instanceof ExplosiveTileEntity) + { + ((ExplosiveTileEntity)te).createExplosion(player); + } + return false; + } + + + /** + * Called when the block is placed in the world. + */ + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null) + { + t.readFromNBT(itemStack.stackTagCompound); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + int facing=3; + int mask[] = { + 0,1,2,3,4,5, + 1,0,3,2,4,5, + 2,3,0,1,4,5, + 2,3,1,0,4,5, + 2,3,5,4,0,1, + 2,3,4,5,1,0 + }; + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof IWrenchable) + { + IWrenchable tebh = (IWrenchable) te; + facing=tebh.getFacing(); + } + return this.getIconFromFacing(facing, side); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + return this.getIconFromFacing(3, side); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromFacing(int facing, int side) + { + return this.textureSide; + } + + @Override + public boolean onBlockEventReceived(World world, int x, int y, int z, int metadata, int flag) + { + return true; + } + + public enum ExplosiveType + { + MuffleFurnace("muffleFurnance",MuffleFurnanceTileEntity.class, true, new ItemStack(Items.brick)); + ExplosiveType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1,ItemStack itemDroppedOnBlockDestroy1) + { + unlocalizedName=unlocalizedName1; + teclass=teclass1; + isNormalBlock=isNormalBlock1; + itemDroppedOnBlockDestroy=itemDroppedOnBlockDestroy1; + } + String unlocalizedName; + Class teclass; + boolean isNormalBlock=true; + ItemStack itemDroppedOnBlockDestroy; + } + + @Override + public int getRenderType() + { + return 0; + } + + @Override + public boolean isOpaqueCube() + { + return true; + } + + @Override + public boolean renderAsNormalBlock() + { + return true; + } + + @SideOnly(Side.CLIENT) + public IIcon getInnerTextureForBlockRenderer() + { + return this.blockIcon; + } +} diff --git a/ihl/items_blocks/FiberItem.java b/ihl/items_blocks/FiberItem.java new file mode 100644 index 0000000..0682abb --- /dev/null +++ b/ihl/items_blocks/FiberItem.java @@ -0,0 +1,107 @@ +package ihl.items_blocks; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.interfaces.IWire; + +public class FiberItem extends Item implements IWire { + + protected String info; + protected FiberMaterial material; + private String registryName; + + public FiberItem(FiberMaterial material1, int leadsNum1, String registryName1) + { + super(); + this.registryName=registryName1; + this.material=material1; + this.info=material.description; + this.setCreativeTab(IHLCreativeTab.tab); + this.setMaxStackSize(1); + this.setUnlocalizedName(registryName); + } + + public FiberItem() + { + super(); + } + + public static void init() + { + FiberMaterial[] var1 = FiberMaterial.values(); + for(int i=0;i yellowColoredWires = new HashSet(3); + 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; + } + + @Override + @SideOnly(Side.CLIENT) + 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"); + } + + 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)t).getEnergyNetNode(facing); + } + else + { + te = (ICableHolder)t; + } + 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.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); + } + } + + 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(); + } + return stack.stackTagCompound.getString("material"); + } + + public int getVoltageLimit(ItemStack stack) + { + if(stack.stackTagCompound==null) + { + stack.stackTagCompound=new NBTTagCompound(); + } + 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(); + } + return IHLUtils.getResistance(stack.stackTagCompound); + } + + private void cleanUp(int uid) + { + Set cs = IHLMod.proxy.nodeEntityRegistry.get(uid); + 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) + { + EntityPlayer player = event.player; + for(ItemStack stack:player.inventory.mainInventory) + { + if(stack!=null && stack.getItem() instanceof FlexibleCableItem) + { + if(stack.stackTagCompound.getBoolean("firstConnection")) + { + int can = -1; + Set 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; + } + } + 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); + 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); + } + } + } + } + + + 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.colorIndex = this.getColor(stack); + node.addCable((NBTTagCompound) stack.stackTagCompound.copy()); + 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))) + { + return 0xFF9900; + } + else + { + return 0xAAAABB; + } + } + return 0xFFFFFF; + } + + @Override + 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() + { + return "length"; + } + + @Override + 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"); + } + + @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))) + { + return this.thickCopper; + } + else + { + return this.thickIron; + } + } + else + { + if(yellowColoredWires.contains(this.getMaterial(stack))) + { + return this.itemIcon; + } + else + { + return this.thinIron; + } + } + } + else + { + return this.insulatedIronRawruber; + } + } + return this.itemIcon; + } + + @Override + 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); + } + } + return false; + } + + 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"); + } + return 0; + } +} diff --git a/ihl/items_blocks/FlexiblePipeItem.java b/ihl/items_blocks/FlexiblePipeItem.java new file mode 100644 index 0000000..5de333f --- /dev/null +++ b/ihl/items_blocks/FlexiblePipeItem.java @@ -0,0 +1,128 @@ +package ihl.items_blocks; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.interfaces.IWire; +import ihl.utils.IHLUtils; + +public class FlexiblePipeItem extends Item implements IWire { + + private static Map iconMap = new HashMap(); + private static Map nameMap = new HashMap(); + private static Map infoMap = new HashMap(); + private static Map materialMap = new HashMap(); + + public FlexiblePipeItem() + { + super(); + this.setCreativeTab(IHLCreativeTab.tab); + this.setMaxStackSize(1); + this.setUnlocalizedName("flexiblePipe"); + } + + public static void init() + { + FlexiblePipeItem item = new FlexiblePipeItem(); + Type[] var1 = Type.values(); + GameRegistry.registerItem(item,item.getUnlocalizedName()); + for(int i=0;i removableBlockSet = new HashSet(); + + public GroundRemoverItem(String registryName1) + { + super(); + this.registryName=registryName1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setMaxStackSize(1); + this.setUnlocalizedName(registryName); + removableBlockSet.add(Blocks.sandstone); + removableBlockSet.add(Blocks.sand); + removableBlockSet.add(Blocks.stone); + removableBlockSet.add(Blocks.flowing_water); + removableBlockSet.add(Blocks.flowing_lava); + removableBlockSet.add(Blocks.water); + removableBlockSet.add(Blocks.lava); + removableBlockSet.add(Blocks.clay); + removableBlockSet.add(Blocks.gravel); + removableBlockSet.add(Blocks.dirt); + } + + public GroundRemoverItem() + { + super(); + } + + public static void init() + { + //GameRegistry.registerItem(new GroundRemoverItem("groundRemover"),"groundRemover"); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) + { + info.add("Vanilla block remover tool"); + } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":vacuumSwitch"); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) + { + if(entity instanceof EntityPlayer && isCurrentItem && MinecraftServer.getServer().getTickCounter()%100==99) + { + int x = (int)entity.posX; + int y = (int)entity.posY; + int z = (int)entity.posZ; + for(int ix = x-16;ix < x+16;ix++) + { + for(int iz = z-16;iz < z+16;iz++) + { + for(int iy = 4;iy < y;iy++) + { + if(!(world.getBlock(ix, iy, iz) instanceof BlockOre || world.getBlock(ix, iy, iz) instanceof IHLFluidBlock)) + { + world.setBlockToAir(ix, iy, iz); + } + } + } + } + } + } +} diff --git a/ihl/items_blocks/IHLFluidBlock.java b/ihl/items_blocks/IHLFluidBlock.java new file mode 100644 index 0000000..29d2d99 --- /dev/null +++ b/ihl/items_blocks/IHLFluidBlock.java @@ -0,0 +1,120 @@ +package ihl.items_blocks; + +import ihl.IHLModInfo; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; + +public class IHLFluidBlock extends BlockFluidClassic { + + private String textureName = "fluidRubberTreeSap"; + @SideOnly(Side.CLIENT) + protected IIcon stillIcon; + @SideOnly(Side.CLIENT) + protected IIcon flowingIcon; + private boolean flammable; + + public IHLFluidBlock(Fluid fluid, Material material, String textureName1, String registryName1) { + super(fluid, material); + textureName = textureName1; + GameRegistry.registerBlock(this, registryName1); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + return this.blockMaterial==Material.lava?15:0; + } + + public IHLFluidBlock setFlammable(boolean flammable) + { + this.flammable = flammable; + return this; + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable ? 300 : 0; + } + + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable ? 5 : 0; + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable; + } + + + @Override + public IIcon getIcon(int side, int meta) { + return (side == 0 || side == 1)? stillIcon : flowingIcon; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister register) { + stillIcon = register.registerIcon(IHLModInfo.MODID + ":" + textureName + "Still"); + flowingIcon = register.registerIcon(IHLModInfo.MODID + ":" + textureName + "Flowing"); + } + + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.displaceIfPossible(world, x, y, z); + } + + @Override + public int onBlockPlaced(World world, int x, int y, int z, int meta, float xF, float yF, float zF, int meta2) + { + int var = super.onBlockPlaced(world, x, y, z, meta, xF, yF, zF, meta2); + if(!world.isRemote && this.isAirCompound()) + { + world.setBlockToAir(x, y, z); + } + return var; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + super.onBlockPlacedBy(world, x, y, z, player, itemStack); + if(!world.isRemote && this.isAirCompound()) + { + world.setBlockToAir(x, y, z); + } + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + super.onNeighborBlockChange(world, x, y, z, block); + if(!world.isRemote && this.isAirCompound()) + { + world.setBlockToAir(x, y, z); + } + } + + private boolean isAirCompound() + { + return this.fluidName.equals("air") || this.fluidName.equals("nitrogen") || this.fluidName.equals("oxygen"); + } +} diff --git a/ihl/items_blocks/IHLItemBlock.java b/ihl/items_blocks/IHLItemBlock.java new file mode 100644 index 0000000..8ac81a2 --- /dev/null +++ b/ihl/items_blocks/IHLItemBlock.java @@ -0,0 +1,280 @@ +package ihl.items_blocks; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.collector.ChargerEjectorTileEntity; +import ihl.processing.metallurgy.PassiveBlock; +import ihl.tunneling_shield.DriverTileEntity; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class IHLItemBlock extends ItemBlock{ + public Map nameMap = new HashMap(); + public IHLItemBlock(Block block1) + { + super(block1); + this.setFull3D(); + this.setHasSubtypes(true); + this.setCreativeTab(IHLCreativeTab.tab); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) + { + Block block = world.getBlock(x, y, z); + + if (block == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 7) < 1) + { + par7 = 1; + } + else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush) + { + if (par7 == 0) + { + --y; + } + + if (par7 == 1) + { + ++y; + } + + if (par7 == 2) + { + --z; + } + + if (par7 == 3) + { + ++z; + } + + if (par7 == 4) + { + --x; + } + + if (par7 == 5) + { + ++x; + } + } + + if (par1ItemStack.stackSize == 0) + { + return false; + } + else if (!player.canPlayerEdit(x, y, z, par7, par1ItemStack)) + { + return false; + } + else if (y == 255) + { + return false; + } + else if (world.canPlaceEntityOnSide(this.field_150939_a, x, y, z, false, par7, player, par1ItemStack)) + { + int metadata = par1ItemStack.getItemDamage(); + int var13 = this.field_150939_a.onBlockPlaced(world, x, y, z, par7, par8, par9, par10, metadata); + + if (world.setBlock(x, y, z, this.field_150939_a, var13, 3)) + { + if (world.getBlock(x, y, z) == this.field_150939_a) + { + this.field_150939_a.onBlockPlacedBy(world, x, y, z, player, par1ItemStack); + this.field_150939_a.onPostBlockPlaced(world, x, y, z, var13); + TileEntity tile=world.getTileEntity(x, y, z); + if(tile!=null && par1ItemStack.stackTagCompound!=null && par1ItemStack.stackTagCompound.hasKey("energy") && tile instanceof ChargerEjectorTileEntity && IC2.platform.isSimulating()) + { + ChargerEjectorTileEntity te=(ChargerEjectorTileEntity)tile; + double energy; + try + { + energy = par1ItemStack.stackTagCompound.getDouble("energy"); + } + catch (Exception var3) + { + energy = par1ItemStack.stackTagCompound.getInteger("energy"); + + if (energy > Integer.MAX_VALUE) + { + energy *= 10.0D; + } + } + te.setStored(energy); + } + if(tile instanceof IWrenchable && IC2.platform.isSimulating()) + { + IWrenchable te=(IWrenchable)tile; + int var6 = MathHelper.floor_double(player.rotationPitch * 4.0F / 360.0F + 0.5D) & 3; + int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + if(player.isSneaking()) + { + if(var6==1) + { + te.setFacing((short) 0); + } + else if(var6==3) + { + te.setFacing((short) 1); + } + else + { + + switch (l) + { + case 0: + te.setFacing((short)3); + break; + + case 1: + te.setFacing((short)4); + break; + + case 2: + te.setFacing((short)2); + break; + + case 3: + te.setFacing((short)5); + } + } + } + else + { + if(var6==1) + { + te.setFacing((short) 1); + } + else if(var6==3) + { + te.setFacing((short) 0); + } + else + { + + switch (l) + { + case 0: + te.setFacing((short)2); + break; + + case 1: + te.setFacing((short)5); + break; + + case 2: + te.setFacing((short)3); + break; + + case 3: + te.setFacing((short)4); + } } + } + } + } + + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "step.stone", 1.0F, 0.8F); + --par1ItemStack.stackSize; + } + + return true; + } + else + { + return false; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":driverItem"); + } + + public Block getBlockContained() + { + return this.field_150939_a; + } + + @Override + public CreativeTabs getCreativeTab() + { + return IHLCreativeTab.tab; + } + + @Override + public String getUnlocalizedName(ItemStack stack) + { + if(!nameMap.isEmpty() && nameMap.containsKey(stack.getItemDamage())) + { + return nameMap.get(stack.getItemDamage()); + } + else + { + return this.field_150939_a.getUnlocalizedName(); + } + } + + @Override + public boolean onItemUseFirst(ItemStack itemstack, EntityPlayer entityPlayer, World world, int x, int y, int z, int l, float hitX, float hitY, float hitZ) + { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof DriverTileEntity && IC2.platform.isSimulating()) + { + DriverTileEntity dte = (DriverTileEntity) tileEntity; + if(itemstack.getUnlocalizedName()==PassiveBlock.Type.IHLShieldAssemblyUnitBlock.unlocalizedName) + { + dte.installShield(); + itemstack.stackSize--; + } + else if(itemstack.getUnlocalizedName()==PassiveBlock.Type.AdvancedShieldAssemblyUnitBlock.unlocalizedName) + { + dte.installAdvancedShield(); + itemstack.stackSize--; + } + } + return false; + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) + { + if(itemStack.stackTagCompound!=null && itemStack.stackTagCompound.hasKey("resultSuffix")) + { + info.add(StatCollector.translateToLocal("result_of_molding") + StatCollector.translateToLocal("ihl."+itemStack.stackTagCompound.getString("resultSuffix"))); + if(itemStack.stackTagCompound.hasKey("isContainStearin") && itemStack.stackTagCompound.getBoolean("isContainStearin")) + { + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 1: "+StatCollector.translateToLocal("remove_wax_using_muffle_furnace")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 2: "+StatCollector.translateToLocal("fill_from_top_with_molten_metal")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 3: "+StatCollector.translateToLocal("wait_for_10_seconds")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 4: "+StatCollector.translateToLocal("destroy_mold_to_get_results")); + + } + else + { + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 1: "+StatCollector.translateToLocal("fill_from_top_with_molten_metal")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 2: "+StatCollector.translateToLocal("wait_for_10_seconds")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 3: "+StatCollector.translateToLocal("destroy_mold_to_get_results")); + } + } + } +} diff --git a/ihl/items_blocks/IHLTool.java b/ihl/items_blocks/IHLTool.java new file mode 100644 index 0000000..7ddf3fb --- /dev/null +++ b/ihl/items_blocks/IHLTool.java @@ -0,0 +1,431 @@ +package ihl.items_blocks; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.reactor.IReactor; +import ic2.core.Ic2Items; +import ihl.IHLCreativeTab; +import ihl.IHLMod; +import ihl.IHLModInfo; +import ihl.flexible_cable.SetOfDiesMiniGUI; +import ihl.interfaces.IHasTemperature; +import ihl.interfaces.IItemHasMiniGUI; +import ihl.interfaces.ItemMiniGUI; +import ihl.utils.IHLUtils; +public class IHLTool extends Item implements IItemHasMiniGUI{ + + private static Map iconMap = new HashMap(); + private static Map nameMap = new HashMap(); + private static Map hintMap = new HashMap(); + private static Map maxToolDamageMap = new HashMap(); + private static Map isWeaponMap = new HashMap(); + private static Map damageVersusEntityMap = new HashMap(); + public static Item instance; + + private IIcon dice240; + + public IHLTool() + { + super(); + this.setMaxDamage(0); + this.setNoRepair(); + this.setHasSubtypes(true); + this.setCreativeTab(IHLCreativeTab.tab); + this.setUnlocalizedName("ihlTool"); + this.setMaxStackSize(1); + instance=this; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) + { + if(itemStack.getItemDamage()!=19 || world.isRemote) + { + return itemStack; + } + MovingObjectPosition movingobjectposition = IHLUtils.returnMOPFromPlayer(entityPlayer, world); + if(movingobjectposition!=null) + { + int x=movingobjectposition.blockX; + int y=movingobjectposition.blockY; + int z=movingobjectposition.blockZ; + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof IHasTemperature) + { + this.setThermometerTemperature(itemStack, entityPlayer, ((IHasTemperature)te).getTemperature()); + } + if(te instanceof IReactor) + { + this.setThermometerTemperature(itemStack, entityPlayer, ((IReactor)te).getHeat()+273); + } + } + return itemStack; + } + + @Override + public final ItemStack getContainerItem(ItemStack stack) + { + ItemStack outStack = stack.copy(); + IHLUtils.damageItemViaNBTTag(outStack, 100); + if(outStack.stackSize<=0) + { + return null; + } + else + { + return outStack; + } + } + + @Override + public final boolean doesContainerItemLeaveCraftingGrid(ItemStack aStack) + { + return false; + } + + @Override + public final boolean hasContainerItem(ItemStack aStack) + { + return true; + } + + public static void init() + { + if(IHLUtils.getFirstOreDictName(Ic2Items.bronzeAxe).equals("")) + { + OreDictionary.registerOre("craftingToolAxe", Ic2Items.bronzeAxe.getItem()); + } + if(IHLUtils.getFirstOreDictName(Ic2Items.bronzePickaxe).equals("")) + { + OreDictionary.registerOre("craftingToolPickaxe", Ic2Items.bronzePickaxe.getItem()); + } + IHLTool item = new IHLTool(); + GameRegistry.registerItem(item,item.getUnlocalizedName()); + Type[] var1 = Type.values(); + for(int i=0;i0) + { + for(int i1=0;i1=240) + { + return dice240; + } + } + return this.getIconFromDamage(stack.getItemDamage()); + } + + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int i) + { + return iconMap.get(i); + } + + public enum Type + { + Thermometer("mercuryThermometer",19,1,0.1f,false,null,(String[])null), + FiberGlassDie("fiberGlassDieSteel",18,20000,0.5f,false,null,(String[])null), + SharpenedCarvingKnifeBronze("sharpenedCarvingKnifeBronze",17,2000,3.5f, true, "ihl.mutton_drop_hint", "craftingToolBlade", "craftingToolKnife"), + GlassBlowingTube("glassBlowingTubeSteel",16,2000,0.5f,false,null,(String[])null), + PolishingPucks("polishingPucksSteel",15,2000,0.5f,false,null,(String[])null), + GravelSteel("graverSteelHardened",14,10,0.5f,false,null,(String[])null), + DiceM10Steel("diceM10x1SteelHardened",13,2000,0.5f,false,null,(String[])null), + TapM10("tapM10x1SteelHardened",12,2000,0.5f,false,null,(String[])null), + Vise("viseSteel",11,200000,0.5f,false,null,(String[])null), + SetOfFiles("setOfFilesSteel",10,20000,1.5f,false,null,"craftingToolFile"), + HandDrillBronze("handDrillBronze",9,20000,0.5f,false,null,(String[])null), + HackSawSteel("hackSawSteel",8,200,0.5f,false,null,"craftingToolSaw"), + DrillSteel("drillSteelHardened",7,200,0.5f,false,null,(String[])null), + NeedleFile("needleFile",6,2000,0.1f,false,null,(String[])null), + Chisel("chisel",5,2000,1.5f,false,null,"craftingToolChisel"), + Grindstone("grindstone",4,2000,0.5f,false,null,(String[])null), + Hammer("hammer",3,20000,2.5f,false,null,"craftingToolHardHammer","craftingToolForgeHammer"), + TinSnipsSteel("tinSnipsSteel",2,2000,0.5f,false,null,"craftingToolWireCutter"), + SetOfDies1_5sqmm("setOfDies1_5sqmm",0,2000,0.5f,false,null,(String[])null); + Type(String unlocalizedName1,int itemDamage1, int maxToolDamage1, float damageVersusEntity1, boolean isWeapon1, String hint1, String... oreDictName1) + { + unLocalizedName=unlocalizedName1; + itemDamage=itemDamage1; + maxToolDamage=maxToolDamage1; + damageVersusEntity=damageVersusEntity1; + isWeapon=isWeapon1; + hint=hint1; + oreDictName=oreDictName1; + } + public final String unLocalizedName; + public final String[] oreDictName; + public final int itemDamage; + public final int maxToolDamage; + public final float damageVersusEntity; + public final boolean isWeapon; + public final String hint; + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) + { + info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.durability") +EnumChatFormatting.GREEN + (IHLUtils.getMaxDamageValueViaNBTTag(itemStack) - IHLUtils.getDamageValueViaNBTTag(itemStack))+" / "+IHLUtils.getMaxDamageValueViaNBTTag(itemStack)); + info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.attack_damage") +EnumChatFormatting.DARK_BLUE + damageVersusEntityMap.get(itemStack.getItemDamage())); + if(hintMap.containsKey(itemStack.getItemDamage())) + { + info.add(EnumChatFormatting.DARK_RED+StatCollector.translateToLocal(hintMap.get(itemStack.getItemDamage()))); + } + if(itemStack.stackTagCompound.hasKey("transverseSection")) + { + info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.transversesection") +EnumChatFormatting.GREEN + (itemStack.stackTagCompound.getInteger("transverseSection")/10f)+" sq. mm."); + } + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) + { + IHLUtils.damageItemViaNBTTag(stack, 1); + if(target!=null && target instanceof EntitySheep && !target.isChild() && target.getHealth()<=0F) + { + target.entityDropItem(IHLUtils.getThisModItemStackWithSize("muttonLard", target.worldObj.rand.nextInt(2)+2), 1F); + } + return true; + } + + @Override//That was taken from Gregtech. I think Greg wouldn't mind. + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) + { + if (entity.canAttackWithItem() && !entity.hitByEntity(player)) + { + float tMagicDamage = entity instanceof EntityLivingBase ? EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLivingBase)entity) : 0.0F; + float tDamage = (float)player.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() + damageVersusEntityMap.get(stack.getItemDamage()); + + if (tDamage + tMagicDamage > 0.0F) + { + boolean tCriticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null && entity instanceof EntityLivingBase; + + if (tCriticalHit && tDamage > 0.0F) + { + tDamage *= 1.5F; + } + + tDamage += tMagicDamage; + + if (entity.attackEntityFrom(DamageSource.generic, tDamage)) + { + if (entity instanceof EntityLivingBase) + { + entity.setFire(EnchantmentHelper.getFireAspectModifier(player) * 4); + } + + int tKnockcack = (player.isSprinting() ? 1 : 0) + (entity instanceof EntityLivingBase ? EnchantmentHelper.getKnockbackModifier(player, (EntityLivingBase)entity) : 0); + + if (tKnockcack > 0) + { + entity.addVelocity(-MathHelper.sin(player.rotationYaw * (float)Math.PI / 180.0F) * tKnockcack * 0.5F, 0.1D, MathHelper.cos(player.rotationYaw * (float)Math.PI / 180.0F) * tKnockcack * 0.5F); + player.motionX *= 0.6D; + player.motionZ *= 0.6D; + player.setSprinting(false); + } + + if (tCriticalHit) + { + player.onCriticalHit(entity); + } + + if (tMagicDamage > 0.0F) + { + player.onEnchantmentCritical(entity); + } + + if (tDamage >= 18.0F) + { + player.triggerAchievement(AchievementList.overkill); + } + + player.setLastAttacker(entity); + + if (entity instanceof EntityLivingBase) + { + EnchantmentHelper.func_151384_a((EntityLivingBase)entity, player); + } + + EnchantmentHelper.func_151385_b(player, entity); + + if (entity instanceof EntityLivingBase) + { + player.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F)); + } + entity.hurtResistantTime = isWeaponMap.get(stack.getItemDamage())?0:1; + if(entity!=null && entity instanceof EntitySheep && !((EntityLivingBase) entity).isChild() && ((EntityLivingBase) entity).getHealth()<=0F && isWeaponMap.get(stack.getItemDamage())) + { + entity.entityDropItem(IHLUtils.getThisModItemStackWithSize("muttonLard", entity.worldObj.rand.nextInt(2)+1), 1F); + } + player.addExhaustion(0.3F); + IHLUtils.damageItemViaNBTTag(stack, 1); + } + } + } + if (stack.stackSize <= 0) + { + player.destroyCurrentEquippedItem(); + } + return true; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return true; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + return ((double)IHLUtils.getDamageValueViaNBTTag(stack))/(double)IHLUtils.getMaxDamageValueViaNBTTag(stack); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) + { + if(stack.stackTagCompound!=null && !world.isRemote) + { + if(stack.stackTagCompound.hasKey("showTemperature")) + { + byte timerDelay = stack.stackTagCompound.getByte("showTemperature"); + if(timerDelay>0) + { + timerDelay--; + if(Math.abs(stack.stackTagCompound.getDouble("playerPosX")-entity.prevPosX)>0.2d || + Math.abs(stack.stackTagCompound.getDouble("playerPosY")-entity.prevPosY)>0.2d || + Math.abs(stack.stackTagCompound.getDouble("playerPosZ")-entity.prevPosZ)>0.2d) + { + timerDelay=0; + } + stack.stackTagCompound.setByte("showTemperature",timerDelay); + if(timerDelay==0 && entity instanceof EntityPlayer) + { + ((EntityPlayer)entity).inventoryContainer.detectAndSendChanges(); + } + } + } + } + } + private void setThermometerTemperature(ItemStack itemStack, EntityPlayer entityPlayer, long l) + { + if(itemStack.stackTagCompound==null) + { + itemStack.stackTagCompound=new NBTTagCompound(); + } + itemStack.stackTagCompound.setLong("temperature", l); + itemStack.stackTagCompound.setByte("showTemperature", (byte) 60); + itemStack.stackTagCompound.setDouble("playerPosX", entityPlayer.prevPosX); + itemStack.stackTagCompound.setDouble("playerPosY", entityPlayer.prevPosY); + itemStack.stackTagCompound.setDouble("playerPosZ", entityPlayer.prevPosZ); + entityPlayer.inventoryContainer.detectAndSendChanges(); + + } + + @Override + @SideOnly(Side.CLIENT) + public ItemMiniGUI getMiniGUI(GuiContainer gui, Slot slot) + { + if(slot.getHasStack() && slot.getStack().getItemDamage()==0 && slot.getStack().stackTagCompound!=null) + { + return new SetOfDiesMiniGUI(gui, slot); + } + return null; + } +} diff --git a/ihl/items_blocks/ItemSubstance.java b/ihl/items_blocks/ItemSubstance.java new file mode 100644 index 0000000..bef37fa --- /dev/null +++ b/ihl/items_blocks/ItemSubstance.java @@ -0,0 +1,392 @@ +package ihl.items_blocks; + +import ic2.api.item.IC2Items; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.api.recipe.Recipes; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid.IHLFluidType; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemSubstance extends Item { + + private static Map iconMap = new HashMap(); + private static Map nameMap = new HashMap(); + private static Map descriptionMap = new HashMap(); + public static ItemSubstance instance; + + public ItemSubstance() + { + super(); + this.setMaxDamage(0); + this.setNoRepair(); + this.setHasSubtypes(true); + this.setCreativeTab(IHLCreativeTab.tab); + this.setUnlocalizedName("ihlSimpleItem"); + instance=this; + } + + public static void init() + { + Item breadWithLard = (new ItemFood(4, 0.1F, false)).setUnlocalizedName("breadWithLard").setTextureName(IHLModInfo.MODID+":breadWithLard").setCreativeTab(IHLCreativeTab.tab); + GameRegistry.registerItem(breadWithLard,"food"); + IHLUtils.registerLocally("breadWithLard", new ItemStack(breadWithLard,1,0)); + ItemSubstance item = new ItemSubstance(); + GameRegistry.registerItem(item,item.getUnlocalizedName()); + Type[] var1 = Type.values(); + for(int i=0;i instances = new ArrayList(); + + @SideOnly(Side.CLIENT) + IIcon textureSide, + textureBack, + textureFrontMuffleFurnance, + textureTop, + textureTopAchesonFurnance, + textureTopGoldFurnace, + textureFrontGoldFurnace, + textureSideGoldFurnace, + textureFrontCryogenicDistiller, + textureTopCryogenicDistiller, + textureBackCryogenicDistiller, + textureFrontChemicalReactor, + textureLeftMachineCasing, + textureTopMachineCasing, + textureRightMachineCasing, + textureFrontMachineCasing, + textureFrontPaperMachine, + textureBackMachineCasing, + frequencyGeneratorBack, + frequencyGeneratorBottom, + frequencyGeneratorFront, + frequencyGeneratorLeft, + frequencyGeneratorRight, + frequencyGeneratorTop, + bronzeTubTop, + bronzeTubSide, + glassBoxTop, + glassBoxSide, + glassBoxBottom, + glassBoxInnerSide, + glassBoxInnerBottom, + vacuumInductionMeltingFurnaceFront, + vacuumInductionMeltingFurnaceBack, + vacuumInductionMeltingFurnaceLeft, + vacuumInductionMeltingFurnaceRight, + hydrotransportPulpRegeneratorFront, + hydrotransportPulpRegeneratorBack, + redstoneSignalConverterEmitterSide, + redstoneSignalConverterEmptySide, + redstoneSignalConverterSensorSide, + steel, + redPaint, + greenPaint, + rubberInsulatedCase, + powerPort; + + public MachineBaseBlock(MachineType type1) + { + super(Material.iron); + this.type=type1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockName(type.unlocalizedName); + this.setHardness(2F); + this.setResistance(1F); + instances.add(this); + } + + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + { + if(IC2.platform.isSimulating()) + { + TileEntity te = world.getTileEntity(x,y,z); + if(world.getBlock(x, y+1, z)==Blocks.fire) + { + if(te instanceof DetonationSprayingMachineTileEntity) + { + ((DetonationSprayingMachineTileEntity)te).operate(); + world.setBlockToAir(x, y+1, z); + } + } + if(te instanceof RedstoneSignalConverterTileEntity) + { + RedstoneSignalConverterTileEntity rscte = (RedstoneSignalConverterTileEntity) te; + rscte.linksOrInventoryChanged=true; + } + } + } + + + @Override + public void onBlockPreDestroy(World world, int x, int y, int z, int meta) + { + if(!world.isRemote) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te!=null) + { + if(te instanceof IEnergyNetNode) + { + IEnergyNetNode ate = (IEnergyNetNode) te; + ate.removeAttachedChains(); + } + if(te instanceof IMultiPowerCableHolder) + { + IMultiPowerCableHolder ate = (IMultiPowerCableHolder) te; + ate.removeAttachedChains(); + } + if(te instanceof IronWorkbenchTileEntity) + { + IronWorkbenchTileEntity iwb=(IronWorkbenchTileEntity) te; + iwb.dropContents(); + } + else if(te instanceof IInventory) + { + IInventory inventory = (IInventory)te; + for(int i = 0; i< inventory.getSizeInventory();i++) + { + if(inventory.getStackInSlot(i)!=null)world.spawnEntityInWorld(new EntityItem(world, x, y+1, z, inventory.getStackInSlot(i))); + } + } + if(te instanceof RedstoneSignalConverterTileEntity) + { + RedstoneSignalConverterTileEntity rsce = (RedstoneSignalConverterTileEntity)te; + rsce.removeAttachedChains(); + } + } + } + super.onBlockPreDestroy(world, x, y, z, meta); + } + + @Override + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) + { + switch(this.type) + { + case BronzeTub: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.9F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.9F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBoundsForItemRender(); + break; + case GlassBox: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.9F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.9F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBoundsForItemRender(); + break; + case RedstoneSignalConverter: + this.setBlockBounds(0.2F, 0.2F, 0.2F, 0.8F, 0.8F, 0.8F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + break; + default: + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + break; + } + } + + @Override + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) + { + int facing = 3; + TileEntity te = blockAccess.getTileEntity(x, y, z); + if(te!=null && te instanceof IWrenchable) + { + IWrenchable tebh = (IWrenchable) te; + facing=tebh.getFacing(); + } + switch(this.type) + { + case VacuumInductionMeltingFurnace: + switch(facing) + { + case 0: + this.setBlockBounds(-1.0F, -2.0F, 0.0F, 2.0F, 1.0F, 3.0F); + break; + case 1: + this.setBlockBounds(-1.0F, 0.0F, 0.0F, 2.0F, 3.0F, 3.0F); + break; + case 2: + this.setBlockBounds(-1.0F, 0.0F, -2.0F, 2.0F, 3.0F, 1.0F); + break; + case 3: + this.setBlockBounds(-1.0F, 0.0F, 0.0F, 2.0F, 3.0F, 3.0F); + break; + case 4: + this.setBlockBounds(-2.0F, 0.0F, -1.0F, 1.0F, 3.0F, 2.0F); + break; + case 5: + this.setBlockBounds(0.0F, 0.0F, -1.0F, 3.0F, 3.0F, 2.0F); + break; + default: + break; + } + break; + default: + super.setBlockBoundsBasedOnState(blockAccess, x, y, z); + break; + } + } + + public static void init() + { + MachineType[] var1 = MachineType.values(); + for(int i=0;i