[Bleeding] Add new MaterialData classes for new blocks and update existing blocks with new data
This commit is contained in:
parent
0249a23179
commit
91de17c900
@ -72,7 +72,7 @@ public enum Material {
|
|||||||
FIRE(51),
|
FIRE(51),
|
||||||
MOB_SPAWNER(52),
|
MOB_SPAWNER(52),
|
||||||
WOOD_STAIRS(53, Stairs.class),
|
WOOD_STAIRS(53, Stairs.class),
|
||||||
CHEST(54),
|
CHEST(54, Chest.class),
|
||||||
REDSTONE_WIRE(55, RedstoneWire.class),
|
REDSTONE_WIRE(55, RedstoneWire.class),
|
||||||
DIAMOND_ORE(56),
|
DIAMOND_ORE(56),
|
||||||
DIAMOND_BLOCK(57),
|
DIAMOND_BLOCK(57),
|
||||||
@ -291,18 +291,18 @@ public enum Material {
|
|||||||
RECORD_9(2264, 1),
|
RECORD_9(2264, 1),
|
||||||
RECORD_10(2265, 1),
|
RECORD_10(2265, 1),
|
||||||
RECORD_11(2266, 1),
|
RECORD_11(2266, 1),
|
||||||
WOOD_DOUBLE_STEP(125, Step.class),
|
WOOD_DOUBLE_STEP(125, WoodenStep.class),
|
||||||
WOOD_STEP(126, Step.class),
|
WOOD_STEP(126, WoodenStep.class),
|
||||||
COCOA(127),
|
COCOA(127, CocoaPlant.class),
|
||||||
SANDSTONE_STAIRS(128, Stairs.class),
|
SANDSTONE_STAIRS(128, Stairs.class),
|
||||||
EMERALD_ORE(129),
|
EMERALD_ORE(129),
|
||||||
ENDER_CHEST(130),
|
ENDER_CHEST(130, EnderChest.class),
|
||||||
TRIPWIRE_HOOK(131, Button.class),
|
TRIPWIRE_HOOK(131, TripwireHook.class),
|
||||||
TRIPWIRE(132),
|
TRIPWIRE(132, Tripwire.class),
|
||||||
EMERALD_BLOCK(133),
|
EMERALD_BLOCK(133),
|
||||||
SPRUCE_WOOD_STAIRS(134),
|
SPRUCE_WOOD_STAIRS(134, Stairs.class),
|
||||||
BIRCH_WOOD_STAIRS(135),
|
BIRCH_WOOD_STAIRS(135, Stairs.class),
|
||||||
JUNGLE_WOOD_STAIRS(136),
|
JUNGLE_WOOD_STAIRS(136, Stairs.class),
|
||||||
BOOK_AND_QUILL(386, 1),
|
BOOK_AND_QUILL(386, 1),
|
||||||
WRITTEN_BOOK(387, 1),
|
WRITTEN_BOOK(387, 1),
|
||||||
EMERALD(388, 64);
|
EMERALD(388, 64);
|
||||||
|
45
src/main/java/org/bukkit/material/Chest.java
Normal file
45
src/main/java/org/bukkit/material/Chest.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a chest
|
||||||
|
*/
|
||||||
|
public class Chest extends FurnaceAndDispenser {
|
||||||
|
|
||||||
|
public Chest() {
|
||||||
|
super(Material.CHEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate a chest facing in a particular direction.
|
||||||
|
*
|
||||||
|
* @param direction the direction the chest's lit opens towards
|
||||||
|
*/
|
||||||
|
public Chest(BlockFace direction) {
|
||||||
|
this();
|
||||||
|
setFacingDirection(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chest(final int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chest(final Material type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chest(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chest(final Material type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chest clone() {
|
||||||
|
return (Chest) super.clone();
|
||||||
|
}
|
||||||
|
}
|
117
src/main/java/org/bukkit/material/CocoaPlant.java
Normal file
117
src/main/java/org/bukkit/material/CocoaPlant.java
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the cocoa plant
|
||||||
|
*/
|
||||||
|
public class CocoaPlant extends MaterialData implements Directional {
|
||||||
|
|
||||||
|
public enum CocoaPlantSize {
|
||||||
|
SMALL,
|
||||||
|
MEDIUM,
|
||||||
|
LARGE
|
||||||
|
}
|
||||||
|
|
||||||
|
public CocoaPlant() {
|
||||||
|
super(Material.COCOA);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CocoaPlant(final int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CocoaPlant(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CocoaPlant(CocoaPlantSize sz) {
|
||||||
|
this();
|
||||||
|
setSize(sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CocoaPlant(CocoaPlantSize sz, BlockFace dir) {
|
||||||
|
this();
|
||||||
|
setSize(sz);
|
||||||
|
setFacingDirection(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get size of plant
|
||||||
|
* @return size
|
||||||
|
*/
|
||||||
|
public CocoaPlantSize getSize() {
|
||||||
|
switch (getData() & 0xC) {
|
||||||
|
case 0:
|
||||||
|
return CocoaPlantSize.SMALL;
|
||||||
|
case 4:
|
||||||
|
return CocoaPlantSize.MEDIUM;
|
||||||
|
default:
|
||||||
|
return CocoaPlantSize.LARGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set size of plant
|
||||||
|
* @param sz - size of plant
|
||||||
|
*/
|
||||||
|
public void setSize(CocoaPlantSize sz) {
|
||||||
|
int dat = getData() & 0x3;
|
||||||
|
switch (sz) {
|
||||||
|
case SMALL:
|
||||||
|
break;
|
||||||
|
case MEDIUM:
|
||||||
|
dat |= 0x4;
|
||||||
|
break;
|
||||||
|
case LARGE:
|
||||||
|
dat |= 0x8;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFacingDirection(BlockFace face) {
|
||||||
|
int dat = getData() & 0xC;
|
||||||
|
switch (face) {
|
||||||
|
case WEST:
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
dat |= 0x1;
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
dat |= 0x2;
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
dat |= 0x3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFace getFacing() {
|
||||||
|
switch (getData() & 0x3) {
|
||||||
|
case 0:
|
||||||
|
return BlockFace.WEST;
|
||||||
|
case 1:
|
||||||
|
return BlockFace.NORTH;
|
||||||
|
case 2:
|
||||||
|
return BlockFace.EAST;
|
||||||
|
case 3:
|
||||||
|
return BlockFace.SOUTH;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CocoaPlant clone() {
|
||||||
|
return (CocoaPlant) super.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " facing " + getFacing() + " " + getSize();
|
||||||
|
}
|
||||||
|
}
|
45
src/main/java/org/bukkit/material/EnderChest.java
Normal file
45
src/main/java/org/bukkit/material/EnderChest.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an ender chest
|
||||||
|
*/
|
||||||
|
public class EnderChest extends FurnaceAndDispenser {
|
||||||
|
|
||||||
|
public EnderChest() {
|
||||||
|
super(Material.ENDER_CHEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate an ender chest facing in a particular direction.
|
||||||
|
*
|
||||||
|
* @param direction the direction the ender chest's lid opens towards
|
||||||
|
*/
|
||||||
|
public EnderChest(BlockFace direction) {
|
||||||
|
this();
|
||||||
|
setFacingDirection(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnderChest(final int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnderChest(final Material type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnderChest(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnderChest(final Material type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnderChest clone() {
|
||||||
|
return (EnderChest) super.clone();
|
||||||
|
}
|
||||||
|
}
|
@ -70,6 +70,11 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone {
|
|||||||
case 0x5:
|
case 0x5:
|
||||||
case 0x6:
|
case 0x6:
|
||||||
return BlockFace.DOWN;
|
return BlockFace.DOWN;
|
||||||
|
|
||||||
|
case 0x0:
|
||||||
|
case 0x7:
|
||||||
|
return BlockFace.UP;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -80,8 +85,9 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone {
|
|||||||
*/
|
*/
|
||||||
public void setFacingDirection(BlockFace face) {
|
public void setFacingDirection(BlockFace face) {
|
||||||
byte data = (byte) (getData() & 0x8);
|
byte data = (byte) (getData() & 0x8);
|
||||||
|
BlockFace attach = getAttachedFace();
|
||||||
if (getAttachedFace() == BlockFace.DOWN) {
|
|
||||||
|
if (attach == BlockFace.DOWN) {
|
||||||
switch (face) {
|
switch (face) {
|
||||||
case WEST:
|
case WEST:
|
||||||
case EAST:
|
case EAST:
|
||||||
@ -93,6 +99,18 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone {
|
|||||||
data |= 0x6;
|
data |= 0x6;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (attach == BlockFace.UP) {
|
||||||
|
switch (face) {
|
||||||
|
case WEST:
|
||||||
|
case EAST:
|
||||||
|
data |= 0x7;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOUTH:
|
||||||
|
case NORTH:
|
||||||
|
data |= 0x0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (face) {
|
switch (face) {
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
|
@ -30,7 +30,7 @@ public class Stairs extends MaterialData implements Directional {
|
|||||||
public BlockFace getAscendingDirection() {
|
public BlockFace getAscendingDirection() {
|
||||||
byte data = getData();
|
byte data = getData();
|
||||||
|
|
||||||
switch (data) {
|
switch (data & 0x3) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
default:
|
default:
|
||||||
return BlockFace.SOUTH;
|
return BlockFace.SOUTH;
|
||||||
@ -78,7 +78,7 @@ public class Stairs extends MaterialData implements Directional {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setData(data);
|
setData((byte) ((getData() & 0xC) | data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,9 +88,29 @@ public class Stairs extends MaterialData implements Directional {
|
|||||||
return getDescendingDirection();
|
return getDescendingDirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if step is inverted
|
||||||
|
* @return true if inverted (top half), false if normal (bottom half)
|
||||||
|
*/
|
||||||
|
public boolean isInverted() {
|
||||||
|
return ((getData() & 0x4) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set step inverted state
|
||||||
|
* @param inv - true if step is inverted (top half), false if step is normal (bottom half)
|
||||||
|
*/
|
||||||
|
public void setInverted(boolean inv) {
|
||||||
|
int dat = getData() & 0x3;
|
||||||
|
if (inv) {
|
||||||
|
dat |= 0x4;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + " facing " + getFacing();
|
return super.toString() + " facing " + getFacing() + (isInverted()?" inverted":"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,8 +47,43 @@ public class Step extends TexturedMaterial {
|
|||||||
return textures;
|
return textures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if step is inverted
|
||||||
|
* @return true if inverted (top half), false if normal (bottom half)
|
||||||
|
*/
|
||||||
|
public boolean isInverted() {
|
||||||
|
return ((getData() & 0x8) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set step inverted state
|
||||||
|
* @param inv - true if step is inverted (top half), false if step is normal (bottom half)
|
||||||
|
*/
|
||||||
|
public void setInverted(boolean inv) {
|
||||||
|
int dat = getData() & 0x7;
|
||||||
|
if (inv) {
|
||||||
|
dat |= 0x8;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getTextureIndex() {
|
||||||
|
return getData() & 0x7;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setTextureIndex(int idx) {
|
||||||
|
setData((byte) ((getData() & 0x8) | idx));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Step clone() {
|
public Step clone() {
|
||||||
return (Step) super.clone();
|
return (Step) super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + (isInverted()?"inverted":"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public abstract class TexturedMaterial extends MaterialData {
|
|||||||
* @return Material of this block
|
* @return Material of this block
|
||||||
*/
|
*/
|
||||||
public Material getMaterial() {
|
public Material getMaterial() {
|
||||||
int n = (int) getData();
|
int n = getTextureIndex();
|
||||||
if (n > getTextures().size() - 1) {
|
if (n > getTextures().size() - 1) {
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
@ -54,12 +54,28 @@ public abstract class TexturedMaterial extends MaterialData {
|
|||||||
*/
|
*/
|
||||||
public void setMaterial(Material material) {
|
public void setMaterial(Material material) {
|
||||||
if (getTextures().contains(material)) {
|
if (getTextures().contains(material)) {
|
||||||
setData((byte) getTextures().indexOf(material));
|
setTextureIndex(getTextures().indexOf(material));
|
||||||
} else {
|
} else {
|
||||||
setData((byte) 0x0);
|
setTextureIndex(0x0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get material index from data
|
||||||
|
* @return index of data in textures list
|
||||||
|
*/
|
||||||
|
protected int getTextureIndex() {
|
||||||
|
return getData(); // Default to using all bits - override for other mappings
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set material index
|
||||||
|
* @param idx - index of data in textures list
|
||||||
|
*/
|
||||||
|
protected void setTextureIndex(int idx) {
|
||||||
|
setData((byte) idx); // Defult to using all bits - override for other mappings
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getMaterial() + " " + super.toString();
|
return getMaterial() + " " + super.toString();
|
||||||
|
@ -2,6 +2,7 @@ package org.bukkit.material;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.TreeSpecies;
|
import org.bukkit.TreeSpecies;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the different types of Trees.
|
* Represents the different types of Trees.
|
||||||
@ -16,6 +17,12 @@ public class Tree extends MaterialData {
|
|||||||
setSpecies(species);
|
setSpecies(species);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Tree(TreeSpecies species, BlockFace dir) {
|
||||||
|
this();
|
||||||
|
setSpecies(species);
|
||||||
|
setDirection(dir);
|
||||||
|
}
|
||||||
|
|
||||||
public Tree(final int type) {
|
public Tree(final int type) {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
@ -38,7 +45,7 @@ public class Tree extends MaterialData {
|
|||||||
* @return TreeSpecies of this tree
|
* @return TreeSpecies of this tree
|
||||||
*/
|
*/
|
||||||
public TreeSpecies getSpecies() {
|
public TreeSpecies getSpecies() {
|
||||||
return TreeSpecies.getByData(getData());
|
return TreeSpecies.getByData((byte) (getData() & 0x3));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,12 +54,57 @@ public class Tree extends MaterialData {
|
|||||||
* @param species New species of this tree
|
* @param species New species of this tree
|
||||||
*/
|
*/
|
||||||
public void setSpecies(TreeSpecies species) {
|
public void setSpecies(TreeSpecies species) {
|
||||||
setData(species.getData());
|
setData((byte) ((getData() & 0xC) | species.getData()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get direction of the log
|
||||||
|
*
|
||||||
|
* @return BlockFace.TOP for upright (default), BlockFace.EAST (east-west), BlockFace.NORTH (north-sout), BlockFace.SELF (directionless)
|
||||||
|
*/
|
||||||
|
public BlockFace getDirection() {
|
||||||
|
switch ((getData() >> 2) & 0x3) {
|
||||||
|
case 0: // Up-down
|
||||||
|
default:
|
||||||
|
return BlockFace.UP;
|
||||||
|
case 1: // North-south
|
||||||
|
return BlockFace.NORTH;
|
||||||
|
case 2: // East-west
|
||||||
|
return BlockFace.EAST;
|
||||||
|
case 3: // Directionless (bark on all sides)
|
||||||
|
return BlockFace.SELF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set direction of the log
|
||||||
|
* @param dir - direction of end of log (BlockFace.SELF for no direction)
|
||||||
|
*/
|
||||||
|
public void setDirection(BlockFace dir) {
|
||||||
|
int dat;
|
||||||
|
switch (dir) {
|
||||||
|
case UP:
|
||||||
|
case DOWN:
|
||||||
|
default:
|
||||||
|
dat = 0;
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
case SOUTH:
|
||||||
|
dat = 1;
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
case WEST:
|
||||||
|
dat = 2;
|
||||||
|
break;
|
||||||
|
case SELF:
|
||||||
|
dat = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setData((byte) ((getData() & 0x3) | (dat << 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getSpecies() + " " + super.toString();
|
return getSpecies() + " " + getDirection() + " " + super.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
71
src/main/java/org/bukkit/material/Tripwire.java
Normal file
71
src/main/java/org/bukkit/material/Tripwire.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the tripwire
|
||||||
|
*/
|
||||||
|
public class Tripwire extends MaterialData {
|
||||||
|
|
||||||
|
public Tripwire() {
|
||||||
|
super(Material.TRIPWIRE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tripwire(final int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tripwire(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if tripwire is currently activated
|
||||||
|
* @return true if activated, false if not
|
||||||
|
*/
|
||||||
|
public boolean isActivated() {
|
||||||
|
return (getData() & 0x4) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set tripwire activated state
|
||||||
|
* @param act - true if activated, false if not
|
||||||
|
*/
|
||||||
|
public void setActivated(boolean act) {
|
||||||
|
int dat = getData() & (0x8 | 0x3);
|
||||||
|
if (act) {
|
||||||
|
dat |= 0x4;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if object triggering this tripwire directly
|
||||||
|
* @return true if object activating tripwire, false if not
|
||||||
|
*/
|
||||||
|
public boolean isObjectTriggering() {
|
||||||
|
return (getData() & 0x1) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set object triggering state for this tripwire
|
||||||
|
* @param trig - true if object activating tripwire, false if not
|
||||||
|
*/
|
||||||
|
public void setObjectTriggering(boolean trig) {
|
||||||
|
int dat = getData() & 0xE;
|
||||||
|
if (trig) {
|
||||||
|
dat |= 0x1;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tripwire clone() {
|
||||||
|
return (Tripwire) super.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + (isActivated()?" Activated":"") + (isObjectTriggering()?" Triggered":"");
|
||||||
|
}
|
||||||
|
}
|
115
src/main/java/org/bukkit/material/TripwireHook.java
Normal file
115
src/main/java/org/bukkit/material/TripwireHook.java
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the tripwire hook
|
||||||
|
*/
|
||||||
|
public class TripwireHook extends MaterialData implements Directional, Redstone {
|
||||||
|
|
||||||
|
public TripwireHook() {
|
||||||
|
super(Material.TRIPWIRE_HOOK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TripwireHook(final int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TripwireHook(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TripwireHook(BlockFace dir) {
|
||||||
|
this();
|
||||||
|
setFacingDirection(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if tripwire is connected
|
||||||
|
* @return true if connected, false if not
|
||||||
|
*/
|
||||||
|
public boolean isConnected() {
|
||||||
|
return (getData() & 0x4) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set tripwire connection state
|
||||||
|
* @param connected - true if connected, false if not
|
||||||
|
*/
|
||||||
|
public void setConnected(boolean connected) {
|
||||||
|
int dat = getData() & (0x8 | 0x3);
|
||||||
|
if (connected) {
|
||||||
|
dat |= 0x4;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if hook is currently activated
|
||||||
|
* @return true if activated, false if not
|
||||||
|
*/
|
||||||
|
public boolean isActivated() {
|
||||||
|
return (getData() & 0x8) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set hook activated state
|
||||||
|
* @param act - true if activated, false if not
|
||||||
|
*/
|
||||||
|
public void setActivated(boolean act) {
|
||||||
|
int dat = getData() & (0x4 | 0x3);
|
||||||
|
if (act) {
|
||||||
|
dat |= 0x8;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFacingDirection(BlockFace face) {
|
||||||
|
int dat = getData() & 0xC;
|
||||||
|
switch (face) {
|
||||||
|
case EAST:
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
dat |= 0x1;
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
dat |= 0x2;
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
dat |= 0x3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFace getFacing() {
|
||||||
|
switch (getData() & 0x3) {
|
||||||
|
case 0:
|
||||||
|
return BlockFace.EAST;
|
||||||
|
case 1:
|
||||||
|
return BlockFace.SOUTH;
|
||||||
|
case 2:
|
||||||
|
return BlockFace.WEST;
|
||||||
|
case 3:
|
||||||
|
return BlockFace.NORTH;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPowered() {
|
||||||
|
return isActivated();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TripwireHook clone() {
|
||||||
|
return (TripwireHook) super.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " facing " + getFacing() + (isActivated()?" Activated":"") + (isConnected()?" Connected":"");
|
||||||
|
}
|
||||||
|
}
|
85
src/main/java/org/bukkit/material/WoodenStep.java
Normal file
85
src/main/java/org/bukkit/material/WoodenStep.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package org.bukkit.material;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.TreeSpecies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the different types of wooden steps.
|
||||||
|
*/
|
||||||
|
public class WoodenStep extends MaterialData {
|
||||||
|
|
||||||
|
public WoodenStep() {
|
||||||
|
super(Material.WOOD_STEP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WoodenStep(final int type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WoodenStep(TreeSpecies species) {
|
||||||
|
this();
|
||||||
|
setSpecies(species);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WoodenStep(TreeSpecies species, boolean inv) {
|
||||||
|
this();
|
||||||
|
setSpecies(species);
|
||||||
|
setInverted(inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WoodenStep(final int type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WoodenStep(final Material type, final byte data) {
|
||||||
|
super(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current species of this tree
|
||||||
|
*
|
||||||
|
* @return TreeSpecies of this tree
|
||||||
|
*/
|
||||||
|
public TreeSpecies getSpecies() {
|
||||||
|
return TreeSpecies.getByData((byte) (getData() & 0x3));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the species of this tree
|
||||||
|
*
|
||||||
|
* @param species New species of this tree
|
||||||
|
*/
|
||||||
|
public void setSpecies(TreeSpecies species) {
|
||||||
|
setData((byte) ((getData() & 0xC) | species.getData()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if step is inverted
|
||||||
|
* @return true if inverted (top half), false if normal (bottom half)
|
||||||
|
*/
|
||||||
|
public boolean isInverted() {
|
||||||
|
return ((getData() & 0x8) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set step inverted state
|
||||||
|
* @param inv - true if step is inverted (top half), false if step is normal (bottom half)
|
||||||
|
*/
|
||||||
|
public void setInverted(boolean inv) {
|
||||||
|
int dat = getData() & 0x7;
|
||||||
|
if (inv) {
|
||||||
|
dat |= 0x8;
|
||||||
|
}
|
||||||
|
setData((byte) dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WoodenStep clone() {
|
||||||
|
return (WoodenStep) super.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString() + " " + getSpecies() + (isInverted()?" inverted":"");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user