9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-29 03:49:21 +00:00
Files
Leaf/patches/server/0043-Fix-MC-172047.patch
2024-05-25 17:06:00 +08:00

59 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: HaHaWTH <fsjk947@gmail.com>
Date: Fri, 15 Mar 2024 02:12:38 +0800
Subject: [PATCH] Fix MC-172047
Mojang issues: https://bugs.mojang.com/browse/MC-172047
diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
index 64bceae4d06b35fcbecb0daca2496ba30e39d995..47d1ca92aa71a6101496f8fdbd70d02ef75a55df 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
@@ -58,6 +58,7 @@ import net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal;
import net.minecraft.world.entity.ai.goal.target.ResetUniversalAngerTargetGoal;
import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.entity.animal.horse.Llama;
+import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.entity.monster.AbstractSkeleton;
import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.world.entity.monster.Ghast;
@@ -670,17 +671,29 @@ public class Wolf extends TamableAnimal implements NeutralMob {
@Override
public boolean wantsToAttack(LivingEntity target, LivingEntity owner) {
- if (!(target instanceof Creeper) && !(target instanceof Ghast)) {
- if (target instanceof Wolf) {
- Wolf entitywolf = (Wolf) target;
-
- return !entitywolf.isTame() || entitywolf.getOwner() != owner;
- } else {
- return target instanceof Player && owner instanceof Player && !((Player) owner).canHarmPlayer((Player) target) ? false : (target instanceof AbstractHorse && ((AbstractHorse) target).isTamed() ? false : !(target instanceof TamableAnimal) || !((TamableAnimal) target).isTame());
- }
- } else {
+ // Leaf start - Improve readability
+ if (target instanceof Creeper || target instanceof Ghast || target instanceof ArmorStand) { // Leaf - Fix MC-172047
return false;
}
+
+ if (target instanceof Wolf entityWolf) {
+ return !entityWolf.isTame() || entityWolf.getOwner() != owner;
+ }
+
+ if (target instanceof Player targetPlayer && owner instanceof Player ownerPlayer) {
+ return ownerPlayer.canHarmPlayer(targetPlayer);
+ }
+
+ if (target instanceof AbstractHorse targetHorse) {
+ return !targetHorse.isTamed();
+ }
+
+ if (target instanceof TamableAnimal tamableAnimalTarget) {
+ return !tamableAnimalTarget.isTame();
+ }
+
+ return true;
+ // Leaf end
}
@Override