Added Block.getPistonMoveReaction, BlockPistonExtend and BlockPistonRetractEvent
By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
@@ -66,6 +66,15 @@ public interface Block {
|
||||
*/
|
||||
Block getRelative(BlockFace face);
|
||||
|
||||
/**
|
||||
* Gets the block at the given offsets
|
||||
*
|
||||
* @param face face
|
||||
* @param distance distance
|
||||
* @return Block at the given offset and distance
|
||||
*/
|
||||
Block getRelative(BlockFace face, int distance);
|
||||
|
||||
/**
|
||||
* Gets the type of this block
|
||||
*
|
||||
@@ -268,4 +277,11 @@ public interface Block {
|
||||
* @return Humidity of this block
|
||||
*/
|
||||
double getHumidity();
|
||||
|
||||
/**
|
||||
* Returns the reaction of the block when moved by a piston
|
||||
*
|
||||
* @return reaction
|
||||
*/
|
||||
PistonMoveReaction getPistonMoveReaction();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.bukkit.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum PistonMoveReaction {
|
||||
MOVE(0),
|
||||
BREAK(1),
|
||||
BLOCK(2);
|
||||
|
||||
private int id;
|
||||
private static Map<Integer, PistonMoveReaction> byId = new HashMap<Integer, PistonMoveReaction>();
|
||||
static {
|
||||
for (PistonMoveReaction reaction: PistonMoveReaction.values()) {
|
||||
byId.put(reaction.id, reaction);
|
||||
}
|
||||
}
|
||||
|
||||
private PistonMoveReaction(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public static PistonMoveReaction getById(int id) {
|
||||
return byId.get(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user