From aaf151c03d48f51b10f278e26143dd8ea9db6acb Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 14 Dec 2024 18:55:46 -0800 Subject: [PATCH] net.minecraft.world.entity.ai.goal --- .../entity/ai/goal/BreakDoorGoal.java.patch | 4 +- .../entity/ai/goal/EatBlockGoal.java.patch | 35 ++++++++++++ .../world/entity/ai/goal/FloatGoal.java.patch | 2 +- .../entity/ai/goal/FollowOwnerGoal.java.patch | 10 ++-- .../world/entity/ai/goal/Goal.java.patch | 13 +++-- .../entity/ai/goal/RemoveBlockGoal.java.patch | 42 ++++++++++++++ .../ai/goal/RunAroundLikeCrazyGoal.java.patch | 11 ++++ .../ai/goal/SitWhenOrderedToGoal.java.patch | 2 +- .../world/entity/ai/goal/SwellGoal.java.patch | 12 ++-- .../world/entity/ai/goal/TemptGoal.java.patch | 27 +++++++++ .../entity/ai/goal/EatBlockGoal.java.patch | 46 ---------------- .../entity/ai/goal/RemoveBlockGoal.java.patch | 55 ------------------- .../ai/goal/RunAroundLikeCrazyGoal.java.patch | 22 -------- .../world/entity/ai/goal/TemptGoal.java.patch | 44 --------------- 14 files changed, 137 insertions(+), 188 deletions(-) rename paper-server/patches/{unapplied => sources}/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch (98%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch rename paper-server/patches/{unapplied => sources}/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch (96%) rename paper-server/patches/{unapplied => sources}/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch (51%) rename paper-server/patches/{unapplied => sources}/net/minecraft/world/entity/ai/goal/Goal.java.patch (82%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch rename paper-server/patches/{unapplied => sources}/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch (96%) rename paper-server/patches/{unapplied => sources}/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch (60%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch delete mode 100644 paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch similarity index 98% rename from paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch index 8323bfa7ee..9fd1ccd71c 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java +++ b/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java -@@ -72,9 +72,16 @@ +@@ -73,9 +_,16 @@ } if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level().getDifficulty())) { @@ -16,5 +16,5 @@ - this.mob.level().levelEvent(2001, this.doorPos, Block.getId(this.mob.level().getBlockState(this.doorPos))); + this.mob.level().levelEvent(2001, this.doorPos, Block.getId(oldState)); // Paper - fix MC-263999 } - } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch new file mode 100644 index 0000000000..8cc09baa9d --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -0,0 +1,35 @@ +--- a/net/minecraft/world/entity/ai/goal/EatBlockGoal.java ++++ b/net/minecraft/world/entity/ai/goal/EatBlockGoal.java +@@ -26,6 +_,11 @@ + + @Override + public boolean canUse() { ++ // Paper start - Fix MC-210802 ++ if (!((net.minecraft.server.level.ServerLevel) this.level).chunkSource.chunkMap.anyPlayerCloseEnoughForSpawning(this.mob.chunkPosition())) { ++ return false; ++ } ++ // Paper end + if (this.mob.getRandom().nextInt(this.mob.isBaby() ? 50 : 1000) != 0) { + return false; + } else { +@@ -60,8 +_,9 @@ + this.eatAnimationTick = Math.max(0, this.eatAnimationTick - 1); + if (this.eatAnimationTick == this.adjustedTickDelay(4)) { + BlockPos blockPos = this.mob.blockPosition(); +- if (IS_TALL_GRASS.test(this.level.getBlockState(blockPos))) { +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ final BlockState blockState = this.level.getBlockState(blockPos); // Paper - fix wrong block state ++ if (IS_TALL_GRASS.test(blockState)) { // Paper - fix wrong block state ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos, blockState.getFluidState().createLegacyBlock(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - fix wrong block state + this.level.destroyBlock(blockPos, false); + } + +@@ -69,7 +_,7 @@ + } else { + BlockPos blockPos1 = blockPos.below(); + if (this.level.getBlockState(blockPos1).is(Blocks.GRASS_BLOCK)) { +- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos1, Blocks.DIRT.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - Fix wrong block state + this.level.levelEvent(2001, blockPos1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); + this.level.setBlock(blockPos1, Blocks.DIRT.defaultBlockState(), 2); + } diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch similarity index 96% rename from paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch index ed90ccea87..0fab13edb2 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FloatGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/FloatGoal.java +++ b/net/minecraft/world/entity/ai/goal/FloatGoal.java -@@ -9,6 +9,7 @@ +@@ -9,6 +_,7 @@ public FloatGoal(Mob mob) { this.mob = mob; diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch similarity index 51% rename from paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch index 4cdf53ef91..32807a319e 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java +++ b/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java -@@ -72,7 +72,7 @@ +@@ -72,7 +_,7 @@ public void tick() { - boolean bl = this.tamable.shouldTryTeleportToOwner(); - if (!bl) { -- this.tamable.getLookControl().setLookAt(this.owner, 10.0F, (float)this.tamable.getMaxHeadXRot()); -+ if (this.tamable.distanceToSqr(this.owner) <= 16 * 16) this.tamable.getLookControl().setLookAt(this.owner, 10.0F, (float)this.tamable.getMaxHeadXRot()); // Paper - Limit pet look distance + boolean shouldTryTeleportToOwner = this.tamable.shouldTryTeleportToOwner(); + if (!shouldTryTeleportToOwner) { +- this.tamable.getLookControl().setLookAt(this.owner, 10.0F, this.tamable.getMaxHeadXRot()); ++ if (this.tamable.distanceToSqr(this.owner) <= 16 * 16) this.tamable.getLookControl().setLookAt(this.owner, 10.0F, this.tamable.getMaxHeadXRot()); // Paper - Limit pet look distance } if (--this.timeToRecalcPath <= 0) { diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/Goal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch similarity index 82% rename from paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/Goal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch index a354e63b19..34a28aaf49 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/Goal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch @@ -1,9 +1,10 @@ --- a/net/minecraft/world/entity/ai/goal/Goal.java +++ b/net/minecraft/world/entity/ai/goal/Goal.java -@@ -46,6 +46,16 @@ +@@ -46,6 +_,17 @@ return this.flags; } ++ + // Paper start - Mob Goal API + public boolean hasFlag(final Goal.Flag flag) { + return this.flags.contains(flag); @@ -12,13 +13,13 @@ + public void addFlag(final Goal.Flag flag) { + this.flags.add(flag); + } -+ // Paper end - Mob Goal API + - protected int adjustedTickDelay(int ticks) { - return this.requiresUpdateEveryTick() ? ticks : reducedTickDelay(ticks); ++ // Paper end - Mob Goal API + protected int adjustedTickDelay(int adjustment) { + return this.requiresUpdateEveryTick() ? adjustment : reducedTickDelay(adjustment); } -@@ -62,7 +72,19 @@ - return (ServerLevel)world; +@@ -62,7 +_,19 @@ + return (ServerLevel)level; } + // Paper start - Mob goal api diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch new file mode 100644 index 0000000000..16ce65055d --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java ++++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java +@@ -104,6 +_,11 @@ + } + + if (this.ticksSinceReachedGoal > 60) { ++ // CraftBukkit start - Step on eggs ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityInteractEvent(this.removerMob, org.bukkit.craftbukkit.block.CraftBlock.at(level, posWithBlock))) { ++ return; ++ } ++ // CraftBukkit end + level.removeBlock(posWithBlock, false); + if (!level.isClientSide) { + for (int i = 0; i < 20; i++) { +@@ -124,13 +_,16 @@ + + @Nullable + private BlockPos getPosWithBlock(BlockPos pos, BlockGetter level) { +- if (level.getBlockState(pos).is(this.blockToRemove)) { ++ net.minecraft.world.level.block.state.BlockState block = level.getBlockStateIfLoaded(pos); // Paper - Prevent AI rules from loading chunks ++ if (block == null) return null; // Paper - Prevent AI rules from loading chunks ++ if (block.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks + return pos; + } else { + BlockPos[] blockPoss = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()}; + + for (BlockPos blockPos : blockPoss) { +- if (level.getBlockState(blockPos).is(this.blockToRemove)) { ++ net.minecraft.world.level.block.state.BlockState block2 = level.getBlockStateIfLoaded(blockPos); // Paper - Prevent AI rules from loading chunks ++ if (block2 != null && block2.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks + return blockPos; + } + } +@@ -141,7 +_,7 @@ + + @Override + protected boolean isValidTarget(LevelReader level, BlockPos pos) { +- ChunkAccess chunk = level.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()), ChunkStatus.FULL, false); ++ ChunkAccess chunk = level.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); // Paper - Prevent AI rules from loading chunks + return chunk != null + && chunk.getBlockState(pos).is(this.blockToRemove) + && chunk.getBlockState(pos.above()).isAir() diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch new file mode 100644 index 0000000000..bab3ed29fe --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java ++++ b/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java +@@ -58,7 +_,7 @@ + if (firstPassenger instanceof Player player) { + int temper = this.horse.getTemper(); + int maxTemper = this.horse.getMaxTemper(); +- if (maxTemper > 0 && this.horse.getRandom().nextInt(maxTemper) < temper) { ++ if (maxTemper > 0 && this.horse.getRandom().nextInt(maxTemper) < temper && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { // CraftBukkit - fire EntityTameEvent + this.horse.tameWithName(player); + return; + } diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch similarity index 96% rename from paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch index 64830b4a5b..d467f6a9a1 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java +++ b/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java -@@ -22,7 +22,7 @@ +@@ -20,7 +_,7 @@ @Override public boolean canUse() { if (!this.mob.isTame()) { diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch similarity index 60% rename from paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch index 885e0fd98c..acde7d31dd 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SwellGoal.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/entity/ai/goal/SwellGoal.java +++ b/net/minecraft/world/entity/ai/goal/SwellGoal.java -@@ -21,7 +21,14 @@ - return this.creeper.getSwellDir() > 0 || livingEntity != null && this.creeper.distanceToSqr(livingEntity) < 9.0; +@@ -21,6 +_,14 @@ + return this.creeper.getSwellDir() > 0 || target != null && this.creeper.distanceToSqr(target) < 9.0; } + // Paper start - Fix MC-179072 - @Override ++ @Override + public boolean canContinueToUse() { -+ return !net.minecraft.world.entity.EntitySelector.NO_CREATIVE_OR_SPECTATOR.test(this.creeper.getTarget()) && canUse(); ++ return !net.minecraft.world.entity.EntitySelector.NO_CREATIVE_OR_SPECTATOR.test(this.creeper.getTarget()) && this.canUse(); + } + // Paper end + -+ @Override ++ + @Override public void start() { this.creeper.getNavigation().stop(); - this.target = this.creeper.getTarget(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch new file mode 100644 index 0000000000..96b15bc9f4 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/world/entity/ai/goal/TemptGoal.java ++++ b/net/minecraft/world/entity/ai/goal/TemptGoal.java +@@ -21,7 +_,7 @@ + private double pRotX; + private double pRotY; + @Nullable +- protected Player player; ++ protected LivingEntity player; // CraftBukkit + private int calmDown; + private boolean isRunning; + private final Predicate items; +@@ -44,6 +_,15 @@ + } else { + this.player = getServerLevel(this.mob) + .getNearestPlayer(this.targetingConditions.range(this.mob.getAttributeValue(Attributes.TEMPT_RANGE)), this.mob); ++ // CraftBukkit start ++ if (this.player != null) { ++ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TEMPT); ++ if (event.isCancelled()) { ++ return false; ++ } ++ this.player = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); ++ } ++ // CraftBukkit end + return this.player != null; + } + } diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch deleted file mode 100644 index 72de1e0703..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ /dev/null @@ -1,46 +0,0 @@ ---- a/net/minecraft/world/entity/ai/goal/EatBlockGoal.java -+++ b/net/minecraft/world/entity/ai/goal/EatBlockGoal.java -@@ -11,6 +11,10 @@ - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+// CraftBukkit end -+ - public class EatBlockGoal extends Goal { - - private static final int EAT_ANIMATION_TICKS = 40; -@@ -27,6 +31,11 @@ - - @Override - public boolean canUse() { -+ // Paper start - Fix MC-210802 -+ if (!((net.minecraft.server.level.ServerLevel) this.level).chunkSource.chunkMap.anyPlayerCloseEnoughForSpawning(this.mob.chunkPosition())) { -+ return false; -+ } -+ // Paper end - if (this.mob.getRandom().nextInt(this.mob.isBaby() ? 50 : 1000) != 0) { - return false; - } else { -@@ -63,8 +72,9 @@ - if (this.eatAnimationTick == this.adjustedTickDelay(4)) { - BlockPos blockposition = this.mob.blockPosition(); - -- if (EatBlockGoal.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) { -- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ final BlockState blockState = this.level.getBlockState(blockposition); // Paper - fix wrong block state -+ if (EatBlockGoal.IS_TALL_GRASS.test(blockState)) { // Paper - fix wrong block state -+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, blockState.getFluidState().createLegacyBlock(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - fix wrong block state - this.level.destroyBlock(blockposition, false); - } - -@@ -73,7 +83,7 @@ - BlockPos blockposition1 = blockposition.below(); - - if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) { -- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.DIRT.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - Fix wrong block state - this.level.levelEvent(2001, blockposition1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); - this.level.setBlock(blockposition1, Blocks.DIRT.defaultBlockState(), 2); - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch b/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch deleted file mode 100644 index 2111952674..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java -+++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java -@@ -21,6 +21,10 @@ - import net.minecraft.world.level.chunk.ChunkAccess; - import net.minecraft.world.level.chunk.status.ChunkStatus; - import net.minecraft.world.phys.Vec3; -+// CraftBukkit start -+import org.bukkit.craftbukkit.block.CraftBlock; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+// CraftBukkit end - - public class RemoveBlockGoal extends MoveToBlockGoal { - -@@ -97,6 +101,11 @@ - } - - if (this.ticksSinceReachedGoal > 60) { -+ // CraftBukkit start - Step on eggs -+ if (!CraftEventFactory.callEntityInteractEvent(this.removerMob, CraftBlock.at(world, blockposition1))) { -+ return; -+ } -+ // CraftBukkit end - world.removeBlock(blockposition1, false); - if (!world.isClientSide) { - for (int i = 0; i < 20; ++i) { -@@ -118,7 +127,9 @@ - - @Nullable - private BlockPos getPosWithBlock(BlockPos pos, BlockGetter world) { -- if (world.getBlockState(pos).is(this.blockToRemove)) { -+ net.minecraft.world.level.block.state.BlockState block = world.getBlockStateIfLoaded(pos); // Paper - Prevent AI rules from loading chunks -+ if (block == null) return null; // Paper - Prevent AI rules from loading chunks -+ if (block.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks - return pos; - } else { - BlockPos[] ablockposition = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()}; -@@ -128,7 +139,8 @@ - for (int j = 0; j < i; ++j) { - BlockPos blockposition1 = ablockposition1[j]; - -- if (world.getBlockState(blockposition1).is(this.blockToRemove)) { -+ net.minecraft.world.level.block.state.BlockState block2 = world.getBlockStateIfLoaded(blockposition1); // Paper - Prevent AI rules from loading chunks -+ if (block2 != null && block2.is(this.blockToRemove)) { // Paper - Prevent AI rules from loading chunks - return blockposition1; - } - } -@@ -139,7 +151,7 @@ - - @Override - protected boolean isValidTarget(LevelReader world, BlockPos pos) { -- ChunkAccess ichunkaccess = world.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()), ChunkStatus.FULL, false); -+ ChunkAccess ichunkaccess = world.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); // Paper - Prevent AI rules from loading chunks - - return ichunkaccess == null ? false : ichunkaccess.getBlockState(pos).is(this.blockToRemove) && ichunkaccess.getBlockState(pos.above()).isAir() && ichunkaccess.getBlockState(pos.above(2)).isAir(); - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch b/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch deleted file mode 100644 index 4f41b508ea..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java -+++ b/net/minecraft/world/entity/ai/goal/RunAroundLikeCrazyGoal.java -@@ -6,6 +6,10 @@ - import net.minecraft.world.entity.animal.horse.AbstractHorse; - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.phys.Vec3; -+// CraftBukkit start -+import org.bukkit.craftbukkit.entity.CraftHumanEntity; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+// CraftBukkit end - - public class RunAroundLikeCrazyGoal extends Goal { - -@@ -63,7 +67,7 @@ - int i = this.horse.getTemper(); - int j = this.horse.getMaxTemper(); - -- if (j > 0 && this.horse.getRandom().nextInt(j) < i) { -+ if (j > 0 && this.horse.getRandom().nextInt(j) < i && !CraftEventFactory.callEntityTameEvent(this.horse, ((CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { // CraftBukkit - fire EntityTameEvent - this.horse.tameWithName(entityhuman); - return; - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch b/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch deleted file mode 100644 index 8d33e61ef6..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/entity/ai/goal/TemptGoal.java.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- a/net/minecraft/world/entity/ai/goal/TemptGoal.java -+++ b/net/minecraft/world/entity/ai/goal/TemptGoal.java -@@ -8,9 +8,15 @@ - import net.minecraft.world.entity.PathfinderMob; - import net.minecraft.world.entity.ai.attributes.Attributes; - import net.minecraft.world.entity.ai.targeting.TargetingConditions; --import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.ItemStack; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.entity.CraftLivingEntity; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.event.entity.EntityTargetEvent; -+import org.bukkit.event.entity.EntityTargetLivingEntityEvent; -+// CraftBukkit end -+ - public class TemptGoal extends Goal { - - private static final TargetingConditions TEMPT_TARGETING = TargetingConditions.forNonCombat().ignoreLineOfSight(); -@@ -23,7 +29,7 @@ - private double pRotX; - private double pRotY; - @Nullable -- protected Player player; -+ protected LivingEntity player; // CraftBukkit - private int calmDown; - private boolean isRunning; - private final Predicate items; -@@ -47,6 +53,15 @@ - return false; - } else { - this.player = getServerLevel((Entity) this.mob).getNearestPlayer(this.targetingConditions.range(this.mob.getAttributeValue(Attributes.TEMPT_RANGE)), this.mob); -+ // CraftBukkit start -+ if (this.player != null) { -+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, EntityTargetEvent.TargetReason.TEMPT); -+ if (event.isCancelled()) { -+ return false; -+ } -+ this.player = (event.getTarget() == null) ? null : ((CraftLivingEntity) event.getTarget()).getHandle(); -+ } -+ // CraftBukkit end - return this.player != null; - } - }