Created
March 22, 2013 05:11
-
-
Save riking/5219088 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void triggerRedstone(final PhysicalShop plugin) { | |
if(!plugin.getConfig().getBoolean(TRIGGER_REDSTONE)) return; | |
final BlockFace face = ShopHelpers.getBack(sign); | |
switch(face) { | |
case NORTH: | |
case SOUTH: | |
case WEST: | |
case EAST: | |
break; | |
default: | |
return; | |
} | |
final Block signBlock = sign.getBlock().getRelative(face); | |
final Block activatedBlock = signBlock.getRelative(face); | |
final Material type = activatedBlock.getType(); | |
if(type != Material.LEVER && type != Material.STONE_BUTTON) return; | |
if(((Attachable) activatedBlock.getState().getData()).getAttachedFace() != face.getOppositeFace()) return; | |
if(!(activatedBlock.getChunk() instanceof CraftChunk)) return; | |
final CraftChunk chunk = (CraftChunk) activatedBlock.getChunk(); | |
net.minecraft.server.v1_4_R1.Block | |
.byId[chunk.getHandle().world.getTypeId( | |
activatedBlock.getX(), | |
activatedBlock.getY(), | |
activatedBlock.getZ() | |
) | |
].interact( | |
chunk.getHandle().world, | |
activatedBlock.getX(), | |
activatedBlock.getY(), | |
activatedBlock.getZ(), | |
null, | |
0, | |
Float.NaN, | |
Float.NaN, | |
Float.NaN | |
); | |
// This is Notch code for toggling something. | |
// This means I wont need to toggle the button back myself! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment