Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
31699ae9a8
* Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: a6a9d2a4 Remove some old ApiStatus.Experimental annotations be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration 08f86d1c PR-971: Add Player methods for client-side potion effects 2e3024a9 PR-963: Add API for in-world structures a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality 1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent CraftBukkit Changes: 38fd4bd50 Fix accidentally renamed internal damage method 80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage 7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects 4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration 22a541a29 Improve support for per-world game rules cb7dccce2 PR-1348: Add Player methods for client-side potion effects b8d6109f0 PR-1335: Add API for in-world structures 4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity e74107678 Fix Crafter maximum stack size 0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality 4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason 20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette 3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook 333701839 SPIGOT-7572: Bee nests generated without bees f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
100 Zeilen
7.4 KiB
Diff
100 Zeilen
7.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Mon, 10 Sep 2018 23:56:36 -0400
|
|
Subject: [PATCH] Prevent various interactions from causing chunk loads
|
|
|
|
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
|
index e3d070d46729c023d594699619a4b3f8658edbce..5580a396a56c6e0f364a5368985ee99b9e2be0a8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
|
@@ -126,7 +126,9 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
|
|
|
@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()};
|
|
@@ -136,7 +138,8 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
|
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;
|
|
}
|
|
}
|
|
@@ -147,7 +150,7 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
|
|
|
@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/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
|
index 13ba764d51f941c2b0d1d2af88ffd0c1fc3982c0..9637c26a3c381869f0a4dfe9189c0095387009b4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
|
@@ -517,7 +517,8 @@ public class EnderMan extends Monster implements NeutralMob {
|
|
int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 2.0D);
|
|
int k = Mth.floor(this.enderman.getZ() - 1.0D + randomsource.nextDouble() * 2.0D);
|
|
BlockPos blockposition = new BlockPos(i, j, k);
|
|
- BlockState iblockdata = world.getBlockState(blockposition);
|
|
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper - Prevent endermen from loading chunks
|
|
+ if (iblockdata == null) return; // Paper - Prevent endermen from loading chunks
|
|
BlockPos blockposition1 = blockposition.below();
|
|
BlockState iblockdata1 = world.getBlockState(blockposition1);
|
|
BlockState iblockdata2 = this.enderman.getCarriedBlock();
|
|
@@ -561,7 +562,8 @@ public class EnderMan extends Monster implements NeutralMob {
|
|
int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 3.0D);
|
|
int k = Mth.floor(this.enderman.getZ() - 2.0D + randomsource.nextDouble() * 4.0D);
|
|
BlockPos blockposition = new BlockPos(i, j, k);
|
|
- BlockState iblockdata = world.getBlockState(blockposition);
|
|
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper - Prevent endermen from loading chunks
|
|
+ if (iblockdata == null) return; // Paper - Prevent endermen from loading chunks
|
|
Vec3 vec3d = new Vec3((double) this.enderman.getBlockX() + 0.5D, (double) j + 0.5D, (double) this.enderman.getBlockZ() + 0.5D);
|
|
Vec3 vec3d1 = new Vec3((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D);
|
|
BlockHitResult movingobjectpositionblock = world.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.enderman));
|
|
diff --git a/src/main/java/net/minecraft/world/item/CompassItem.java b/src/main/java/net/minecraft/world/item/CompassItem.java
|
|
index 5d3047a420efe59063e90bfc7b42392127e0ad7d..b3c67c954acf7e518d89d6af65a55d6f22dac059 100644
|
|
--- a/src/main/java/net/minecraft/world/item/CompassItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/CompassItem.java
|
|
@@ -77,7 +77,7 @@ public class CompassItem extends Item implements Vanishable {
|
|
Optional<ResourceKey<Level>> optional = getLodestoneDimension(compoundTag);
|
|
if (optional.isPresent() && optional.get() == world.dimension() && compoundTag.contains("LodestonePos")) {
|
|
BlockPos blockPos = NbtUtils.readBlockPos(compoundTag.getCompound("LodestonePos"));
|
|
- if (!world.isInWorldBounds(blockPos) || !((ServerLevel)world).getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos)) {
|
|
+ if (!world.isInWorldBounds(blockPos) || (world.hasChunkAt(blockPos) && !((ServerLevel)world).getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos))) { // Paper - Prevent compass from loading chunks
|
|
compoundTag.remove("LodestonePos");
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
|
index d6d8bbc98fc71997cb52521d59ebb59d727d3c22..c3760e0c8ac0b3ea200f4e1c237e250137a78caf 100644
|
|
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
|
|
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
|
@@ -70,7 +70,15 @@ public interface BlockGetter extends LevelHeightAccessor {
|
|
|
|
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
|
|
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
|
|
- BlockState iblockdata = this.getBlockState(blockposition);
|
|
+ // Paper start - Prevent raytrace from loading chunks
|
|
+ BlockState iblockdata = this.getBlockStateIfLoaded(blockposition);
|
|
+ if (iblockdata == null) {
|
|
+ // copied the last function parameter (listed below)
|
|
+ Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo());
|
|
+
|
|
+ return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo()));
|
|
+ }
|
|
+ // Paper end - Prevent raytrace from loading chunks
|
|
FluidState fluid = this.getFluidState(blockposition);
|
|
Vec3 vec3d = raytrace1.getFrom();
|
|
Vec3 vec3d1 = raytrace1.getTo();
|