Skip to content

Commit

Permalink
fix: Fix ProtocolEquipment#toNMSSlot()
Browse files Browse the repository at this point in the history
fix: NbtUtil中不会对生成的Profile设置UUID
  • Loading branch information
MATRIX-feather committed May 30, 2024
1 parent e5b2751 commit 27175f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ private static EquipmentSlot toNMSSlot(org.bukkit.inventory.EquipmentSlot bukkit
{
return switch (bukkitSlot)
{
case HAND -> net.minecraft.world.entity.EquipmentSlot.MAINHAND;
case OFF_HAND -> net.minecraft.world.entity.EquipmentSlot.OFFHAND;
case HAND -> EquipmentSlot.MAINHAND;
case OFF_HAND -> EquipmentSlot.OFFHAND;

case HEAD -> net.minecraft.world.entity.EquipmentSlot.HEAD;
case CHEST -> net.minecraft.world.entity.EquipmentSlot.CHEST;
case LEGS -> net.minecraft.world.entity.EquipmentSlot.LEGS;
case FEET -> net.minecraft.world.entity.EquipmentSlot.FEET;
case HEAD -> EquipmentSlot.HEAD;
case CHEST -> EquipmentSlot.CHEST;
case LEGS -> EquipmentSlot.LEGS;
case FEET -> EquipmentSlot.FEET;

case BODY -> throw new IllegalArgumentException("BODY is not supported.");
case BODY -> EquipmentSlot.BODY;
};
}

Expand All @@ -46,7 +46,10 @@ private static Pair<EquipmentSlot, ItemStack> toEquipmentPair(EntityEquipment eq
try
{
if (equipment instanceof CraftInventoryPlayer && bukkitSlot == org.bukkit.inventory.EquipmentSlot.BODY)
{
MorphPlugin.getInstance().getSLF4JLogger().info("Returning air...");
return Pair.of(toNMSSlot(bukkitSlot), ItemUtils.nmsAir);
}

var bukkitItem = equipment.getItem(bukkitSlot);
var nmsItem = ItemStack.fromBukkitCopy(bukkitItem);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/xiamomc/morph/utilities/NbtUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static GameProfile readGameProfile(String snbt)

UUID uuid = Util.NIL_UUID;
if (compound.hasUUID("Id"))
compound.getUUID("Id");
uuid = compound.getUUID("Id");

var profile = new MorphGameProfile(new GameProfile(uuid, name));

Expand Down

0 comments on commit 27175f9

Please sign in to comment.