diff --git a/nms-patches/EntityFireballFireball.patch b/nms-patches/EntityFireballFireball.patch index 652a80b547..8a253b5663 100644 --- a/nms-patches/EntityFireballFireball.patch +++ b/nms-patches/EntityFireballFireball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityFireballFireball.java +++ b/net/minecraft/server/EntityFireballFireball.java -@@ -18,7 +18,7 @@ +@@ -18,14 +18,14 @@ public void b(ItemStack itemstack) { if (itemstack.getItem() != Items.FIRE_CHARGE || itemstack.hasTag()) { @@ -9,6 +9,14 @@ itemstack1.setCount(1); })); } + + } + +- protected ItemStack l() { ++ public ItemStack l() { // PAIL protected -> public + return (ItemStack) this.getDataWatcher().get(EntityFireballFireball.f); + } + @@ -50,6 +50,6 @@ super.a(nbttagcompound); ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("Item")); diff --git a/nms-patches/EntityProjectileThrowable.patch b/nms-patches/EntityProjectileThrowable.patch index 746440e7b0..73c0fe5551 100644 --- a/nms-patches/EntityProjectileThrowable.patch +++ b/nms-patches/EntityProjectileThrowable.patch @@ -11,3 +11,18 @@ })); } +@@ -27,7 +27,13 @@ + + protected abstract Item i(); + +- protected ItemStack getItem() { ++ // CraftBukkit start ++ public Item getDefaultItem() { ++ return i(); ++ } ++ // CraftBukkit end ++ ++ public ItemStack getItem() { // PAIL protected -> public + return (ItemStack) this.getDataWatcher().get(EntityProjectileThrowable.e); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java index 1d0f430381..f9db955154 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Egg; import org.bukkit.entity.EntityType; -public class CraftEgg extends CraftProjectile implements Egg { +public class CraftEgg extends CraftThrowableProjectile implements Egg { public CraftEgg(CraftServer server, EntityEgg entity) { super(server, entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java index 32221ead38..7fdefcc928 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.EntityType; -public class CraftEnderPearl extends CraftProjectile implements EnderPearl { +public class CraftEnderPearl extends CraftThrowableProjectile implements EnderPearl { public CraftEnderPearl(CraftServer server, EntityEnderPearl entity) { super(server, entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java index 9ab8f6606d..7ff0ad2624 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.LargeFireball; -public class CraftLargeFireball extends CraftFireball implements LargeFireball { +public class CraftLargeFireball extends CraftSizedFireball implements LargeFireball { public CraftLargeFireball(CraftServer server, EntityLargeFireball entity) { super(server, entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java new file mode 100644 index 0000000000..f5db1ed38e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java @@ -0,0 +1,34 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityFireballFireball; +import org.bukkit.Material; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.entity.SizedFireball; +import org.bukkit.inventory.ItemStack; + +public class CraftSizedFireball extends CraftFireball implements SizedFireball { + + public CraftSizedFireball(CraftServer server, EntityFireballFireball entity) { + super(server, entity); + } + + @Override + public ItemStack getDisplayItem() { + if (getHandle().l().isEmpty()) { // PAIL rename getItem + return new ItemStack(Material.FIRE_CHARGE); + } else { + return CraftItemStack.asBukkitCopy(getHandle().l()); // PAIL rename getItem + } + } + + @Override + public void setDisplayItem(ItemStack item) { + getHandle().b(CraftItemStack.asNMSCopy(item)); // PAIL rename setItem + } + + @Override + public EntityFireballFireball getHandle() { + return (EntityFireballFireball) entity; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java index 02fac8b4a6..bd60de99f9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.SmallFireball; -public class CraftSmallFireball extends CraftFireball implements SmallFireball { +public class CraftSmallFireball extends CraftSizedFireball implements SmallFireball { public CraftSmallFireball(CraftServer server, EntitySmallFireball entity) { super(server, entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java index 222977d79f..186ebc9705 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Snowball; -public class CraftSnowball extends CraftProjectile implements Snowball { +public class CraftSnowball extends CraftThrowableProjectile implements Snowball { public CraftSnowball(CraftServer server, EntitySnowball entity) { super(server, entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java new file mode 100644 index 0000000000..4a6fce47be --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java @@ -0,0 +1,33 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityProjectileThrowable; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.entity.ThrowableProjectile; +import org.bukkit.inventory.ItemStack; + +public abstract class CraftThrowableProjectile extends CraftProjectile implements ThrowableProjectile { + + public CraftThrowableProjectile(CraftServer server, EntityProjectileThrowable entity) { + super(server, entity); + } + + @Override + public ItemStack getItem() { + if (getHandle().getItem().isEmpty()) { + return CraftItemStack.asBukkitCopy(new net.minecraft.server.ItemStack(getHandle().getDefaultItem())); + } else { + return CraftItemStack.asBukkitCopy(getHandle().getItem()); + } + } + + @Override + public void setItem(ItemStack item) { + getHandle().setItem(CraftItemStack.asNMSCopy(item)); + } + + @Override + public EntityProjectileThrowable getHandle() { + return (EntityProjectileThrowable) entity; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java index 338bc530c4..fc649413a4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.ThrownExpBottle; -public class CraftThrownExpBottle extends CraftProjectile implements ThrownExpBottle { +public class CraftThrownExpBottle extends CraftThrowableProjectile implements ThrownExpBottle { public CraftThrownExpBottle(CraftServer server, EntityThrownExpBottle entity) { super(server, entity); }