From 3c51dae83b50a42a02540cbc0d41b0ff108572e1 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 30 May 2013 08:46:51 +1200 Subject: [PATCH] Fix fireball, giant, ghast and items --- .../disguise/DisguiseTypes/Disguise.java | 12 ++++-------- .../disguise/DisguiseTypes/WatcherValues.java | 7 +++++-- .../{ItemWatcher.java => DroppedItemWatcher.java} | 4 ++-- src/me/libraryaddict/disguise/LibsDisguises.java | 8 +++++--- 4 files changed, 16 insertions(+), 15 deletions(-) rename src/me/libraryaddict/disguise/DisguiseTypes/Watchers/{ItemWatcher.java => DroppedItemWatcher.java} (85%) diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java index 1e59d84d..f905c110 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/Disguise.java @@ -67,8 +67,6 @@ public class Disguise { } else if (getType().isMob()) { - // entity = ((MobDisguise) this).getEntityLiving(((CraftEntity) e).getHandle().world, e.getLocation(), - // e.getEntityId()); double d1 = 3.9D; Vector vec = e.getVelocity(); double d2 = vec.getX(); @@ -100,11 +98,11 @@ public class Disguise { } else if (disguiseType == DisguiseType.SPLASH_POTION) name = "Potion"; else if (disguiseType == DisguiseType.GIANT) - name = "Giant Zombie"; + name = "GiantZombie"; else if (disguiseType == DisguiseType.DROPPED_ITEM) name = "Item"; else if (disguiseType == DisguiseType.FIREBALL) - name = "Large Fireball"; + name = "LargeFireball"; try { Class entityClass = Class.forName("net.minecraft.server.v1_5_R3.Entity" + name); Field field = EntityTypes.class.getDeclaredField("e"); @@ -124,6 +122,8 @@ public class Disguise { byte yawValue = (byte) (int) (entity.yaw * 256.0F / 360.0F); if (getType() == DisguiseType.ENDER_DRAGON) yawValue -= 128; + else if (getType() == DisguiseType.GHAST) + yawValue += 64; mods.write(8, yawValue); mods.write(9, (byte) (int) (entity.pitch * 256.0F / 360.0F)); mods.write(10, (byte) (int) (((EntityLiving) entity).aA * 256.0F / 360.0F)); @@ -132,7 +132,6 @@ public class Disguise { } else if (getType().isMisc()) { - // getEntity(((CraftEntity) e).getHandle().world, e.getLocation(), e.getEntityId()); int id = getType().getEntityId(); int data = 0; if (((MiscDisguise) this).getId() >= 0) @@ -176,9 +175,6 @@ public class Disguise { } else if (getType().isPlayer()) { - // EntityPlayer entityPlayer = (EntityPlayer) getEntity(((CraftEntity) e).getHandle().world, e.getLocation(), - // e.getEntityId()); - // entityPlayer.name = ((PlayerDisguise) this).getName(); spawnPacket = manager.createPacket(Packets.Server.NAMED_ENTITY_SPAWN); StructureModifier mods = spawnPacket.getModifier(); mods.write(0, e.getEntityId()); diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/WatcherValues.java b/src/me/libraryaddict/disguise/DisguiseTypes/WatcherValues.java index ed0ef352..6d5aec1c 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/WatcherValues.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/WatcherValues.java @@ -3,10 +3,13 @@ package me.libraryaddict.disguise.DisguiseTypes; import java.util.HashMap; import java.util.Set; +import org.bukkit.craftbukkit.v1_5_R3.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; + public enum WatcherValues { ARROW(16, (byte) 0), BAT(16, (byte) 0), BLAZE(16, (byte) 0), BOAT(19, 40, 17, 10, 18, 0), CAVE_SPIDER(), CHICKEN(12, 0), COW( - 12, 0), CREEPER(16, (byte) 0, 17, (byte) 0), DROPPED_ITEM(), EGG(), ENDER_CRYSTAL(), ENDER_DRAGON(16, 300), ENDER_PEARL(), ENDER_SIGNAL(), ENDERMAN( - 16, (byte) 0, 17, (byte) 1, 18, (byte) 0), EXPERIENCE_ORB(), FALLING_BLOCK(), FIREBALL(), FIREWORKS(), FISHING_HOOK(), GHAST( + 12, 0), CREEPER(16, (byte) 0, 17, (byte) 0), DROPPED_ITEM(10, CraftItemStack.asNMSCopy(new ItemStack(1))), EGG(), ENDER_CRYSTAL(), ENDER_DRAGON( + 16, 300), ENDER_PEARL(), ENDER_SIGNAL(), ENDERMAN(16, (byte) 0, 17, (byte) 1, 18, (byte) 0), EXPERIENCE_ORB(), FALLING_BLOCK(), FIREBALL(), FIREWORKS(), FISHING_HOOK(), GHAST( 16, (byte) 0), GIANT(), IRON_GOLEM(), ITEM_FRAME(2, 5, 3, (byte) 0), MAGMA_CUBE(16, (byte) 0, 18, (byte) 0), MINECART_CHEST( 16, (byte) 0, 17, 0, 18, 1, 19, 0, 20, 0, 21, 6, 22, (byte) 0), MINECART_FURNACE(16, (byte) 0, 17, 0, 18, 1, 19, 0, 20, 0, 21, 6, 22, (byte) 0), MINECART_HOPPER(16, (byte) 0, 17, 0, 18, 1, 19, 0, 20, 0, 21, 6, 22, (byte) 0), MINECART_MOB_SPAWNER( diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ItemWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/DroppedItemWatcher.java similarity index 85% rename from src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ItemWatcher.java rename to src/me/libraryaddict/disguise/DisguiseTypes/Watchers/DroppedItemWatcher.java index 8f034d93..49c9b71e 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/ItemWatcher.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/Watchers/DroppedItemWatcher.java @@ -5,9 +5,9 @@ import org.bukkit.inventory.ItemStack; import me.libraryaddict.disguise.DisguiseTypes.FlagWatcher; -public class ItemWatcher extends FlagWatcher { +public class DroppedItemWatcher extends FlagWatcher { - public ItemWatcher(int entityId) { + public DroppedItemWatcher(int entityId) { super(entityId); setValue(10, CraftItemStack.asNMSCopy(new ItemStack(1))); } diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 259d9136..cf78d3bd 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -89,12 +89,14 @@ public class LibsDisguises extends JavaPlugin { if (disguise.getType() == DisguiseType.ENDER_DRAGON) { byte value = (Byte) mods.read(4); mods.write(4, (byte) (value - 128)); - } else if (disguise.getType().isMisc()) { + } else if (disguise.getType().isMisc() || disguise.getType() == DisguiseType.GHAST) { byte value = (Byte) mods.read(4); if (disguise.getType() != DisguiseType.PAINTING) - mods.write(4, (byte) (value + 64)); + mods.write(4, (byte) (value + 128)); + else if (disguise.getType().isMisc()) + mods.write(4, (byte) -(value + 128)); else - mods.write(4, (byte) -(value += 128)); + mods.write(4, (byte) (value - 64)); } } }