diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-01-29 22:50:29 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-01-30 13:24:39 +0100 |
commit | df69047324abc54f5d5b8d069bb69b1061b20cce (patch) | |
tree | 76f8d13addf80730deea9285f4bd9a1ffbe45f80 /src/main/java/net/minecraft/server/BlockRedstoneWire.java | |
parent | d0cd8c6cc7d1aaf38934996e7e5d3e03272e4ff1 (diff) | |
download | craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar.gz craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar.lz craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar.xz craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.zip |
Port to new mc-dev format.
Diffstat (limited to 'src/main/java/net/minecraft/server/BlockRedstoneWire.java')
-rw-r--r-- | src/main/java/net/minecraft/server/BlockRedstoneWire.java | 412 |
1 files changed, 203 insertions, 209 deletions
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java index 11812a56..81d85c6c 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java @@ -2,24 +2,23 @@ package net.minecraft.server; import java.util.ArrayList; import java.util.HashSet; -import java.util.List; import java.util.Random; import java.util.Set; + +// CraftBukkit start import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.event.block.BlockRedstoneEvent; -import org.bukkit.plugin.PluginLoader; +// CraftBukkit end public class BlockRedstoneWire extends Block { - private boolean a; - private Set b; + private boolean a = true; + private Set b = new HashSet(); public BlockRedstoneWire(int i, int j) { - super(i, j, Material.n); - a = true; - b = ((Set) (new HashSet())); - a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); + super(i, j, Material.ORIENTABLE); + this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); } public AxisAlignedBB d(World world, int i, int j, int k) { @@ -35,60 +34,67 @@ public class BlockRedstoneWire extends Block { } private void g(World world, int i, int j, int k) { - a(world, i, j, k, i, j, k); - ArrayList arraylist = new ArrayList(((java.util.Collection) (b))); + this.a(world, i, j, k, i, j, k); + ArrayList arraylist = new ArrayList(this.b); + + this.b.clear(); - b.clear(); - for (int l = 0; l < ((List) (arraylist)).size(); l++) { - ChunkPosition chunkposition = (ChunkPosition) ((List) (arraylist)).get(l); + for (int l = 0; l < arraylist.size(); ++l) { + ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l); - world.h(chunkposition.a, chunkposition.b, chunkposition.c, bi); + world.h(chunkposition.a, chunkposition.b, chunkposition.c, this.id); } } private void a(World world, int i, int j, int k, int l, int i1, int j1) { - int k1 = world.b(i, j, k); + int k1 = world.getData(i, j, k); int l1 = 0; - a = false; + this.a = false; boolean flag = world.p(i, j, k); - a = true; + this.a = true; + int i2; + int j2; + int k2; + if (flag) { l1 = 15; } else { - for (int i2 = 0; i2 < 4; i2++) { - int k2 = i; - int i3 = k; - + for (i2 = 0; i2 < 4; ++i2) { + j2 = i; + k2 = k; if (i2 == 0) { - k2--; + j2 = i - 1; } + if (i2 == 1) { - k2++; + ++j2; } + if (i2 == 2) { - i3--; + k2 = k - 1; } + if (i2 == 3) { - i3++; + ++k2; } - if (k2 != l || j != i1 || i3 != j1) { - l1 = f(world, k2, j, i3, l1); + + if (j2 != l || j != i1 || k2 != j1) { + l1 = this.f(world, j2, j, k2, l1); } - if (world.d(k2, j, i3) && !world.d(i, j + 1, k)) { - if (k2 != l || j + 1 != i1 || i3 != j1) { - l1 = f(world, k2, j + 1, i3, l1); + + if (world.d(j2, j, k2) && !world.d(i, j + 1, k)) { + if (j2 != l || j + 1 != i1 || k2 != j1) { + l1 = this.f(world, j2, j + 1, k2, l1); } - continue; - } - if (!world.d(k2, j, i3) && (k2 != l || j - 1 != i1 || i3 != j1)) { - l1 = f(world, k2, j - 1, i3, l1); + } else if (!world.d(j2, j, k2) && (j2 != l || j - 1 != i1 || k2 != j1)) { + l1 = this.f(world, j2, j - 1, k2, l1); } } if (l1 > 0) { - l1--; + --l1; } else { l1 = 0; } @@ -97,250 +103,238 @@ public class BlockRedstoneWire extends Block { // Craftbukkit start if (k1 != l1) { CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); - BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, k1, l1); - ((WorldServer) world).getServer().getPluginManager().callEvent(bre); - l1 = bre.getNewCurrent(); + BlockRedstoneEvent event = new BlockRedstoneEvent(block, BlockFace.SELF, k1, l1); + ((WorldServer) world).getServer().getPluginManager().callEvent(event); + l1 = event.getNewCurrent(); } // Craftbukkit end - + if (k1 != l1) { world.i = true; world.c(i, j, k, l1); world.b(i, j, k, i, j, k); world.i = false; - for (int j2 = 0; j2 < 4; j2++) { - int l2 = i; - int j3 = k; - int k3 = j - 1; - if (j2 == 0) { - l2--; + for (i2 = 0; i2 < 4; ++i2) { + j2 = i; + k2 = k; + int l2 = j - 1; + + if (i2 == 0) { + j2 = i - 1; } - if (j2 == 1) { - l2++; + + if (i2 == 1) { + ++j2; } - if (j2 == 2) { - j3--; + + if (i2 == 2) { + k2 = k - 1; } - if (j2 == 3) { - j3++; + + if (i2 == 3) { + ++k2; } - if (world.d(l2, j, j3)) { - k3 += 2; + + if (world.d(j2, j, k2)) { + l2 += 2; } - int l3 = 0; - l3 = f(world, l2, j, j3, -1); - l1 = world.b(i, j, k); + boolean flag1 = false; + int i3 = this.f(world, j2, j, k2, -1); + + l1 = world.getData(i, j, k); if (l1 > 0) { - l1--; + --l1; } - if (l3 >= 0 && l3 != l1) { - a(world, l2, j, j3, i, j, k); + + if (i3 >= 0 && i3 != l1) { + this.a(world, j2, j, k2, i, j, k); } - l3 = f(world, l2, k3, j3, -1); - l1 = world.b(i, j, k); + + i3 = this.f(world, j2, l2, k2, -1); + l1 = world.getData(i, j, k); if (l1 > 0) { - l1--; + --l1; } - if (l3 >= 0 && l3 != l1) { - a(world, l2, k3, j3, i, j, k); + + if (i3 >= 0 && i3 != l1) { + this.a(world, j2, l2, k2, i, j, k); } } if (k1 == 0 || l1 == 0) { - b.add(((new ChunkPosition(i, j, k)))); - b.add(((new ChunkPosition(i - 1, j, k)))); - b.add(((new ChunkPosition(i + 1, j, k)))); - b.add(((new ChunkPosition(i, j - 1, k)))); - b.add(((new ChunkPosition(i, j + 1, k)))); - b.add(((new ChunkPosition(i, j, k - 1)))); - b.add(((new ChunkPosition(i, j, k + 1)))); + this.b.add(new ChunkPosition(i, j, k)); + this.b.add(new ChunkPosition(i - 1, j, k)); + this.b.add(new ChunkPosition(i + 1, j, k)); + this.b.add(new ChunkPosition(i, j - 1, k)); + this.b.add(new ChunkPosition(i, j + 1, k)); + this.b.add(new ChunkPosition(i, j, k - 1)); + this.b.add(new ChunkPosition(i, j, k + 1)); } } } private void h(World world, int i, int j, int k) { - if (world.a(i, j, k) != bi) { - return; - } else { - world.h(i, j, k, bi); - world.h(i - 1, j, k, bi); - world.h(i + 1, j, k, bi); - world.h(i, j, k - 1, bi); - world.h(i, j, k + 1, bi); - world.h(i, j - 1, k, bi); - world.h(i, j + 1, k, bi); - return; + if (world.getTypeId(i, j, k) == this.id) { + world.h(i, j, k, this.id); + world.h(i - 1, j, k, this.id); + world.h(i + 1, j, k, this.id); + world.h(i, j, k - 1, this.id); + world.h(i, j, k + 1, this.id); + world.h(i, j - 1, k, this.id); + world.h(i, j + 1, k, this.id); } } public void e(World world, int i, int j, int k) { super.e(world, i, j, k); - if (world.z) { - return; - } - g(world, i, j, k); - world.h(i, j + 1, k, bi); - world.h(i, j - 1, k, bi); - h(world, i - 1, j, k); - h(world, i + 1, j, k); - h(world, i, j, k - 1); - h(world, i, j, k + 1); - if (world.d(i - 1, j, k)) { - h(world, i - 1, j + 1, k); - } else { - h(world, i - 1, j - 1, k); - } - if (world.d(i + 1, j, k)) { - h(world, i + 1, j + 1, k); - } else { - h(world, i + 1, j - 1, k); - } - if (world.d(i, j, k - 1)) { - h(world, i, j + 1, k - 1); - } else { - h(world, i, j - 1, k - 1); - } - if (world.d(i, j, k + 1)) { - h(world, i, j + 1, k + 1); - } else { - h(world, i, j - 1, k + 1); + if (!world.isStatic) { + this.g(world, i, j, k); + world.h(i, j + 1, k, this.id); + world.h(i, j - 1, k, this.id); + this.h(world, i - 1, j, k); + this.h(world, i + 1, j, k); + this.h(world, i, j, k - 1); + this.h(world, i, j, k + 1); + if (world.d(i - 1, j, k)) { + this.h(world, i - 1, j + 1, k); + } else { + this.h(world, i - 1, j - 1, k); + } + + if (world.d(i + 1, j, k)) { + this.h(world, i + 1, j + 1, k); + } else { + this.h(world, i + 1, j - 1, k); + } + + if (world.d(i, j, k - 1)) { + this.h(world, i, j + 1, k - 1); + } else { + this.h(world, i, j - 1, k - 1); + } + + if (world.d(i, j, k + 1)) { + this.h(world, i, j + 1, k + 1); + } else { + this.h(world, i, j - 1, k + 1); + } } } public void b(World world, int i, int j, int k) { super.b(world, i, j, k); - if (world.z) { - return; - } - world.h(i, j + 1, k, bi); - world.h(i, j - 1, k, bi); - g(world, i, j, k); - h(world, i - 1, j, k); - h(world, i + 1, j, k); - h(world, i, j, k - 1); - h(world, i, j, k + 1); - if (world.d(i - 1, j, k)) { - h(world, i - 1, j + 1, k); - } else { - h(world, i - 1, j - 1, k); - } - if (world.d(i + 1, j, k)) { - h(world, i + 1, j + 1, k); - } else { - h(world, i + 1, j - 1, k); - } - if (world.d(i, j, k - 1)) { - h(world, i, j + 1, k - 1); - } else { - h(world, i, j - 1, k - 1); - } - if (world.d(i, j, k + 1)) { - h(world, i, j + 1, k + 1); - } else { - h(world, i, j - 1, k + 1); + if (!world.isStatic) { + world.h(i, j + 1, k, this.id); + world.h(i, j - 1, k, this.id); + this.g(world, i, j, k); + this.h(world, i - 1, j, k); + this.h(world, i + 1, j, k); + this.h(world, i, j, k - 1); + this.h(world, i, j, k + 1); + if (world.d(i - 1, j, k)) { + this.h(world, i - 1, j + 1, k); + } else { + this.h(world, i - 1, j - 1, k); + } + + if (world.d(i + 1, j, k)) { + this.h(world, i + 1, j + 1, k); + } else { + this.h(world, i + 1, j - 1, k); + } + + if (world.d(i, j, k - 1)) { + this.h(world, i, j + 1, k - 1); + } else { + this.h(world, i, j - 1, k - 1); + } + + if (world.d(i, j, k + 1)) { + this.h(world, i, j + 1, k + 1); + } else { + this.h(world, i, j - 1, k + 1); + } } } private int f(World world, int i, int j, int k, int l) { - if (world.a(i, j, k) != bi) { + if (world.getTypeId(i, j, k) != this.id) { return l; - } - int i1 = world.b(i, j, k); - - if (i1 > l) { - return i1; } else { - return l; + int i1 = world.getData(i, j, k); + + return i1 > l ? i1 : l; } } public void b(World world, int i, int j, int k, int l) { - if (world.z) { - return; - } - int i1 = world.b(i, j, k); - boolean flag = a(world, i, j, k); + if (!world.isStatic) { + int i1 = world.getData(i, j, k); + boolean flag = this.a(world, i, j, k); - if (!flag) { - a_(world, i, j, k, i1); - world.e(i, j, k, 0); - } else { - g(world, i, j, k); + if (!flag) { + this.a_(world, i, j, k, i1); + world.e(i, j, k, 0); + } else { + this.g(world, i, j, k); + } + + super.b(world, i, j, k, l); } - super.b(world, i, j, k, l); } public int a(int i, Random random) { - return Item.aA.ba; + return Item.REDSTONE.id; } public boolean d(World world, int i, int j, int k, int l) { - if (!a) { - return false; - } else { - return b(((IBlockAccess) (world)), i, j, k, l); - } + return !this.a ? false : this.b((IBlockAccess) world, i, j, k, l); } public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - if (!a) { + if (!this.a) { return false; - } - if (iblockaccess.b(i, j, k) == 0) { + } else if (iblockaccess.getData(i, j, k) == 0) { return false; - } - if (l == 1) { + } else if (l == 1) { return true; - } - boolean flag = b(iblockaccess, i - 1, j, k) || !iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j - 1, k); - boolean flag1 = b(iblockaccess, i + 1, j, k) || !iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j - 1, k); - boolean flag2 = b(iblockaccess, i, j, k - 1) || !iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j - 1, k - 1); - boolean flag3 = b(iblockaccess, i, j, k + 1) || !iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j - 1, k + 1); - - if (!iblockaccess.d(i, j + 1, k)) { - if (iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j + 1, k)) { - flag = true; - } - if (iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j + 1, k)) { - flag1 = true; - } - if (iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j + 1, k - 1)) { - flag2 = true; - } - if (iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j + 1, k + 1)) { - flag3 = true; + } else { + boolean flag = b(iblockaccess, i - 1, j, k) || !iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j - 1, k); + boolean flag1 = b(iblockaccess, i + 1, j, k) || !iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j - 1, k); + boolean flag2 = b(iblockaccess, i, j, k - 1) || !iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j - 1, k - 1); + boolean flag3 = b(iblockaccess, i, j, k + 1) || !iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j - 1, k + 1); + + if (!iblockaccess.d(i, j + 1, k)) { + if (iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j + 1, k)) { + flag = true; + } + + if (iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j + 1, k)) { + flag1 = true; + } + + if (iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j + 1, k - 1)) { + flag2 = true; + } + + if (iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j + 1, k + 1)) { + flag3 = true; + } } + + return !flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5 ? true : (l == 2 && flag2 && !flag && !flag1 ? true : (l == 3 && flag3 && !flag && !flag1 ? true : (l == 4 && flag && !flag2 && !flag3 ? true : l == 5 && flag1 && !flag2 && !flag3))); } - if (!flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5) { - return true; - } - if (l == 2 && flag2 && !flag && !flag1) { - return true; - } - if (l == 3 && flag3 && !flag && !flag1) { - return true; - } - if (l == 4 && flag && !flag2 && !flag3) { - return true; - } - return l == 5 && flag1 && !flag2 && !flag3; } public boolean c() { - return a; + return this.a; } public static boolean b(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.a(i, j, k); + int l = iblockaccess.getTypeId(i, j, k); - if (l == Block.av.bi) { - return true; - } - if (l == 0) { - return false; - } - return Block.m[l].c(); + return l == Block.REDSTONE_WIRE.id ? true : (l == 0 ? false : Block.byId[l].c()); } } |