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/i_hate_liquids | |
Initial commit
Diffstat (limited to 'ihl/i_hate_liquids')
| -rw-r--r-- | ihl/i_hate_liquids/BlockDynamicLiquidPlus.java | 81 | ||||
| -rw-r--r-- | ihl/i_hate_liquids/IHLBucketHandler.java | 21 | ||||
| -rw-r--r-- | ihl/i_hate_liquids/IHLEventHandler.java | 59 | ||||
| -rw-r--r-- | ihl/i_hate_liquids/InvisibleMagicanEntity.java | 570 | ||||
| -rw-r--r-- | ihl/i_hate_liquids/XYZ.java | 26 |
5 files changed, 757 insertions, 0 deletions
diff --git a/ihl/i_hate_liquids/BlockDynamicLiquidPlus.java b/ihl/i_hate_liquids/BlockDynamicLiquidPlus.java new file mode 100644 index 0000000..7b7a8d7 --- /dev/null +++ b/ihl/i_hate_liquids/BlockDynamicLiquidPlus.java @@ -0,0 +1,81 @@ +package ihl.i_hate_liquids;
+
+import java.util.Random;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockLiquid;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+public class BlockDynamicLiquidPlus extends BlockLiquid{
+
+ public BlockDynamicLiquidPlus(Material material)
+ {
+ super(material);
+ this.enableStats = false;
+ //this.setCreativeTab(CreativeTabs.tabMisc);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister par1IconRegister)
+ {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID+":metalShards");
+ }
+
+ @Override
+ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
+ return this.blockIcon;
+ }
+
+ @Override
+ public void updateTick(World world, int x, int y, int z, Random p_149674_5_)
+ {
+ if(!world.isRemote)
+ {
+ int meta = world.getBlockMetadata(x, y, z);
+ if(meta>=7)
+ {
+ world.setBlockToAir(x,y,z);
+ return;
+ }
+ int meta2=16;
+ int fd;
+ Block block;
+ int xz[] = {0,-1,0,1,0};
+ for(int i=0;i<=3;i++)
+ {
+ fd=getFlowDecay(world,x+xz[i], y, z+xz[i+1]);
+ if(fd!=-1 && meta2>fd)
+ {
+ meta2=fd;
+ }
+ }
+ if(meta2==16)
+ {
+ world.setBlockMetadataWithNotify(x,y,z,meta+1,3);
+ }
+ else if(meta2>=6)
+ {
+ world.setBlockToAir(x,y,z);
+ return;
+ }
+ else
+ {
+ world.setBlockMetadataWithNotify(x,y,z,meta2+1,3);
+ }
+ world.scheduleBlockUpdate(x, y, z, this,20);
+ }
+ }
+
+ private int getFlowDecay(World par1World, int par2, int par3, int par4)
+ {
+ Block block = par1World.getBlock(par2, par3, par4);
+ return block.getMaterial().isLiquid() ? par1World.getBlockMetadata(par2, par3, par4) : -1;
+ }
+}
diff --git a/ihl/i_hate_liquids/IHLBucketHandler.java b/ihl/i_hate_liquids/IHLBucketHandler.java new file mode 100644 index 0000000..d8a9943 --- /dev/null +++ b/ihl/i_hate_liquids/IHLBucketHandler.java @@ -0,0 +1,21 @@ +package ihl.i_hate_liquids;
+
+import ihl.items_blocks.IHLFluidBlock;
+import net.minecraft.block.Block;
+import net.minecraftforge.event.entity.player.FillBucketEvent;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+
+public class IHLBucketHandler
+{
+ public IHLBucketHandler() {}
+ @SubscribeEvent
+ public void onBucketFill(FillBucketEvent event)
+ {
+ Block block = event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ);
+ if (block instanceof IHLFluidBlock && event.isCancelable())
+ {
+ event.setCanceled(true);
+ }
+ }
+
+}
diff --git a/ihl/i_hate_liquids/IHLEventHandler.java b/ihl/i_hate_liquids/IHLEventHandler.java new file mode 100644 index 0000000..cd777ed --- /dev/null +++ b/ihl/i_hate_liquids/IHLEventHandler.java @@ -0,0 +1,59 @@ +package ihl.i_hate_liquids;
+
+import net.minecraft.block.Block;
+import net.minecraft.world.World;
+import net.minecraftforge.event.world.BlockEvent.BreakEvent;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+
+public class IHLEventHandler {
+
+ public IHLEventHandler() {}
+
+
+ @SubscribeEvent
+ public void onBlockBreak(BreakEvent event)
+ {
+ World world = event.world;
+ if(!world.isRemote)
+ {
+ int x = event.x;
+ int y = event.y;
+ int z = event.z;
+ Block block = world.getBlock(x, y+1, z);
+ if(block.getMaterial().isLiquid())
+ {
+ InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
+ world.spawnEntityInWorld(im);
+ return;
+ }
+ block = world.getBlock(x+1, y, z);
+ if(block.getMaterial().isLiquid())
+ {
+ InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
+ world.spawnEntityInWorld(im);
+ return;
+ }
+ block = world.getBlock(x-1, y, z);
+ if(block.getMaterial().isLiquid())
+ {
+ InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
+ world.spawnEntityInWorld(im);
+ return;
+ }
+ block = world.getBlock(x, y, z+1);
+ if(block.getMaterial().isLiquid())
+ {
+ InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
+ world.spawnEntityInWorld(im);
+ return;
+ }
+ block = world.getBlock(x, y, z-1);
+ if(block.getMaterial().isLiquid())
+ {
+ InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
+ world.spawnEntityInWorld(im);
+ return;
+ }
+ }
+ }
+}
diff --git a/ihl/i_hate_liquids/InvisibleMagicanEntity.java b/ihl/i_hate_liquids/InvisibleMagicanEntity.java new file mode 100644 index 0000000..88539dc --- /dev/null +++ b/ihl/i_hate_liquids/InvisibleMagicanEntity.java @@ -0,0 +1,570 @@ +package ihl.i_hate_liquids;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ihl.IHLMod;
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.Entity;
+import net.minecraft.init.Blocks;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.IFluidBlock;
+
+public class InvisibleMagicanEntity extends Entity {
+ private int entityAge=0;
+ private int timer=0;
+ private int viscosityTimer=0;
+ private int viscosity=5;
+ public int x0=0;
+ public int y0=0;
+ public int z0=0;
+ public List<XYZ> flowXYZ = new ArrayList();
+ public List<Block> blockList = new ArrayList();
+ private Block block;
+ private int lowestPointsCounter=0;
+
+ public InvisibleMagicanEntity(World arg0)
+ {
+ super(arg0);
+ this.isImmuneToFire=true;
+ this.noClip=true;
+ this.setSize(0F, 0F);
+ }
+
+ public InvisibleMagicanEntity(World arg0, int x, int y, int z)
+ {
+ super(arg0);
+ this.x0=x;
+ this.y0=y;
+ this.z0=z;
+ this.setPosition(x, y, z);
+ this.isImmuneToFire=true;
+ this.noClip=true;
+ this.setSize(0F, 0F);
+ }
+
+ @Override
+ public void onUpdate()
+ {
+ if(!this.worldObj.isRemote)
+ {
+ if(this.blockList.isEmpty())
+ {
+ if(!takeLowestPoint())
+ {
+ this.setDead();
+ return;
+ }
+ else
+ {
+ if(this.block!=null)
+ {
+ if(this.block==Blocks.water||this.block==Blocks.flowing_water)
+ {
+ this.viscosity=-1;
+ }
+ else if(this.block instanceof IFluidBlock)
+ {
+ IFluidBlock bf = (IFluidBlock) this.block;
+ if(bf.getFluid()!=null && bf.getFluid().getViscosity()>600)
+ {
+ this.viscosity=bf.getFluid().getViscosity()/300;
+ }
+ }
+ else if(this.block.getMaterial()==Material.lava)
+ {
+ this.viscosity=20;
+ }
+ else
+ {
+ this.viscosity=20;
+ }
+ }
+ else
+ {
+ this.entityAge++;
+ }
+ }
+ }
+ else
+ {
+ if(this.viscosityTimer < this.viscosity)
+ {
+ this.viscosityTimer++;
+ }
+ else
+ {
+ this.viscosityTimer=0;
+ XYZ xyz;
+ if(!this.flowXYZ.isEmpty())
+ {
+ xyz = this.flowXYZ.remove(0);
+ if(this.flowXYZ.isEmpty())
+ {
+ this.timer=0;
+ Block block1=this.blockList.get(0);
+ //System.out.println("Trying to create new source");
+ if(this.setBlock(xyz.x, xyz.y, xyz.z, block1))
+ {
+ this.blockList.remove(0);
+ //System.out.println("Creating new source at "+xyz.x+","+xyz.y+","+xyz.z);
+ }
+ else
+ {
+ //System.out.println("Failed to create new source!");
+ }
+ if(!takeLowestPoint())
+ {
+ this.setDead();
+ return;
+ }
+ }
+ else
+ {
+ Block blockToReplace = this.worldObj.getBlock(xyz.x, xyz.y, xyz.z);
+ if(blockToReplace==null || blockToReplace.isAir(worldObj, xyz.x, xyz.y, xyz.z) || blockToReplace.getMaterial().isLiquid() || blockToReplace==Blocks.snow_layer || blockToReplace==Blocks.vine || blockToReplace==Blocks.tallgrass || blockToReplace==Blocks.deadbush)
+ {
+ if(this.flowXYZ.size()<=this.blockList.size())
+ {
+ Block block1=this.blockList.get(0);
+ if(this.setBlock(xyz.x, xyz.y, xyz.z, block1))
+ {
+ this.blockList.remove(0);
+ //System.out.println("Creating new source at "+xyz.x+","+xyz.y+","+xyz.z);
+ }
+ }
+ else
+ {
+ if(!this.setNonSourceBlock(xyz.x, xyz.y, xyz.z, block))
+ {
+ //System.out.println("Failed to setNonSourceBlock at "+xyz.x+","+xyz.y+","+xyz.z);
+ }
+ }
+ }
+ else
+ {
+ this.flowXYZ.clear();
+ }
+ }
+ }
+ }
+ }
+ if(this.lowestPointsCounter > this.blockList.size())
+ {
+ this.searchSourceDestroyCount(worldObj, this.x0, this.y0, this.z0, block, this.lowestPointsCounter);
+ if(!this.blockList.isEmpty())
+ {
+ this.block=this.blockList.get(0);
+ }
+ }
+ if(this.entityAge>200)
+ {
+ this.setDead();
+ return;
+ }
+ }
+ }
+
+ @Override
+ protected void entityInit() {}
+
+ @Override
+ protected void readEntityFromNBT(NBTTagCompound arg0) {}
+
+ @Override
+ protected void writeEntityToNBT(NBTTagCompound arg0) {}
+
+ private int getFlowDecay(int par2, int par3, int par4)
+ {
+ Block block = this.worldObj.getBlock(par2, par3, par4);
+ return block.getMaterial().isLiquid() ? this.worldObj.getBlockMetadata(par2, par3, par4) : -1;
+ }
+
+ private boolean writeLowestFlowPoint()
+ {
+ int startx = this.x0;
+ int starty = this.y0;
+ int startz = this.z0;
+ int currentFlowDecay=getFlowDecay(startx, starty, startz);
+ for (int i=0; i<64;i++)
+ {
+ //Go search up, if possible.
+ if(getFlowDecay(startx, starty+1, startz)>=0)
+ {
+ starty++;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+
+ else if(getFlowDecay(startx+1, starty+1, startz)>=0)
+ {
+ starty++;
+ startx++;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+
+ else if(getFlowDecay(startx-1, starty+1, startz)>=0)
+ {
+ starty++;
+ startx--;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+
+ else if(getFlowDecay(startx, starty+1, startz+1)>=0)
+ {
+ starty++;
+ startz++;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+
+ else if(getFlowDecay(startx, starty+1, startz-1)>=0)
+ {
+ starty++;
+ startz--;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+ //Start checking neighbor blocks to lower flow decay.
+ else if(getFlowDecay(startx-1, starty, startz)<currentFlowDecay&&getFlowDecay(startx-1, starty, startz)!=-1)
+ {
+ startx--;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+ else if(getFlowDecay(startx, starty, startz+1)<currentFlowDecay&&getFlowDecay(startx, starty, startz+1)!=-1)
+ {
+ startz++;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+ else if(getFlowDecay(startx, starty, startz-1)<currentFlowDecay&&getFlowDecay(startx, starty, startz-1)!=-1)
+ {
+ startz--;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+ else if(getFlowDecay(startx+1, starty, startz)<currentFlowDecay&&getFlowDecay(startx+1, starty, startz)!=-1)
+ {
+ startx++;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+ else if(currentFlowDecay==0)
+ {
+ break;
+ }
+ else if(getFlowDecay(startx-1, starty, startz)==currentFlowDecay&&getFlowDecay(startx-1, starty, startz)!=-1)
+ {
+ startx--;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+ else if(getFlowDecay(startx, starty, startz+1)==currentFlowDecay&&getFlowDecay(startx, starty, startz+1)!=-1)
+ {
+ startz++;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+ else if(getFlowDecay(startx, starty, startz-1)==currentFlowDecay&&getFlowDecay(startx, starty, startz-1)!=-1)
+ {
+ startz--;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+ else if(getFlowDecay(startx+1, starty, startz)==currentFlowDecay&&getFlowDecay(startx+1, starty, startz)!=-1)
+ {
+ startx++;
+ currentFlowDecay=getFlowDecay(startx, starty, startz);
+ }
+ else {break;}
+ }
+ if(currentFlowDecay==0)
+ {
+ Block block1 = this.worldObj.getBlock(startx, starty, startz);
+ if(this.replaceBlock(startx, starty, startz, block1))
+ {
+ this.block=block1;
+ return true;
+ }
+ }
+ else if(currentFlowDecay>=7)
+ {
+ this.worldObj.setBlockToAir(startx, starty, startz);
+ }
+ else
+ {
+ this.worldObj.setBlockMetadataWithNotify(startx, starty, startz, currentFlowDecay+1, 0);
+ }
+ return false;
+ }
+
+ public boolean replaceBlock(int x,int y,int z, Block block)
+ {
+ if(!IHLMod.cccFiniteWater&&(block==Blocks.flowing_water || block==Blocks.water))
+ {
+ if(this.worldObj.setBlock(x,y,z,IHLMod.flowing_water,6,3))
+ {
+ this.worldObj.scheduleBlockUpdate(x,y,z,IHLMod.flowing_water,10);
+ return true;
+ }
+ return false;
+ }
+ else
+ if(!IHLMod.cccFiniteWater&&this.worldObj.provider.isHellWorld&&(block==Blocks.flowing_lava || block==Blocks.lava))
+ {
+ if(this.worldObj.setBlock(x,y,z,IHLMod.flowing_lava,6,3))
+ {
+ this.worldObj.scheduleBlockUpdate(x,y,z,IHLMod.flowing_lava,10);
+ return true;
+ }
+ return false;
+ }
+ else
+ {
+ if(this.worldObj.setBlockMetadataWithNotify(x, y, z, 6,3))
+ {
+ this.worldObj.scheduleBlockUpdate(x,y,z,this.worldObj.getBlock(x, y, z),10);
+ return true;
+ }
+ return false;
+ }
+ }
+
+ public boolean setNonSourceBlock(int x,int y,int z,Block block)
+ {
+ if(block==Blocks.flowing_water || block==Blocks.water)
+ {
+ if(this.worldObj.setBlock(x,y,z,Blocks.flowing_water,1,3))
+ {
+ this.worldObj.scheduleBlockUpdate(x,y,z,Blocks.flowing_water,80);
+ return true;
+ }
+ return false;
+ }
+ else
+ if(block==Blocks.flowing_lava || block==Blocks.lava)
+ {
+ if(this.worldObj.setBlock(x,y,z,Blocks.flowing_lava,1,3))
+ {
+ this.worldObj.scheduleBlockUpdate(x,y,z,Blocks.flowing_lava,80);
+ return true;
+ }
+ return false;
+ }
+ else
+ {
+ if(this.worldObj.setBlock(x, y, z, block, 1,3))
+ {
+ this.worldObj.scheduleBlockUpdate(x,y,z, block ,80);
+ return true;
+ }
+ return false;
+ }
+ }
+
+ public boolean setBlock(int x,int y,int z, Block block)
+ {
+ if(block==Blocks.flowing_water || block==Blocks.water)
+ {
+ if(this.worldObj.setBlock(x,y,z,Blocks.flowing_water,0,3))
+ {
+ this.worldObj.scheduleBlockUpdate(x,y,z,Blocks.flowing_water,20);
+ return true;
+ }
+ return false;
+ }
+ else
+ if(block==Blocks.flowing_lava || block==Blocks.lava)
+ {
+ if(this.worldObj.setBlock(x,y,z,Blocks.flowing_lava,0,3))
+ {
+ this.worldObj.scheduleBlockUpdate(x,y,z,Blocks.flowing_lava,20);
+ return true;
+ }
+ return false;
+ }
+ else
+ {
+ if(this.worldObj.setBlock(x,y,z,block,0,3))
+ {
+ this.worldObj.scheduleBlockUpdate(x,y,z,block,20);
+ return true;
+ }
+ return false;
+ }
+ }
+
+ private boolean takeLowestPoint()
+ {
+ int xz[]={0,1,0,-1,0};
+ Block block;
+ int x=x0;
+ int y=y0;
+ int z=z0;
+ List list = new ArrayList();
+ list.clear();
+ this.flowXYZ.clear();
+ for(int thread=0;thread<=256;thread++)
+ {
+
+ long number = new Long(x*256L*256L+y*256L+z);
+ list.add(number);
+ boolean skip=false;
+ block = this.worldObj.getBlock(x, y-1, z);
+ number = new Long(x*256L*256L+(y-1)*256L+z);
+ if((block.isAir(this.worldObj, x, y-1, z)||getFlowDecay(x, y-1, z)>=1) && !list.contains(number))
+ {
+ y--;
+ this.lowestPointsCounter=1;
+ skip=true;
+ }
+ if(!skip)
+ {
+ for(int i=0;i<=3;i++)
+ {
+ block = this.worldObj.getBlock(x+xz[i], y, z+xz[i+1]);
+ number = new Long((x+xz[i])*256L*256L+y*256L+z+xz[i+1]);
+ if((block.isAir(this.worldObj, x+xz[i], y, z+xz[i+1])||getFlowDecay(x+xz[i], y, z+xz[i+1])>=1) && !list.contains(number))
+ {
+ x+=xz[i];
+ z+=xz[i+1];
+ skip=true;
+ this.lowestPointsCounter++;
+ break;
+ }
+ }
+ }
+ XYZ xyz=new XYZ(x,y,z);
+ this.flowXYZ.add(xyz);
+ if(!skip)
+ {
+ break;
+ }
+ }
+ if(y<y0)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private int searchSourceDestroyCount(World world, int startx, int starty, int startz,
+ Block type, int countCells) {
+ int currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ for (int i=0; i<64;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;}
+ }
+ List<XYZ> xyzlist = new ArrayList();
+ if(currentFlowDecay==0)
+ {
+ xyzlist.add(new XYZ(startx, starty, startz));
+ Block block=worldObj.getBlock(startx, starty, startz);
+ replaceBlock(startx, starty, startz, block);
+ this.blockList.add(block);
+ int listPos=0;
+ for(int i=0;i<=countCells;i++)
+ {
+ if(getFlowDecay(world, 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;
+ block=worldObj.getBlock(startx, starty, startz);
+ replaceBlock(startx, starty, startz, block);
+ this.blockList.add(block);
+ }
+ else if(getFlowDecay(world, 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;
+ block=worldObj.getBlock(startx, starty, startz);
+ replaceBlock(startx, starty, startz, block);
+ this.blockList.add(block);
+ }
+ else if(getFlowDecay(world, 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;
+ block=worldObj.getBlock(startx, starty, startz);
+ replaceBlock(startx, starty, startz, block);
+ this.blockList.add(block);
+ }
+ else if(getFlowDecay(world, 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;
+ block=worldObj.getBlock(startx, starty, startz);
+ replaceBlock(startx, starty, startz, block);
+ this.blockList.add(block);
+ }
+ else
+ {
+ if(listPos>0)
+ {
+ listPos--;
+ XYZ xyz = xyzlist.get(listPos);
+ startx=xyz.x;
+ starty=xyz.y;
+ startz=xyz.z;
+ }
+ }
+ }
+ }
+ return xyzlist.size();
+ }
+
+ private int getFlowDecay(World world, int startx, int starty, int startz) {
+ return this.getFlowDecay(startx, starty, startz);
+ }
+}
diff --git a/ihl/i_hate_liquids/XYZ.java b/ihl/i_hate_liquids/XYZ.java new file mode 100644 index 0000000..287b11a --- /dev/null +++ b/ihl/i_hate_liquids/XYZ.java @@ -0,0 +1,26 @@ +package ihl.i_hate_liquids;
+
+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;
+ }
+
+}
|
