From bbaffb2ab38a825c0ab4ec7a360bf0ac831fa773 Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Tue, 23 Apr 2024 19:12:20 -0400 Subject: [PATCH] Wolf interactions --- .../living/animal/tameable/WolfEntity.java | 25 ++++++++++++++----- .../geysermc/geyser/util/InteractiveTag.java | 5 +++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java index ee7281772..ff130aeff 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java @@ -133,16 +133,29 @@ public class WolfEntity extends TameableEntity { if (itemInHand.asItem() == Items.BONE && !getFlag(EntityFlag.TAMED)) { // Bone and untamed - can tame return InteractiveTag.TAME; - } else { - if (itemInHand.asItem() instanceof DyeItem item) { + } + if (getFlag(EntityFlag.TAMED) && ownerBedrockId == session.getPlayerEntity().getGeyserId()) { + if (itemInHand.asItem() instanceof DyeItem dyeItem) { // If this fails, as of Java Edition 1.18.1, you cannot toggle sit/stand - if (item.dyeColor() != this.collarColor) { + if (dyeItem.dyeColor() != this.collarColor) { return InteractiveTag.DYE; + } else { + return super.testMobInteraction(hand, itemInHand); } - } else if (getFlag(EntityFlag.TAMED) && ownerBedrockId == session.getPlayerEntity().getGeyserId()) { - // Tamed and owned by player - can sit/stand - return getFlag(EntityFlag.SITTING) ? InteractiveTag.STAND : InteractiveTag.SIT; } + if (itemInHand.asItem() == Items.WOLF_ARMOR && !this.chestplate.isValid() && !getFlag(EntityFlag.BABY)) { + return InteractiveTag.EQUIP_WOLF_ARMOR; + } + if (itemInHand.asItem() == Items.SHEARS && this.chestplate.isValid()) { // TODO: check curse of binding + return InteractiveTag.REMOVE_WOLF_ARMOR; + } + if (Items.WOLF_ARMOR.isValidRepairItem(itemInHand.asItem()) && getFlag(EntityFlag.SITTING) && + this.chestplate.isValid() && this.chestplate.getTag() != null && + this.chestplate.getTag().getInt("Damage") > 0) { + return InteractiveTag.REPAIR_WOLF_ARMOR; + } + // Tamed and owned by player - can sit/stand + return getFlag(EntityFlag.SITTING) ? InteractiveTag.STAND : InteractiveTag.SIT; } return super.testMobInteraction(hand, itemInHand); } diff --git a/core/src/main/java/org/geysermc/geyser/util/InteractiveTag.java b/core/src/main/java/org/geysermc/geyser/util/InteractiveTag.java index 9607ac61e..168c861f5 100644 --- a/core/src/main/java/org/geysermc/geyser/util/InteractiveTag.java +++ b/core/src/main/java/org/geysermc/geyser/util/InteractiveTag.java @@ -70,7 +70,10 @@ public enum InteractiveTag { READ, WAKE_VILLAGER("wakevillager"), BARTER, - GIVE_ITEM_TO_ALLAY("allay"); + GIVE_ITEM_TO_ALLAY("allay"), + EQUIP_WOLF_ARMOR("equipwolfarmor"), + REMOVE_WOLF_ARMOR("removewolfarmor"), + REPAIR_WOLF_ARMOR("repairwolfarmor"); /** * The full string that should be passed on to the client.