Wolf interactions

This commit is contained in:
AJ Ferguson 2024-04-23 19:12:20 -04:00 committed by Camotoy
parent 687d299ff5
commit bbaffb2ab3
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 23 additions and 7 deletions

View file

@ -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);
}

View file

@ -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.