Search in sources :

Example 1 with UpdateBlockPacket

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;
}
Also used : BlockPosition(org.dragonet.common.maths.BlockPosition) UpdateBlockPacket(org.dragonet.protocol.packets.UpdateBlockPacket) ItemEntry(org.dragonet.common.data.itemsblocks.ItemEntry)

Example 2 with UpdateBlockPacket

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);
}
Also used : BlockPosition(org.dragonet.common.maths.BlockPosition) UpdateBlockPacket(org.dragonet.protocol.packets.UpdateBlockPacket)

Example 3 with UpdateBlockPacket

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;
}
Also used : BlockPosition(org.dragonet.common.maths.BlockPosition) ItemEntry(org.dragonet.common.data.itemsblocks.ItemEntry) UpdateBlockPacket(org.dragonet.protocol.packets.UpdateBlockPacket)

Aggregations

BlockPosition (org.dragonet.common.maths.BlockPosition)3 UpdateBlockPacket (org.dragonet.protocol.packets.UpdateBlockPacket)3 ItemEntry (org.dragonet.common.data.itemsblocks.ItemEntry)2