Read desc

Fixed enderdragon flying backwards.
Fixed vechiles not facing the right way
Fixed entitys sometimes remaining in the world
This commit is contained in:
Andrew 2013-05-28 00:11:12 +12:00
parent bed69e85d3
commit 902fc99686
3 changed files with 23 additions and 10 deletions

View file

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>LibsDisguises</groupId> <groupId>LibsDisguises</groupId>
<artifactId>LibsDisguises</artifactId> <artifactId>LibsDisguises</artifactId>
<version>v3.4</version> <version>3.4</version>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<defaultGoal>clean package</defaultGoal> <defaultGoal>clean package</defaultGoal>

View file

@ -21,7 +21,7 @@ import org.bukkit.entity.Player;
public class Disguise { public class Disguise {
protected DisguiseType disguiseType; protected DisguiseType disguiseType;
private Entity entity; private Entity entity = null;
private FlagWatcher watcher; private FlagWatcher watcher;
protected Disguise(DisguiseType newType) { protected Disguise(DisguiseType newType) {
@ -40,6 +40,8 @@ public class Disguise {
EntityLiving entityLiving = ((MobDisguise) this).getEntityLiving(((CraftPlayer) p).getHandle().world, EntityLiving entityLiving = ((MobDisguise) this).getEntityLiving(((CraftPlayer) p).getHandle().world,
p.getLocation(), p.getEntityId()); p.getLocation(), p.getEntityId());
spawnPacket = new Packet24MobSpawn(entityLiving); spawnPacket = new Packet24MobSpawn(entityLiving);
if (getType() == DisguiseType.ENDER_DRAGON)
((Packet24MobSpawn) spawnPacket).i -= 128;
} else if (getType().isMisc()) { } else if (getType().isMisc()) {
@ -52,6 +54,8 @@ public class Disguise {
spawnPacket = new Packet23VehicleSpawn(entity, getType().getEntityId(), ((MiscDisguise) this).getId()); spawnPacket = new Packet23VehicleSpawn(entity, getType().getEntityId(), ((MiscDisguise) this).getId());
} else } else
spawnPacket = new Packet23VehicleSpawn(entity, getType().getEntityId()); spawnPacket = new Packet23VehicleSpawn(entity, getType().getEntityId());
((Packet23VehicleSpawn) spawnPacket).i += 64;
} else if (getType().isPlayer()) { } else if (getType().isPlayer()) {
EntityHuman entityHuman = ((CraftPlayer) p).getHandle(); EntityHuman entityHuman = ((CraftPlayer) p).getHandle();
@ -65,6 +69,7 @@ public class Disguise {
public Entity getEntity(World world, Location loc, int entityId) { public Entity getEntity(World world, Location loc, int entityId) {
if (entity != null) { if (entity != null) {
entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
entity.id = entityId;
return entity; return entity;
} }
try { try {

View file

@ -12,6 +12,7 @@ import net.minecraft.server.v1_5_R3.WatchableObject;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_5_R3.CraftSound; import org.bukkit.craftbukkit.v1_5_R3.CraftSound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -28,7 +29,8 @@ public class LibsDisguises extends JavaPlugin {
public void onEnable() { public void onEnable() {
ProtocolLibrary.getProtocolManager().addPacketListener( ProtocolLibrary.getProtocolManager().addPacketListener(
new PacketAdapter(this, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, Packets.Server.NAMED_ENTITY_SPAWN, new PacketAdapter(this, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, Packets.Server.NAMED_ENTITY_SPAWN,
Packets.Server.ENTITY_METADATA, Packets.Server.NAMED_SOUND_EFFECT, Packets.Server.ARM_ANIMATION) { Packets.Server.ENTITY_METADATA, Packets.Server.NAMED_SOUND_EFFECT, Packets.Server.ARM_ANIMATION,
Packets.Server.REL_ENTITY_MOVE_LOOK, Packets.Server.ENTITY_LOOK, Packets.Server.ENTITY_TELEPORT) {
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
StructureModifier<Object> mods = event.getPacket().getModifier(); StructureModifier<Object> mods = event.getPacket().getModifier();
@ -110,8 +112,9 @@ public class LibsDisguises extends JavaPlugin {
} }
} }
} else { } else {
org.bukkit.entity.Entity entity = event.getPacket().getEntityModifier(observer.getWorld()) StructureModifier<Entity> entityModifer = event.getPacket()
.read(0); .getEntityModifier(observer.getWorld());
org.bukkit.entity.Entity entity = entityModifer.read(0);
if (entity instanceof Player) { if (entity instanceof Player) {
Player watched = (Player) entity; Player watched = (Player) entity;
if (DisguiseAPI.isDisguised(watched.getName())) { if (DisguiseAPI.isDisguised(watched.getName())) {
@ -132,12 +135,17 @@ public class LibsDisguises extends JavaPlugin {
event.setCancelled(true); event.setCancelled(true);
DisguiseAPI.disguiseToPlayer(watched, observer, disguise); DisguiseAPI.disguiseToPlayer(watched, observer, disguise);
} }
} else { } else if (event.getPacketID() == Packets.Server.ARM_ANIMATION) {
// Set the sounds and cancel bad packets.
if (disguise.getType().isMisc()) { if (disguise.getType().isMisc()) {
if (event.getPacketID() == Packets.Server.ARM_ANIMATION) { event.setCancelled(true);
event.setCancelled(true); }
} } else {
if (disguise.getType() == DisguiseType.ENDER_DRAGON) {
byte value = (Byte) mods.read(4);
mods.write(4, (byte) (value - 128));
} else if (disguise.getType().isMisc()) {
byte value = (Byte) mods.read(4);
mods.write(4, (byte) (value + 64));
} }
} }
} }