Update Bukkit for Minecraft 1.4(.2) changes.

By: Travis Watkins <amaranth@ubuntu.com>
This commit is contained in:
Bukkit/Spigot 2012-10-22 03:30:04 -05:00
parent 93362adea2
commit c73a3c02f0
23 changed files with 486 additions and 34 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.3.2-R3.0</version>
<version>1.4.2-R0.1-SNAPSHOT</version>
<name>Bukkit</name>
<url>http://www.bukkit.org</url>

View File

@ -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<String, Art> BY_NAME = Maps.newHashMap();

View File

@ -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<? extends MaterialData> 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)

View File

@ -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] <target>\n/tp [player] <x> <y> <z>";
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");

View File

@ -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();

View File

@ -0,0 +1,6 @@
package org.bukkit.entity;
/**
* Represents an ambient mob
*/
public interface Ambient extends LivingEntity {}

View File

@ -0,0 +1,6 @@
package org.bukkit.entity;
/**
* Represents a Bat
*/
public interface Bat extends Ambient {}

View File

@ -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;
}
}
}

View File

@ -0,0 +1,6 @@
package org.bukkit.entity;
/**
* Represents a Hanging entity
*/
public interface Hanging extends Entity {}

View File

@ -0,0 +1,6 @@
package org.bukkit.entity;
/**
* Represents an Item Frame
*/
public interface ItemFrame extends Hanging {}

View File

@ -0,0 +1,7 @@
package org.bukkit.entity;
/**
* Represents a large {@link Fireball}
*/
public interface LargeFireball extends Fireball {
}

View File

@ -0,0 +1,7 @@
package org.bukkit.entity;
/**
* Represents a Witch
*/
public interface Witch extends Monster {
}

View File

@ -0,0 +1,7 @@
package org.bukkit.entity;
/**
* Represents a Wither boss
*/
public interface Wither extends Monster {
}

View File

@ -0,0 +1,8 @@
package org.bukkit.entity;
/**
* Represents a wither skull {@link Fireball}
*/
public interface WitherSkull extends Fireball {
}

View File

@ -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
*/

View File

@ -176,6 +176,10 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
* Damage: variable
*/
MAGIC,
/**
*
*/
WITHER,
/**
* Custom damage.
* <p />

View File

@ -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
*/

View File

@ -0,0 +1,4 @@
package org.bukkit.inventory;
public interface AnvilInventory extends Inventory {
}

View File

@ -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();
}

View 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();
}
}

View 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();
}
}

View 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();
}
}

View File

@ -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<String, PotionEffectType> byName = new HashMap<String, PotionEffectType>();
// will break on updates.
private static boolean acceptingNew = true;