From c73a3c02f0885d0b21a23bd15ab62e19b88799ab Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Mon, 22 Oct 2012 03:30:04 -0500 Subject: [PATCH] Update Bukkit for Minecraft 1.4(.2) changes. By: Travis Watkins --- paper-api/pom.xml | 2 +- paper-api/src/main/java/org/bukkit/Art.java | 13 +- .../src/main/java/org/bukkit/Material.java | 61 ++++++--- .../command/defaults/TeleportCommand.java | 46 ++++++- .../command/defaults/VanillaCommand.java | 20 +++ .../main/java/org/bukkit/entity/Ambient.java | 6 + .../src/main/java/org/bukkit/entity/Bat.java | 6 + .../java/org/bukkit/entity/EntityType.java | 9 +- .../main/java/org/bukkit/entity/Hanging.java | 6 + .../java/org/bukkit/entity/ItemFrame.java | 6 + .../java/org/bukkit/entity/LargeFireball.java | 7 ++ .../main/java/org/bukkit/entity/Witch.java | 7 ++ .../main/java/org/bukkit/entity/Wither.java | 7 ++ .../java/org/bukkit/entity/WitherSkull.java | 8 ++ .../event/entity/CreatureSpawnEvent.java | 4 + .../event/entity/EntityDamageEvent.java | 4 + .../event/entity/EntityRegainHealthEvent.java | 8 ++ .../org/bukkit/inventory/AnvilInventory.java | 4 + .../org/bukkit/inventory/BeaconInventory.java | 14 +++ .../java/org/bukkit/material/Command.java | 59 +++++++++ .../java/org/bukkit/material/FlowerPot.java | 119 ++++++++++++++++++ .../main/java/org/bukkit/material/Skull.java | 92 ++++++++++++++ .../org/bukkit/potion/PotionEffectType.java | 12 +- 23 files changed, 486 insertions(+), 34 deletions(-) create mode 100644 paper-api/src/main/java/org/bukkit/entity/Ambient.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/Bat.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/Hanging.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/ItemFrame.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/LargeFireball.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/Witch.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/Wither.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/WitherSkull.java create mode 100644 paper-api/src/main/java/org/bukkit/inventory/AnvilInventory.java create mode 100644 paper-api/src/main/java/org/bukkit/inventory/BeaconInventory.java create mode 100644 paper-api/src/main/java/org/bukkit/material/Command.java create mode 100644 paper-api/src/main/java/org/bukkit/material/FlowerPot.java create mode 100644 paper-api/src/main/java/org/bukkit/material/Skull.java diff --git a/paper-api/pom.xml b/paper-api/pom.xml index 414074a4a6..9168c29e21 100644 --- a/paper-api/pom.xml +++ b/paper-api/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.bukkit bukkit - 1.3.2-R3.0 + 1.4.2-R0.1-SNAPSHOT Bukkit http://www.bukkit.org diff --git a/paper-api/src/main/java/org/bukkit/Art.java b/paper-api/src/main/java/org/bukkit/Art.java index 02ac898391..7f35d7e71c 100644 --- a/paper-api/src/main/java/org/bukkit/Art.java +++ b/paper-api/src/main/java/org/bukkit/Art.java @@ -29,12 +29,13 @@ public enum Art { STAGE(16, 2, 2), VOID(17, 2, 2), SKULL_AND_ROSES(18, 2, 2), - FIGHTERS(19, 4, 2), - POINTER(20, 4, 4), - PIGSCENE(21, 4, 4), - BURNINGSKULL(22, 4, 4), - SKELETON(23, 4, 3), - DONKEYKONG(24, 4, 3); + WITHER(19, 2, 2), + FIGHTERS(20, 4, 2), + POINTER(21, 4, 4), + PIGSCENE(22, 4, 4), + BURNINGSKULL(23, 4, 4), + SKELETON(24, 4, 3), + DONKEYKONG(25, 4, 3); private int id, width, height; private static final HashMap BY_NAME = Maps.newHashMap(); diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index 5ea0337976..102db215e7 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -143,6 +143,27 @@ public enum Material { DRAGON_EGG(122), REDSTONE_LAMP_OFF(123), REDSTONE_LAMP_ON(124), + WOOD_DOUBLE_STEP(125, WoodenStep.class), + WOOD_STEP(126, WoodenStep.class), + COCOA(127, CocoaPlant.class), + SANDSTONE_STAIRS(128, Stairs.class), + EMERALD_ORE(129), + ENDER_CHEST(130, EnderChest.class), + TRIPWIRE_HOOK(131, TripwireHook.class), + TRIPWIRE(132, Tripwire.class), + EMERALD_BLOCK(133), + SPRUCE_WOOD_STAIRS(134, Stairs.class), + BIRCH_WOOD_STAIRS(135, Stairs.class), + JUNGLE_WOOD_STAIRS(136, Stairs.class), + COMMAND(137, Command.class), + BEACON(138), + COBBLE_WALL(139), + FLOWER_POT(140, FlowerPot.class), + CARROT(141), + POTATO(142), + WOOD_BUTTON(143, Button.class), + SKULL(144, Skull.class), + ANVIL(145), // ----- Item Separator ----- IRON_SPADE(256, 1, 250), IRON_PICKAXE(257, 1, 250), @@ -249,7 +270,7 @@ public enum Material { /** * @see MapView */ - MAP(358, 1, MaterialData.class), + MAP(358, MaterialData.class), SHEARS(359, 1, 238), MELON(360), PUMPKIN_SEEDS(361), @@ -280,6 +301,21 @@ public enum Material { MONSTER_EGG(383, 64, SpawnEgg.class), EXP_BOTTLE(384, 64), FIREBALL(385, 64), + BOOK_AND_QUILL(386, 1), + WRITTEN_BOOK(387, 1), + EMERALD(388, 64), + ITEM_FRAME(389), + FLOWER_POT_ITEM(390), + CARROT_ITEM(391), + POTATO_ITEM(392), + BAKED_POTATO(393), + POISONOUS_POTATO(394), + EMPTY_MAP(395), + GOLDEN_CARROT(396), + SKULL_ITEM(397), + CARROT_STICK(398, 1, 25), + NETHER_STAR(399), + PUMPKIN_PIE(400), GOLD_RECORD(2256, 1), GREEN_RECORD(2257, 1), RECORD_3(2258, 1), @@ -291,22 +327,7 @@ public enum Material { RECORD_9(2264, 1), RECORD_10(2265, 1), RECORD_11(2266, 1), - WOOD_DOUBLE_STEP(125, WoodenStep.class), - WOOD_STEP(126, WoodenStep.class), - COCOA(127, CocoaPlant.class), - SANDSTONE_STAIRS(128, Stairs.class), - EMERALD_ORE(129), - ENDER_CHEST(130, EnderChest.class), - TRIPWIRE_HOOK(131, TripwireHook.class), - TRIPWIRE(132, Tripwire.class), - EMERALD_BLOCK(133), - SPRUCE_WOOD_STAIRS(134, Stairs.class), - BIRCH_WOOD_STAIRS(135, Stairs.class), - JUNGLE_WOOD_STAIRS(136, Stairs.class), - BOOK_AND_QUILL(386, 1), - WRITTEN_BOOK(387, 1), - EMERALD(388, 64); - + ; private final int id; private final Class data; @@ -423,6 +444,12 @@ public enum Material { */ public boolean isEdible() { return equals(Material.BREAD) + || equals(Material.CARROT_ITEM) + || equals(Material.BAKED_POTATO) + || equals(Material.POTATO_ITEM) + || equals(Material.POISONOUS_POTATO) + || equals(Material.GOLDEN_CARROT) + || equals(Material.PUMPKIN_PIE) || equals(Material.COOKIE) || equals(Material.MELON) || equals(Material.MUSHROOM_SOUP) diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java index 55be9da355..cbb42abe34 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java @@ -16,7 +16,7 @@ import com.google.common.collect.ImmutableList; public class TeleportCommand extends VanillaCommand { public TeleportCommand() { super("tp"); - this.description = "Teleports the given player to another player"; + this.description = "Teleports the given player to another player or location"; this.usageMessage = "/tp [player] \n/tp [player] "; this.setPermission("bukkit.command.teleport"); } @@ -56,9 +56,14 @@ public class TeleportCommand extends VanillaCommand { player.teleport(target, TeleportCause.COMMAND); Command.broadcastCommandMessage(sender, "Teleported " + player.getName() + " to " + target.getName()); } else if (player.getWorld() != null) { - int x = getInteger(sender, args[args.length - 3], -30000000, 30000000); - int y = getInteger(sender, args[args.length - 2], 0, 256); - int z = getInteger(sender, args[args.length - 1], -30000000, 30000000); + double x = getCoordinate(sender, player.getLocation().getX(), args[args.length - 3]); + double y = getCoordinate(sender,player.getLocation().getY(), args[args.length - 2], 0, 0); + double z = getCoordinate(sender, player.getLocation().getZ(), args[args.length - 1]); + + if (x == -30000001 || y == -30000001 || z == -30000001) { + sender.sendMessage("Please provide a valid location!"); + return true; + } Location location = new Location(player.getWorld(), x, y, z); player.teleport(location); @@ -67,6 +72,39 @@ public class TeleportCommand extends VanillaCommand { return true; } + private double getCoordinate(CommandSender sender, double current, String input) { + return getCoordinate(sender, current, input, -30000000, 30000000); + } + + private double getCoordinate(CommandSender sender, double current, String input, int min, int max) { + boolean relative = input.startsWith("~"); + double result = relative ? current : 0; + + if (!relative || input.length() > 1) { + boolean exact = input.contains("."); + if (relative) input = input.substring(1); + + double testResult = getDouble(sender, input); + if (testResult == -30000001) { + return -30000001; + } + result += testResult; + + if (!exact && !relative) result += 0.5f; + } + if (min != 0 || max != 0) { + if (result < min) { + result = -30000001; + } + + if (result > max) { + result = -30000001; + } + } + + return result; + } + @Override public boolean matches(String input) { return input.equalsIgnoreCase("tp"); diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/VanillaCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/VanillaCommand.java index 1fdcc81ee0..fc0edf9024 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/VanillaCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/VanillaCommand.java @@ -38,6 +38,26 @@ public abstract class VanillaCommand extends Command { return i; } + public static double getDouble(CommandSender sender, String input) { + try { + return Double.parseDouble(input); + } catch (NumberFormatException ex) { + return -30000001; + } + } + + public static double getDouble(CommandSender sender, String input, double min, double max) { + double result = getDouble(sender, input); + + if (result < min) { + result = min; + } else if (result > max) { + result = max; + } + + return result; + } + protected String createString(String[] args, int start) { StringBuilder string = new StringBuilder(); diff --git a/paper-api/src/main/java/org/bukkit/entity/Ambient.java b/paper-api/src/main/java/org/bukkit/entity/Ambient.java new file mode 100644 index 0000000000..779e38971a --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Ambient.java @@ -0,0 +1,6 @@ +package org.bukkit.entity; + +/** + * Represents an ambient mob + */ +public interface Ambient extends LivingEntity {} diff --git a/paper-api/src/main/java/org/bukkit/entity/Bat.java b/paper-api/src/main/java/org/bukkit/entity/Bat.java new file mode 100644 index 0000000000..a1e400e345 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Bat.java @@ -0,0 +1,6 @@ +package org.bukkit.entity; + +/** + * Represents a Bat + */ +public interface Bat extends Ambient {} diff --git a/paper-api/src/main/java/org/bukkit/entity/EntityType.java b/paper-api/src/main/java/org/bukkit/entity/EntityType.java index 7f1e08d571..4a5f0d0e24 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EntityType.java +++ b/paper-api/src/main/java/org/bukkit/entity/EntityType.java @@ -13,11 +13,13 @@ public enum EntityType { PAINTING("Painting", Painting.class, 9), ARROW("Arrow", Arrow.class, 10), SNOWBALL("Snowball", Snowball.class, 11), - FIREBALL("Fireball", Fireball.class, 12), + LARGE_FIREBALL("Fireball", LargeFireball.class, 12), SMALL_FIREBALL("SmallFireball", SmallFireball.class, 13), ENDER_PEARL("ThrownEnderpearl", EnderPearl.class, 14), ENDER_SIGNAL("EyeOfEnderSignal", EnderSignal.class, 15), THROWN_EXP_BOTTLE("ThrownExpBottle", ThrownExpBottle.class, 17), + ITEM_FRAME("ItemFrame", ItemFrame.class, 18), + WITHER_SKULL("WitherSkull", WitherSkull.class, 19), PRIMED_TNT("PrimedTnt", TNTPrimed.class, 20), FALLING_BLOCK("FallingSand", FallingBlock.class, 21, false), MINECART("Minecart", Minecart.class, 40), @@ -36,6 +38,9 @@ public enum EntityType { BLAZE("Blaze", Blaze.class, 61), MAGMA_CUBE("LavaSlime", MagmaCube.class, 62), ENDER_DRAGON("EnderDragon", EnderDragon.class, 63), + WITHER("WitherBoss", Wither.class, 64), + BAT("Bat", Bat.class, 65), + WITCH("Witch", Witch.class, 66), PIG("Pig", Pig.class, 90), SHEEP("Sheep", Sheep.class, 91), COW("Cow", Cow.class, 92), @@ -136,4 +141,4 @@ public enum EntityType { public boolean isAlive() { return living; } -} \ No newline at end of file +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Hanging.java b/paper-api/src/main/java/org/bukkit/entity/Hanging.java new file mode 100644 index 0000000000..46548ec0f1 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Hanging.java @@ -0,0 +1,6 @@ +package org.bukkit.entity; + +/** + * Represents a Hanging entity + */ +public interface Hanging extends Entity {} diff --git a/paper-api/src/main/java/org/bukkit/entity/ItemFrame.java b/paper-api/src/main/java/org/bukkit/entity/ItemFrame.java new file mode 100644 index 0000000000..769cfd2f5e --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/ItemFrame.java @@ -0,0 +1,6 @@ +package org.bukkit.entity; + +/** + * Represents an Item Frame + */ +public interface ItemFrame extends Hanging {} diff --git a/paper-api/src/main/java/org/bukkit/entity/LargeFireball.java b/paper-api/src/main/java/org/bukkit/entity/LargeFireball.java new file mode 100644 index 0000000000..fc3a1093cc --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/LargeFireball.java @@ -0,0 +1,7 @@ +package org.bukkit.entity; + +/** + * Represents a large {@link Fireball} + */ +public interface LargeFireball extends Fireball { +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Witch.java b/paper-api/src/main/java/org/bukkit/entity/Witch.java new file mode 100644 index 0000000000..9c5dc1f97b --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Witch.java @@ -0,0 +1,7 @@ +package org.bukkit.entity; + +/** + * Represents a Witch + */ +public interface Witch extends Monster { +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Wither.java b/paper-api/src/main/java/org/bukkit/entity/Wither.java new file mode 100644 index 0000000000..0922c5c6a2 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/Wither.java @@ -0,0 +1,7 @@ +package org.bukkit.entity; + +/** + * Represents a Wither boss + */ +public interface Wither extends Monster { +} diff --git a/paper-api/src/main/java/org/bukkit/entity/WitherSkull.java b/paper-api/src/main/java/org/bukkit/entity/WitherSkull.java new file mode 100644 index 0000000000..8c71a9b9c2 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/WitherSkull.java @@ -0,0 +1,8 @@ +package org.bukkit.entity; + +/** + * Represents a wither skull {@link Fireball} + */ +public interface WitherSkull extends Fireball { + +} diff --git a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java index ce6797a775..c674629409 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java @@ -127,6 +127,10 @@ public class CreatureSpawnEvent extends EntityEvent implements Cancellable { * When an iron golem is spawned by being built */ BUILD_IRONGOLEM, + /** + * When a wither boss is spawned by being built + */ + BUILD_WITHER, /** * When an iron golem is spawned to defend a village */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java index f059b407ad..5238cd58ee 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -176,6 +176,10 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * Damage: variable */ MAGIC, + /** + * + */ + WITHER, /** * Custom damage. *

diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java index fceabee070..2d4c927b3a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java @@ -92,6 +92,14 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable * When a player is healed over time by a potion or spell */ MAGIC_REGEN, + /** + * When a wither is filling its health during spawning + */ + WITHER_SPAWN, + /** + * When an entity is damaged by the Wither potion effect + */ + WITHER, /** * Any other reason not covered by the reasons above */ diff --git a/paper-api/src/main/java/org/bukkit/inventory/AnvilInventory.java b/paper-api/src/main/java/org/bukkit/inventory/AnvilInventory.java new file mode 100644 index 0000000000..52c89647d6 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/AnvilInventory.java @@ -0,0 +1,4 @@ +package org.bukkit.inventory; + +public interface AnvilInventory extends Inventory { +} diff --git a/paper-api/src/main/java/org/bukkit/inventory/BeaconInventory.java b/paper-api/src/main/java/org/bukkit/inventory/BeaconInventory.java new file mode 100644 index 0000000000..342a8be9e3 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/inventory/BeaconInventory.java @@ -0,0 +1,14 @@ +package org.bukkit.inventory; + +public interface BeaconInventory extends Inventory { + /** + * Set the item powering the beacon. + * @param item The new item + */ + void setItem(ItemStack item); + /** + * Get the item powering the beacon. + * @return The current item. + */ + ItemStack getItem(); +} diff --git a/paper-api/src/main/java/org/bukkit/material/Command.java b/paper-api/src/main/java/org/bukkit/material/Command.java new file mode 100644 index 0000000000..01d0ac7ffd --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Command.java @@ -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(); + } +} diff --git a/paper-api/src/main/java/org/bukkit/material/FlowerPot.java b/paper-api/src/main/java/org/bukkit/material/FlowerPot.java new file mode 100644 index 0000000000..c59891adac --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/FlowerPot.java @@ -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(); + } +} diff --git a/paper-api/src/main/java/org/bukkit/material/Skull.java b/paper-api/src/main/java/org/bukkit/material/Skull.java new file mode 100644 index 0000000000..77130fb9ff --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Skull.java @@ -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(); + } +} diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java index 59e0ac36da..c478844f75 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java @@ -75,7 +75,7 @@ public abstract class PotionEffectType { public static final PotionEffectType WATER_BREATHING = new PotionEffectTypeWrapper(13); /** - * Grants invisibility. NOTE: Unusable due to not being implemented by Minecraft. + * Grants invisibility. */ @Deprecated public static final PotionEffectType INVISIBILITY = new PotionEffectTypeWrapper(14); // unimplemented @@ -86,8 +86,7 @@ public abstract class PotionEffectType { public static final PotionEffectType BLINDNESS = new PotionEffectTypeWrapper(15); /** - * Allows an entity to see in the dark. NOTE: Unusable due to not being - * implemented by Minecraft. + * Allows an entity to see in the dark. */ @Deprecated public static final PotionEffectType NIGHT_VISION = new PotionEffectTypeWrapper(16); // unimplemented @@ -107,6 +106,11 @@ public abstract class PotionEffectType { */ public static final PotionEffectType POISON = new PotionEffectTypeWrapper(19); + /** + * Deals damage to an entity over time and gives the health to the shooter. + */ + public static final PotionEffectType WITHER = new PotionEffectTypeWrapper(20); + private final int id; protected PotionEffectType(int id) { @@ -172,7 +176,7 @@ public abstract class PotionEffectType { return "PotionEffectType[" + id + ", " + getName() + "]"; } - private static final PotionEffectType[] byId = new PotionEffectType[20]; + private static final PotionEffectType[] byId = new PotionEffectType[21]; private static final Map byName = new HashMap(); // will break on updates. private static boolean acceptingNew = true;