summaryrefslogtreecommitdiff
path: root/ihl/handpump/BlockWithCoordinates.java
diff options
context:
space:
mode:
authorFoghrye4 <foghrye4@gmail.com>2016-04-11 19:44:54 +0300
committerFoghrye4 <foghrye4@gmail.com>2016-04-11 19:44:54 +0300
commit05c78126859231a68e199dc34613689bd0978e2f (patch)
tree050bea104a18c72905095d29f31bec2935a27a24 /ihl/handpump/BlockWithCoordinates.java
Initial commit
Diffstat (limited to 'ihl/handpump/BlockWithCoordinates.java')
-rw-r--r--ihl/handpump/BlockWithCoordinates.java115
1 files changed, 115 insertions, 0 deletions
diff --git a/ihl/handpump/BlockWithCoordinates.java b/ihl/handpump/BlockWithCoordinates.java
new file mode 100644
index 0000000..0cdc965
--- /dev/null
+++ b/ihl/handpump/BlockWithCoordinates.java
@@ -0,0 +1,115 @@
+package ihl.handpump;
+
+import ihl.IHLMod;
+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() && IHLMod.cccFiniteWater)
+ {
+ 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(isWaterBlock())
+ {
+ if(world.setBlock(x,y,z,IHLMod.flowing_water,meta,3))
+ {
+ world.scheduleBlockUpdate(x,y,z,IHLMod.flowing_water,2);
+ return true;
+ }
+ return false;
+ }
+ else if(isLavaBlock() && world.provider.isHellWorld && !IHLMod.cccFiniteWater)
+ {
+ if(world.setBlock(x,y,z,IHLMod.flowing_lava,meta,3))
+ {
+ world.scheduleBlockUpdate(x,y,z,IHLMod.flowing_lava,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||block2==IHLMod.flowing_water;
+ }
+ else if(isLavaBlock())
+ {
+ return block2==Blocks.lava||block2==Blocks.flowing_lava||block2==IHLMod.flowing_lava;
+ }
+ else
+ {
+ return block2==block;
+ }
+}
+
+public boolean isWaterBlock()
+{
+ if(block==Blocks.water||block==Blocks.flowing_water||block==IHLMod.flowing_water)
+ {
+ return true;
+ }
+ return false;
+}
+
+public boolean isLavaBlock()
+{
+ if(block==Blocks.lava||block==Blocks.flowing_lava||block==IHLMod.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;
+}
+
+}