Update to 1.7
This commit is contained in:
parent
762e66b69b
commit
542376d7b3
@ -41,10 +41,14 @@ public enum Material {
|
|||||||
BED_BLOCK(26, Bed.class),
|
BED_BLOCK(26, Bed.class),
|
||||||
POWERED_RAIL(27, PoweredRail.class),
|
POWERED_RAIL(27, PoweredRail.class),
|
||||||
DETECTOR_RAIL(28, DetectorRail.class),
|
DETECTOR_RAIL(28, DetectorRail.class),
|
||||||
|
PISTON_STICKY_BASE(29, PistonBaseMaterial.class),
|
||||||
WEB(30),
|
WEB(30),
|
||||||
LONG_GRASS(31, LongGrass.class),
|
LONG_GRASS(31, LongGrass.class),
|
||||||
DEAD_BUSH(32),
|
DEAD_BUSH(32),
|
||||||
|
PISTON_BASE(33, PistonBaseMaterial.class),
|
||||||
|
PISTON_EXTENSION(34, PistonExtensionMaterial.class),
|
||||||
WOOL(35, Wool.class),
|
WOOL(35, Wool.class),
|
||||||
|
PISTON_MOVING_PIECE(36),
|
||||||
YELLOW_FLOWER(37),
|
YELLOW_FLOWER(37),
|
||||||
RED_ROSE(38),
|
RED_ROSE(38),
|
||||||
BROWN_MUSHROOM(39),
|
BROWN_MUSHROOM(39),
|
||||||
@ -209,6 +213,7 @@ public enum Material {
|
|||||||
DIODE(356),
|
DIODE(356),
|
||||||
COOKIE(357),
|
COOKIE(357),
|
||||||
MAP(358),
|
MAP(358),
|
||||||
|
SHEARS(359),
|
||||||
GOLD_RECORD(2256, 1),
|
GOLD_RECORD(2256, 1),
|
||||||
GREEN_RECORD(2257, 1);
|
GREEN_RECORD(2257, 1);
|
||||||
|
|
||||||
|
93
src/main/java/org/bukkit/material/PistonBaseMaterial.java
Normal file
93
src/main/java/org/bukkit/material/PistonBaseMaterial.java
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
|
||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Material data for the piston base block
|
||||||
|
*/
|
||||||
|
public class PistonBaseMaterial extends MaterialData implements Directional, Redstone {
|
||||||
|
public PistonBaseMaterial(final int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PistonBaseMaterial(final Material type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PistonBaseMaterial(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PistonBaseMaterial(final Material type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFacingDirection(BlockFace face) {
|
||||||
|
byte data = (byte)(getData() ^ 7);
|
||||||
|
|
||||||
|
switch (face) {
|
||||||
|
case UP:
|
||||||
|
data |= 1;
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
data |= 2;
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
data |= 3;
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
data |= 4;
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
data |= 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFace getFacing() {
|
||||||
|
byte dir = (byte)(getData() & 7);
|
||||||
|
|
||||||
|
switch (dir) {
|
||||||
|
case 0:
|
||||||
|
return BlockFace.DOWN;
|
||||||
|
case 1:
|
||||||
|
return BlockFace.UP;
|
||||||
|
case 2:
|
||||||
|
return BlockFace.NORTH;
|
||||||
|
case 3:
|
||||||
|
return BlockFace.SOUTH;
|
||||||
|
case 4:
|
||||||
|
return BlockFace.WEST;
|
||||||
|
case 5:
|
||||||
|
return BlockFace.EAST;
|
||||||
|
default:
|
||||||
|
return BlockFace.SELF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPowered() {
|
||||||
|
return (getData() & 0x8) == 0x8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current state of this piston
|
||||||
|
*
|
||||||
|
* @param powered true if the piston is extended & powered, or false
|
||||||
|
*/
|
||||||
|
public void setPowered(boolean powered) {
|
||||||
|
setData((byte) (powered ? (getData() | 0x8) : (getData() & ~0x8)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this piston base is sticky, and returns true if so
|
||||||
|
*
|
||||||
|
* @return true if this piston is "sticky", or false
|
||||||
|
*/
|
||||||
|
public boolean isSticky() {
|
||||||
|
return this.getItemType() == Material.PISTON_STICKY_BASE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
|
||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Material data for the piston extension block
|
||||||
|
*/
|
||||||
|
public class PistonExtensionMaterial extends MaterialData implements Directional, Attachable {
|
||||||
|
public PistonExtensionMaterial(final int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PistonExtensionMaterial(final Material type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PistonExtensionMaterial(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PistonExtensionMaterial(final Material type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFacingDirection(BlockFace face) {
|
||||||
|
byte data = (byte)(getData() ^ 7);
|
||||||
|
|
||||||
|
switch (face) {
|
||||||
|
case UP:
|
||||||
|
data |= 1;
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
data |= 2;
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
data |= 3;
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
data |= 4;
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
data |= 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFace getFacing() {
|
||||||
|
byte dir = (byte)(getData() & 7);
|
||||||
|
|
||||||
|
switch (dir) {
|
||||||
|
case 0:
|
||||||
|
return BlockFace.DOWN;
|
||||||
|
case 1:
|
||||||
|
return BlockFace.UP;
|
||||||
|
case 2:
|
||||||
|
return BlockFace.NORTH;
|
||||||
|
case 3:
|
||||||
|
return BlockFace.SOUTH;
|
||||||
|
case 4:
|
||||||
|
return BlockFace.WEST;
|
||||||
|
case 5:
|
||||||
|
return BlockFace.EAST;
|
||||||
|
default:
|
||||||
|
return BlockFace.SELF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this piston extension is sticky, and returns true if so
|
||||||
|
*
|
||||||
|
* @return true if this piston is "sticky", or false
|
||||||
|
*/
|
||||||
|
public boolean isSticky() {
|
||||||
|
return (getData() & 8) == 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether or not this extension is sticky
|
||||||
|
*
|
||||||
|
* @param sticky true if sticky, otherwise false
|
||||||
|
*/
|
||||||
|
public void setSticky(boolean sticky) {
|
||||||
|
setData((byte) (sticky ? (getData() | 0x8) : (getData() & ~0x8)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFace getAttachedFace() {
|
||||||
|
return getFacing().getOppositeFace();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user