/** * Stop Piston from pulling an OreGin or it's light */ @EventHandler public void oreGinPistonPull(BlockPistonRetractEvent event) { MaterialData materialData = event.getBlock().getState().getData(); BlockFace blockFace; Block movedBlock; if (materialData instanceof PistonBaseMaterial) { blockFace = ((PistonBaseMaterial) materialData).getFacing(); movedBlock = event.getBlock().getRelative(blockFace, 2); if (event.isSticky() && movedBlock != null) { if (oreGinMan.machineExistsAt(movedBlock.getLocation()) || oreGinMan.oreGinLightExistsAt(movedBlock.getLocation())) { event.setCancelled(true); } } } }
@Override @Nullable protected Boolean[] get(Event e) { MaterialData piston = block.getSingle(e).getState().getData(); if (piston instanceof PistonBaseMaterial) { return new Boolean[]{((PistonBaseMaterial)piston).isPowered()}; } return null; }
@Override public void change(Event e, Object[] delta, Changer.ChangeMode mode){ if (mode == ChangeMode.SET) { BlockState state = block.getSingle(e).getState(); MaterialData piston = state.getData(); if (piston instanceof PistonBaseMaterial) { ((PistonBaseMaterial)piston).setPowered((Boolean)delta[0]); state.setData(piston); state.update(true, false); Bukkit.getLogger().info(((PistonBaseMaterial)piston).isPowered() + " TEST1"); Bukkit.getLogger().info(((PistonBaseMaterial)block.getSingle(e).getState().getData()).isPowered() + " TEST2"); } } }
public boolean check(Event e) { MaterialData piston = block.getSingle(e).getState().getData(); if (!(piston instanceof PistonBaseMaterial)) { return false; } if (((PistonBaseMaterial)piston).isSticky()) { return isNegated(); } else { return !isNegated(); } }
@Deprecated public PistonBaseMaterial(int type) { }
public PistonBaseMaterial(Material type) { }
@Deprecated public PistonBaseMaterial(int type, byte data) { }
@Deprecated public PistonBaseMaterial(Material type, byte data) { }
public PistonBaseMaterial clone() { return null; }