forked from GeyserMC/Geyser
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.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
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.EntityData;
|
||||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
||||||
|
@ -47,6 +48,7 @@ public class LivingEntity extends Entity {
|
||||||
protected ItemData leggings = ItemData.AIR;
|
protected ItemData leggings = ItemData.AIR;
|
||||||
protected ItemData boots = ItemData.AIR;
|
protected ItemData boots = ItemData.AIR;
|
||||||
protected ItemData hand = 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) {
|
public LivingEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
||||||
super(entityId, geyserId, entityType, position, motion, rotation);
|
super(entityId, geyserId, entityType, position, motion, rotation);
|
||||||
|
@ -80,12 +82,22 @@ public class LivingEntity extends Entity {
|
||||||
armorEquipmentPacket.setLeggings(leggings);
|
armorEquipmentPacket.setLeggings(leggings);
|
||||||
armorEquipmentPacket.setBoots(boots);
|
armorEquipmentPacket.setBoots(boots);
|
||||||
|
|
||||||
MobEquipmentPacket mobEquipmentPacket = new MobEquipmentPacket();
|
MobEquipmentPacket handPacket = new MobEquipmentPacket();
|
||||||
mobEquipmentPacket.setRuntimeEntityId(geyserId);
|
handPacket.setRuntimeEntityId(geyserId);
|
||||||
mobEquipmentPacket.setItem(hand);
|
handPacket.setItem(hand);
|
||||||
mobEquipmentPacket.setHotbarSlot(-1);
|
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(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);
|
livingEntity.setHand(item);
|
||||||
break;
|
break;
|
||||||
case OFF_HAND:
|
case OFF_HAND:
|
||||||
// TODO: livingEntity.setOffHand(item);
|
livingEntity.setOffHand(item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue