Remove Y pos workaround in BedrockItemFrameDropItemTranslator (#1037)

This commit is contained in:
AJ Ferguson 2020-08-01 10:41:59 -08:00 committed by GitHub
parent 07f3d45cc4
commit 86f18c9392
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,15 +40,7 @@ public class BedrockItemFrameDropItemTranslator extends PacketTranslator<ItemFra
@Override @Override
public void translate(ItemFrameDropItemPacket packet, GeyserSession session) { public void translate(ItemFrameDropItemPacket packet, GeyserSession session) {
// I hope that, when we die, God (or whoever is waiting for us) tells us exactly why this code exists Vector3i position = Vector3i.from(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
// The packet sends the Y coordinate (and just the Y coordinate) divided by two, and it's negative if it needs to be subtracted by one
int y;
if (packet.getBlockPosition().getY() > 0) {
y = packet.getBlockPosition().getY() * 2;
} else {
y = (packet.getBlockPosition().getY() * -2) - 1;
}
Vector3i position = Vector3i.from(packet.getBlockPosition().getX(), y, packet.getBlockPosition().getZ());
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, position), ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, position),
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking()); InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
session.sendDownstreamPacket(interactPacket); session.sendDownstreamPacket(interactPacket);