diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2017-06-17 08:12:18 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2017-06-17 08:12:18 +0300 |
| commit | dc3df3edd5843bde0c1335d6a8e460b2c832aa48 (patch) | |
| tree | af13bfeee567f2351e35e1ef176d168fe37c8aac /ihl/handpump | |
| parent | 1da8dcd58647e34c9af94ceeecaeaf3b0d08c48c (diff) | |
full project files
Diffstat (limited to 'ihl/handpump')
| -rw-r--r-- | ihl/handpump/AdvancedHandPump.java | 351 | ||||
| -rw-r--r-- | ihl/handpump/BlockWithCoordinates.java | 96 | ||||
| -rw-r--r-- | ihl/handpump/IHLHandPump.java | 351 | ||||
| -rw-r--r-- | ihl/handpump/XYZ.java | 26 |
4 files changed, 0 insertions, 824 deletions
diff --git a/ihl/handpump/AdvancedHandPump.java b/ihl/handpump/AdvancedHandPump.java deleted file mode 100644 index c842a2b..0000000 --- a/ihl/handpump/AdvancedHandPump.java +++ /dev/null @@ -1,351 +0,0 @@ -package ihl.handpump;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ic2.api.item.ElectricItem;
-import ic2.api.item.IC2Items;
-import ic2.core.Ic2Items;
-import ic2.core.util.LiquidUtil;
-import ihl.IHLMod;
-import ihl.IHLModInfo;
-import ihl.utils.IHLUtils;
-import ihl.worldgen.ores.IHLFluid;
-import net.minecraft.block.Block;
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Blocks;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.MovingObjectPosition;
-import net.minecraft.world.World;
-import net.minecraftforge.fluids.BlockFluidBase;
-import net.minecraftforge.fluids.FluidContainerRegistry;
-import net.minecraftforge.fluids.FluidRegistry;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.IFluidContainerItem;
-
-public class AdvancedHandPump extends IHLHandPump {
-
- public AdvancedHandPump()
- {
- super();
- this.maxCharge=IHLMod.config.advancedHandpumpMaxCharge;
- this.operationEUCost=IHLMod.config.advancedHandpumpOperationEUCost;
- this.tier=IHLMod.config.advancedHandpumpTier;
- }
-
- @Override
- public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
- {
- MovingObjectPosition movingobjectposition = IHLUtils.returnMOPFromPlayer(entityPlayer, world);
- if(movingobjectposition!=null)
- {
- int x=movingobjectposition.blockX;
- int y=movingobjectposition.blockY;
- int z=movingobjectposition.blockZ;
- Block block = world.getBlock(x, y, z);
- if(!block.getMaterial().isLiquid())
- {
- y++;
- block = world.getBlock(x, y, z);
- if(!block.getMaterial().isLiquid())
- {
- return itemStack;
- }
- }
- if(world.isRemote && ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer))
- {
- entityPlayer.playSound(IHLModInfo.MODID+":handpumpOne", (float) (Math.random()*0.2D+0.6D), (float) (Math.random()*0.1D+0.9D));
- return itemStack;
- }
- else
- {
- BlockWithCoordinates blockXYZ = this.searchSource(world, x, y, z);
- if(blockXYZ==null)
- {
- return itemStack;
- }
- block = blockXYZ.block;
- FluidStack fluid1 = null;
- if(block instanceof BlockFluidBase)
- {
- fluid1 = ((BlockFluidBase)block).drain(world, blockXYZ.x, blockXYZ.y, blockXYZ.z, false);
- }
- else if(block==Blocks.water||block==Blocks.flowing_water)
- {
- fluid1 = new FluidStack(FluidRegistry.WATER, 1000);
- }
- else if(block==Blocks.lava||block==Blocks.flowing_lava)
- {
- fluid1 = new FluidStack(FluidRegistry.LAVA, 1000);
- }
- int amount2=0;
- ItemStack stack = this.getItemStackContains(fluid1, entityPlayer);
- if(stack!=null && fluid1 != null)
- {
- amount2 = LiquidUtil.fillContainerStack(stack, entityPlayer, fluid1, true);
- }
- if(amount2 >0)
- {
- if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer))
- {
- fluid1.amount=Integer.MAX_VALUE;
- int countFreeAmount = this.countAmountOfEmptyFluidCells(Ic2Items.FluidCell, fluid1, entityPlayer);
- Set<BlockWithCoordinates> blockXYZSet = this.searchSourcesAndDestroyThem(world, blockXYZ, countFreeAmount/1000);
- int countDestroedSources = blockXYZSet.size();
- this.destroyAllSources(world, blockXYZSet);
- ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false);
- this.fillUniversalFluidCells(fluid1, entityPlayer,countDestroedSources);
- entityPlayer.inventoryContainer.detectAndSendChanges();
- }
- return itemStack;
- }
- else if(entityPlayer.inventory.hasItemStack(IC2Items.getItem("cell")))
- {
- if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer))
- {
- int countCells = this.countEmptyCells(IC2Items.getItem("cell"), entityPlayer);
- Set<BlockWithCoordinates> blockXYZSet = this.searchSourcesAndDestroyThem(world, blockXYZ, countCells);
- int countDestroedSources = blockXYZSet.size();
- this.destroyAllSources(world, blockXYZSet);
- ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false);
- this.fillFluidCells(fluid1, entityPlayer, countDestroedSources);
- entityPlayer.inventoryContainer.detectAndSendChanges();
- return itemStack;
- }
- }
- }
- }
- return itemStack;
- }
-
- private void destroyAllSources(World world,Set<BlockWithCoordinates> blockXYZSet)
- {
- Iterator<BlockWithCoordinates> iterator = blockXYZSet.iterator();
- while(iterator.hasNext())
- {
- BlockWithCoordinates blockXYZ = iterator.next();
- blockXYZ.setMetadataOrDestroyBlock(world, 1, 7);
- }
- }
-
- private void fillUniversalFluidCells(FluidStack fluid1, EntityPlayer entityPlayer,
- int countDestroedSources) {
- fluid1.amount=countDestroedSources*1000;
- //System.out.println("countDestroedSources="+countDestroedSources);
- //System.out.println("fluidStackAmount="+fluid1.amount);
- a:for (int i=0;i<entityPlayer.inventory.getSizeInventory();i++)
- {
- if(entityPlayer.inventory.getStackInSlot(i)!=null)
- {
- if(entityPlayer.inventory.getStackInSlot(i).getItem() instanceof IFluidContainerItem)
- {
- int amount2 = LiquidUtil.fillContainerStack(entityPlayer.inventory.getStackInSlot(i), entityPlayer, fluid1, false);
- fluid1.amount-=amount2;
- while(fluid1.amount>=1000 && entityPlayer.inventory.getStackInSlot(i).stackSize>=1 && amount2>0)
- {
- amount2 = LiquidUtil.fillContainerStack(entityPlayer.inventory.getStackInSlot(i), entityPlayer, fluid1, false);
- fluid1.amount-=amount2;
- }
- if(fluid1.amount<1000)
- {
- break a;
- }
- }
- }
- }
- }
-
- private void fillFluidCells(FluidStack fluid1, EntityPlayer player, int countDestroedSources) {
- ItemStack cell = IHLFluid.getCell(fluid1.getFluid().getName());
- if(cell==null)
- {
- return;
- }
- ItemStack emptyCells = IC2Items.getItem("cell").copy();
- emptyCells.stackSize=player.inventory.clearInventory(IC2Items.getItem("cell").getItem(),0)-countDestroedSources;
- cell.stackSize=countDestroedSources;
- IHLUtils.addItemStackToInventory(player, cell);
- if(emptyCells.stackSize>0)
- {
- IHLUtils.addItemStackToInventory(player, emptyCells);
- }
- }
-
- private Set<BlockWithCoordinates> searchSourcesAndDestroyThem(World world, BlockWithCoordinates blockXYZ, int countCells)
- {
- int startx = blockXYZ.x;
- int starty = blockXYZ.y;
- int startz = blockXYZ.z;
- int currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- HashSet<BlockWithCoordinates> outputSet = new HashSet<BlockWithCoordinates>();
- for (int i=0; i<256;i++)
- {
- if(getFlowDecay(world, blockXYZ, startx, starty+1, startz)>=0)
- {
- starty++;
- currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- }
-
- else if(getFlowDecay(world, blockXYZ, startx+1, starty+1, startz)>=0)
- {
- starty++;
- startx++;
- currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- }
-
- else if(getFlowDecay(world, blockXYZ, startx-1, starty+1, startz)>=0)
- {
- starty++;
- startx--;
- currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- }
-
- else if(getFlowDecay(world, blockXYZ, startx, starty+1, startz+1)>=0)
- {
- starty++;
- startz++;
- currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- }
-
- else if(getFlowDecay(world, blockXYZ, startx, starty+1, startz-1)>=0)
- {
- starty++;
- startz--;
- currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- }
- //Start checking neighbor blocks to lower flow decay.
- else if(getFlowDecay(world, blockXYZ, startx-1, starty, startz)<currentFlowDecay&&getFlowDecay(world, startx-1, starty, startz)!=-1)
- {
- startx--;
- currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- }
- else if(getFlowDecay(world, blockXYZ, startx, starty, startz+1)<currentFlowDecay&&getFlowDecay(world, startx, starty, startz+1)!=-1)
- {
- startz++;
- currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- }
- else if(getFlowDecay(world, blockXYZ, startx, starty, startz-1)<currentFlowDecay&&getFlowDecay(world, startx, starty, startz-1)!=-1)
- {
- startz--;
- currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- }
- else if(getFlowDecay(world, blockXYZ, startx+1, starty, startz)<currentFlowDecay&&getFlowDecay(world, startx+1, starty, startz)!=-1)
- {
- startx++;
- currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
- }
- else {break;}
- }
- List<XYZ> xyzlist = new ArrayList<XYZ>();
- if(currentFlowDecay==0)
- {
- xyzlist.add(new XYZ(startx, starty, startz));
- outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
- int listPos=0;
- for(int i=0;i<=countCells;i++)
- {
- if(getFlowDecay(world, blockXYZ, startx-1, starty, startz)==0 && !xyzlist.contains(new XYZ(startx-1, starty, startz)))
- {
- startx--;
- xyzlist.add(new XYZ(startx, starty, startz));
- listPos=xyzlist.size()-1;
- outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
- }
- else if(getFlowDecay(world, blockXYZ, startx, starty, startz+1)==0 && !xyzlist.contains(new XYZ(startx, starty, startz+1)))
- {
- startz++;
- xyzlist.add(new XYZ(startx, starty, startz));
- listPos=xyzlist.size()-1;
- outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
- }
- else if(getFlowDecay(world, blockXYZ, startx, starty, startz-1)==0 && !xyzlist.contains(new XYZ(startx, starty, startz-1)))
- {
- startz--;
- xyzlist.add(new XYZ(startx, starty, startz));
- listPos=xyzlist.size()-1;
- outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
- }
- else if(getFlowDecay(world, blockXYZ, startx+1, starty, startz)==0 && !xyzlist.contains(new XYZ(startx+1, starty, startz)))
- {
- startx++;
- xyzlist.add(new XYZ(startx, starty, startz));
- listPos=xyzlist.size()-1;
- outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
- }
- else
- {
- if(listPos>0)
- {
- listPos--;
- XYZ xyz = xyzlist.get(listPos);
- startx=xyz.x;
- starty=xyz.y;
- startz=xyz.z;
- }
- }
- }
- }
- return outputSet;
- }
-
- private int countEmptyCells(ItemStack fluidCell, EntityPlayer player) {
- int num=0;
- ItemStack[] inv = player.inventory.mainInventory;
- for (int i=0;i<=35;i++)
- {
- if(inv[i]!=null)
- {
- if(inv[i].getItem() == fluidCell.getItem())
- {
- if(FluidContainerRegistry.isEmptyContainer(inv[i]))
- {
- num+=inv[i].stackSize;
- }
- }
- }
- }
- return num;
- }
-
- private int countAmountOfEmptyFluidCells(ItemStack fluidCell, FluidStack fluid, EntityPlayer entityPlayer) {
- int num=0;
- for (int i=0;i<entityPlayer.inventory.getSizeInventory();i++)
- {
- if(entityPlayer.inventory.getStackInSlot(i)!=null)
- {
- if(entityPlayer.inventory.getStackInSlot(i).getItem() instanceof IFluidContainerItem)
- {
- int amount = LiquidUtil.fillContainerStack(entityPlayer.inventory.getStackInSlot(i), entityPlayer, fluid, true)*entityPlayer.inventory.getStackInSlot(i).stackSize;
- num+=amount;
- }
- }
- }
- return num;
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(IIconRegister par1IconRegister)
- {
- this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":itemAdvancedElectricHandpump");
- }
-
- protected int getFlowDecay(World world, BlockWithCoordinates blockXYZ, int x, int y, int z)
- {
- if(blockXYZ.isSameTypeBlock(world,x,y,z))
- {
- return world.getBlockMetadata(x, y, z);
- }
- else
- {
- return -1;
- }
- }
-
-}
diff --git a/ihl/handpump/BlockWithCoordinates.java b/ihl/handpump/BlockWithCoordinates.java deleted file mode 100644 index d934b35..0000000 --- a/ihl/handpump/BlockWithCoordinates.java +++ /dev/null @@ -1,96 +0,0 @@ -package ihl.handpump;
-
-import net.minecraft.block.Block;
-import net.minecraft.init.Blocks;
-import net.minecraft.world.World;
-
-public class BlockWithCoordinates {
-public Block block;
-public int x;
-public int y;
-public int z;
-public int meta;
-
-public BlockWithCoordinates(Block block1, int x1, int y1, int z1, int meta1)
-{
- block=block1;
- x=x1;
- y=y1;
- z=z1;
- meta=meta1;
-}
-
-public boolean setMetadataOrDestroyBlock(World world, int meta, int maxMeta)
-{
- if(meta>maxMeta)
- {
- return world.setBlockToAir(x, y, z);
- }
- else if(isWaterBlock())
- {
- if(world.setBlock(x,y,z,Blocks.flowing_water,meta,3))
- {
- world.scheduleBlockUpdate(x,y,z,Blocks.flowing_water,2);
- return true;
- }
- return false;
- }
- else if(isLavaBlock())
- {
- if(world.setBlock(x,y,z,Blocks.flowing_lava,meta,3))
- {
- world.scheduleBlockUpdate(x,y,z,Blocks.flowing_lava,2);
- return true;
- }
- return false;
- }
- return world.setBlockMetadataWithNotify(x, y, z, meta, 3);
-}
-
-public boolean isSameTypeBlock(World world, int x2, int y2, int z2)
-{
- Block block2 = world.getBlock(x2, y2, z2);
- if(isWaterBlock())
- {
- return block2==Blocks.water||block2==Blocks.flowing_water;
- }
- else if(isLavaBlock())
- {
- return block2==Blocks.lava||block2==Blocks.flowing_lava;
- }
- else
- {
- return block2==block;
- }
-}
-
-public boolean isWaterBlock()
-{
- if(block==Blocks.water||block==Blocks.flowing_water)
- {
- return true;
- }
- return false;
-}
-
-public boolean isLavaBlock()
-{
- if(block==Blocks.lava||block==Blocks.flowing_lava)
- {
- return true;
- }
- return false;
-}
-
-@Override
-public boolean equals(Object other)
-{
- if(other instanceof BlockWithCoordinates)
- {
- BlockWithCoordinates bwc = (BlockWithCoordinates)other;
- return bwc.block==this.block && bwc.x==this.x && bwc.y==this.y && bwc.z==this.z;
- }
- return false;
-}
-
-}
diff --git a/ihl/handpump/IHLHandPump.java b/ihl/handpump/IHLHandPump.java deleted file mode 100644 index a21919d..0000000 --- a/ihl/handpump/IHLHandPump.java +++ /dev/null @@ -1,351 +0,0 @@ -package ihl.handpump;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ic2.api.item.ElectricItem;
-import ic2.api.item.IBoxable;
-import ic2.api.item.IC2Items;
-import ic2.api.item.IElectricItem;
-import ic2.api.item.IItemHudInfo;
-import ic2.core.item.resources.ItemCell;
-import ic2.core.util.LiquidUtil;
-import ihl.IHLCreativeTab;
-import ihl.IHLMod;
-import ihl.IHLModInfo;
-import ihl.utils.IHLUtils;
-import ihl.worldgen.ores.IHLFluid;
-import net.minecraft.block.Block;
-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.util.MovingObjectPosition;
-import net.minecraft.world.World;
-import net.minecraftforge.fluids.BlockFluidBase;
-import net.minecraftforge.fluids.FluidRegistry;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.IFluidContainerItem;
-
-public class IHLHandPump extends Item implements IElectricItem, IBoxable, IItemHudInfo {
-
- protected int tier=1;
- protected int maxCharge=30000;
- protected int operationEUCost=600;
- protected int transferLimit = 2000;
-
- public IHLHandPump()
- {
- super();
- this.setMaxDamage(27);
- this.maxCharge=IHLMod.config.handpumpMaxCharge;
- this.operationEUCost=IHLMod.config.handpumpOperationEUCost;
- this.tier=IHLMod.config.handpumpTier;
- this.setCreativeTab(IHLCreativeTab.tab);
- this.maxStackSize=1;
- }
-
- @Override
- public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
- {
- MovingObjectPosition movingobjectposition = IHLUtils.returnMOPFromPlayer(entityPlayer, world);
- if(movingobjectposition!=null)
- {
- int x=movingobjectposition.blockX;
- int y=movingobjectposition.blockY;
- int z=movingobjectposition.blockZ;
- Block block = world.getBlock(x, y, z);
- if(!block.getMaterial().isLiquid())
- {
- y++;
- block = world.getBlock(x, y, z);
- if(!block.getMaterial().isLiquid())
- {
- return itemStack;
- }
- }
- if(world.isRemote && ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer))
- {
- entityPlayer.playSound(IHLModInfo.MODID+":handpumpOne", (float) (Math.random()*0.2D+0.6D), (float) (Math.random()*0.1D+0.9D));
- return itemStack;
- }
- else
- {
- BlockWithCoordinates blockXYZ = this.searchSource(world, x, y, z);
- if(blockXYZ==null)
- {
- return itemStack;
- }
- block = blockXYZ.block;
- FluidStack fluid1 = null;
- if(block instanceof BlockFluidBase)
- {
- fluid1 = ((BlockFluidBase)block).drain(world, blockXYZ.x, blockXYZ.y, blockXYZ.z, false);
- }
- else if(blockXYZ.isWaterBlock())
- {
- fluid1 = new FluidStack(FluidRegistry.WATER, 1000);
- }
- else if(blockXYZ.isLavaBlock())
- {
- fluid1 = new FluidStack(FluidRegistry.LAVA, 1000);
- }
- int amount2=0;
- ItemStack stack = this.getItemStackContains(fluid1, entityPlayer);
- if(stack!=null && fluid1 != null)
- {
- amount2 = LiquidUtil.fillContainerStack(stack, entityPlayer, fluid1, true);
- }
- if(amount2 > 0)
- {
- if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer) && blockXYZ.setMetadataOrDestroyBlock(world, blockXYZ.meta+1,7))
- {
- ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false);
- LiquidUtil.fillContainerStack(stack, entityPlayer, fluid1, false);
- entityPlayer.inventoryContainer.detectAndSendChanges();
- }
- return itemStack;
- }
- else if(entityPlayer.inventory.hasItemStack(IC2Items.getItem("cell")))
- {
- if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer) && blockXYZ.setMetadataOrDestroyBlock(world, blockXYZ.meta+1,7))
- {
- ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false);
- this.fillFluidCell(fluid1, entityPlayer);
- entityPlayer.inventoryContainer.detectAndSendChanges();
- return itemStack;
- }
- }
- }
- }
- return itemStack;
- }
-
-
- protected ItemStack getItemStackContains(FluidStack fluidStack, EntityPlayer player) {
- for (int i=0;i<player.inventory.getSizeInventory();i++)
- {
- if(player.inventory.getStackInSlot(i)!=null)
- {
- if(player.inventory.getStackInSlot(i).getItem() instanceof IFluidContainerItem)
- {
- if(LiquidUtil.fillContainerStack(player.inventory.getStackInSlot(i), player, fluidStack, true) > 0)
- {
- return player.inventory.getStackInSlot(i);
- }
- }
- }
- }
- return null;
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(IIconRegister par1IconRegister)
- {
- this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":itemElectricHandpump");
- }
-
- @Override
- public boolean canProvideEnergy(ItemStack itemStack) {
- return false;
- }
-
- @Override
- public Item getChargedItem(ItemStack itemStack) {
- return this;
- }
-
- @Override
- public Item getEmptyItem(ItemStack itemStack) {
- return this;
- }
-
- @Override
- public double getMaxCharge(ItemStack itemStack) {
- return this.maxCharge;
- }
-
- @Override
- public double getTransferLimit(ItemStack itemStack) {
- return this.transferLimit;
- }
-
- @Override
- public int getTier(ItemStack itemStack) {
- return this.tier;
- }
-
- @Override
- public List<String> getHudInfo(ItemStack itemStack) {
- LinkedList<String> info = new LinkedList<String>();
- info.add(ElectricItem.manager.getToolTip(itemStack));
- info.add("Power Tier: " + this.tier);
- return info;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b)
- {
- info.add("PowerTier: " + this.tier);
- }
-
- @Override
- public boolean canBeStoredInToolbox(ItemStack itemstack) {
- return true;
- }
-
- @Override
- public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2)
- {
- return false;
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void getSubItems(Item item, CreativeTabs tabs, List itemList)
- {
- itemList.add(this.getItemStack(this.maxCharge));
- itemList.add(this.getItemStack(0));
- }
-
- public ItemStack getItemStack(int charge)
- {
- ItemStack ret = new ItemStack(this);
- ElectricItem.manager.charge(ret, charge, this.maxCharge, true, false);
- return ret;
- }
-
-
- @Override
- public double getDurabilityForDisplay(ItemStack stack)
- {
- return (this.maxCharge-ElectricItem.manager.getCharge(stack))/this.maxCharge;
- }
-
- protected void fillFluidCell(FluidStack fluid1, EntityPlayer player)
- {
- ItemStack cell = IHLFluid.getCell(fluid1.getFluid().getName());
- if(cell==null)
- {
- return;
- }
- ItemStack[] inv = player.inventory.mainInventory;
- for (int i=0;i<=35;i++)
- {
- if(inv[i]!=null)
- {
- if(inv[i].getItem() instanceof ItemCell)
- {
- if(inv[i].getItemDamage()==0)
- {
- if (IHLUtils.addItemStackToInventory(player, cell))
- {
- if(inv[i].stackSize<=1)
- {
- ItemStack sourceItemStack = inv[i].copy();
- sourceItemStack.stackSize=player.inventory.clearInventory(sourceItemStack.getItem(),0)-1;
- if(sourceItemStack.stackSize>0)
- {
- player.inventory.addItemStackToInventory(sourceItemStack);
- }
- }
- else
- {
- inv[i].stackSize--;
- }
- return;
- }
- }
- }
- }
- }
- }
-
- protected BlockWithCoordinates searchSource(World world, int startx, int starty, int startz)
- {
- int currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- for (int i=0; i<256;i++)
- {
- if(getFlowDecay(world, startx, starty+1, startz)>=0)
- {
- starty++;
- currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- }
-
- else if(getFlowDecay(world, startx+1, starty+1, startz)>=0)
- {
- starty++;
- startx++;
- currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- }
-
- else if(getFlowDecay(world, startx-1, starty+1, startz)>=0)
- {
- starty++;
- startx--;
- currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- }
-
- else if(getFlowDecay(world, startx, starty+1, startz+1)>=0)
- {
- starty++;
- startz++;
- currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- }
-
- else if(getFlowDecay(world, startx, starty+1, startz-1)>=0)
- {
- starty++;
- startz--;
- currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- }
- //Start checking neighbor blocks to lower flow decay.
- else if(getFlowDecay(world, startx-1, starty, startz)<currentFlowDecay&&getFlowDecay(world, startx-1, starty, startz)!=-1)
- {
- startx--;
- currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- }
- else if(getFlowDecay(world, startx, starty, startz+1)<currentFlowDecay&&getFlowDecay(world, startx, starty, startz+1)!=-1)
- {
- startz++;
- currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- }
- else if(getFlowDecay(world, startx, starty, startz-1)<currentFlowDecay&&getFlowDecay(world, startx, starty, startz-1)!=-1)
- {
- startz--;
- currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- }
- else if(getFlowDecay(world, startx+1, starty, startz)<currentFlowDecay&&getFlowDecay(world, startx+1, starty, startz)!=-1)
- {
- startx++;
- currentFlowDecay=getFlowDecay(world, startx, starty, startz);
- }
- else {break;}
- }
- if(currentFlowDecay==0)
- {
- Block block = world.getBlock(startx, starty, startz);
- return new BlockWithCoordinates(block, startx, starty, startz,0);
- }
- else
- {
- if(currentFlowDecay < 7)
- {
- world.setBlockMetadataWithNotify(startx, starty, startz,currentFlowDecay+1,3);
- return null;
- }
- }
- return null;
- }
-
- protected int getFlowDecay(World par1World, int par2, int par3, int par4)
- {
- return par1World.getBlock(par2, par3, par4).getMaterial().isLiquid() ? par1World.getBlockMetadata(par2, par3, par4) : -1;
- }
-}
\ No newline at end of file diff --git a/ihl/handpump/XYZ.java b/ihl/handpump/XYZ.java deleted file mode 100644 index 9a2627e..0000000 --- a/ihl/handpump/XYZ.java +++ /dev/null @@ -1,26 +0,0 @@ -package ihl.handpump;
-
-public class XYZ {
- public int x;
- public int y;
- public int z;
-
- public XYZ(int x1,int y1,int z1)
- {
- this.x=x1;
- this.y=y1;
- this.z=z1;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if(obj instanceof XYZ)
- {
- XYZ xyz2 = (XYZ) obj;
- return (this.x==xyz2.x && this.y==xyz2.y && this.z==xyz2.z);
- }
- return false;
- }
-
-}
|
