use of org.dragonet.protocol.packets.UpdateBlockPacket in project DragonProxy by DragonetMC.
the class PCMultiBlockChangePacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerMultiBlockChangePacket packet) {
UpdateBlockPacket[] packets = new UpdateBlockPacket[packet.getRecords().length];
// int generalFlag = packet.getRecords().length > 64 ? UpdateBlockPacket.FLAG_ALL_PRIORITY : UpdateBlockPacket.FLAG_NEIGHBORS;
for (int i = 0; i < packets.length; i++) {
// update cache
session.getChunkCache().update(packet.getRecords()[i].getPosition(), packet.getRecords()[i].getBlock());
packets[i] = new UpdateBlockPacket();
packets[i].blockPosition = new BlockPosition(packet.getRecords()[i].getPosition().getX(), packet.getRecords()[i].getPosition().getY(), packet.getRecords()[i].getPosition().getZ());
ItemEntry entry = session.getChunkCache().translateBlock(packet.getRecords()[i].getPosition());
packets[i].id = entry.getId();
packets[i].flags = UpdateBlockPacket.FLAG_NEIGHBORS;
packets[i].data = entry.getPEDamage();
// Save glitchy items in cache
// Position blockPosition = new Position(packets[i].blockPosition.x, packets[i].blockPosition.y, packets[i].blockPosition.z);
}
return packets;
}
use of org.dragonet.protocol.packets.UpdateBlockPacket in project DragonProxy by DragonetMC.
the class UpstreamSession method sendFakeBlock.
public void sendFakeBlock(int x, int y, int z, int id, int meta) {
UpdateBlockPacket pkBlock = new UpdateBlockPacket();
pkBlock.id = id;
pkBlock.data = meta;
pkBlock.flags = UpdateBlockPacket.FLAG_NEIGHBORS;
pkBlock.blockPosition = new BlockPosition(x, y, z);
sendPacket(pkBlock);
}
use of org.dragonet.protocol.packets.UpdateBlockPacket in project DragonProxy by DragonetMC.
the class PCBlockChangePacketTranslator method translate.
@Override
public PEPacket[] translate(UpstreamSession session, ServerBlockChangePacket packet) {
// update cache
session.getChunkCache().update(packet.getRecord().getPosition(), packet.getRecord().getBlock());
// Save glitchy items in cache
// Position blockPosition = new Position(pk.blockPosition.x, pk.blockPosition.y, pk.blockPosition.z);
// session.getBlockCache().checkBlock(entry.getId(), entry.getPEDamage(), blockPosition);
ItemEntry entry = session.getChunkCache().translateBlock(packet.getRecord().getPosition());
if (entry != null) {
UpdateBlockPacket pk = new UpdateBlockPacket();
pk.flags = UpdateBlockPacket.FLAG_NEIGHBORS;
pk.data = entry.getPEDamage();
pk.id = entry.getId();
pk.blockPosition = new BlockPosition(packet.getRecord().getPosition());
session.putCachePacket(pk);
}
return null;
}
Aggregations