Skip to content

Commit

Permalink
RedstoneChangeHook tweaks for Buttons, addresses #41
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdiplomat committed Sep 2, 2013
1 parent a8a4c04 commit 1892bad
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/main/java/net/minecraft/server/BlockButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import java.util.Random;
import net.canarymod.api.world.blocks.CanaryBlock;
import net.canarymod.hook.world.RedstoneChangeHook;

public abstract class BlockButton extends Block {
Expand Down Expand Up @@ -141,10 +142,10 @@ public boolean a(World world, int i0, int i1, int i2, EntityPlayer entityplayer,
return true;
}

// CanaryMod: RedstoneChange; Button On
// CanaryMod: RedstoneChange; Button On via Click
RedstoneChangeHook hook = (RedstoneChangeHook) new RedstoneChangeHook(world.getCanaryWorld().getBlockAt(i0, i1, i2), 0, 15).call();
if (hook.isCanceled()) {
return true;
return false;
//
} else {
world.b(i0, i1, i2, i5 + i6, 3);
Expand All @@ -158,8 +159,10 @@ public boolean a(World world, int i0, int i1, int i2, EntityPlayer entityplayer,

public void a(World world, int i0, int i1, int i2, int i3, int i4) {
if ((i4 & 8) > 0) {
// CanaryMod: RedstoneChangeHook (Button broke)
new RedstoneChangeHook(new CanaryBlock((short) this.cF, (short) i3, i0, i1, i2, world.getCanaryWorld()), 15, 0).call();
//
int i5 = i4 & 7;

this.d(world, i0, i1, i2, i5);
}

Expand Down Expand Up @@ -194,7 +197,7 @@ public void a(World world, int i0, int i1, int i2, Random random) {
if (this.a) {
this.n(world, i0, i1, i2);
} else {
// CanaryMod: RedstoneChange; Button off
// CanaryMod: RedstoneChange; Stone Button off
RedstoneChangeHook hook = (RedstoneChangeHook) new RedstoneChangeHook(world.getCanaryWorld().getBlockAt(i0, i1, i2), 15, 0).call();
if (hook.isCanceled()) {
return;
Expand Down Expand Up @@ -240,13 +243,27 @@ private void n(World world, int i0, int i1, int i2) {
boolean flag1 = !list.isEmpty();

if (flag1 && !flag0) {
// CanaryMod: RedstoneChange; Wood Button on
RedstoneChangeHook hook = (RedstoneChangeHook) new RedstoneChangeHook(world.getCanaryWorld().getBlockAt(i0, i1, i2), 0, 15).call();
if (hook.isCanceled()) {
world.a(i0, i1, i2, this.cF, this.a(world)); // Reschedule
return;
}
//
world.b(i0, i1, i2, i4 | 8, 3);
this.d(world, i0, i1, i2, i4);
world.g(i0, i1, i2, i0, i1, i2);
world.a((double) i0 + 0.5D, (double) i1 + 0.5D, (double) i2 + 0.5D, "random.click", 0.3F, 0.6F);
}

if (!flag1 && flag0) {
// CanaryMod: RedstoneChange; Wood Button off
RedstoneChangeHook hook = (RedstoneChangeHook) new RedstoneChangeHook(world.getCanaryWorld().getBlockAt(i0, i1, i2), 15, 0).call();
if (hook.isCanceled()) {
world.a(i0, i1, i2, this.cF, this.a(world)); // Reschedule
return;
}
//
world.b(i0, i1, i2, i4, 3);
this.d(world, i0, i1, i2, i4);
world.g(i0, i1, i2, i0, i1, i2);
Expand Down

0 comments on commit 1892bad

Please sign in to comment.