use of org.dragonet.common.maths.BlockPosition in project DragonProxy by DragonetMC.
the class ChestWindowTranslator method prepare.
public boolean prepare(UpstreamSession session, CachedWindow window) {
BlockPosition pos = new BlockPosition((int) session.getEntityCache().getClientEntity().x, (int) session.getEntityCache().getClientEntity().y - 4, (int) session.getEntityCache().getClientEntity().z);
session.getDataCache().put(CacheKey.CURRENT_WINDOW_POSITION, pos);
session.sendFakeBlock(pos.x, pos.y, pos.z, 54, 0);
BlockEntityDataPacket blockEntityData = new BlockEntityDataPacket();
blockEntityData.blockPosition = pos;
blockEntityData.tag = ItemBlockTranslator.translateBlockEntityToPE(ItemBlockTranslator.newTileTag("minecraft:chest", pos.x, pos.y, pos.z));
if (window.size - 36 > 27) {
// DoubleChest
blockEntityData.tag.putInt("pairx", pos.x + 1);
blockEntityData.tag.putInt("pairz", pos.z);
} else
// SimpleChest
session.sendPacket(blockEntityData);
if (window.size - 36 > 27) {
// DoubleChest
BlockPosition pos2 = new BlockPosition(pos.x + 1, pos.y, pos.z);
session.sendFakeBlock(pos2.x, pos2.y, pos2.z, 54, 0);
BlockEntityDataPacket blockEntityData2 = new BlockEntityDataPacket();
blockEntityData2.blockPosition = pos2;
blockEntityData2.tag = ItemBlockTranslator.translateBlockEntityToPE(ItemBlockTranslator.newTileTag("minecraft:chest", pos2.x, pos2.y, pos2.z));
blockEntityData2.tag.putInt("pairx", pos.x);
blockEntityData2.tag.putInt("pairz", pos.z);
session.sendPacket(blockEntityData2);
session.sendPacket(blockEntityData);
ArrayList<BlockPosition> posList = new ArrayList<>();
posList.add(pos);
posList.add(pos2);
session.getDataCache().put(CacheKey.CURRENT_WINDOW_POSITION, posList);
}
// System.out.println("ChestWindowTranslator.prepare " + window.windowId);
return true;
}
use of org.dragonet.common.maths.BlockPosition 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