Update CraftBukkit to 1.6.1
By: Nate Mortensen <nate.richard.mortensen@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import net.minecraft.server.EntityEnderDragon;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.ComplexEntityPart;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderDragon {
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.EnderDragonPart;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
|
||||
public class CraftEnderDragonPart extends CraftComplexPart implements EnderDragonPart {
|
||||
public CraftEnderDragonPart(CraftServer server, EntityComplexPart entity) {
|
||||
@@ -26,31 +27,61 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago
|
||||
return "CraftEnderDragonPart";
|
||||
}
|
||||
|
||||
public void damage(int amount) {
|
||||
public void damage(double amount) {
|
||||
getParent().damage(amount);
|
||||
}
|
||||
|
||||
public void damage(int amount, Entity source) {
|
||||
public void damage(double amount, Entity source) {
|
||||
getParent().damage(amount, source);
|
||||
}
|
||||
|
||||
public int getHealth() {
|
||||
public double getHealth() {
|
||||
return getParent().getHealth();
|
||||
}
|
||||
|
||||
public void setHealth(int health) {
|
||||
public void setHealth(double health) {
|
||||
getParent().setHealth(health);
|
||||
}
|
||||
|
||||
public int getMaxHealth() {
|
||||
public double getMaxHealth() {
|
||||
return getParent().getMaxHealth();
|
||||
}
|
||||
|
||||
public void setMaxHealth(int health) {
|
||||
public void setMaxHealth(double health) {
|
||||
getParent().setMaxHealth(health);
|
||||
}
|
||||
|
||||
public void resetMaxHealth() {
|
||||
getParent().resetMaxHealth();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_damage(int amount) {
|
||||
damage(amount);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_damage(int amount, Entity source) {
|
||||
damage(amount, source);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int _INVALID_getHealth() {
|
||||
return NumberConversions.ceil(getHealth());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_setHealth(int health) {
|
||||
setHealth(health);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int _INVALID_getMaxHealth() {
|
||||
return NumberConversions.ceil(getMaxHealth());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_setMaxHealth(int health) {
|
||||
setMaxHealth(health);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityAnimal;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
|
||||
public class CraftHorse extends CraftAnimals implements Horse {
|
||||
|
||||
public CraftHorse(CraftServer server, EntityAnimal entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftHorse";
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return EntityType.HORSE;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getHandle().name;
|
||||
return getHandle().getName();
|
||||
}
|
||||
|
||||
public PlayerInventory getInventory() {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CraftIronGolem extends CraftGolem implements IronGolem {
|
||||
}
|
||||
|
||||
public boolean isPlayerCreated() {
|
||||
return getHandle().p();
|
||||
return getHandle().bS();
|
||||
}
|
||||
|
||||
public void setPlayerCreated(boolean playerCreated) {
|
||||
|
||||
@@ -25,11 +25,11 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
|
||||
}
|
||||
|
||||
public org.bukkit.inventory.ItemStack getItem() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().i());
|
||||
return CraftItemStack.asBukkitCopy(getHandle().h());
|
||||
}
|
||||
|
||||
public Rotation getRotation() {
|
||||
return toBukkitRotation(getHandle().j());
|
||||
return toBukkitRotation(getHandle().i());
|
||||
}
|
||||
|
||||
Rotation toBukkitRotation(int value) {
|
||||
@@ -44,7 +44,7 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
|
||||
case 3:
|
||||
return Rotation.COUNTER_CLOCKWISE;
|
||||
default:
|
||||
throw new AssertionError("Unknown rotation " + getHandle().j() + " for " + getHandle());
|
||||
throw new AssertionError("Unknown rotation " + getHandle().i() + " for " + getHandle());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.server.EntityArrow;
|
||||
import net.minecraft.server.EntityEgg;
|
||||
import net.minecraft.server.EntityEnderDragon;
|
||||
import net.minecraft.server.EntityEnderPearl;
|
||||
import net.minecraft.server.EntityInsentient;
|
||||
import net.minecraft.server.EntityLargeFireball;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import net.minecraft.server.EntitySmallFireball;
|
||||
@@ -51,6 +52,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
@@ -59,16 +61,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
public CraftLivingEntity(final CraftServer server, final EntityLiving entity) {
|
||||
super(server, entity);
|
||||
|
||||
if (!(this instanceof HumanEntity)) {
|
||||
if (entity instanceof EntityInsentient) {
|
||||
equipment = new CraftEntityEquipment(this);
|
||||
}
|
||||
}
|
||||
|
||||
public int getHealth() {
|
||||
public double getHealth() {
|
||||
return Math.min(Math.max(0, getHandle().getHealth()), getMaxHealth());
|
||||
}
|
||||
|
||||
public void setHealth(int health) {
|
||||
public void setHealth(double health) {
|
||||
if ((health < 0) || (health > getMaxHealth())) {
|
||||
throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
|
||||
}
|
||||
@@ -77,17 +79,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
((EntityPlayer) entity).die(DamageSource.GENERIC);
|
||||
}
|
||||
|
||||
getHandle().setHealth(health);
|
||||
getHandle().setHealth((float) health);
|
||||
}
|
||||
|
||||
public int getMaxHealth() {
|
||||
public double getMaxHealth() {
|
||||
return getHandle().maxHealth;
|
||||
}
|
||||
|
||||
public void setMaxHealth(int amount) {
|
||||
public void setMaxHealth(double amount) {
|
||||
Validate.isTrue(amount > 0, "Max health must be greater than 0");
|
||||
|
||||
getHandle().maxHealth = amount;
|
||||
getHandle().maxHealth = (float) amount;
|
||||
|
||||
if (getHealth() > amount) {
|
||||
setHealth(amount);
|
||||
@@ -176,11 +178,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
getHandle().maxAirTicks = ticks;
|
||||
}
|
||||
|
||||
public void damage(int amount) {
|
||||
public void damage(double amount) {
|
||||
damage(amount, null);
|
||||
}
|
||||
|
||||
public void damage(int amount, org.bukkit.entity.Entity source) {
|
||||
public void damage(double amount, org.bukkit.entity.Entity source) {
|
||||
DamageSource reason = DamageSource.GENERIC;
|
||||
|
||||
if (source instanceof HumanEntity) {
|
||||
@@ -190,9 +192,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
if (entity instanceof EntityEnderDragon) {
|
||||
((EntityEnderDragon) entity).dealDamage(reason, amount);
|
||||
((EntityEnderDragon) entity).dealDamage(reason, (float) amount);
|
||||
} else {
|
||||
entity.damageEntity(reason, amount);
|
||||
entity.damageEntity(reason, (float) amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,12 +212,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
getHandle().maxNoDamageTicks = ticks;
|
||||
}
|
||||
|
||||
public int getLastDamage() {
|
||||
public double getLastDamage() {
|
||||
return getHandle().lastDamage;
|
||||
}
|
||||
|
||||
public void setLastDamage(int damage) {
|
||||
getHandle().lastDamage = damage;
|
||||
public void setLastDamage(double damage) {
|
||||
getHandle().lastDamage = (float) damage;
|
||||
}
|
||||
|
||||
public int getNoDamageTicks() {
|
||||
@@ -332,15 +334,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public boolean hasLineOfSight(Entity other) {
|
||||
return getHandle().getEntitySenses().canSee(((CraftEntity) other).getHandle());
|
||||
return getHandle() instanceof EntityInsentient && ((EntityInsentient) getHandle()).getEntitySenses().canSee(((CraftEntity) other).getHandle());
|
||||
}
|
||||
|
||||
public boolean getRemoveWhenFarAway() {
|
||||
return !getHandle().persistent;
|
||||
return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).persistent;
|
||||
}
|
||||
|
||||
public void setRemoveWhenFarAway(boolean remove) {
|
||||
getHandle().persistent = !remove;
|
||||
if (getHandle() instanceof EntityInsentient) {
|
||||
((EntityInsentient) getHandle()).persistent = !remove;
|
||||
}
|
||||
}
|
||||
|
||||
public EntityEquipment getEquipment() {
|
||||
@@ -348,11 +352,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public void setCanPickupItems(boolean pickup) {
|
||||
getHandle().canPickUpLoot = pickup;
|
||||
if (getHandle() instanceof EntityInsentient) {
|
||||
((EntityInsentient) getHandle()).canPickUpLoot = pickup;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getCanPickupItems() {
|
||||
return getHandle().canPickUpLoot;
|
||||
return getHandle() instanceof EntityInsentient && ((EntityInsentient) getHandle()).canPickUpLoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -365,6 +371,10 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public void setCustomName(String name) {
|
||||
if (!(getHandle() instanceof EntityInsentient)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
name = "";
|
||||
}
|
||||
@@ -374,11 +384,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
name = name.substring(0, 64);
|
||||
}
|
||||
|
||||
getHandle().setCustomName(name);
|
||||
((EntityInsentient) getHandle()).setCustomName(name);
|
||||
}
|
||||
|
||||
public String getCustomName() {
|
||||
String name = getHandle().getCustomName();
|
||||
if (!(getHandle() instanceof EntityInsentient)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String name = ((EntityInsentient) getHandle()).getCustomName();
|
||||
|
||||
if (name == null || name.length() == 0) {
|
||||
return null;
|
||||
@@ -388,10 +402,52 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean flag) {
|
||||
getHandle().setCustomNameVisible(flag);
|
||||
if (getHandle() instanceof EntityInsentient) {
|
||||
((EntityInsentient) getHandle()).setCustomNameVisible(flag);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible() {
|
||||
return getHandle().getCustomNameVisible();
|
||||
return getHandle() instanceof EntityInsentient && ((EntityInsentient) getHandle()).getCustomNameVisible();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int _INVALID_getLastDamage() {
|
||||
return NumberConversions.ceil(getLastDamage());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_setLastDamage(int damage) {
|
||||
setLastDamage(damage);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_damage(int amount) {
|
||||
damage(amount);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_damage(int amount, Entity source) {
|
||||
damage(amount, source);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int _INVALID_getHealth() {
|
||||
return NumberConversions.ceil(getHealth());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_setHealth(int health) {
|
||||
setHealth(health);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int _INVALID_getMaxHealth() {
|
||||
return NumberConversions.ceil(getMaxHealth());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_setMaxHealth(int health) {
|
||||
setMaxHealth(health);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.server.EntityMinecartAbstract;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
||||
@@ -11,11 +12,11 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
public void setDamage(int damage) {
|
||||
getHandle().setDamage(damage);
|
||||
public void setDamage(double damage) {
|
||||
getHandle().setDamage((float) damage);
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
public double getDamage() {
|
||||
return getHandle().getDamage();
|
||||
}
|
||||
|
||||
@@ -57,4 +58,14 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
||||
public EntityMinecartAbstract getHandle() {
|
||||
return (EntityMinecartAbstract) entity;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void _INVALID_setDamage(int damage) {
|
||||
setDamage(damage);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int _INVALID_getDamage() {
|
||||
return NumberConversions.ceil(getDamage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public boolean isOnline() {
|
||||
for (Object obj : server.getHandle().players) {
|
||||
EntityPlayer player = (EntityPlayer) obj;
|
||||
if (player.name.equalsIgnoreCase(getName())) {
|
||||
if (player.getName().equalsIgnoreCase(getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void sendRawMessage(String message) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
getHandle().playerConnection.sendPacket(new Packet3Chat(message));
|
||||
getHandle().playerConnection.sendPacket(new Packet3Chat(ChatMessage.d(message)));
|
||||
}
|
||||
|
||||
public void sendMessage(String message) {
|
||||
@@ -859,10 +859,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
server.getPlayerMetadata().setMetadata(this, metadataKey, newMetadataValue);
|
||||
}
|
||||
@@ -967,11 +969,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxHealth(int amount) {
|
||||
@Override
|
||||
public void setMaxHealth(double amount) {
|
||||
super.setMaxHealth(amount);
|
||||
getHandle().triggerHealthUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetMaxHealth() {
|
||||
super.resetMaxHealth();
|
||||
getHandle().triggerHealthUpdate();
|
||||
|
||||
Reference in New Issue
Block a user