Read merge message

This commit is contained in:
libraryaddict 2014-12-06 02:22:52 +13:00
parent 21e80af6cb
commit 307d280534

View File

@ -50,13 +50,15 @@ public class BlockForm extends Form
private Location _loc;
private int _selfEntityId1;
private int _selfEntityId2;
private Location _lastSaw;
private Vector _lastSaw;
private Vector _sawDiff = new Vector();
private boolean _is18;
public BlockForm(HideSeek host, Player player, Material mat)
{
super(host, player);
_is18 = UtilPlayer.is1_8(player);
_mat = mat;
_loc = player.getLocation();
_selfEntityId1 = UtilEnt.getNewEntityId();
@ -88,27 +90,40 @@ public class BlockForm extends Form
// Apply Falling Block
FallingBlockCheck();
PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving();
packet1.a = _selfEntityId1;
packet1.b = EntityType.SILVERFISH.getTypeId();
packet1.c = (int) Math.floor(_lastSaw.getX() * 32);
packet1.d = (int) Math.floor(_lastSaw.getY() * 32);
packet1.e = (int) Math.floor(_lastSaw.getZ() * 32);
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 32);
watcher.a(1, 0);
packet1.l = watcher;
player.playerConnection.sendPacket(packet1);
Packet[] packets = new Packet[3];
if (_is18)
{
PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving();
packet1.a = _selfEntityId1;
packet1.b = EntityType.SILVERFISH.getTypeId();
packet1.c = (int) Math.floor(_lastSaw.getX() * 32);
packet1.d = (int) Math.floor(_lastSaw.getY() * 32);
packet1.e = (int) Math.floor(_lastSaw.getZ() * 32);
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 32);
watcher.a(1, 0);
packet1.l = watcher;
packets[0] = packet1;
PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity();
packet3.b = _selfEntityId2;
packet3.c = _selfEntityId1;
packets[2] = packet3;
}
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(player, 70, _mat.getId());
packet2.a = _selfEntityId2;
player.playerConnection.sendPacket(packet2);
packet2.a = _is18 ? _selfEntityId2 : _selfEntityId1;
packets[1] = packet2;
PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity();
packet3.b = _selfEntityId2;
packet3.c = _selfEntityId1;
player.playerConnection.sendPacket(packet3);
for (Packet packet : packets)
{
if (packet != null)
{
player.playerConnection.sendPacket(packet);
}
}
// Inform
String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false));
@ -209,6 +224,26 @@ public class BlockForm extends Form
// Sound
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
// Teleport falling block to the position.
Vector blockLoc = _block.getLocation().add(0.5, _is18 ? -.21875 : 0, 0.5).toVector();
_sawDiff.add(blockLoc.clone().subtract(_lastSaw));
Packet packet = this.getPacket(_sawDiff, blockLoc);
_lastSaw = Player.getLocation().toVector().subtract(new Vector(0, _is18 ? 0.15625 : 0, 0));
_sawDiff = _lastSaw.clone().subtract(blockLoc);
if (packet != null)
{
if (packet instanceof PacketPlayOutEntityTeleport)
{
_sawDiff = new Vector();
}
((CraftPlayer) Player).getHandle().playerConnection.sendPacket(packet);
}
}
}
}
@ -269,7 +304,6 @@ public class BlockForm extends Form
// Self
Player.sendBlockChange(Player.getLocation(), 36, (byte) 0);
FallingBlockCheck();
}
public void FallingBlockCheck()
@ -302,43 +336,72 @@ public class BlockForm extends Form
((CraftFallingSand) Player.getPassenger()).getHandle().ticksLived = 1;
Player.getPassenger().setTicksLived(1);
}
}
if (_lastSaw == null || _lastSaw.getWorld() != Player.getWorld())
{
_lastSaw = Player.getLocation();
}
this._sawDiff.add(Player.getLocation().subtract(_lastSaw).toVector());
_lastSaw = Player.getLocation();
/* if (_lastSaw != null && _lastSaw.getWorld() == Player.getWorld())
{
this._sawDiff.add(_lastSaw.clone().subtract(_lastSaw).toVector());
}
_lastSaw = Player.getLocation().subtract(0, 0.15, 0);*/
if (_lastSaw != null)
{
this._sawDiff.add(Player.getLocation().subtract(0, _is18 ? 0.15625 : 0, 0).toVector().subtract(_lastSaw));
}
_lastSaw = Player.getLocation().subtract(0, _is18 ? 0.15625 : 0, 0).toVector();
Packet packet = this.getPacket(_sawDiff, _lastSaw);
if (packet != null)
{
if (packet instanceof PacketPlayOutRelEntityMove)
{
PacketPlayOutRelEntityMove relPacket = (PacketPlayOutRelEntityMove) packet;
_sawDiff.subtract(new Vector(relPacket.b / 32D, relPacket.c / 32D, relPacket.d / 32D));
}
else
{
_sawDiff = new Vector();
}
player.playerConnection.sendPacket(packet);
}
}
}
private Packet getPacket(Vector blocksFromNewPosition, Vector newPosition)
{
int x = (int) Math.floor(blocksFromNewPosition.getX() * 32);
int y = (int) Math.floor(blocksFromNewPosition.getY() * 32);
int z = (int) Math.floor(blocksFromNewPosition.getZ() * 32);
int x = (int) Math.floor(_sawDiff.getX() * 32);
int y = (int) Math.floor(_sawDiff.getY() * 32);
int z = (int) Math.floor(_sawDiff.getZ() * 32);
if (x != 0 || y != 0 || z != 0)
{
Packet packet;
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
{
_sawDiff.subtract(new Vector(x / 32D, y / 32D, z / 32D));
PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove();
relMove.a = this._selfEntityId1;
relMove.b = (byte) x;
relMove.c = (byte) y;
relMove.d = (byte) z;
packet = relMove;
return relMove;
}
else
{
_sawDiff = new Vector();
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
teleportPacket.a = _selfEntityId1;
teleportPacket.b = (int) Math.floor(32 * _lastSaw.getX());
teleportPacket.c = (int) Math.floor(32 * _lastSaw.getY());
teleportPacket.d = (int) Math.floor(32 * _lastSaw.getZ());
packet = teleportPacket;
teleportPacket.b = (int) Math.floor(32 * newPosition.getX());
teleportPacket.c = (int) Math.floor(32 * newPosition.getY());
teleportPacket.d = (int) Math.floor(32 * newPosition.getZ());
return teleportPacket;
}
player.playerConnection.sendPacket(packet);
}
return null;
}
public Block GetBlock()