summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/minecraft/server/BlockButton.java45
-rw-r--r--src/main/java/net/minecraft/server/BlockLever.java37
-rw-r--r--src/main/java/net/minecraft/server/BlockPressurePlate.java14
-rw-r--r--src/main/java/net/minecraft/server/BlockRedstoneTorch.java160
-rw-r--r--src/main/java/net/minecraft/server/BlockRedstoneWire.java313
5 files changed, 536 insertions, 33 deletions
diff --git a/src/main/java/net/minecraft/server/BlockButton.java b/src/main/java/net/minecraft/server/BlockButton.java
index f29662bd..54cf1fed 100644
--- a/src/main/java/net/minecraft/server/BlockButton.java
+++ b/src/main/java/net/minecraft/server/BlockButton.java
@@ -3,10 +3,12 @@ package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
+import org.bukkit.BlockFace;
import org.bukkit.craftbukkit.CraftBlock;
import org.bukkit.craftbukkit.CraftPlayer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
+import org.bukkit.event.block.BlockRedstoneEvent;
// CraftBukkit end
public class BlockButton extends Block {
@@ -143,9 +145,12 @@ public class BlockButton extends Block {
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
- if (bie.isCancelled()) return true;
+ if (bie.isCancelled()) {
+ return true;
+ }
// CraftBukkit end
+
if (world.z) {
return true;
}
@@ -156,22 +161,30 @@ public class BlockButton extends Block {
if (j1 == 0) {
return true;
}
- world.b(i, j, k, i1 + j1);
- world.b(i, j, k, i, j, k);
- world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
- world.g(i, j, k, bh);
- if (i1 == 1) {
- world.g(i - 1, j, k, bh);
- } else if (i1 == 2) {
- world.g(i + 1, j, k, bh);
- } else if (i1 == 3) {
- world.g(i, j, k - 1, bh);
- } else if (i1 == 4) {
- world.g(i, j, k + 1, bh);
- } else {
- world.g(i, j - 1, k, bh);
+
+ //Allow the lever to change the current
+ int old = (j1 != 8) ? 1 : 0;
+ int current = (j1 == 8) ? 1 : 0;
+ BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.Self, old, current);
+ ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
+ if ((bre.getNewCurrent() > 0) == (k == 8)) {
+ world.b(i, j, k, i1 + j1);
+ world.b(i, j, k, i, j, k);
+ world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
+ world.g(i, j, k, bh);
+ if (i1 == 1) {
+ world.g(i - 1, j, k, bh);
+ } else if (i1 == 2) {
+ world.g(i + 1, j, k, bh);
+ } else if (i1 == 3) {
+ world.g(i, j, k - 1, bh);
+ } else if (i1 == 4) {
+ world.g(i, j, k + 1, bh);
+ } else {
+ world.g(i, j - 1, k, bh);
+ }
+ world.h(i, j, k, bh);
}
- world.h(i, j, k, bh);
return true;
}
diff --git a/src/main/java/net/minecraft/server/BlockLever.java b/src/main/java/net/minecraft/server/BlockLever.java
index 796c0757..d8f264c2 100644
--- a/src/main/java/net/minecraft/server/BlockLever.java
+++ b/src/main/java/net/minecraft/server/BlockLever.java
@@ -1,10 +1,12 @@
package net.minecraft.server;
// CraftBukkit start
+import org.bukkit.BlockFace;
import org.bukkit.craftbukkit.CraftBlock;
import org.bukkit.craftbukkit.CraftPlayer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
+import org.bukkit.event.block.BlockRedstoneEvent;
// CraftBukkit end
public class BlockLever extends Block {
@@ -159,20 +161,27 @@ public class BlockLever extends Block {
int i1 = l & 7;
int j1 = 8 - (l & 8);
- world.b(i, j, k, i1 + j1);
- world.b(i, j, k, i, j, k);
- world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 <= 0 ? 0.5F : 0.6F);
- world.g(i, j, k, bh);
- if (i1 == 1) {
- world.g(i - 1, j, k, bh);
- } else if (i1 == 2) {
- world.g(i + 1, j, k, bh);
- } else if (i1 == 3) {
- world.g(i, j, k - 1, bh);
- } else if (i1 == 4) {
- world.g(i, j, k + 1, bh);
- } else {
- world.g(i, j - 1, k, bh);
+ //Allow the lever to change the current
+ int old = (j1 != 8) ? 1 : 0;
+ int current = (j1 == 8) ? 1 : 0;
+ BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.Self, old, current);
+ ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
+ if ((bre.getNewCurrent() > 0) == (k == 8)) {
+ world.b(i, j, k, i1 + j1);
+ world.b(i, j, k, i, j, k);
+ world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 <= 0 ? 0.5F : 0.6F);
+ world.g(i, j, k, bh);
+ if (i1 == 1) {
+ world.g(i - 1, j, k, bh);
+ } else if (i1 == 2) {
+ world.g(i + 1, j, k, bh);
+ } else if (i1 == 3) {
+ world.g(i, j, k - 1, bh);
+ } else if (i1 == 4) {
+ world.g(i, j, k + 1, bh);
+ } else {
+ world.g(i, j - 1, k, bh);
+ }
}
return true;
}
diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java
index 0e984995..3e228536 100644
--- a/src/main/java/net/minecraft/server/BlockPressurePlate.java
+++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java
@@ -4,11 +4,12 @@ import java.util.List;
import java.util.Random;
// CraftBukkit start
-import org.bukkit.craftbukkit.CraftBlock;
+import org.bukkit.BlockFace;import org.bukkit.craftbukkit.CraftBlock;
import org.bukkit.craftbukkit.CraftLivingEntity;
import org.bukkit.craftbukkit.CraftPlayer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
+import org.bukkit.event.block.BlockRedstoneEvent;
// CraftBukkit end
public class BlockPressurePlate extends Block {
@@ -40,7 +41,8 @@ public class BlockPressurePlate extends Block {
return world.d(i, j - 1, k);
}
- public void e(World world, int i, int j, int k) {}
+ public void e(World world, int i, int j, int k) {
+ }
public void b(World world, int i, int j, int k, int l) {
boolean flag = false;
@@ -87,7 +89,9 @@ public class BlockPressurePlate extends Block {
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
- if (bie.isCancelled()) return;
+ if (bie.isCancelled()) {
+ return;
+ }
}
// CraftBukkit end
@@ -114,6 +118,10 @@ public class BlockPressurePlate extends Block {
if (list.size() > 0) {
flag1 = true;
}
+ CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
+ BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.Self, flag ? 15 : 0, flag1 ? 15 : 0);
+ ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
+ flag1 = bre.getNewCurrent() > 0;
if (flag1 && !flag) {
world.b(i, j, k, 1);
world.g(i, j, k, bh);
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
new file mode 100644
index 00000000..366e2876
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
@@ -0,0 +1,160 @@
+package net.minecraft.server;
+
+import java.util.*;
+import org.bukkit.BlockFace;
+import org.bukkit.craftbukkit.CraftBlock;
+import org.bukkit.event.block.BlockRedstoneEvent;
+
+public class BlockRedstoneTorch extends BlockTorch {
+
+ private boolean a;
+ private static List b = new ArrayList();
+
+ private boolean a(World world, int i, int j, int k, boolean flag) {
+ if (flag) {
+ b.add(((new RedstoneUpdateInfo(i, j, k, world.e))));
+ }
+ int l = 0;
+
+ for (int i1 = 0; i1 < b.size(); i1++) {
+ RedstoneUpdateInfo redstoneupdateinfo = (RedstoneUpdateInfo) b.get(i1);
+
+ if (redstoneupdateinfo.a == i && redstoneupdateinfo.b == j && redstoneupdateinfo.c == k && ++l >= 8) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected BlockRedstoneTorch(int i, int j, boolean flag) {
+ super(i, j);
+ a = false;
+ a = flag;
+ a(true);
+ }
+
+ public int b() {
+ return 2;
+ }
+
+ public void e(World world, int i, int j, int k) {
+ if (world.b(i, j, k) == 0) {
+ super.e(world, i, j, k);
+ }
+ if (a) {
+ world.g(i, j - 1, k, bh);
+ world.g(i, j + 1, k, bh);
+ world.g(i - 1, j, k, bh);
+ world.g(i + 1, j, k, bh);
+ world.g(i, j, k - 1, bh);
+ world.g(i, j, k + 1, bh);
+ }
+ }
+
+ public void b(World world, int i, int j, int k) {
+ if (a) {
+ world.g(i, j - 1, k, bh);
+ world.g(i, j + 1, k, bh);
+ world.g(i - 1, j, k, bh);
+ world.g(i + 1, j, k, bh);
+ world.g(i, j, k - 1, bh);
+ world.g(i, j, k + 1, bh);
+ }
+ }
+
+ public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
+ if (!a) {
+ return false;
+ }
+ int i1 = iblockaccess.b(i, j, k);
+
+ if (i1 == 5 && l == 1) {
+ return false;
+ }
+ if (i1 == 3 && l == 3) {
+ return false;
+ }
+ if (i1 == 4 && l == 2) {
+ return false;
+ }
+ if (i1 == 1 && l == 5) {
+ return false;
+ }
+ return i1 != 2 || l != 4;
+ }
+
+ private boolean g(World world, int i, int j, int k) {
+ int l = world.b(i, j, k);
+
+ if (l == 5 && world.j(i, j - 1, k, 0)) {
+ return true;
+ }
+ if (l == 3 && world.j(i, j, k - 1, 2)) {
+ return true;
+ }
+ if (l == 4 && world.j(i, j, k + 1, 3)) {
+ return true;
+ }
+ if (l == 1 && world.j(i - 1, j, k, 4)) {
+ return true;
+ }
+ return l == 2 && world.j(i + 1, j, k, 5);
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ boolean flag = g(world, i, j, k);
+
+ for (; b.size() > 0 && world.e - ((RedstoneUpdateInfo) b.get(0)).d > 100L; b.remove(0)) {
+ ;
+ }
+ //Added by craftbukkit
+ CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
+ BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.Self, flag ? 15 : 0, flag ? 0 : 15);
+ ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
+ if ((bre.getNewCurrent() != 0) == flag) {
+ return;
+ }
+ if (a) {
+ if (flag) {
+ world.b(i, j, k, Block.aP.bh, world.b(i, j, k));
+
+ if (a(world, i, j, k, true)) {
+ world.a((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F);
+ for (int l = 0; l < 5; l++) {
+ double d1 = (double) i + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
+ double d2 = (double) j + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
+ double d3 = (double) k + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
+
+ world.a("smoke", d1, d2, d3, 0.0D, 0.0D, 0.0D);
+ }
+ }
+ }
+ } else if (!flag
+ && !a(world, i, j, k,
+ false)) {
+ world.b(i, j, k, Block.aQ.bh, world.b(i, j, k));
+ }
+ }
+
+ public void b(World world, int i, int j, int k, int l) {
+ super.b(world, i, j, k, l);
+ world.h(i, j, k, bh);
+ }
+
+ public boolean d(World world, int i, int j, int k, int l) {
+ if (l == 0) {
+ return b(((IBlockAccess) (world)), i, j, k, l);
+ } else {
+ return false;
+ }
+ }
+
+ public int a(int i, Random random) {
+ return Block.aQ.bh;
+ }
+
+ public boolean c() {
+ return true;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
new file mode 100644
index 00000000..3548570d
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
@@ -0,0 +1,313 @@
+package net.minecraft.server;
+
+import java.util.Random;
+import org.bukkit.BlockFace;
+import org.bukkit.craftbukkit.CraftBlock;
+import org.bukkit.event.block.BlockRedstoneEvent;
+import org.bukkit.plugin.PluginLoader;
+
+public class BlockRedstoneWire extends Block {
+
+ private boolean a;
+
+ public BlockRedstoneWire(int i, int j) {
+ super(i, j, Material.n);
+ a = true;
+ a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
+ }
+
+ public AxisAlignedBB d(World world, int i, int j, int k) {
+ return null;
+ }
+
+ public boolean a() {
+ return false;
+ }
+
+ public boolean a(World world, int i, int j, int k) {
+ return world.d(i, j - 1, k);
+ }
+
+ private void g(World world, int i, int j, int k) {
+ int l = world.b(i, j, k);
+ int i1 = 0;
+
+ a = false;
+ boolean flag = world.o(i, j, k);
+
+ a = true;
+ if (flag) {
+ i1 = 15;
+ } else {
+ for (int j1 = 0; j1 < 4; j1++) {
+ int l1 = i;
+ int j2 = k;
+
+ if (j1 == 0) {
+ l1--;
+ }
+ if (j1 == 1) {
+ l1++;
+ }
+ if (j1 == 2) {
+ j2--;
+ }
+ if (j1 == 3) {
+ j2++;
+ }
+ i1 = f(world, l1, j, j2, i1);
+ if (world.d(l1, j, j2) && !world.d(i, j + 1, k)) {
+ i1 = f(world, l1, j + 1, j2, i1);
+ continue;
+ }
+ if (!world.d(l1, j, j2)) {
+ i1 = f(world, l1, j - 1, j2, i1);
+ }
+ }
+
+ if (i1 > 0) {
+ i1--;
+ } else {
+ i1 = 0;
+ }
+ }
+ //Allow redstone wire current changes
+ if (l != i1) {
+ CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
+ BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.Self, l, i1);
+ ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
+ i1 = bre.getNewCurrent();
+ }
+ if (l != i1) {
+ world.b(i, j, k, i1);
+ world.b(i, j, k, i, j, k);
+ if (i1 > 0) {
+ i1--;
+ }
+ for (int k1 = 0; k1 < 4; k1++) {
+ int i2 = i;
+ int k2 = k;
+ int l2 = j - 1;
+
+ if (k1 == 0) {
+ i2--;
+ }
+ if (k1 == 1) {
+ i2++;
+ }
+ if (k1 == 2) {
+ k2--;
+ }
+ if (k1 == 3) {
+ k2++;
+ }
+ if (world.d(i2, j, k2)) {
+ l2 += 2;
+ }
+ int i3 = f(world, i2, j, k2, -1);
+
+ if (i3 >= 0 && i3 != i1) {
+ g(world, i2, j, k2);
+ }
+ i3 = f(world, i2, l2, k2, -1);
+ if (i3 >= 0 && i3 != i1) {
+ g(world, i2, l2, k2);
+ }
+ }
+
+ if (l == 0 || i1 == 0) {
+ world.g(i, j, k, bh);
+ world.g(i - 1, j, k, bh);
+ world.g(i + 1, j, k, bh);
+ world.g(i, j, k - 1, bh);
+ world.g(i, j, k + 1, bh);
+ world.g(i, j - 1, k, bh);
+ world.g(i, j + 1, k, bh);
+ }
+ }
+ }
+
+ private void h(World world, int i, int j, int k) {
+ if (world.a(i, j, k) != bh) {
+ return;
+ } else {
+ world.g(i, j, k, bh);
+ world.g(i - 1, j, k, bh);
+ world.g(i + 1, j, k, bh);
+ world.g(i, j, k - 1, bh);
+ world.g(i, j, k + 1, bh);
+ world.g(i, j - 1, k, bh);
+ world.g(i, j + 1, k, bh);
+ return;
+ }
+ }
+
+ 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.g(i, j + 1, k, bh);
+ world.g(i, j - 1, k, bh);
+ 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);
+ }
+ }
+
+ public void b(World world, int i, int j, int k) {
+ super.b(world, i, j, k);
+ if (world.z) {
+ return;
+ }
+ world.g(i, j + 1, k, bh);
+ world.g(i, j - 1, k, bh);
+ 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);
+ }
+ }
+
+ private int f(World world, int i, int j, int k, int l) {
+ if (world.a(i, j, k) != bh) {
+ return l;
+ }
+ int i1 = world.b(i, j, k);
+
+ if (i1 > l) {
+ return i1;
+ } else {
+ return 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 (!flag) {
+ a_(world, i, j, k, i1);
+ world.d(i, j, k, 0);
+ } else {
+ g(world, i, j, k);
+ }
+ super.b(world, i, j, k, l);
+ }
+
+ public int a(int i, Random random) {
+ return Item.aA.aW;
+ }
+
+ 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);
+ }
+ }
+
+ public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
+ if (!a) {
+ return false;
+ }
+ if (iblockaccess.b(i, j, k) == 0) {
+ return false;
+ }
+ 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;
+ }
+ }
+ 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;
+ }
+
+ public static boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
+ int l = iblockaccess.a(i, j, k);
+
+ if (l == Block.av.bh) {
+ return true;
+ }
+ if (l == 0) {
+ return false;
+ }
+ return Block.m[l].c();
+ }
+}