hopeful fix for blocks not being pistons when they should be

This commit is contained in:
Tahg 2011-09-30 03:27:36 -04:00
parent 2276eb899e
commit 963622f8cf
3 changed files with 12 additions and 7 deletions

View File

@ -8,9 +8,11 @@ import org.bukkit.material.PistonBaseMaterial;
public abstract class BlockPistonEvent extends BlockEvent implements Cancellable { public abstract class BlockPistonEvent extends BlockEvent implements Cancellable {
private boolean cancelled; private boolean cancelled;
private BlockFace direction;
public BlockPistonEvent(Type type, Block block) { public BlockPistonEvent(Type type, Block block, BlockFace direction) {
super(type, block); super(type, block);
this.direction = direction;
} }
public boolean isCancelled() { public boolean isCancelled() {
@ -37,7 +39,8 @@ public abstract class BlockPistonEvent extends BlockEvent implements Cancellable
*/ */
public BlockFace getDirection() { public BlockFace getDirection() {
// Both are meh! // Both are meh!
// return ((PistonBaseMaterial) block.getType().getNewData(block.getData ())).getFacing(); // return ((PistonBaseMaterial) block.getType().getNewData(block.getData())).getFacing();
return ((PistonBaseMaterial) block.getState().getData()).getFacing(); // return ((PistonBaseMaterial) block.getState().getData()).getFacing();
return direction;
} }
} }

View File

@ -5,13 +5,14 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
public class BlockPistonExtendEvent extends BlockPistonEvent { public class BlockPistonExtendEvent extends BlockPistonEvent {
private int length; private int length;
private List<Block> blocks; private List<Block> blocks;
public BlockPistonExtendEvent(Block block, int length) { public BlockPistonExtendEvent(Block block, int length, BlockFace direction) {
super(Type.BLOCK_PISTON_EXTEND, block); super(Type.BLOCK_PISTON_EXTEND, block, direction);
this.length = length; this.length = length;
} }

View File

@ -2,10 +2,11 @@ package org.bukkit.event.block;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
public class BlockPistonRetractEvent extends BlockPistonEvent { public class BlockPistonRetractEvent extends BlockPistonEvent {
public BlockPistonRetractEvent(Block block) { public BlockPistonRetractEvent(Block block, BlockFace direction) {
super(Type.BLOCK_PISTON_RETRACT, block); super(Type.BLOCK_PISTON_RETRACT, block, direction);
} }
/** /**