From 62c6d223e4d8197eb578c4969d4dba5b30661cfd Mon Sep 17 00:00:00 2001 From: Carlos Cobo Date: Sat, 23 Mar 2013 15:28:23 +0100 Subject: [PATCH] Include ThrownPotion in spawn methods. Adds BUKKIT-2542 --- src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 2 ++ .../org/bukkit/craftbukkit/entity/CraftLivingEntity.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index adb2bba3ba..41cb825e42 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -848,6 +848,8 @@ public class CraftWorld implements World { } else if (ThrownExpBottle.class.isAssignableFrom(clazz)) { entity = new EntityThrownExpBottle(world); entity.setPositionRotation(x, y, z, 0, 0); + } else if (ThrownPotion.class.isAssignableFrom(clazz)) { + entity = new EntityPotion(world, x, y, z, CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.POTION, 1))); } else if (Fireball.class.isAssignableFrom(clazz)) { if (SmallFireball.class.isAssignableFrom(clazz)) { entity = new EntitySmallFireball(world); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 7a7fd39134..58c7db0902 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -16,6 +16,7 @@ import net.minecraft.server.EntityLiving; import net.minecraft.server.EntitySmallFireball; import net.minecraft.server.EntitySnowball; import net.minecraft.server.EntityPlayer; +import net.minecraft.server.EntityPotion; import net.minecraft.server.EntityWitherSkull; import net.minecraft.server.MobEffect; import net.minecraft.server.MobEffectList; @@ -24,10 +25,12 @@ import net.minecraft.server.Packet42RemoveMobEffect; import org.apache.commons.lang.Validate; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.inventory.CraftEntityEquipment; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.Arrow; import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; @@ -40,9 +43,11 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.SmallFireball; import org.bukkit.entity.Snowball; +import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.WitherSkull; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.BlockIterator; @@ -299,6 +304,8 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { launch = new EntityEnderPearl(world, getHandle()); } else if (Arrow.class.isAssignableFrom(projectile)) { launch = new EntityArrow(world, getHandle(), 1); + } else if (ThrownPotion.class.isAssignableFrom(projectile)) { + launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.POTION, 1))); } else if (Fireball.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection().multiply(10);