mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 03:35:51 -07:00
Update Bukkit for Minecraft 1.4(.2) changes.
By: Travis Watkins <amaranth@ubuntu.com>
This commit is contained in:
59
paper-api/src/main/java/org/bukkit/material/Command.java
Normal file
59
paper-api/src/main/java/org/bukkit/material/Command.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Represents a command block
|
||||
*/
|
||||
public class Command extends MaterialData implements Redstone {
|
||||
public Command() {
|
||||
super(Material.COMMAND);
|
||||
}
|
||||
|
||||
public Command(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Command(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Command(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Command(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current state of this Material, indicating if it's powered or
|
||||
* unpowered
|
||||
*
|
||||
* @return true if powered, otherwise false
|
||||
*/
|
||||
public boolean isPowered() {
|
||||
return (getData() & 1) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current state of this Material
|
||||
*
|
||||
* @param bool
|
||||
* whether or not the command block is powered
|
||||
*/
|
||||
public void setPowered(boolean bool) {
|
||||
setData((byte) (bool ? (getData() | 1) : (getData() & -2)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " " + (isPowered() ? "" : "NOT ") + "POWERED";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Command clone() {
|
||||
return (Command) super.clone();
|
||||
}
|
||||
}
|
119
paper-api/src/main/java/org/bukkit/material/FlowerPot.java
Normal file
119
paper-api/src/main/java/org/bukkit/material/FlowerPot.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.GrassSpecies;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
|
||||
/**
|
||||
* Represents a flower pot.
|
||||
*/
|
||||
public class FlowerPot extends MaterialData {
|
||||
|
||||
/**
|
||||
* Default constructor for a flower pot.
|
||||
*/
|
||||
public FlowerPot() {
|
||||
super(Material.FLOWER_POT);
|
||||
}
|
||||
|
||||
public FlowerPot(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public FlowerPot(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public FlowerPot(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public FlowerPot(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the material in the flower pot
|
||||
*
|
||||
* @return material MaterialData for the block currently in the flower pot or null if empty
|
||||
*/
|
||||
public MaterialData getContents() {
|
||||
switch (getData()) {
|
||||
case 1:
|
||||
return new MaterialData(Material.RED_ROSE);
|
||||
case 2:
|
||||
return new MaterialData(Material.YELLOW_FLOWER);
|
||||
case 3:
|
||||
return new Tree(TreeSpecies.GENERIC);
|
||||
case 4:
|
||||
return new Tree(TreeSpecies.REDWOOD);
|
||||
case 5:
|
||||
return new Tree(TreeSpecies.BIRCH);
|
||||
case 6:
|
||||
return new Tree(TreeSpecies.JUNGLE);
|
||||
case 7:
|
||||
return new MaterialData(Material.RED_MUSHROOM);
|
||||
case 8:
|
||||
return new MaterialData(Material.BROWN_MUSHROOM);
|
||||
case 9:
|
||||
return new MaterialData(Material.CACTUS);
|
||||
case 10:
|
||||
return new MaterialData(Material.DEAD_BUSH);
|
||||
case 11:
|
||||
return new LongGrass(GrassSpecies.FERN_LIKE);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the contents of the flower pot
|
||||
*
|
||||
* @param materialData MaterialData of the block to put in the flower pot.
|
||||
*/
|
||||
public void setContents(MaterialData materialData) {
|
||||
Material mat = materialData.getItemType();
|
||||
|
||||
if (mat == Material.RED_ROSE) {
|
||||
setData((byte) 1);
|
||||
} else if (mat == Material.YELLOW_FLOWER) {
|
||||
setData((byte) 2);
|
||||
} else if (mat == Material.RED_MUSHROOM) {
|
||||
setData((byte) 7);
|
||||
} else if (mat == Material.BROWN_MUSHROOM) {
|
||||
setData((byte) 8);
|
||||
} else if (mat == Material.CACTUS) {
|
||||
setData((byte) 9);
|
||||
} else if (mat == Material.DEAD_BUSH) {
|
||||
setData((byte) 10);
|
||||
} else if (mat == Material.SAPLING) {
|
||||
TreeSpecies species = ((Tree) materialData).getSpecies();
|
||||
|
||||
if (species == TreeSpecies.GENERIC) {
|
||||
setData((byte) 3);
|
||||
} else if (species == TreeSpecies.REDWOOD) {
|
||||
setData((byte) 4);
|
||||
} else if (species == TreeSpecies.BIRCH) {
|
||||
setData((byte) 5);
|
||||
} else {
|
||||
setData((byte) 6);
|
||||
}
|
||||
} else if (mat == Material.LONG_GRASS) {
|
||||
GrassSpecies species = ((LongGrass) materialData).getSpecies();
|
||||
|
||||
if (species == GrassSpecies.FERN_LIKE) {
|
||||
setData((byte) 11);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " containing " + getContents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowerPot clone() {
|
||||
return (FlowerPot) super.clone();
|
||||
}
|
||||
}
|
92
paper-api/src/main/java/org/bukkit/material/Skull.java
Normal file
92
paper-api/src/main/java/org/bukkit/material/Skull.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package org.bukkit.material;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
/**
|
||||
* Represents a skull.
|
||||
*/
|
||||
public class Skull extends MaterialData implements Directional {
|
||||
public Skull() {
|
||||
super(Material.SKULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a skull facing in a particular direction.
|
||||
*
|
||||
* @param direction the direction the skull's face is facing
|
||||
*/
|
||||
public Skull(BlockFace direction) {
|
||||
this();
|
||||
setFacingDirection(direction);
|
||||
}
|
||||
|
||||
public Skull(final int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Skull(final Material type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Skull(final int type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Skull(final Material type, final byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public void setFacingDirection(BlockFace face) {
|
||||
int data;
|
||||
|
||||
switch (face) {
|
||||
case EAST:
|
||||
data = 0x1;
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
data = 0x2;
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
data = 0x3;
|
||||
break;
|
||||
|
||||
case NORTH:
|
||||
default:
|
||||
data = 0x4;
|
||||
}
|
||||
|
||||
setData((byte) (data & 3));
|
||||
}
|
||||
|
||||
public BlockFace getFacing() {
|
||||
int data = getData() & 7;
|
||||
|
||||
switch (data) {
|
||||
case 0x1:
|
||||
return BlockFace.EAST;
|
||||
|
||||
case 0x2:
|
||||
return BlockFace.SOUTH;
|
||||
|
||||
case 0x3:
|
||||
return BlockFace.WEST;
|
||||
|
||||
case 0x4:
|
||||
default:
|
||||
return BlockFace.SOUTH;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " facing " + getFacing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Skull clone() {
|
||||
return (Skull) super.clone();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user