Uncomment SleighHorse

This commit is contained in:
libraryaddict 2014-12-11 15:24:10 +13:00
parent 6b1fa91565
commit 3a8ab0afb0

View File

@ -74,110 +74,110 @@ public class SleighHorse
public void onTick()
{
// EntityTrackerEntry entityTrackerEntry = (EntityTrackerEntry) ((CraftWorld) Ent.getWorld()).getHandle().tracker.trackedEntities
// .get(Ent.getEntityId());
// if (entityTrackerEntry != null)
// {
// Location newLocation = Ent.getLocation().add(0, 0.5, 0);
// newLocation.setPitch(_lastFacing.getPitch());
//
// if (!newLocation.equals(_lastFacing))
// {
// Packet[] packets1_8 = new Packet[2];
// _lastMovement.add(new Vector(newLocation.getX() - _lastFacing.getX(), newLocation.getY() - _lastFacing.getY(),
// newLocation.getZ() - _lastFacing.getZ()));
// final int xP = (int) Math.floor(32 * _lastMovement.getX());
// final int yP = (int) Math.floor(32 * _lastMovement.getY());
// final int zP = (int) Math.floor(32 * _lastMovement.getZ());
// _lastMovement.subtract(new Vector(xP / 32D, yP / 32D, zP / 32D));
// _lastFacing = newLocation;
// int[] angles = getAngles(_lastFacing.getYaw());
// boolean tp = false;
// for (int i = 0; i < 2; i++)
// {
// int pX = angles[i * 2] - _previousDir[i * 2];
// int pZ = angles[(i * 2) + 1] - _previousDir[(i * 2) + 1];
// int x = xP + pX;
// int y = yP;
// int z = zP + pZ;
// if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
// {
// PacketPlayOutEntity relMove = pX != 0 || pZ != 0 ? new PacketPlayOutRelEntityMoveLook()
// : new PacketPlayOutRelEntityMove();
// relMove.a = hornsAndNose[i];
// relMove.b = (byte) x;
// relMove.c = (byte) y;
// relMove.d = (byte) z;
// relMove.e = ((byte) (int) (newLocation.getYaw() * 256.0F / 360.0F));
// packets1_8[i] = relMove;
// }
// else
// {
// x = (int) Math.floor(32 * newLocation.getX());
// y = (int) Math.floor(32 * newLocation.getY());
// z = (int) Math.floor(32 * newLocation.getZ());
// tp = true;
// PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
// teleportPacket.a = hornsAndNose[i];
// teleportPacket.b = x + pX;
// teleportPacket.c = y;
// teleportPacket.d = z + pZ;
// teleportPacket.e = ((byte) (int) (newLocation.getYaw() * 256.0F / 360.0F));
// packets1_8[i] = teleportPacket;
// }
// }
// if (tp)
// {
// int x = (int) Math.floor(32 * newLocation.getX());
// int y = (int) Math.floor(32 * newLocation.getY());
// int z = (int) Math.floor(32 * newLocation.getZ());
// _lastMovement = new Vector(newLocation.getX() - (x / 32D), newLocation.getY() - (y / 32D), newLocation.getZ()
// - (z / 32D));
// }
// _previousDir = angles;
// HashSet trackedPlayers = (HashSet) entityTrackerEntry.trackedPlayers;
// HashSet<EntityPlayer> cloned = (HashSet) trackedPlayers.clone();
// for (EntityPlayer p : cloned)
// {
// if (!UtilPlayer.is1_8(p.getBukkitEntity()))
// continue;
// for (Packet packet : packets1_8)
// {
// p.playerConnection.sendPacket(packet);
// }
// }
// }
// }
EntityTrackerEntry entityTrackerEntry = (EntityTrackerEntry) ((CraftWorld) Ent.getWorld()).getHandle().tracker.trackedEntities
.get(Ent.getEntityId());
if (entityTrackerEntry != null)
{
Location newLocation = Ent.getLocation().add(0, 0.5, 0);
newLocation.setPitch(_lastFacing.getPitch());
if (!newLocation.equals(_lastFacing))
{
Packet[] packets1_8 = new Packet[2];
_lastMovement.add(new Vector(newLocation.getX() - _lastFacing.getX(), newLocation.getY() - _lastFacing.getY(),
newLocation.getZ() - _lastFacing.getZ()));
final int xP = (int) Math.floor(32 * _lastMovement.getX());
final int yP = (int) Math.floor(32 * _lastMovement.getY());
final int zP = (int) Math.floor(32 * _lastMovement.getZ());
_lastMovement.subtract(new Vector(xP / 32D, yP / 32D, zP / 32D));
_lastFacing = newLocation;
int[] angles = getAngles(_lastFacing.getYaw());
boolean tp = false;
for (int i = 0; i < 2; i++)
{
int pX = angles[i * 2] - _previousDir[i * 2];
int pZ = angles[(i * 2) + 1] - _previousDir[(i * 2) + 1];
int x = xP + pX;
int y = yP;
int z = zP + pZ;
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
{
PacketPlayOutEntity relMove = pX != 0 || pZ != 0 ? new PacketPlayOutRelEntityMoveLook()
: new PacketPlayOutRelEntityMove();
relMove.a = hornsAndNose[i];
relMove.b = (byte) x;
relMove.c = (byte) y;
relMove.d = (byte) z;
relMove.e = ((byte) (int) (newLocation.getYaw() * 256.0F / 360.0F));
packets1_8[i] = relMove;
}
else
{
x = (int) Math.floor(32 * newLocation.getX());
y = (int) Math.floor(32 * newLocation.getY());
z = (int) Math.floor(32 * newLocation.getZ());
tp = true;
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
teleportPacket.a = hornsAndNose[i];
teleportPacket.b = x + pX;
teleportPacket.c = y;
teleportPacket.d = z + pZ;
teleportPacket.e = ((byte) (int) (newLocation.getYaw() * 256.0F / 360.0F));
packets1_8[i] = teleportPacket;
}
}
if (tp)
{
int x = (int) Math.floor(32 * newLocation.getX());
int y = (int) Math.floor(32 * newLocation.getY());
int z = (int) Math.floor(32 * newLocation.getZ());
_lastMovement = new Vector(newLocation.getX() - (x / 32D), newLocation.getY() - (y / 32D), newLocation.getZ()
- (z / 32D));
}
_previousDir = angles;
HashSet trackedPlayers = (HashSet) entityTrackerEntry.trackedPlayers;
HashSet<EntityPlayer> cloned = (HashSet) trackedPlayers.clone();
for (EntityPlayer p : cloned)
{
if (!UtilPlayer.is1_8(p.getBukkitEntity()))
continue;
for (Packet packet : packets1_8)
{
p.playerConnection.sendPacket(packet);
}
}
}
}
}
public void spawnHorns(Player player)
{
// if (!UtilPlayer.is1_8(player))
// return;
// Location loc = Ent == null ? _lastFacing : Ent.getLocation().add(0, 0.5, 0);
// for (int i = 0; i < 2; i++)
// {
// int id = hornsAndNose[i];
// PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
// packet.a = id;
// packet.b = 30;
// packet.c = (int) (loc.getX() * 32) + this._previousDir[i * 2];
// packet.d = (int) (loc.getY() * 32);
// packet.e = (int) (loc.getZ() * 32) + this._previousDir[(i * 2) + 1];
// packet.f = ((byte) (int) (loc.getYaw() * 256.0F / 360.0F));
// // Setup datawatcher for armor stand
// DataWatcher watcher = new DataWatcher(null);
// watcher.a(0, (byte) 32);
// watcher.a(10, (byte) 4);
// watcher.a(11, new Vector(0, i * 180, (i == 0 ? -1 : 1) * 60f));
// packet.l = watcher;
// PacketPlayOutEntityEquipment enquipPacket = new PacketPlayOutEntityEquipment();
// enquipPacket.a = id;
// enquipPacket.b = 4;
// enquipPacket.c = CraftItemStack.asNMSCopy(new ItemStack(Material.DEAD_BUSH));
// ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
// ((CraftPlayer) player).getHandle().playerConnection.sendPacket(enquipPacket);
// }
if (!UtilPlayer.is1_8(player))
return;
Location loc = Ent == null ? _lastFacing : Ent.getLocation().add(0, 0.5, 0);
for (int i = 0; i < 2; i++)
{
int id = hornsAndNose[i];
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = id;
packet.b = 30;
packet.c = (int) (loc.getX() * 32) + this._previousDir[i * 2];
packet.d = (int) (loc.getY() * 32);
packet.e = (int) (loc.getZ() * 32) + this._previousDir[(i * 2) + 1];
packet.f = ((byte) (int) (loc.getYaw() * 256.0F / 360.0F));
// Setup datawatcher for armor stand
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 32);
watcher.a(10, (byte) 4);
watcher.a(11, new Vector(0, i * 180, (i == 0 ? -1 : 1) * 60f));
packet.l = watcher;
PacketPlayOutEntityEquipment enquipPacket = new PacketPlayOutEntityEquipment();
enquipPacket.a = id;
enquipPacket.b = 4;
enquipPacket.c = CraftItemStack.asNMSCopy(new ItemStack(Material.DEAD_BUSH));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(enquipPacket);
}
}
public void spawnHorse()