diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2016-04-11 19:44:54 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2016-04-11 19:44:54 +0300 |
| commit | 05c78126859231a68e199dc34613689bd0978e2f (patch) | |
| tree | 050bea104a18c72905095d29f31bec2935a27a24 /ihl/items_blocks | |
Initial commit
Diffstat (limited to 'ihl/items_blocks')
| -rw-r--r-- | ihl/items_blocks/ExplosiveBlock.java | 255 | ||||
| -rw-r--r-- | ihl/items_blocks/FiberItem.java | 107 | ||||
| -rw-r--r-- | ihl/items_blocks/FlexibleCableItem.java | 573 | ||||
| -rw-r--r-- | ihl/items_blocks/FlexiblePipeItem.java | 128 | ||||
| -rw-r--r-- | ihl/items_blocks/GroundRemoverItem.java | 92 | ||||
| -rw-r--r-- | ihl/items_blocks/IHLFluidBlock.java | 120 | ||||
| -rw-r--r-- | ihl/items_blocks/IHLItemBlock.java | 280 | ||||
| -rw-r--r-- | ihl/items_blocks/IHLTool.java | 431 | ||||
| -rw-r--r-- | ihl/items_blocks/ItemSubstance.java | 392 | ||||
| -rw-r--r-- | ihl/items_blocks/MachineBaseBlock.java | 880 | ||||
| -rw-r--r-- | ihl/items_blocks/RecipeInputs.java | 25 |
11 files changed, 3283 insertions, 0 deletions
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<var1.length;i++)
+ {
+ String registryName = "fiber"+var1[i].description;
+ GameRegistry.registerItem(new FiberItem(var1[i],1,registryName),registryName);
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList)
+ {
+ ItemStack stack = new ItemStack(item);
+ stack.stackTagCompound=new NBTTagCompound();
+ stack.stackTagCompound.setInteger("fullLength", 1024);
+ stack.stackTagCompound.setInteger("length", 1024);
+ itemList.add(stack);
+ }
+
+ @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(this.info);
+ }
+
+ @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 + ":"+this.registryName);
+ }
+
+ public static enum FiberMaterial
+ {
+ Glass("Glass");
+ FiberMaterial(String description1)
+ {
+ description=description1;
+ }
+ public String description;
+ }
+
+
+ @Override
+ public boolean isSameWire(ItemStack stack1,ItemStack stack2)
+ {
+ return stack1.getItem()==stack2.getItem();
+ }
+
+}
diff --git a/ihl/items_blocks/FlexibleCableItem.java b/ihl/items_blocks/FlexibleCableItem.java new file mode 100644 index 0000000..11023c4 --- /dev/null +++ b/ihl/items_blocks/FlexibleCableItem.java @@ -0,0 +1,573 @@ +package ihl.items_blocks;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent;
+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.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.Vec3;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+import ic2.api.energy.tile.IEnergyTile;
+import ihl.IHLCreativeTab;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import ihl.flexible_cable.AnchorTileEntity;
+import ihl.flexible_cable.NodeEntity;
+import ihl.flexible_cable.PowerCableNodeEntity;
+import ihl.interfaces.ICableHolder;
+import ihl.interfaces.IDataCableHolder;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.interfaces.IMultiPowerCableHolder;
+import ihl.interfaces.IWire;
+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;
+ public final Set<String> 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<NodeEntity> 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<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;
+ }
+ }
+ 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<Integer, IIcon> iconMap = new HashMap();
+ private static Map<Integer, String> nameMap = new HashMap();
+ private static Map<Integer, String> infoMap = new HashMap();
+ private static Map<Integer, Type> 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<var1.length;i++)
+ {
+ nameMap.put(var1[i].damage,var1[i].unLocalizedName);
+ IHLUtils.registerLocally(var1[i].unLocalizedName, new ItemStack(item,1,var1[i].damage));
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ ItemStack stack = IHLUtils.getThisModItemStack(var1[i].unLocalizedName);
+ stack.stackTagCompound=new NBTTagCompound();
+ stack.stackTagCompound.setInteger("fullLength", 16);
+ stack.stackTagCompound.setInteger("length", 16);
+ itemList.add(stack);
+ }
+ }
+
+ @Override
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag)
+ {
+ if(itemStack.stackTagCompound!=null)
+ {
+ info.add("Length " + itemStack.stackTagCompound.getInteger("length") +"m");
+ }
+ }
+
+ @Override
+ public String getTag()
+ {
+ return "length";
+ }
+
+ @Override
+ public String getTagSecondary()
+ {
+ return "fullLength";
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ iconMap.put(var1[i].damage, register.registerIcon(IHLModInfo.MODID + ":"+var1[i].unLocalizedName));
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int i)
+ {
+ return iconMap.get(i);
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack)
+ {
+ return nameMap.get(stack.getItemDamage());
+ }
+
+ public static enum Type
+ {
+ VulcanizedRubber(1, "pipeVulcanizedRubber"),
+ RubberWithSulfurPipe(0, "pipeRubberWithSulfur");
+ Type(int damage1, String unLocalizedName1)
+ {
+ damage=damage1;
+ unLocalizedName=unLocalizedName1;
+ }
+ public int damage;
+ public String unLocalizedName;
+ }
+
+
+ @Override
+ public boolean isSameWire(ItemStack stack1,ItemStack stack2)
+ {
+ return stack1.getItem()==stack2.getItem();
+ }
+}
diff --git a/ihl/items_blocks/GroundRemoverItem.java b/ihl/items_blocks/GroundRemoverItem.java new file mode 100644 index 0000000..47c5a1f --- /dev/null +++ b/ihl/items_blocks/GroundRemoverItem.java @@ -0,0 +1,92 @@ +package ihl.items_blocks;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.world.World;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.worldgen.ores.BlockOre;
+
+public class GroundRemoverItem extends Item{
+
+ private String registryName;
+ private final Set<Block> 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<Integer, String> 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<Integer, IIcon> iconMap = new HashMap();
+ private static Map<Integer, String> nameMap = new HashMap();
+ private static Map<Integer, String> hintMap = new HashMap();
+ private static Map<Integer, Integer> maxToolDamageMap = new HashMap();
+ private static Map<Integer, Boolean> isWeaponMap = new HashMap();
+ private static Map<Integer, Float> 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;i<var1.length;i++)
+ {
+ nameMap.put(var1[i].itemDamage,var1[i].unLocalizedName);
+ ItemStack stack = new ItemStack(item,1,var1[i].itemDamage);
+ stack.stackTagCompound = new NBTTagCompound();
+ NBTTagCompound stats = new NBTTagCompound();
+ stats.setInteger("MaxDamage", var1[i].maxToolDamage);
+ stack.stackTagCompound.setTag("GT.ToolStats", stats);
+ if(var1[i].equals(Type.SetOfDies1_5sqmm))
+ {
+ stack.stackTagCompound.setInteger("transverseSection",15);
+ }
+ IHLUtils.registerLocally(var1[i].unLocalizedName, stack);
+ if(var1[i].hint!=null)
+ {
+ hintMap.put(var1[i].itemDamage, var1[i].hint);
+ }
+ isWeaponMap.put(var1[i].itemDamage, var1[i].isWeapon);
+ damageVersusEntityMap.put(var1[i].itemDamage, var1[i].damageVersusEntity);
+ if(var1[i].oreDictName!=null && var1[i].oreDictName.length>0)
+ {
+ for(int i1=0;i1<var1[i].oreDictName.length;i1++)
+ {
+ OreDictionary.registerOre(var1[i].oreDictName[i1], stack);
+ }
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ ItemStack stack = IHLUtils.getThisModItemStack(var1[i].unLocalizedName);
+ itemList.add(stack);
+ if(var1[i].equals(Type.SetOfDies1_5sqmm))
+ {
+ stack = IHLUtils.getItemStackWithTag(var1[i].unLocalizedName, "transverseSection",240);
+ itemList.add(stack);
+ }
+ }
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack)
+ {
+ return nameMap.get(stack.getItemDamage());
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ iconMap.put(var1[i].itemDamage, register.registerIcon(IHLModInfo.MODID + ":"+var1[i].unLocalizedName));
+ }
+ dice240 = register.registerIcon(IHLModInfo.MODID + ":setOfDies24sqmm");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(ItemStack stack, int i)
+ {
+ if(stack.stackTagCompound!=null && stack.stackTagCompound.hasKey("transverseSection"))
+ {
+ if(stack.stackTagCompound.getInteger("transverseSection")>=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<Integer, IIcon> iconMap = new HashMap();
+ private static Map<Integer, String> nameMap = new HashMap();
+ private static Map<Integer, String> 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<var1.length;i++)
+ {
+ nameMap.put(var1[i].damage,var1[i].unLocalizedName);
+ IHLUtils.registerLocally(var1[i].unLocalizedName, new ItemStack(item,1,var1[i].damage));
+ if(var1[i].registerInOreDictionary)
+ {
+ OreDictionary.registerOre(var1[i].oreRegistryName, new ItemStack(item,1,var1[i].damage));
+ }
+ if(var1[i].description!=null)
+ {
+ descriptionMap.put(var1[i].damage,var1[i].description);
+ }
+ }
+ ItemStack emptyCell = IC2Items.getItem("cell");
+ IHLFluidType[] var2 = IHLFluidType.values();
+ for(int i=0;i<var2.length;i++)
+ {
+ IHLFluidType type = var2[i];
+ if(type.cell!=null)
+ {
+ OreDictionary.registerOre("cell"+type.fluidName.replaceFirst("fluid", ""), type.cell);
+ FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(type.fluid, FluidContainerRegistry.BUCKET_VOLUME), type.cell, emptyCell.copy()));
+ }
+ else
+ {
+ ItemStack filledCell = FluidContainerRegistry.fillFluidContainer(new FluidStack(type.fluid, FluidContainerRegistry.BUCKET_VOLUME),emptyCell.copy());
+ if(filledCell==null && type.hasCell)
+ {
+ ItemStack stack = new ItemStack(item,1,type.damage);
+ nameMap.put(type.damage,type.cellName);
+ IHLUtils.registerLocally(type.cellName, stack);
+ type.cell = stack;
+ OreDictionary.registerOre("cell"+type.fluidName.replaceFirst("fluid", ""), type.cell);
+ FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(type.fluid, FluidContainerRegistry.BUCKET_VOLUME), stack, emptyCell.copy()));
+ }
+ else
+ {
+ type.cell=filledCell;
+ }
+ }
+ }
+ OreDictionary.registerOre("itemSalt",IHLUtils.getThisModItemStack("dustSalt"));
+ }
+
+ public static void postInit()
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ if(var1[i].registerInOreDictionary)
+ {
+ if(var1[i].oreRegistryName.contains("dustTiny"))
+ {
+ RecipeInputOreDict stack = new RecipeInputOreDict(var1[i].oreRegistryName);;
+ Recipes.advRecipes.addShapelessRecipe(IHLUtils.getOreDictItemStackWithSize(var1[i].oreRegistryName,9),new RecipeInputOreDict(var1[i].oreRegistryName.replace("dustTiny", "dust")));
+ Recipes.advRecipes.addShapelessRecipe(IHLUtils.getOreDictItemStack(var1[i].oreRegistryName.replace("dustTiny", "dust")),stack,stack,stack,stack,stack,stack,stack,stack,stack);
+ }
+ if(var1[i].oreRegistryName.contains("ingot") && IHLUtils.hasOreDictionaryEntry(var1[i].oreRegistryName.replace("ingot", "dust")))
+ {
+ IHLUtils.addIC2MaceratorRecipe(var1[i].oreRegistryName, IHLUtils.getOreDictItemStack(var1[i].oreRegistryName.replace("ingot", "dust")));
+ }
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ ItemStack stack = IHLUtils.getThisModItemStack(var1[i].unLocalizedName);
+ itemList.add(stack);
+ }
+ IHLFluidType[] var2 = IHLFluidType.values();
+ for(int i=0;i<var2.length;i++)
+ {
+ if(var2[i].hasCell && var2[i].cell!=null)
+ {
+ itemList.add(var2[i].cell);
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ iconMap.put(var1[i].damage, register.registerIcon(IHLModInfo.MODID + ":"+var1[i].textureName));
+ }
+ IHLFluidType[] var2 = IHLFluidType.values();
+ for(int i=0;i<var2.length;i++)
+ {
+ IHLFluidType type = var2[i];
+ if(var2[i].hasCell)
+ {
+ iconMap.put(type.damage, register.registerIcon(IHLModInfo.MODID + ":"+type.cellName));
+ }
+ }
+
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int i)
+ {
+ return iconMap.get(i);
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack)
+ {
+ return nameMap.get(stack.getItemDamage());
+ }
+
+ @Override
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag)
+ {
+ if(ItemSubstance.descriptionMap.containsKey(itemStack.getItemDamage()))
+ {
+ info.add(ItemSubstance.descriptionMap.get(itemStack.getItemDamage()));
+ }
+ }
+
+ public enum Type
+ {
+ TinySiliconDioxide(182, "dustTinySiliconDioxide",true,"SiO\u2082"),
+ TinyIronOxide(181, "dustTinyIronOxide",true,"Fe\u2082O\u2083"),
+ TinyManganeseOxide(180, "dustTinyManganeseOxide",true,"Mn\u2083O\u2084"),
+ TinyGypsum(179, "dustTinyGypsum",true,"CaSO\u2084\u00B72H\u2082O"),
+ SodiumZeoliteCoked(178,"dustSodiumZeoliteCoked",true,"Na[AlSi\u2083O\u2088]+C"),
+ SodiumZeolite(177,"dustSodiumZeolite",true,"Na[AlSi\u2083O\u2088]"),
+ SodiumAluminate(176,"dustSodiumAluminate",true,"NaAlO\u2082"),
+ SodiumHydroxide(175,"dustSodiumHydroxide",true,"NaOH"),
+ DustTinyTungsten(174,"dustTinyTungsten",true,"W"),
+ BauxiteDust(173, "dustBauxite",true,"Al\u2082O\u2083\u00B7H\u2082O"),
+ LithiumIngot(172,"ingotLithium",true,"Li"),
+ DustLithiumChloride(171,"dustLithiumChloride",true,"LiCl"),
+ CoalPlate(170, "plateCoal", true, "C (amorphic)"),
+ GraphitePlate(156, "plateGraphite", true, "C (graphite)"),
+ CoalRawPlate(155, "plateRawCoal"),
+ //RedstoneSensor(169,"redstoneSensor"),
+ //RedstoneEmitter(168,"redstoneEmitter"),
+ IncisorSteelDiamondCoated(167,"incisorSteelDiamondCoated"),
+ IncisorSteel(166,"incisorSteel"),
+ LampHolderPorcelain(165,"lampHolderPorcelain"),
+ LampHolderRawPorcelain(164,"lampHolderRawPorcelain"),
+ DustIridium(163,"dustIridium",true,"Ir"),
+ SiliconTiny(162, "dustTinySilicon",true,"Si"),
+ DustMagnesiumOxide(161,"dustMagnesiumOxide",true,"MgO"),
+ Silicon(160, "dustSilicon",true,"Si"),
+ Bischofite(159,"dustBischofite",true,"MgCl\u2082\u00B76H\u2082O"),
+ DustMagnesium(158,"dustMagnesium",true,"Mg"),
+ IngotMagnesium(157,"ingotMagnesium",true,"Mg"),
+ Ignitron(154,"ignitron"),
+ BoronCarbideElectrode(153,"stickBoronCarbide",true,"B\u2084C"),
+ LeadFoil(152,"foilLead",true,"Pb"),
+ DustLeadPlumbate(151,"dustLeadPlumbate",true,"Pb\u2082PbO\u2084"),
+ VacuumSwitch(150,"vacuumSwitch"),
+ HallSensor(149,"hallSensor"),
+ BatteryCells(148,"batteryCellsEbonite"),
+ //BatteryCellsRaw(147,"batteryCellsRawEbonite"),
+ MuscoviteGetinax(146,"plateMica",true,"KAl\u2082(AlSi\u2083O\u2081\u2080)(OH)\u2082"),
+ BoronCarbide(145,"dustBoronCarbide",true,"B\u2084C"),
+ DustBoricAcid(144,"dustBoricAcid",true,"H\u2083BO\u2083"),
+ DustDatolite(143,"dustDatolite",true,"H\u2082Ca\u2082B\u2082Si\u2082O\u2081\u2080"),
+ DustFerrite(142,"dustFerrite",true,"Li\u2082Fe\u2082O\u2084"),
+ RingFerrite(141,"ringFerrite",true,"Li\u2082Fe\u2082O\u2084"),
+ RingRawFerrite(140,"ringRawFerrite"),
+ LithiumOxide(139,"dustLithiumOxide",true,"Li\u2082O"),
+ SolderingAlloyDust(138,"dustSolderingAlloy",true,"Sn\u2089Sb"),
+ AntimonyTinyDust(137,"dustTinyAntimony",true,"Sb"),
+ InsulatorPorcelain(136,"insulatorPorcelain"),
+ InsulatorRawPorcelain(135,"insulatorRawPorcelain"),
+ AntimonyDust(134,"dustAntimony",true,"Sb"),
+ AntimonyOxide(133,"dustAntimonyOxide",true,"Sb\u2082O\u2083"),
+ StibniteDust(132,"dustStibnite",true,"Sb\u2082S\u2083"),
+ CrushedPurifiedStibnite(131,"crushedPurifiedStibnite",true,"Sb\u2082S\u2083"),
+ CrushedStibnite(130,"crushedStibnite",true,"Sb\u2082S\u2083"),
+ RingPorcelain(129,"ringPorcelain"),
+ RingRawPorcelain(128,"ringRawPorcelain"),
+ CopperFoil(127,"foilCopper",true,"Cu"),
+ 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"),
+ dustWood(122,"dustWood",true),
+ Kenotron(121,"valveTube1C21P"),
+ HighVolatgeCapacitor(120,"highVoltageCapacitor"),
+ MuscovitePaper(119,"foilMica",true,"KAl\u2082(AlSi\u2083O\u2081\u2080)(OH)\u2082"),
+ MuscoviteDust(118,"dustMica",true,"KAl\u2082(AlSi\u2083O\u2081\u2080)(OH)\u2082"),
+ GaedesPumpBarrel(117, "gaedesPumpBarrelPorcelain"),
+ RawGaedesPumpBarrel(116, "gaedesPumpBarrelRawPorcelain"),
+ GlassDust(115, "dustGlass",true),
+ Gu81m(114, "gu-81m"),
+ TungstenFoil(113, "foilTungsten",true),
+ TungstenIngot(112, "ingotTungsten",true),
+ TungstenPlate(111, "plateTungsten",true),
+ TungstenHotPlate(110, "plateHotTungsten",true),
+ CrushedPurifiedCinnabar(109, "crushedPurifiedCinnabar",true,"HgS"),
+ CrushedCinnabar(108, "crushedCinnabar",true,"HgS"),
+ OvenRawPorcelain(107,"ovenRawPorcelain"),
+ PrecipitatorCondenserRawPorcelain(106,"precipitatorCondenserRawPorcelain"),
+ ChimneyKneeRawPorcelain(105,"chimneyKneeRawPorcelain"),
+ TungstenDust(104, "dustTungsten",true,"W"),
+ ElectrolysisBathPorcelain(103,"electrolysisBathPorcelain"),
+ ElectrolysisBathRawPorcelain(102,"electrolysisBathRawPorcelain"),
+ Porcelain(99,"dustPorcelain",true),
+ FoilGold(98, "foilGold",true),
+ TungsticAcid(97, "dustTungsticAcid",true,"WO\u2083\u00B7H\u2082O"),
+ TurboCompressorSetOfMoldedParts(96,"turboCompressorSetOfMoldedPartsBronze"),
+ TungstenOxide(94, "dustTungstenOxide",true,"WO\u2083"),
+ CalciumTungstate(93, "dustCalciumTungstate",true,"CaWO\u2084"),
+ SodiumHydrogenSulfate(92, "dustSodiumHydrogenSulfate",true,"NaHSO\u2084"),
+ Salt(91, "dustSalt",true,"NaCl"),
+ CalciumChloride(90, "dustCalciumChloride",true,"CaCl\u2082"),
+ PotassiumSulphate(89, "dustPotassiumSulphate",true,"K\u2082SO\u2084"),
+ RockSalt(88, "dustRockSalt",true,"KCl"),
+ CrushedPurifiedGyuibnera(87, "crushedPurifiedGyubnera",true,"(Mn,Fe)WO\u2084 (5:1)"),
+ CrushedGyuibnera(86, "crushedGyubnera",true,"(Mn,Fe)WO\u2084 (5:1)"),
+ ManganeseOxide(85, "dustManganeseOxide",true,"Mn\u2083O\u2084"),
+ IronOxide(84, "dustIronOxide",true,"Fe\u2082O\u2083"),
+ SmallRound(83,"smallRoundSteel"),
+ SmallRoundPolished(82,"smallRoundPolishedSteel"),
+ RollingMachineSetOfMoldedParts(81,"rollingMachineSetOfMoldedPartsSteel"),
+ PistonCylinder(80, "pistonCylinderSteel"),
+ PipelineAccessoriesSteel(77, "pipelineAccessoriesSteel"),
+ DustTrona(76, "dustTrona",true,"Na\u2082CO\u2083�NaHCO\u2083\u00B72H\u2082O"),
+ HighPressureVessel(75, "highPressureVesselSteel"),
+ GasJet(74, "gasJetSteel"),
+ GasReducerSteel(73, "gasReducerSteel"),
+ HotSteelIngot(70, "ingotHotSteel", true),
+ BarD10Gold(69, "barD10Gold"),
+ CalciumCarbide(68, "dustCalciumCarbide",true,"CaC\u2082"),
+ foilRubber(67,"foilRubber", true,"(C\u2085H\u2088)n"),
+ Fabric(66,"fabric"),
+ ThinRubberWithSulfur(65,"foilRubberWithSulfur"),
+ Bucket_tarPitch(64,"bucket_tarPitch"),
+ DetonationSprayingMachineSetOfMoldedParts(63,"detonationSprayingMachineSetOfMoldedPartsBronze"),
+ SetOfPartsForLVElemotorSteel(62,"setOfPartsForLVElemotorSteel"),
+ //PlateNonVulcanizedRubber(60, "plateNonVulcanizedRubber"),
+ TapM10SteelHot(59, "tapM10x1SteelHot"),
+ DiceM10SteelHot(58, "diceM10x1SteelHot"),
+ NailSteel(57,"nailSteel"),
+ NutM10x1Steel(56,"nutM10x1Steel"),
+ GraverSteel(55, "graverSteel"),
+ GraverSteelHot(54, "graverSteelHot"),
+ DrillSteel(53, "drillSteel"),
+ DrillSteelHot(52, "drillSteelHot"),
+ BarD10Steel(51, "barD10Steel"),
+ BarD10SteelHot(50, "barD10SteelHot"),
+ SawBladeSteel(49, "sawBladeSteel"),
+ SawBladeSteelHot(48, "sawBladeSteelHot"),
+ SawBladeSteelHardened(47, "sawBladeSteelHardened"),
+ LinerIronGraphite(46, "linerIronGraphite"),
+ LinerIronGraphiteHot(45, "linerIronGraphiteHot"),
+ LinerIronGraphiteGreased(44, "linerIronGraphiteGreased"),
+ BoltM10x1Steel(43, "boltM10x1Steel"),
+ ExtruderSetOfMoldedParts(42, "extruderSetOfMoldedPartsSteel"),
+ MeshGlass(41, "meshGlass"),
+ TapM10Steel(39, "tapM10x1Steel"),
+ DiceM10Steel(38, "diceM10x1Steel"),
+ BlankSetOfFilesSteel(37, "blankSetOfFilesSteel"),
+ HandDrillSetOfMoldedPartsBronze(36, "handDrillSetOfMoldedPartsBronze"),
+ ViseSetOfMoldedPartsSteel(34, "viseSetOfMoldedPartsSteel"),
+ DustIrongraphite(33, "dustIrongraphite",true),
+ PlateSteelHot(32, "plateHotSteel"),
+ Chisel(31, "blankChiselSteel"),
+ CrucibleMixture(30, "crucibleMixture"),
+ GraphiteDust(29, "dustGraphite", true, "C (graphite)"),
+ BrickDust(28, "dustBrick", true),
+ CalciumSoap(27, "ingotCalciumSoap"),
+ Stearin(26, "ingotStearin"),
+ MuttonLard(25, "muttonLard"),
+ CarvingKnifeBronze(24, "carvingKnifeBronze"),
+ DehydratedGypsum(23, "dustDehydratedGypsum"),
+ BlankNeedleFileSteel(22, "blankNeedleFileSteel"),
+ HammerHead(21, "toolHeadHammerSmallSteel"),
+ SpringSteel(19, "springSteel"),
+ CoalElectrodePremix(18, "dustCoalElectrodePremix"),
+ rawCoalElectrode(17, "stickCoalElectrodePremix"),
+ FoilSteel(16, "foilSteel",true),
+ StickSteel(15, "stickSteel",true),
+ Quicklime(14, "dustQuicklime",true,"CaO"),
+ Calcite(13, "dustCalcite",true,"CaCO\u2082"),
+ Gypsum(12, "dustGypsum",true,"CaSO\u2084\u00B72H\u2082O"),
+ PotassiumFeldspar(11, "dustPotassiumFeldspar",true,"K[AlSi\u2083O\u2088]"),
+ Apatite(10, "gemApatite",true,"Ca\u2085[PO\u2084]\u2083(F,Cl,OH)"),
+ Saltpeter(9, "dustSaltpeter",true,"KNO\u2083"),
+ TarPitch(8, "ingotTarPitch",true),
+ nuggetTarPitch(7, "nuggetTarPitch",true),
+ Graphite_Electrode(6, "stickGraphite",true, "C (graphite)"),
+ Coal_Electrode(5, "stickCoal",true, "C (amorphic)"),
+ Carborundum(4, "dustCarborundum",true,"SiC"),
+ IridiumAndSodiumOxide(3, "dustIridiumAndSodiumOxide",true,"IrO\u2082 + Na\u2082O"),
+ PlatinumGroupSludge(2, "dustPlatinumGroupSludge",true),
+ TinyPlatinumGroupSludge(1, "dustTinyPlatinumGroupSludge",true),
+ SodiumPeroxide(0, "dustSodiumPeroxide",true,"Na\u2082O\u2082");
+ Type(int damage1, String unlocalizedName1)
+ {
+ damage=damage1;
+ textureName=unLocalizedName=unlocalizedName1;
+ }
+ Type(int damage1,String unlocalizedName1, boolean registerInOreDictionary1)
+ {
+ damage=damage1;
+ textureName=oreRegistryName=unLocalizedName=unlocalizedName1;
+ registerInOreDictionary=registerInOreDictionary1;
+ }
+ Type(int damage1,String unlocalizedName1, boolean registerInOreDictionary1,String description1)
+ {
+ damage=damage1;
+ textureName=oreRegistryName=unLocalizedName=unlocalizedName1;
+ registerInOreDictionary=registerInOreDictionary1;
+ description=description1;
+ }
+ Type(int damage1,String unlocalizedName1, boolean registerInOreDictionary1,String description1, String textureName1)
+ {
+ damage=damage1;
+ oreRegistryName=unLocalizedName=unlocalizedName1;
+ registerInOreDictionary=registerInOreDictionary1;
+ description=description1;
+ textureName=textureName1;
+ }
+ public int damage;
+ public String unLocalizedName;
+ public String oreRegistryName;
+ public String description;
+ public String textureName;
+ public boolean registerInOreDictionary=false;
+ }
+
+}
\ No newline at end of file diff --git a/ihl/items_blocks/MachineBaseBlock.java b/ihl/items_blocks/MachineBaseBlock.java new file mode 100644 index 0000000..0cb10cb --- /dev/null +++ b/ihl/items_blocks/MachineBaseBlock.java @@ -0,0 +1,880 @@ +package ihl.items_blocks;
+
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.item.tool.ItemToolCutter;
+import ic2.core.item.tool.ItemToolWrench;
+import ihl.IHLCreativeTab;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import ihl.collector.GlassBoxTileEntity;
+import ihl.datanet.RedstoneSignalConverterTileEntity;
+import ihl.flexible_cable.BatterySwitchUnitTileEntity;
+import ihl.flexible_cable.IronWorkbenchTileEntity;
+import ihl.flexible_cable.RectifierTransformerUnitTileEntity;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.interfaces.IMultiPowerCableHolder;
+import ihl.processing.chemistry.ChemicalReactorTileEntity;
+import ihl.processing.chemistry.CryogenicDistillerTileEntity;
+import ihl.processing.chemistry.ElectrolysisBathTileEntity;
+import ihl.processing.chemistry.FluidizedBedReactorTileEntity;
+import ihl.processing.chemistry.FractionatorBottomTileEntity;
+import ihl.processing.chemistry.FractionatorCoverTileEntity;
+import ihl.processing.chemistry.FractionatorSectionTileEntity;
+import ihl.processing.chemistry.GaedesMercuryRotaryPumpTileEntity;
+import ihl.processing.chemistry.GoldChimneyKneeTileEntity;
+import ihl.processing.chemistry.LabElectrolyzerTileEntity;
+import ihl.processing.chemistry.LeadOvenTileEntity;
+import ihl.processing.chemistry.LoomTileEntity;
+import ihl.processing.chemistry.PaperMachineTileEntity;
+import ihl.processing.chemistry.PrecipitatorCondenserTileEntity;
+import ihl.processing.chemistry.RefluxCondenserTileEntity;
+import ihl.processing.metallurgy.AchesonFurnanceTileEntity;
+import ihl.processing.metallurgy.CoilerTileEntity;
+import ihl.processing.metallurgy.DetonationSprayingMachineTileEntity;
+import ihl.processing.metallurgy.ExtruderTileEntity;
+import ihl.processing.metallurgy.GasWeldingStationTileEntity;
+import ihl.processing.metallurgy.ImpregnatingMachineTileEntity;
+import ihl.processing.metallurgy.LathePart1TileEntity;
+import ihl.processing.metallurgy.LathePart2TileEntity;
+import ihl.processing.metallurgy.MuffleFurnanceTileEntity;
+import ihl.processing.metallurgy.RollingMachinePart1TileEntity;
+import ihl.processing.metallurgy.RollingMachinePart2TileEntity;
+import ihl.processing.metallurgy.VacuumInductionMeltingFurnaceTileEntity;
+import ihl.processing.metallurgy.VulcanizationExtrudingMoldTileEntity;
+import ihl.processing.metallurgy.WireMillTileEntity;
+import ihl.processing.metallurgy.WoodenRollingMachinePart1TileEntity;
+import ihl.processing.metallurgy.WoodenRollingMachinePart2TileEntity;
+import ihl.tunneling_shield.HydrotransportPulpRegeneratorTileEntity;
+import ihl.utils.IHLUtils;
+
+import java.util.ArrayList;
+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.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+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 net.minecraftforge.common.util.ForgeDirection;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class MachineBaseBlock extends Block implements ITileEntityProvider{
+
+ MachineType type;
+ private static List<MachineBaseBlock> 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<var1.length;i++)
+ {
+ if(!var1[i].unlocalizedName.equalsIgnoreCase(IHLMod.config.preventMachineBlockRegistrationName))
+ {
+ GameRegistry.registerBlock(new MachineBaseBlock(var1[i]), IHLItemBlock.class,var1[i].unlocalizedName);
+ GameRegistry.registerTileEntity(var1[i].teclass,var1[i].unlocalizedName);
+ }
+ }
+ IHLUtils.getThisModBlock("tubBronze").setBlockTextureName("tubBronzeIcon");
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
+ {
+ if(this.type.itemDroppedOnBlockDestroy!=null)
+ {
+ this.dropBlockAsItem(world, x, y, z, this.type.itemDroppedOnBlockDestroy.copy());
+ }
+ else
+ {
+ super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag);
+ }
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ TileEntity newTE = null;
+ try
+ {
+ newTE = (TileEntity) type.teclass.newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ e.printStackTrace();
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+ return newTE;
+ }
+
+ @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");
+ this.textureFrontMuffleFurnance = par1IconRegister.registerIcon(IHLModInfo.MODID + ":muffleOvenFront");
+ this.textureTopAchesonFurnance = par1IconRegister.registerIcon(IHLModInfo.MODID + ":achesonOvenTop");
+ this.textureTopGoldFurnace = par1IconRegister.registerIcon(IHLModInfo.MODID + ":porcelainFurnaceTop");
+ this.textureFrontGoldFurnace = par1IconRegister.registerIcon(IHLModInfo.MODID + ":porcelainFurnaceFront");
+ this.textureSideGoldFurnace = par1IconRegister.registerIcon(IHLModInfo.MODID + ":porcelainFurnaceSide");
+ this.textureLeftMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsLeft");
+ this.textureTopMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsTop");
+ this.textureRightMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsRight");
+ this.textureFrontMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsFront");
+ this.textureBackMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsBack");
+ this.textureFrontCryogenicDistiller = par1IconRegister.registerIcon(IHLModInfo.MODID + ":cryogenicDistillerOxygenSide");
+ this.textureTopCryogenicDistiller = par1IconRegister.registerIcon(IHLModInfo.MODID + ":cryogenicDistillerNitrogenSide");
+ this.textureBackCryogenicDistiller = par1IconRegister.registerIcon(IHLModInfo.MODID + ":cryogenicDistillerInputSide");
+ this.textureFrontChemicalReactor = par1IconRegister.registerIcon(IHLModInfo.MODID + ":chemicalReactorOutputSide");
+ this.textureFrontPaperMachine = par1IconRegister.registerIcon(IHLModInfo.MODID + ":paperMachineFront");
+ this.frequencyGeneratorBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":frequencyGeneratorBack");
+ this.frequencyGeneratorFront = par1IconRegister.registerIcon(IHLModInfo.MODID + ":frequencyGeneratorFront");
+ this.frequencyGeneratorTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":frequencyGeneratorTop");
+ this.frequencyGeneratorLeft = par1IconRegister.registerIcon(IHLModInfo.MODID + ":frequencyGeneratorLeft");
+ this.frequencyGeneratorRight = par1IconRegister.registerIcon(IHLModInfo.MODID + ":frequencyGeneratorRight");
+ this.frequencyGeneratorBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":frequencyGeneratorBottom");
+ this.bronzeTubTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tubBronzeTop");
+ this.bronzeTubSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tubBronzeSide");
+ this.glassBoxBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":glassBoxBottom");
+ this.glassBoxInnerBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":glassBoxInnerBottom");
+ this.glassBoxInnerSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":glassBoxInnerSide");
+ this.glassBoxSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":glassBoxSide");
+ this.glassBoxTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":glassBoxTop");
+ this.vacuumInductionMeltingFurnaceFront = par1IconRegister.registerIcon(IHLModInfo.MODID + ":vacuumInductionMeltingFurnaceFront");
+ this.vacuumInductionMeltingFurnaceBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":vacuumInductionMeltingFurnaceBack");
+ this.vacuumInductionMeltingFurnaceLeft = par1IconRegister.registerIcon(IHLModInfo.MODID + ":vacuumInductionMeltingFurnaceLeft");
+ this.vacuumInductionMeltingFurnaceRight = par1IconRegister.registerIcon(IHLModInfo.MODID + ":vacuumInductionMeltingFurnaceRight");
+ this.hydrotransportPulpRegeneratorFront = par1IconRegister.registerIcon(IHLModInfo.MODID + ":hydrotransportPulpRegeneratorFront");
+ this.hydrotransportPulpRegeneratorBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":hydrotransportPulpRegeneratorBack");
+ this.redstoneSignalConverterEmitterSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":redstoneSignalConverterEmitterSide");
+ this.redstoneSignalConverterEmptySide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":redstoneSignalConverterEmptySide");
+ this.redstoneSignalConverterSensorSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":redstoneSignalConverterSensorSide");
+ this.steel = par1IconRegister.registerIcon(IHLModInfo.MODID + ":steel");
+ this.redPaint = par1IconRegister.registerIcon(IHLModInfo.MODID + ":redPaint");
+ this.greenPaint = par1IconRegister.registerIcon(IHLModInfo.MODID + ":greenPaint");
+ this.rubberInsulatedCase = par1IconRegister.registerIcon(IHLModInfo.MODID + ":rubberInsulatedCase");
+ this.powerPort = par1IconRegister.registerIcon(IHLModInfo.MODID + ":powerPort");
+ }
+
+ @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())
+ {
+ if(te instanceof DetonationSprayingMachineTileEntity && player.getCurrentEquippedItem()!=null && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel)
+ {
+ ((DetonationSprayingMachineTileEntity)te).operate();
+ return true;
+ }
+ if(te instanceof LathePart2TileEntity)
+ {
+ LathePart2TileEntity lte = ((LathePart2TileEntity)te);
+ te = world.getTileEntity(x-ForgeDirection.getOrientation(lte.getFacing()).offsetX,y-ForgeDirection.getOrientation(lte.getFacing()).offsetY,z-ForgeDirection.getOrientation(lte.getFacing()).offsetZ);
+ }
+ if(te instanceof RollingMachinePart2TileEntity)
+ {
+ RollingMachinePart2TileEntity lte = ((RollingMachinePart2TileEntity)te);
+ te = world.getTileEntity(x-ForgeDirection.getOrientation(lte.getFacing()).offsetX,y-ForgeDirection.getOrientation(lte.getFacing()).offsetY,z-ForgeDirection.getOrientation(lte.getFacing()).offsetZ);
+ }
+ if(te instanceof WoodenRollingMachinePart2TileEntity)
+ {
+ WoodenRollingMachinePart2TileEntity lte = ((WoodenRollingMachinePart2TileEntity)te);
+ te = world.getTileEntity(x-ForgeDirection.getOrientation(lte.getFacing()).offsetX,y-ForgeDirection.getOrientation(lte.getFacing()).offsetY,z-ForgeDirection.getOrientation(lte.getFacing()).offsetZ);
+ }
+ if(te instanceof RectifierTransformerUnitTileEntity)
+ {
+ RectifierTransformerUnitTileEntity rtu = (RectifierTransformerUnitTileEntity)te;
+ if(player.getCurrentEquippedItem()==null)
+ {
+ if(IC2.keyboard.isModeSwitchKeyDown(player))
+ {
+ rtu.switchModeDown();
+ }
+ else
+ {
+ rtu.switchModeUp();
+ }
+ IC2.platform.messagePlayer(player, "ic2.tooltip.mode", new Object[] {" Voltage output was set to x" + rtu.mode});
+ }
+ }
+ if(te instanceof IEnergyNetNode)
+ {
+ IEnergyNetNode node = (IEnergyNetNode)te;
+ if(player.getCurrentEquippedItem()!=null && player.getCurrentEquippedItem().getItem() instanceof ItemToolCutter)
+ {
+ node.removeAttachedChains();
+ }
+ }
+ }
+ return te instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, (IHasGui)te) : true) : 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 instanceof IWrenchable)
+ {
+ ((IWrenchable)t).setFacing(IHLUtils.getFacingFromPlayerView(player,false));
+ }
+ }
+
+ @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)
+ {
+ if(this.type==MachineType.IronWorkbench)
+ {
+ return this.steel;
+ }
+ if(this.type==MachineType.RedstoneSignalConverter)
+ {
+ return this.redstoneSignalConverterEmptySide;
+ }
+ if(this.type==MachineType.RectifierTransformerUnit)
+ {
+ switch(side)
+ {
+ case 0:
+ return this.bronzeTubSide;
+ case 1:
+ return this.textureSideGoldFurnace;
+ case 2:
+ return this.redPaint;
+ case 3:
+ return this.greenPaint;
+ case 4:
+ return this.rubberInsulatedCase;
+ case 5:
+ return this.powerPort;
+ }
+ }
+ return this.getIconFromFacing(3, side);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromFacing(int facing, int side)
+ {
+ 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
+ };
+ switch(this.type)
+ {
+ case RefluxCondenser:
+ return this.steel;
+ case RectifierTransformerUnit:
+ return this.bronzeTubSide;
+ case IronWorkbench:
+ return this.steel;
+ default:
+ }
+ switch (mask[facing*6+side])
+ {
+ case 0:
+ switch(this.type)
+ {
+ case HydrotransportPulpRegenerator:
+ return this.hydrotransportPulpRegeneratorFront;
+ case GlassBox:
+ return this.glassBoxSide;
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case AchesonFurnace:
+ return this.blockIcon;
+ case MuffleFurnace:
+ return this.textureFrontMuffleFurnance;
+ case LeadOven:
+ return this.textureFrontGoldFurnace;
+ case WireMill:
+ return this.textureFrontMachineCasing;
+ case LabElectrolyzer:
+ return this.textureTopMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureTopMachineCasing;
+ case ChemicalReactor:
+ return this.textureFrontChemicalReactor;
+ case CryogenicDistiller:
+ return this.textureFrontCryogenicDistiller;
+ case PaperMachine:
+ return this.textureFrontPaperMachine;
+ case VacuumInductionMeltingFurnace:
+ return this.vacuumInductionMeltingFurnaceFront;
+ default:
+ break;
+ }
+ case 1:
+ switch(this.type)
+ {
+ case HydrotransportPulpRegenerator:
+ return this.hydrotransportPulpRegeneratorBack;
+ case GlassBox:
+ return this.glassBoxSide;
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case LeadOven:
+ return this.textureSideGoldFurnace;
+ case WireMill:
+ return this.textureBackMachineCasing;
+ case CryogenicDistiller:
+ return this.textureBackCryogenicDistiller;
+ case PaperMachine:
+ return this.textureBackCryogenicDistiller;
+ case LabElectrolyzer:
+ return this.textureBackCryogenicDistiller;
+ case FluidizedBedReactor:
+ return this.textureBackCryogenicDistiller;
+ case ChemicalReactor:
+ return this.textureBackCryogenicDistiller;
+ case VacuumInductionMeltingFurnace:
+ return this.vacuumInductionMeltingFurnaceBack;
+ default:
+ return this.textureBack;
+ }
+
+ case 2:
+ switch(this.type)
+ {
+ case HydrotransportPulpRegenerator:
+ return this.textureBackMachineCasing;
+ case GlassBox:
+ return this.glassBoxBottom;
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case LeadOven:
+ return this.textureSideGoldFurnace;
+ case WireMill:
+ return this.textureBackMachineCasing;
+ case CryogenicDistiller:
+ return this.textureBackMachineCasing;
+ case PaperMachine:
+ return this.textureBackMachineCasing;
+ case LabElectrolyzer:
+ return this.textureBackMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureBackMachineCasing;
+ case ChemicalReactor:
+ return this.textureBackMachineCasing;
+ case VacuumInductionMeltingFurnace:
+ return this.vacuumInductionMeltingFurnaceRight;
+ default:
+ return this.textureTop;
+ }
+ case 3:
+ switch(this.type)
+ {
+ case HydrotransportPulpRegenerator:
+ return this.textureTopMachineCasing;
+ case GlassBox:
+ return this.glassBoxTop;
+ case BronzeTub:
+ return this.bronzeTubTop;
+ case AchesonFurnace:
+ return this.textureTopAchesonFurnance;
+ case MuffleFurnace:
+ return this.textureTop;
+ case LeadOven:
+ return this.textureTopGoldFurnace;
+ case WireMill:
+ return this.textureTopMachineCasing;
+ case CryogenicDistiller:
+ return this.textureTopCryogenicDistiller;
+ case PaperMachine:
+ return this.textureTopMachineCasing;
+ case LabElectrolyzer:
+ return this.textureTopMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureTopMachineCasing;
+ case ChemicalReactor:
+ return this.textureTopMachineCasing;
+ case VacuumInductionMeltingFurnace:
+ return this.vacuumInductionMeltingFurnaceRight;
+ default:
+ return this.textureTop;
+ }
+ case 4:
+ switch(this.type)
+ {
+ case HydrotransportPulpRegenerator:
+ return this.textureRightMachineCasing;
+ case GlassBox:
+ return this.glassBoxSide;
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case LeadOven:
+ return this.textureSideGoldFurnace;
+ case WireMill:
+ return this.textureRightMachineCasing;
+ case CryogenicDistiller:
+ return this.textureRightMachineCasing;
+ case PaperMachine:
+ return this.textureRightMachineCasing;
+ case LabElectrolyzer:
+ return this.textureRightMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureRightMachineCasing;
+ case ChemicalReactor:
+ return this.textureRightMachineCasing;
+ case VacuumInductionMeltingFurnace:
+ return this.vacuumInductionMeltingFurnaceRight;
+ default:
+ return this.textureSide;
+ }
+ case 5:
+ switch(this.type)
+ {
+ case HydrotransportPulpRegenerator:
+ return this.textureLeftMachineCasing;
+ case GlassBox:
+ return this.glassBoxSide;
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case LeadOven:
+ return this.textureSideGoldFurnace;
+ case CryogenicDistiller:
+ return this.textureLeftMachineCasing;
+ case PaperMachine:
+ return this.textureLeftMachineCasing;
+ case WireMill:
+ return this.textureLeftMachineCasing;
+ case ChemicalReactor:
+ return this.textureLeftMachineCasing;
+ case LabElectrolyzer:
+ return this.textureLeftMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureLeftMachineCasing;
+ case VacuumInductionMeltingFurnace:
+ return this.vacuumInductionMeltingFurnaceLeft;
+ default:
+ return this.textureSide;
+ }
+ default:
+ return this.textureSide;
+ }
+ }
+
+ @Override
+ public boolean onBlockEventReceived(World world, int x, int y, int z, int metadata, int flag)
+ {
+ return true;
+ }
+
+ @Override
+ public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side)
+ {
+ TileEntity te = world.getTileEntity(x, y, z);
+ if(te instanceof RedstoneSignalConverterTileEntity)
+ {
+ RedstoneSignalConverterTileEntity rte = (RedstoneSignalConverterTileEntity) te;
+ return rte.isProvidingRedstonePower(side);
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean canProvidePower()
+ {
+ return true;
+ }
+
+ @Override
+ public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int metadata)
+ {
+ return this.isProvidingWeakPower(world, x, y, z, metadata);
+ }
+
+ public enum MachineType
+ {
+
+ IronWorkbench("ironWorkbench",IronWorkbenchTileEntity.class, false, true, null),
+ RedstoneSignalConverter("redstoneSignalConverter",RedstoneSignalConverterTileEntity.class, true, true, IHLUtils.getThisModItemStack("foilSteel")),
+ HydrotransportPulpRegenerator("hydrotransportPulpRegenerator", HydrotransportPulpRegeneratorTileEntity.class, true, IHLUtils.getThisModItemStack("extruderSetOfMoldedPartsSteel")),
+ VacuumInductionMeltingFurnace("vacuumInductionMeltingFurnace", VacuumInductionMeltingFurnaceTileEntity.class, true, IHLUtils.getThisModItemStack("foilSteel")),
+ GlassBox("glassBoxBlock",GlassBoxTileEntity.class, false, true, IHLUtils.getThisModItemStack("dustGlass")),
+ ElectrolysisBath("electrolysisBath",ElectrolysisBathTileEntity.class, false, IHLUtils.getThisModItemStack("plateGraphite")),
+ RectifierTransformerUnit("rectifierTransformerUnit",RectifierTransformerUnitTileEntity.class, false, true, IHLUtils.getThisModItemStack("foilSteel")),
+ BatterySwitchUnit("batterySwitchUnit",BatterySwitchUnitTileEntity.class, false, IHLUtils.getThisModItemStack("foilSteel")),
+ FractionatorBottom("fractionatorBottom",FractionatorBottomTileEntity.class, false, IHLUtils.getThisModItemStack("foilSteel")),
+ FractionatorSection("fractionatorSection",FractionatorSectionTileEntity.class, false, IHLUtils.getThisModItemStackWithSize("ringPorcelain",16)),
+ FractionatorCover("fractionatorCover",FractionatorCoverTileEntity.class, false, IHLUtils.getThisModItemStack("foilSteel")),
+ RefluxCondenser("refluxCondenser",RefluxCondenserTileEntity.class, false,false, IHLUtils.getThisModItemStack("foilSteel")),
+ PaperMachine("paperMachine",PaperMachineTileEntity.class, true, IHLUtils.getThisModItemStack("stickSteel")),
+ GaedesMercuryRotaryPump("gaedesMercuryRotaryPump",GaedesMercuryRotaryPumpTileEntity.class,false, IHLUtils.getThisModItemStack("foilSteel")),
+ LabElectrolyzer("labElectrolyzer",LabElectrolyzerTileEntity.class, true, IHLUtils.getThisModItemStack("stickGraphite")),
+ FluidizedBedReactor("fluidizedBedReactor",FluidizedBedReactorTileEntity.class, true, IHLUtils.getThisModItemStack("highPressureVesselSteel")),
+ ChemicalReactor("chemicalReactor",ChemicalReactorTileEntity.class, true, IHLUtils.getThisModItemStack("highPressureVesselSteel")),
+ CryogenicDistiller("cryogenicDistiller",CryogenicDistillerTileEntity.class, true, IHLUtils.getThisModItemStack("highPressureVesselSteel")),
+ GasWeldingStation("gasWeldingStation",GasWeldingStationTileEntity.class, false, null),
+ WoodenRollingMachine1("woodenRollingMachinePart1",WoodenRollingMachinePart1TileEntity.class, false, IHLUtils.getThisModItemStack("barD10Steel")),
+ WoodenRollingMachine2("woodenRollingMachinePart2",WoodenRollingMachinePart2TileEntity.class, false, IHLUtils.getThisModItemStack("barD10Steel")),
+ WireMill("wireMill",WireMillTileEntity.class, true, IHLUtils.getThisModItemStack("stickSteel")),
+ VulcanizationExtrudingMold("vulcanizationExtrudingMold",VulcanizationExtrudingMoldTileEntity.class, false, IHLUtils.getThisModItemStack("dustCarborundum")),
+ Extruder("extruder",ExtruderTileEntity.class, false, IHLUtils.getThisModItemStack("dustCarborundum")),
+ RollingMachine1("rollingMachinePart1",RollingMachinePart1TileEntity.class, false, IHLUtils.getThisModItemStack("stickSteel")),
+ RollingMachine2("rollingMachinePart2",RollingMachinePart2TileEntity.class, false, IHLUtils.getThisModItemStack("stickSteel")),
+ Loom("loom", LoomTileEntity.class, false, new ItemStack(Items.stick)),
+ Coiler("coiler",CoilerTileEntity.class, false, new ItemStack(Items.stick)),
+ Lathe1("lathePart1",LathePart1TileEntity.class, false, IHLUtils.getThisModItemStack("stickSteel")),
+ Lathe2("lathePart2",LathePart2TileEntity.class, false, IHLUtils.getOreDictItemStack("plateSteel")),
+ PrecipitatorCondenser("goldPrecipitatorCondenser",PrecipitatorCondenserTileEntity.class, false, IHLUtils.getThisModItemStack("dustPorcelain")),
+ GoldChimneyKnee("goldChimneyKnee",GoldChimneyKneeTileEntity.class, false, IHLUtils.getThisModItemStack("dustPorcelain")),
+ LeadOven("leadOven",LeadOvenTileEntity.class, true, IHLUtils.getThisModItemStack("dustPorcelain")),
+ DetonationSprayingMachine("cannonBronze",DetonationSprayingMachineTileEntity.class, false, new ItemStack(Items.stick)),
+ BronzeTub("tubBronze",ImpregnatingMachineTileEntity.class, false, true, null),
+ AchesonFurnace("achesonFurnance",AchesonFurnanceTileEntity.class, true, new ItemStack(Items.brick)),
+ MuffleFurnace("muffleFurnance",MuffleFurnanceTileEntity.class, true, new ItemStack(Items.brick));
+ MachineType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1,ItemStack itemDroppedOnBlockDestroy1)
+ {
+ unlocalizedName=unlocalizedName1;
+ teclass=teclass1;
+ isNormalBlock=isNormalBlock1;
+ if(isNormalBlock)
+ {
+ specialBlockRendererId=0;
+ }
+ else
+ {
+ specialBlockRendererId=-2;
+ }
+ itemDroppedOnBlockDestroy=itemDroppedOnBlockDestroy1;
+ }
+ MachineType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1,boolean hasSpecialBlockRenderer1, ItemStack itemDroppedOnBlockDestroy1)
+ {
+ unlocalizedName=unlocalizedName1;
+ teclass=teclass1;
+ isNormalBlock=isNormalBlock1;
+ hasSpecialBlockRenderer=hasSpecialBlockRenderer1;
+ itemDroppedOnBlockDestroy=itemDroppedOnBlockDestroy1;
+
+ }
+ String unlocalizedName;
+ Class teclass;
+ boolean isNormalBlock=true;
+ boolean hasSpecialBlockRenderer=false;
+ int specialBlockRendererId=-2;
+ ItemStack itemDroppedOnBlockDestroy;
+ }
+
+ @Override
+ public int getRenderType()
+ {
+ if(this.type.hasSpecialBlockRenderer)
+ {
+ return IHLMod.proxy.shareBlockRendererByMachineType(this.type);
+ }
+ return this.type.specialBlockRendererId;
+ }
+
+ @Override
+ public boolean isOpaqueCube()
+ {
+ return this.type==null?false:this.type.isNormalBlock;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock()
+ {
+ return this.type.isNormalBlock;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public IIcon getAdditionalIconsForBlockRenderer(int flag)
+ {
+ switch(this.type)
+ {
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case GlassBox:
+ switch(flag)
+ {
+ case 0:
+ return this.glassBoxInnerSide;
+ case 1:
+ return this.glassBoxInnerBottom;
+ }
+ case RedstoneSignalConverter:
+ switch(flag)
+ {
+ case 0:
+ return this.redstoneSignalConverterEmptySide;
+ case 1:
+ return this.redstoneSignalConverterEmitterSide;
+ case 2:
+ return this.redstoneSignalConverterSensorSide;
+ }
+ default:
+ return this.blockIcon;
+ }
+ }
+
+}
\ No newline at end of file diff --git a/ihl/items_blocks/RecipeInputs.java b/ihl/items_blocks/RecipeInputs.java new file mode 100644 index 0000000..6b49ce2 --- /dev/null +++ b/ihl/items_blocks/RecipeInputs.java @@ -0,0 +1,25 @@ +package ihl.items_blocks;
+
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeInputOreDict;
+import ihl.utils.IHLUtils;
+
+public class RecipeInputs
+{
+ public static IRecipeInput cutter = new RecipeInputOreDict("craftingToolWireCutter");
+ public static IRecipeInput saw = new RecipeInputOreDict("craftingToolSaw");
+ public static IRecipeInput file = new RecipeInputOreDict("craftingToolFile");
+ public static IRecipeInput vise = new RecipeInputItemStack(IHLUtils.getThisModItemStack("viseSteel"));
+ public static IRecipeInput plateSteel = new RecipeInputOreDict("plateSteel");
+ public static IRecipeInput hammer = new RecipeInputOreDict("craftingToolHardHammer");
+
+ public static IRecipeInput get(String name, int amount)
+ {
+ return new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize(name,amount),amount);
+ }
+ public static IRecipeInput get(String name)
+ {
+ return new RecipeInputItemStack(IHLUtils.getThisModItemStack(name));
+ }
+}
|
