From e962b1bc095dda028182f59c6e9a2897ef2cd72f Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 16 Dec 2013 22:40:00 -0500 Subject: [PATCH] [Bleeding] Add support for ThrownExpBottle and Fish to launchProjectile(...). Fixes BUKKIT-1536 Previously, trying to launch a ThrownExpBottle or Fish projectile would result in an IllegalArgumentException. This commit adds support for both ThrownExpBottle and Fish, which means that all current projectiles are now properly supported by this method. --- .../org/bukkit/craftbukkit/entity/CraftLivingEntity.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index e90a91d441..3f45837c50 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -11,6 +11,8 @@ import net.minecraft.server.EntityArrow; import net.minecraft.server.EntityEgg; import net.minecraft.server.EntityEnderDragon; import net.minecraft.server.EntityEnderPearl; +import net.minecraft.server.EntityFishingHook; +import net.minecraft.server.EntityHuman; import net.minecraft.server.EntityInsentient; import net.minecraft.server.EntityLargeFireball; import net.minecraft.server.EntityLiving; @@ -18,6 +20,7 @@ import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPotion; import net.minecraft.server.EntitySmallFireball; import net.minecraft.server.EntitySnowball; +import net.minecraft.server.EntityThrownExpBottle; import net.minecraft.server.EntityWither; import net.minecraft.server.EntityWitherSkull; import net.minecraft.server.GenericAttributes; @@ -38,12 +41,14 @@ import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Fireball; +import org.bukkit.entity.Fish; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.SmallFireball; import org.bukkit.entity.Snowball; +import org.bukkit.entity.ThrownExpBottle; import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.WitherSkull; import org.bukkit.event.player.PlayerTeleportEvent; @@ -303,6 +308,10 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { 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 (ThrownExpBottle.class.isAssignableFrom(projectile)) { + launch = new EntityThrownExpBottle(world, getHandle()); + } else if (Fish.class.isAssignableFrom(projectile) && getHandle() instanceof EntityHuman) { + launch = new EntityFishingHook(world, (EntityHuman) getHandle()); } else if (Fireball.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection().multiply(10);