mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add support for offhand
This commit is contained in:
parent
b18b83fd9a
commit
fa7324e1f5
2 changed files with 18 additions and 6 deletions
|
@ -27,6 +27,7 @@ package org.geysermc.connector.entity;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.data.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
||||
|
@ -47,6 +48,7 @@ public class LivingEntity extends Entity {
|
|||
protected ItemData leggings = ItemData.AIR;
|
||||
protected ItemData boots = ItemData.AIR;
|
||||
protected ItemData hand = ItemData.AIR;
|
||||
protected ItemData offHand = ItemData.AIR;
|
||||
|
||||
public LivingEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
||||
super(entityId, geyserId, entityType, position, motion, rotation);
|
||||
|
@ -80,12 +82,22 @@ public class LivingEntity extends Entity {
|
|||
armorEquipmentPacket.setLeggings(leggings);
|
||||
armorEquipmentPacket.setBoots(boots);
|
||||
|
||||
MobEquipmentPacket mobEquipmentPacket = new MobEquipmentPacket();
|
||||
mobEquipmentPacket.setRuntimeEntityId(geyserId);
|
||||
mobEquipmentPacket.setItem(hand);
|
||||
mobEquipmentPacket.setHotbarSlot(-1);
|
||||
MobEquipmentPacket handPacket = new MobEquipmentPacket();
|
||||
handPacket.setRuntimeEntityId(geyserId);
|
||||
handPacket.setItem(hand);
|
||||
handPacket.setHotbarSlot(-1);
|
||||
handPacket.setInventorySlot(0);
|
||||
handPacket.setContainerId(ContainerId.INVENTORY);
|
||||
|
||||
MobEquipmentPacket offHandPacket = new MobEquipmentPacket();
|
||||
offHandPacket.setRuntimeEntityId(geyserId);
|
||||
offHandPacket.setItem(offHand);
|
||||
offHandPacket.setHotbarSlot(-1);
|
||||
offHandPacket.setInventorySlot(0);
|
||||
offHandPacket.setContainerId(ContainerId.OFFHAND);
|
||||
|
||||
session.getUpstream().sendPacket(armorEquipmentPacket);
|
||||
session.getUpstream().sendPacket(mobEquipmentPacket);
|
||||
session.getUpstream().sendPacket(handPacket);
|
||||
session.getUpstream().sendPacket(offHandPacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class JavaEntityEquipmentTranslator extends PacketTranslator<ServerEntity
|
|||
livingEntity.setHand(item);
|
||||
break;
|
||||
case OFF_HAND:
|
||||
// TODO: livingEntity.setOffHand(item);
|
||||
livingEntity.setOffHand(item);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue