use of org.dragonet.common.data.itemsblocks.ItemEntry in project DragonProxy by DragonetMC.
the class PEMovePlayerPacketTranslator method translate.
public Packet[] translate(UpstreamSession session, MovePlayerPacket packet) {
CachedEntity entity = session.getEntityCache().getClientEntity();
if (entity.riding != 0 && packet.ridingRuntimeId != 0) {
// Riding case
ClientVehicleMovePacket pk = new ClientVehicleMovePacket(packet.position.x, packet.position.y - EntityType.PLAYER.getOffset(), packet.position.z, packet.yaw, packet.pitch);
session.getDownstream().send(pk);
} else {
// not riding
ClientPlayerPositionRotationPacket pk = new ClientPlayerPositionRotationPacket(packet.onGround, packet.position.x, // To simplify the movements
ceilToHalf(packet.position.y - EntityType.PLAYER.getOffset()), packet.position.z, packet.yaw, packet.pitch);
// Special blocks handling
boolean isColliding = false;
BlockPosition blockPos = new BlockPosition(NukkitMath.floorDouble(packet.position.x), NukkitMath.floorDouble(packet.position.y), NukkitMath.floorDouble(packet.position.z));
// System.out.println("block " + blockPos.toString());
try {
ItemEntry PEBlock = session.getChunkCache().translateBlock(blockPos.asPosition());
if (PEBlock != null) {
Block b = Block.get(PEBlock.getId(), PEBlock.getPEDamage(), blockPos);
if (b != null && b.collidesWithBB(session.getEntityCache().getClientEntity().boundingBox.clone())) {
DragonProxy.getInstance().getLogger().info("Player position : " + entity.x + ", " + entity.y + ", " + entity.z + " collide with " + b.getClass().getSimpleName() + " on " + blockPos.toString());
isColliding = true;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
entity.absoluteMove(pk.getX(), pk.getY(), pk.getZ(), (float) pk.getYaw(), (float) pk.getPitch());
if (!isColliding) {
session.getDownstream().send(pk);
session.getChunkCache().sendOrderedChunks();
}
}
return null;
}
use of org.dragonet.common.data.itemsblocks.ItemEntry in project DragonProxy by DragonetMC.
the class ItemBlockTranslator method swap.
private static void swap(int pcId, int peId, IItemDataTranslator translator) {
PC_TO_PE_OVERRIDE.put(pcId, new ItemEntry(peId, null, translator));
PE_TO_PC_OVERRIDE.put(peId, new ItemEntry(pcId, null, translator));
}
use of org.dragonet.common.data.itemsblocks.ItemEntry in project DragonProxy by DragonetMC.
the class ItemBlockTranslator method translateData.
private static void translateData(int id, IItemDataTranslator translator) {
PC_TO_PE_OVERRIDE.put(id, new ItemEntry(id, null, translator));
PE_TO_PC_OVERRIDE.put(id, new ItemEntry(id, null, translator));
}
use of org.dragonet.common.data.itemsblocks.ItemEntry in project DragonProxy by DragonetMC.
the class ItemBlockTranslator method translateSlotToPE.
public static Slot translateSlotToPE(ItemStack item) {
if (item == null || item.getId() == 0)
return null;
Slot slot = new Slot();
ItemEntry entry = translateToPE(item.getId(), item.getData());
slot.id = entry.getId();
slot.damage = entry.getPEDamage() != null ? entry.getPEDamage() : item.getData();
slot.count = item.getAmount();
slot.tag = translateItemNBT(item.getId(), item.getNBT(), null);
return slot;
}
use of org.dragonet.common.data.itemsblocks.ItemEntry in project DragonProxy by DragonetMC.
the class ItemBlockTranslator method swap.
private static void swap(int pcId, ItemEntry toPe) {
PC_TO_PE_OVERRIDE.put(pcId, toPe);
PE_TO_PC_OVERRIDE.put(toPe.getId(), new ItemEntry(pcId));
}
Aggregations