diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/PathfinderMob.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/PathfinderMob.java.patch | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/PathfinderMob.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/PathfinderMob.java.patch new file mode 100644 index 0000000000..73b537e4e4 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/PathfinderMob.java.patch @@ -0,0 +1,112 @@ +--- a/net/minecraft/world/entity/PathfinderMob.java ++++ b/net/minecraft/world/entity/PathfinderMob.java +@@ -3,14 +3,17 @@ + import net.minecraft.core.BlockPos; + import net.minecraft.world.entity.ai.goal.Goal; + import net.minecraft.world.entity.ai.goal.PanicGoal; +-import net.minecraft.world.entity.ai.goal.WrappedGoal; + import net.minecraft.world.entity.ai.memory.MemoryModuleType; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.LevelAccessor; + import net.minecraft.world.level.LevelReader; + import net.minecraft.world.phys.Vec3; ++// CraftBukkit start ++import org.bukkit.event.entity.EntityUnleashEvent; ++// CraftBukkit end + + public abstract class PathfinderMob extends Mob { ++ + protected static final float DEFAULT_WALK_TARGET_VALUE = 0.0F; + + protected PathfinderMob(EntityType<? extends PathfinderMob> entityType, Level level) { +@@ -26,7 +29,7 @@ + } + + @Override +- public boolean checkSpawnRules(LevelAccessor level, MobSpawnType spawnReason) { ++ public boolean checkSpawnRules(LevelAccessor level, EnumMobSpawn spawnReason) { + return this.getWalkTargetValue(this.blockPosition(), level) >= 0.0F; + } + +@@ -35,20 +38,23 @@ + } + + public boolean isPanicking() { +- return this.brain.hasMemoryValue(MemoryModuleType.IS_PANICKING) +- ? this.brain.getMemory(MemoryModuleType.IS_PANICKING).isPresent() +- : this.goalSelector.getRunningGoals().anyMatch(wrappedGoal -> wrappedGoal.getGoal() instanceof PanicGoal); ++ return this.brain.hasMemoryValue(MemoryModuleType.IS_PANICKING) ? this.brain.getMemory(MemoryModuleType.IS_PANICKING).isPresent() : this.goalSelector.getRunningGoals().anyMatch((pathfindergoalwrapped) -> { ++ return pathfindergoalwrapped.getGoal() instanceof PanicGoal; ++ }); + } + + @Override + protected void tickLeash() { + super.tickLeash(); +- Entity leashHolder = this.getLeashHolder(); +- if (leashHolder != null && leashHolder.level() == this.level()) { +- this.restrictTo(leashHolder.blockPosition(), 5); +- float f = this.distanceTo(leashHolder); +- if (this instanceof TamableAnimal && ((TamableAnimal)this).isInSittingPose()) { ++ Entity entity = this.getLeashHolder(); ++ ++ if (entity != null && entity.level() == this.level()) { ++ this.restrictTo(entity.blockPosition(), 5); ++ float f = this.distanceTo(entity); ++ ++ if (this instanceof TamableAnimal && ((TamableAnimal) this).isInSittingPose()) { + if (f > 10.0F) { ++ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit + this.dropLeash(true, true); + } + +@@ -57,25 +63,25 @@ + + this.onLeashDistance(f); + if (f > 10.0F) { ++ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit + this.dropLeash(true, true); +- this.goalSelector.disableControlFlag(Goal.Flag.MOVE); ++ this.goalSelector.disableControlFlag(Goal.Type.MOVE); + } else if (f > 6.0F) { +- double d = (leashHolder.getX() - this.getX()) / (double)f; +- double d1 = (leashHolder.getY() - this.getY()) / (double)f; +- double d2 = (leashHolder.getZ() - this.getZ()) / (double)f; +- this.setDeltaMovement( +- this.getDeltaMovement().add(Math.copySign(d * d * 0.4, d), Math.copySign(d1 * d1 * 0.4, d1), Math.copySign(d2 * d2 * 0.4, d2)) +- ); ++ double d0 = (entity.getX() - this.getX()) / (double) f; ++ double d1 = (entity.getY() - this.getY()) / (double) f; ++ double d2 = (entity.getZ() - this.getZ()) / (double) f; ++ ++ this.setDeltaMovement(this.getDeltaMovement().add(Math.copySign(d0 * d0 * 0.4D, d0), Math.copySign(d1 * d1 * 0.4D, d1), Math.copySign(d2 * d2 * 0.4D, d2))); + this.checkSlowFallDistance(); + } else if (this.shouldStayCloseToLeashHolder() && !this.isPanicking()) { +- this.goalSelector.enableControlFlag(Goal.Flag.MOVE); ++ this.goalSelector.enableControlFlag(Goal.Type.MOVE); + float f1 = 2.0F; +- Vec3 vec3 = new Vec3(leashHolder.getX() - this.getX(), leashHolder.getY() - this.getY(), leashHolder.getZ() - this.getZ()) +- .normalize() +- .scale((double)Math.max(f - 2.0F, 0.0F)); +- this.getNavigation().moveTo(this.getX() + vec3.x, this.getY() + vec3.y, this.getZ() + vec3.z, this.followLeashSpeed()); ++ Vec3 vec3d = (new Vec3(entity.getX() - this.getX(), entity.getY() - this.getY(), entity.getZ() - this.getZ())).normalize().scale((double) Math.max(f - 2.0F, 0.0F)); ++ ++ this.getNavigation().moveTo(this.getX() + vec3d.x, this.getY() + vec3d.y, this.getZ() + vec3d.z, this.followLeashSpeed()); + } + } ++ + } + + protected boolean shouldStayCloseToLeashHolder() { +@@ -83,9 +89,8 @@ + } + + protected double followLeashSpeed() { +- return 1.0; ++ return 1.0D; + } + +- protected void onLeashDistance(float distance) { +- } ++ protected void onLeashDistance(float distance) {} + } |