Skip to content

Commit

Permalink
tweaks to RedstoneChange for PressurePlate, Lever, Repeater, and
Browse files Browse the repository at this point in the history
Comparators. Addresses #41
  • Loading branch information
darkdiplomat committed Sep 1, 2013
1 parent 1277ede commit dda82f9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.minecraft.server;

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

public abstract class BlockBasePressurePlate extends Block {
Expand Down Expand Up @@ -126,6 +127,13 @@ protected AxisAlignedBB a(int i0, int i1, int i2) {
}

public void a(World world, int i0, int i1, int i2, int i3, int i4) {
// CanaryMod: RedstoneChange; block destructions
int oldLvl = this.c(i4);
if (oldLvl > 0) {
new RedstoneChangeHook(new CanaryBlock((short) this.cF, (short) i3, i0, i1, i2, world.getCanaryWorld()), oldLvl, 0).call();
}
//

if (this.c(i4) > 0) {
this.b_(world, i0, i1, i2);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/minecraft/server/BlockComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void a(World world, int i0, int i1, int i2) {

public void a(World world, int i0, int i1, int i2, int i3, int i4) {
// CanaryMod: Comparator break
int oldLvl = this.e(world, i0, i1, i2, i3);
int oldLvl = this.a_(world, i0, i1, i2).a();
if (oldLvl != 0) {
new RedstoneChangeHook(new CanaryBlock(BlockType.RedstoneComparatorOn.getId(), (short) 2, i0, i1, i2, world.getCanaryWorld()), oldLvl, 0).call();
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/net/minecraft/server/BlockLever.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.minecraft.server;

import net.canarymod.api.world.blocks.BlockType;
import net.canarymod.api.world.blocks.CanaryBlock;
import net.canarymod.hook.world.RedstoneChangeHook;

public class BlockLever extends Block {
Expand Down Expand Up @@ -196,10 +198,8 @@ public boolean a(World world, int i0, int i1, int i2, EntityPlayer entityplayer,
int i6 = 8 - (i4 & 8);

// CanaryMod: RedstoneChange
// Get adjusted levels properly
int oldLvl = this.c((IBlockAccess) world, i0, i1, i2, i3);
int newLvl = i6 == 0 ? 0 : 15; //
RedstoneChangeHook hook = (RedstoneChangeHook) new RedstoneChangeHook(world.getCanaryWorld().getBlockAt(i0, i1, i2), oldLvl, newLvl).call();
RedstoneChangeHook hook = (RedstoneChangeHook) new RedstoneChangeHook(world.getCanaryWorld().getBlockAt(i0, i1, i2), ~newLvl & 15, newLvl).call();
if (hook.isCanceled()) {
return true;
} // CanaryMod: end
Expand Down Expand Up @@ -229,6 +229,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: RedstoneChange
new RedstoneChangeHook(new CanaryBlock(BlockType.Lever.getId(), (short) i4, i0, i1, i2, world.canaryDimension), 15, 0).call();
// Not sure if canceling here would be wise
// CanaryMod: end
world.f(i0, i1, i2, this.cF);
int i5 = i4 & 7;

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/net/minecraft/server/BlockRedstoneRepeater.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package net.minecraft.server;

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

public class BlockRedstoneRepeater extends BlockRedstoneLogic {

Expand Down Expand Up @@ -49,6 +52,11 @@ protected boolean e(int i0) {
}

public void a(World world, int i0, int i1, int i2, int i3, int i4) {
// CanaryMod: RedstoneChange
if (this.a) {
new RedstoneChangeHook(new CanaryBlock(BlockType.RedstoneRepeaterOn.getId(), (short) i3, i0, i1, i2, world.getCanaryWorld()), 15, 0).call();
}
// CanaryMod: end
super.a(world, i0, i1, i2, i3, i4);
this.h_(world, i0, i1, i2);
}
Expand Down

0 comments on commit dda82f9

Please sign in to comment.