Skip to content

Commit

Permalink
Merge pull request #78 from AJ-Ferguson/master
Browse files Browse the repository at this point in the history
Fix dropped items
  • Loading branch information
Redned235 authored Nov 10, 2019
2 parents 7ce4b22 + e676a42 commit c83bfe6
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@
package org.geysermc.connector.network.translators.java.entity;

import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityMetadataPacket;
import com.nukkitx.protocol.bedrock.data.EntityFlag;
import com.nukkitx.protocol.bedrock.packet.AddItemEntityPacket;
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.TranslatorsInit;

public class JavaEntityMetadataTranslator extends PacketTranslator<ServerEntityMetadataPacket> {

Expand All @@ -51,6 +55,17 @@ public void translate(ServerEntityMetadataPacket packet, GeyserSession session)
byte xd = (byte)metadata.getValue();
entity.getMetadata().getFlags().setFlag(EntityFlag.SPRINTING, (xd & 0x08) == 0x08);
entity.getMetadata().getFlags().setFlag(EntityFlag.SNEAKING, (xd & 0x02) == 0x02);
} else if (entity.getEntityType() == EntityType.ITEM && metadata.getId() == 7) {
AddItemEntityPacket itemPacket = new AddItemEntityPacket();
itemPacket.setRuntimeEntityId(entity.getGeyserId());
itemPacket.setPosition(entity.getPosition());
itemPacket.setMotion(entity.getMotion());
itemPacket.setUniqueEntityId(entity.getGeyserId());
itemPacket.setFromFishing(false);
itemPacket.getMetadata().putAll(entity.getMetadata());
itemPacket.setItemInHand(TranslatorsInit.getItemTranslator().translateToBedrock((ItemStack) metadata.getValue()));
session.getUpstream().sendPacket(itemPacket);
return;
}
}

Expand Down

0 comments on commit c83bfe6

Please sign in to comment.