Added .equals and fixed up velocitys to look better for worse pings
This commit is contained in:
parent
890e17ba36
commit
efede32c9b
@ -59,6 +59,16 @@ public class Disguise {
|
|||||||
return disguise;
|
return disguise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(Disguise disguise) {
|
||||||
|
if (getType() != disguise.getType())
|
||||||
|
return false;
|
||||||
|
if (replaceSounds() != disguise.replaceSounds())
|
||||||
|
return false;
|
||||||
|
if (!getWatcher().equals(disguise.getWatcher()))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public PacketContainer[] constructPacket(org.bukkit.entity.Entity e) {
|
public PacketContainer[] constructPacket(org.bukkit.entity.Entity e) {
|
||||||
PacketContainer[] spawnPackets = new PacketContainer[2];
|
PacketContainer[] spawnPackets = new PacketContainer[2];
|
||||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
||||||
@ -277,8 +287,8 @@ public class Disguise {
|
|||||||
name = toReadable(getType().name());
|
name = toReadable(getType().name());
|
||||||
}
|
}
|
||||||
Class watcherClass = Class.forName("me.libraryaddict.disguise.DisguiseTypes.Watchers." + name + "Watcher");
|
Class watcherClass = Class.forName("me.libraryaddict.disguise.DisguiseTypes.Watchers." + name + "Watcher");
|
||||||
Constructor<?> contructor = watcherClass.getDeclaredConstructor(int.class);
|
Constructor<?> contructor = watcherClass.getDeclaredConstructor(Disguise.class);
|
||||||
tempWatcher = (FlagWatcher) contructor.newInstance(entity);
|
tempWatcher = (FlagWatcher) contructor.newInstance(this);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// There is no watcher for this entity, or a error was thrown.
|
// There is no watcher for this entity, or a error was thrown.
|
||||||
if (entity.getType().isAlive())
|
if (entity.getType().isAlive())
|
||||||
@ -359,11 +369,14 @@ public class Disguise {
|
|||||||
case 8:
|
case 8:
|
||||||
case 9:
|
case 9:
|
||||||
owningData = EntityLiving.class;
|
owningData = EntityLiving.class;
|
||||||
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
case 11:
|
case 11:
|
||||||
owningData = EntityInsentient.class;
|
owningData = EntityInsentient.class;
|
||||||
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
owningData = EntityAgeable.class;
|
owningData = EntityAgeable.class;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -375,7 +388,7 @@ public class Disguise {
|
|||||||
tempWatcher.setValue(dataNo, disguiseValues.get(dataNo));
|
tempWatcher.setValue(dataNo, disguiseValues.get(dataNo));
|
||||||
}
|
}
|
||||||
watcher = tempWatcher;
|
watcher = tempWatcher;
|
||||||
double fallSpeed = 0.0051;
|
double fallSpeed = 0.0050;
|
||||||
boolean doesntMove = false;
|
boolean doesntMove = false;
|
||||||
boolean movement = false;
|
boolean movement = false;
|
||||||
switch (getType()) {
|
switch (getType()) {
|
||||||
@ -396,18 +409,22 @@ public class Disguise {
|
|||||||
case PLAYER:
|
case PLAYER:
|
||||||
case SQUID:
|
case SQUID:
|
||||||
doesntMove = true;
|
doesntMove = true;
|
||||||
|
break;
|
||||||
case DROPPED_ITEM:
|
case DROPPED_ITEM:
|
||||||
case EXPERIENCE_ORB:
|
case EXPERIENCE_ORB:
|
||||||
case MAGMA_CUBE:
|
case MAGMA_CUBE:
|
||||||
case PRIMED_TNT:
|
case PRIMED_TNT:
|
||||||
fallSpeed = 0.2;
|
fallSpeed = 0.2;
|
||||||
movement = true;
|
movement = true;
|
||||||
|
break;
|
||||||
case WITHER:
|
case WITHER:
|
||||||
case FALLING_BLOCK:
|
case FALLING_BLOCK:
|
||||||
fallSpeed = 0.04;
|
fallSpeed = 0.04;
|
||||||
|
break;
|
||||||
case SPIDER:
|
case SPIDER:
|
||||||
case CAVE_SPIDER:
|
case CAVE_SPIDER:
|
||||||
fallSpeed = 0.0041;
|
fallSpeed = 0.0040;
|
||||||
|
break;
|
||||||
case EGG:
|
case EGG:
|
||||||
case ENDER_PEARL:
|
case ENDER_PEARL:
|
||||||
case ENDER_SIGNAL:
|
case ENDER_SIGNAL:
|
||||||
@ -418,14 +435,16 @@ public class Disguise {
|
|||||||
case THROWN_EXP_BOTTLE:
|
case THROWN_EXP_BOTTLE:
|
||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
fallSpeed = 0.0005;
|
fallSpeed = 0.0005;
|
||||||
|
break;
|
||||||
case FIREWORK:
|
case FIREWORK:
|
||||||
fallSpeed = -0.041;
|
fallSpeed = -0.040;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final boolean sendMovementPacket = movement;
|
final boolean sendMovementPacket = movement;
|
||||||
final boolean sendVector = !doesntMove;
|
final boolean sendVector = !doesntMove;
|
||||||
final int vectorY = (int) (fallSpeed * 8000);
|
final double vectorY = fallSpeed;
|
||||||
// A scheduler to clean up any unused disguises.
|
// A scheduler to clean up any unused disguises.
|
||||||
runnable = new BukkitRunnable() {
|
runnable = new BukkitRunnable() {
|
||||||
private int i = 0;
|
private int i = 0;
|
||||||
@ -447,29 +466,32 @@ public class Disguise {
|
|||||||
Vector vector = entity.getVelocity();
|
Vector vector = entity.getVelocity();
|
||||||
if (vector.getY() != 0)
|
if (vector.getY() != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for (EntityPlayer player : getPerverts()) {
|
||||||
|
if (entity != player) {
|
||||||
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_VELOCITY);
|
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_VELOCITY);
|
||||||
StructureModifier<Object> mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
mods.write(0, entity.getEntityId());
|
mods.write(0, entity.getEntityId());
|
||||||
mods.write(1, (int) (vector.getX() * 8000));
|
mods.write(1, (int) (vector.getX() * 8000));
|
||||||
mods.write(2, vectorY);
|
mods.write(2, (int) (8000 * (vectorY * (double) player.ping * 0.069)));
|
||||||
mods.write(3, (int) (vector.getZ() * 8000));
|
mods.write(3, (int) (vector.getZ() * 8000));
|
||||||
for (EntityPlayer player : getPerverts()) {
|
|
||||||
if (entity != player) {
|
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player.getBukkitEntity(), packet);
|
ProtocolLibrary.getProtocolManager()
|
||||||
|
.sendServerPacket(player.getBukkitEntity(), packet, false);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendMovementPacket) {
|
if (sendMovementPacket) {
|
||||||
packet = new PacketContainer(Packets.Server.REL_ENTITY_MOVE);
|
PacketContainer packet = new PacketContainer(Packets.Server.REL_ENTITY_MOVE);
|
||||||
mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
mods.write(0, entity.getEntityId());
|
mods.write(0, entity.getEntityId());
|
||||||
for (EntityPlayer player : getPerverts()) {
|
for (EntityPlayer player : getPerverts()) {
|
||||||
if (entity != player) {
|
if (entity != player) {
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player.getBukkitEntity(), packet);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player.getBukkitEntity(), packet,
|
||||||
|
false);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user