mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-22 15:05:35 +01:00
Patches
This commit is contained in:
parent
078eb7f455
commit
3342d91bd6
32 changed files with 143 additions and 158 deletions
|
@ -317,7 +317,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
entity.setPortalCooldown();
|
entity.setPortalCooldown();
|
||||||
+ entity.fromNetherPortal = true; // Paper - Add option to nerf pigmen from nether portals
|
+ // Paper start - Add option to nerf pigmen from nether portals
|
||||||
+ if (world.paperConfig().entities.behavior.nerfPigmenFromNetherPortals) ((net.minecraft.world.entity.Mob) entity).aware = false; // Paper - Add option to nerf pigmen from nether portals
|
+ entity.fromNetherPortal = true;
|
||||||
}
|
+ if (world.paperConfig().entities.behavior.nerfPigmenFromNetherPortals) ((net.minecraft.world.entity.Mob) entity).aware = false;
|
||||||
}
|
+ // Paper end - Add option to nerf pigmen from nether portals
|
||||||
}
|
Entity entity1 = entity.getVehicle();
|
||||||
|
|
||||||
|
if (entity1 != null) {
|
|
@ -141,17 +141,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
private KeyPair keyPair;
|
private KeyPair keyPair;
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
this.aggregatedTickTimesNanos += j;
|
this.aggregatedTickTimesNanos += k;
|
||||||
this.tickTimesNanos[k] = j;
|
this.tickTimesNanos[l] = k;
|
||||||
this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) j / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F;
|
this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) k / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F;
|
||||||
+ // Paper start - Add tick times API and /mspt command
|
+ // Paper start - Add tick times API and /mspt command
|
||||||
+ this.tickTimes5s.add(this.tickCount, j);
|
+ this.tickTimes5s.add(this.tickCount, j);
|
||||||
+ this.tickTimes10s.add(this.tickCount, j);
|
+ this.tickTimes10s.add(this.tickCount, j);
|
||||||
+ this.tickTimes60s.add(this.tickCount, j);
|
+ this.tickTimes60s.add(this.tickCount, j);
|
||||||
+ // Paper end - Add tick times API and /mspt command
|
+ // Paper end - Add tick times API and /mspt command
|
||||||
this.logTickMethodTime(i);
|
this.logTickMethodTime(i);
|
||||||
this.profiler.pop();
|
gameprofilerfiller.pop();
|
||||||
org.spigotmc.WatchdogThread.tick(); // Spigot
|
co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
|
||||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
public static record ServerResourcePackInfo(UUID id, String url, String hash, boolean isRequired, @Nullable Component prompt) {
|
public static record ServerResourcePackInfo(UUID id, String url, String hash, boolean isRequired, @Nullable Component prompt) {
|
||||||
|
|
||||||
|
@ -191,6 +191,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
return CraftMagicNumbers.INSTANCE;
|
return CraftMagicNumbers.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public long[] getTickTimes() {
|
+ public long[] getTickTimes() {
|
||||||
+ return this.getServer().tickTimes5s.getTimes();
|
+ return this.getServer().tickTimes5s.getTimes();
|
||||||
|
@ -200,6 +201,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ public double getAverageTickTime() {
|
+ public double getAverageTickTime() {
|
||||||
+ return this.getServer().tickTimes5s.getAverage();
|
+ return this.getServer().tickTimes5s.getAverage();
|
||||||
+ }
|
+ }
|
||||||
|
+ // Paper end
|
||||||
+
|
+
|
||||||
// Spigot start
|
// Spigot start
|
||||||
private final org.bukkit.Server.Spigot spigot = new org.bukkit.Server.Spigot()
|
private final org.bukkit.Server.Spigot spigot = new org.bukkit.Server.Spigot()
|
|
@ -60,4 +60,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ this.age = this.despawnRate - 1; // Spigot // Paper - Alternative item-despawn-rate
|
+ this.age = this.despawnRate - 1; // Spigot // Paper - Alternative item-despawn-rate
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSpin(float tickDelta) {
|
public static float getSpin(float f, float f1) {
|
|
@ -21,6 +21,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- }
|
- }
|
||||||
+ final double fallbackChance = world.getDifficulty() == Difficulty.HARD ? 100d : world.getDifficulty() == Difficulty.NORMAL ? 50d : 0d; // Paper - Configurable chance of villager zombie infection
|
+ final double fallbackChance = world.getDifficulty() == Difficulty.HARD ? 100d : world.getDifficulty() == Difficulty.NORMAL ? 50d : 0d; // Paper - Configurable chance of villager zombie infection
|
||||||
+ if (this.random.nextDouble() * 100 < world.paperConfig().entities.behavior.zombieVillagerInfectionChance.or(fallbackChance) && other instanceof Villager entityvillager) { // Paper - Configurable chance of villager zombie infection
|
+ if (this.random.nextDouble() * 100 < world.paperConfig().entities.behavior.zombieVillagerInfectionChance.or(fallbackChance) && other instanceof Villager entityvillager) { // Paper - Configurable chance of villager zombie infection
|
||||||
// CraftBukkit start
|
|
||||||
flag = Zombie.zombifyVillager(world, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null;
|
if (this.convertVillagerToZombieVillager(world, entityvillager)) {
|
||||||
}
|
flag = false;
|
22
patches/server/Do-not-allow-Vexes-to-load-chunks.patch
Normal file
22
patches/server/Do-not-allow-Vexes-to-load-chunks.patch
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: chickeneer <emcchickeneer@gmail.com>
|
||||||
|
Date: Tue, 17 Mar 2020 14:18:50 -0500
|
||||||
|
Subject: [PATCH] Do not allow Vexes to load chunks
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||||
|
@@ -0,0 +0,0 @@ public class Vex extends Monster implements TraceableEntity {
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
BlockPos blockposition1 = blockposition.offset(Vex.this.random.nextInt(15) - 7, Vex.this.random.nextInt(11) - 5, Vex.this.random.nextInt(15) - 7);
|
||||||
|
|
||||||
|
- if (Vex.this.level().isEmptyBlock(blockposition1)) {
|
||||||
|
+ // Paper start - Don't load chunks
|
||||||
|
+ final net.minecraft.world.level.block.state.BlockState blockState = Vex.this.level().getBlockStateIfLoaded(blockposition1);
|
||||||
|
+ if (blockState != null && blockState.isAir()) {
|
||||||
|
+ // Paper end - Don't load chunks
|
||||||
|
Vex.this.moveControl.setWantedPosition((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.5D, (double) blockposition1.getZ() + 0.5D, 0.25D);
|
||||||
|
if (Vex.this.getTarget() == null) {
|
||||||
|
Vex.this.getLookControl().setLookAt((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.5D, (double) blockposition1.getZ() + 0.5D, 180.0F, 20.0F);
|
|
@ -40,15 +40,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
--- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
||||||
@@ -0,0 +0,0 @@ public class Ravager extends Raider {
|
@@ -0,0 +0,0 @@ public class Ravager extends Raider {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!flag && this.onGround()) {
|
if (!flag && this.onGround()) {
|
||||||
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
|
||||||
this.jumpFromGround();
|
this.jumpFromGround();
|
||||||
+ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
|
+ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@ -25,8 +25,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- if (!this.onGround() || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || (this.tickCount + this.getId()) % 4 == 0) {
|
- if (!this.onGround() || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || (this.tickCount + this.getId()) % 4 == 0) {
|
||||||
+ if (!this.onGround() || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || (this.tickCount + this.getId()) % 4 == 0) { // Paper - Diff on change
|
+ if (!this.onGround() || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || (this.tickCount + this.getId()) % 4 == 0) { // Paper - Diff on change
|
||||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||||
|
this.applyEffectsFromBlocks();
|
||||||
float f = 0.98F;
|
float f = 0.98F;
|
||||||
|
|
||||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
@ -0,0 +1,63 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||||
|
Date: Fri, 27 Dec 2019 09:42:26 -0800
|
||||||
|
Subject: [PATCH] Guard against serializing mismatching chunk coordinate
|
||||||
|
|
||||||
|
Should help if something dumb happens
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||||
|
@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<Void> write(ChunkPos chunkPos, Supplier<CompoundTag> nbtSupplier) {
|
||||||
|
+ // Paper start - guard against possible chunk pos desync
|
||||||
|
+ final Supplier<CompoundTag> guardedPosCheck = () -> {
|
||||||
|
+ CompoundTag nbt = nbtSupplier.get();
|
||||||
|
+ if (nbt != null && !chunkPos.equals(SerializableChunkData.getChunkCoordinate(nbt))) {
|
||||||
|
+ final String world = (ChunkStorage.this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap) ChunkStorage.this).level.getWorld().getName() : null;
|
||||||
|
+ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkPos
|
||||||
|
+ + " but compound says coordinate is " + SerializableChunkData.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world)));
|
||||||
|
+ }
|
||||||
|
+ return nbt;
|
||||||
|
+ };
|
||||||
|
+ // Paper end - guard against possible chunk pos desync
|
||||||
|
this.handleLegacyStructureIndex(chunkPos);
|
||||||
|
- return this.worker.store(chunkPos, nbtSupplier);
|
||||||
|
+ return this.worker.store(chunkPos, guardedPosCheck); // Paper - guard against possible chunk pos desync
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void handleLegacyStructureIndex(ChunkPos chunkPos) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/src/main/java/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
||||||
|
@@ -0,0 +0,0 @@ public record SerializableChunkData(Registry<Biome> biomeRegistry, ChunkPos chun
|
||||||
|
public static final String SECTIONS_TAG = "sections";
|
||||||
|
public static final String BLOCK_LIGHT_TAG = "BlockLight";
|
||||||
|
public static final String SKY_LIGHT_TAG = "SkyLight";
|
||||||
|
+ // Paper start - guard against serializing mismatching coordinates
|
||||||
|
+ // TODO Note: This needs to be re-checked each update
|
||||||
|
+ public static ChunkPos getChunkCoordinate(final CompoundTag chunkData) {
|
||||||
|
+ final int dataVersion = ChunkStorage.getVersion(chunkData);
|
||||||
|
+ if (dataVersion < 2842) { // Level tag is removed after this version
|
||||||
|
+ final CompoundTag levelData = chunkData.getCompound("Level");
|
||||||
|
+ return new ChunkPos(levelData.getInt("xPos"), levelData.getInt("zPos"));
|
||||||
|
+ } else {
|
||||||
|
+ return new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos"));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end - guard against serializing mismatching coordinates
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static SerializableChunkData parse(LevelHeightAccessor world, RegistryAccess registryManager, CompoundTag nbt) {
|
||||||
|
if (!nbt.contains("Status", 8)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
- ChunkPos chunkcoordintpair = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos"));
|
||||||
|
+ ChunkPos chunkcoordintpair = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate
|
||||||
|
long i = nbt.getLong("LastUpdate");
|
||||||
|
long j = nbt.getLong("InhabitedTime");
|
||||||
|
ChunkStatus chunkstatus = ChunkStatus.byName(nbt.getString("Status"));
|
|
@ -9,7 +9,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
|
@ -24,4 +24,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
||||||
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||||
// IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error
|
super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules()))); // Paper - create paper world configs
|
|
@ -20,14 +20,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return ifLoaded;
|
+ return ifLoaded;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Perf: Optimise getChunkAt calls for loaded chunks
|
+ // Paper end - Perf: Optimise getChunkAt calls for loaded chunks
|
||||||
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
|
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||||
|
|
||||||
gameprofilerfiller.incrementCounter("getChunk");
|
gameprofilerfiller.incrementCounter("getChunk");
|
||||||
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
if (Thread.currentThread() != this.mainThread) {
|
if (Thread.currentThread() != this.mainThread) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
- this.level.getProfiler().incrementCounter("getChunkNow");
|
- Profiler.get().incrementCounter("getChunkNow");
|
||||||
- long k = ChunkPos.asLong(chunkX, chunkZ);
|
- long k = ChunkPos.asLong(chunkX, chunkZ);
|
||||||
-
|
-
|
||||||
- ChunkAccess ichunkaccess;
|
- ChunkAccess ichunkaccess;
|
|
@ -4,11 +4,11 @@ Date: Tue, 14 Jan 2020 17:49:03 -0500
|
||||||
Subject: [PATCH] Optimize call to getFluid for explosions
|
Subject: [PATCH] Optimize call to getFluid for explosions
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
||||||
@@ -0,0 +0,0 @@ public class Explosion {
|
@@ -0,0 +0,0 @@ public class ServerExplosion implements Explosion {
|
||||||
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
|
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
|
||||||
BlockPos blockposition = BlockPos.containing(d4, d5, d6);
|
BlockPos blockposition = BlockPos.containing(d4, d5, d6);
|
||||||
BlockState iblockdata = this.level.getBlockState(blockposition);
|
BlockState iblockdata = this.level.getBlockState(blockposition);
|
|
@ -0,0 +1,24 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||||
|
Date: Sun, 5 Jan 2020 17:24:34 -0600
|
||||||
|
Subject: [PATCH] Prevent bees loading chunks checking hive position
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||||
|
@@ -0,0 +0,0 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
BeehiveBlockEntity getBeehiveBlockEntity() {
|
||||||
|
- return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (BeehiveBlockEntity) this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null)); // CraftBukkit - decompile error
|
||||||
|
+ // Paper start - move over logic to accommodate isTooFarAway with chunk load check
|
||||||
|
+ if (this.hivePos != null && !this.isTooFarAway(this.hivePos) && this.level().getChunkIfLoadedImmediately(this.hivePos.getX() >> 4, this.hivePos.getZ() >> 4) != null) {
|
||||||
|
+ return (BeehiveBlockEntity) this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
|
||||||
|
+ }
|
||||||
|
+ return null;
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isHiveValid() {
|
|
@ -1,58 +0,0 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: chickeneer <emcchickeneer@gmail.com>
|
|
||||||
Date: Tue, 17 Mar 2020 14:18:50 -0500
|
|
||||||
Subject: [PATCH] Do not allow bees to load chunks for beehives
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
||||||
@@ -0,0 +0,0 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
||||||
if (this.hivePos == null) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
+ if (!this.level().isLoadedAndInBounds(this.hivePos)) return false; // Paper - Do not allow bees to load chunks for beehives
|
|
||||||
BlockEntity tileentity = this.level().getBlockEntity(this.hivePos);
|
|
||||||
|
|
||||||
return tileentity instanceof BeehiveBlockEntity && ((BeehiveBlockEntity) tileentity).isFireNearby();
|
|
||||||
@@ -0,0 +0,0 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean doesHiveHaveSpace(BlockPos pos) {
|
|
||||||
+ if (!this.level().isLoadedAndInBounds(pos)) return false; // Paper - Do not allow bees to load chunks for beehives
|
|
||||||
BlockEntity tileentity = this.level().getBlockEntity(pos);
|
|
||||||
|
|
||||||
return tileentity instanceof BeehiveBlockEntity ? !((BeehiveBlockEntity) tileentity).isFull() : false;
|
|
||||||
@@ -0,0 +0,0 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
||||||
@Override
|
|
||||||
public boolean canBeeUse() {
|
|
||||||
if (Bee.this.hasHive() && Bee.this.wantsToEnterHive() && Bee.this.hivePos.closerToCenterThan(Bee.this.position(), 2.0D)) {
|
|
||||||
+ if (!Bee.this.level().isLoadedAndInBounds(Bee.this.hivePos)) return false; // Paper - Do not allow bees to load chunks for beehives
|
|
||||||
BlockEntity tileentity = Bee.this.level().getBlockEntity(Bee.this.hivePos);
|
|
||||||
|
|
||||||
if (tileentity instanceof BeehiveBlockEntity) {
|
|
||||||
@@ -0,0 +0,0 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
+ if (!Bee.this.level().isLoadedAndInBounds(Bee.this.hivePos)) return; // Paper - Do not allow bees to load chunks for beehives
|
|
||||||
BlockEntity tileentity = Bee.this.level().getBlockEntity(Bee.this.hivePos);
|
|
||||||
|
|
||||||
if (tileentity instanceof BeehiveBlockEntity tileentitybeehive) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
|
||||||
@@ -0,0 +0,0 @@ public class Vex extends Monster implements TraceableEntity {
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
BlockPos blockposition1 = blockposition.offset(Vex.this.random.nextInt(15) - 7, Vex.this.random.nextInt(11) - 5, Vex.this.random.nextInt(15) - 7);
|
|
||||||
|
|
||||||
- if (Vex.this.level().isEmptyBlock(blockposition1)) {
|
|
||||||
+ // Paper start - Don't load chunks
|
|
||||||
+ final net.minecraft.world.level.block.state.BlockState blockState = Vex.this.level().getBlockStateIfLoaded(blockposition1);
|
|
||||||
+ if (blockState != null && blockState.isAir()) {
|
|
||||||
+ // Paper end - Don't load chunks
|
|
||||||
Vex.this.moveControl.setWantedPosition((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.5D, (double) blockposition1.getZ() + 0.5D, 0.25D);
|
|
||||||
if (Vex.this.getTarget() == null) {
|
|
||||||
Vex.this.getLookControl().setLookAt((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.5D, (double) blockposition1.getZ() + 0.5D, 180.0F, 20.0F);
|
|
|
@ -1,52 +0,0 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
||||||
Date: Fri, 27 Dec 2019 09:42:26 -0800
|
|
||||||
Subject: [PATCH] Guard against serializing mismatching chunk coordinate
|
|
||||||
|
|
||||||
Should help if something dumb happens
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
|
||||||
@@ -0,0 +0,0 @@ public class ChunkSerializer {
|
|
||||||
|
|
||||||
public ChunkSerializer() {}
|
|
||||||
|
|
||||||
+ // Paper start - guard against serializing mismatching coordinates
|
|
||||||
+ // TODO Note: This needs to be re-checked each update
|
|
||||||
+ public static ChunkPos getChunkCoordinate(final CompoundTag chunkData) {
|
|
||||||
+ final int dataVersion = ChunkStorage.getVersion(chunkData);
|
|
||||||
+ if (dataVersion < 2842) { // Level tag is removed after this version
|
|
||||||
+ final CompoundTag levelData = chunkData.getCompound("Level");
|
|
||||||
+ return new ChunkPos(levelData.getInt("xPos"), levelData.getInt("zPos"));
|
|
||||||
+ } else {
|
|
||||||
+ return new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos"));
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ // Paper end - guard against serializing mismatching coordinates
|
|
||||||
+
|
|
||||||
public static ProtoChunk read(ServerLevel world, PoiManager poiStorage, RegionStorageInfo key, ChunkPos chunkPos, CompoundTag nbt) {
|
|
||||||
- ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos"));
|
|
||||||
+ ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate
|
|
||||||
|
|
||||||
if (!Objects.equals(chunkPos, chunkcoordintpair1)) {
|
|
||||||
ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", new Object[]{chunkPos, chunkPos, chunkcoordintpair1});
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
|
||||||
@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable {
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompletableFuture<Void> write(ChunkPos chunkPos, CompoundTag nbt) {
|
|
||||||
+ // Paper start - guard against serializing mismatching coordinates
|
|
||||||
+ if (nbt != null && !chunkPos.equals(ChunkSerializer.getChunkCoordinate(nbt))) {
|
|
||||||
+ final String world = (this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap) this).level.getWorld().getName() : null;
|
|
||||||
+ throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkPos
|
|
||||||
+ + " but compound says coordinate is " + ChunkSerializer.getChunkCoordinate(nbt) + (world == null ? " for an unknown world" : (" for world: " + world)));
|
|
||||||
+ }
|
|
||||||
+ // Paper end - guard against serializing mismatching coordinates
|
|
||||||
this.handleLegacyStructureIndex(chunkPos);
|
|
||||||
return this.worker.store(chunkPos, nbt);
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
||||||
Date: Sun, 5 Jan 2020 17:24:34 -0600
|
|
||||||
Subject: [PATCH] Prevent bees loading chunks checking hive position
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
||||||
@@ -0,0 +0,0 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
||||||
} else if (this.isTooFarAway(this.hivePos)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
+ if (this.level().getChunkIfLoadedImmediately(this.hivePos.getX() >> 4, this.hivePos.getZ() >> 4) == null) return true; // Paper - just assume the hive is still there, no need to load the chunk(s)
|
|
||||||
BlockEntity tileentity = this.level().getBlockEntity(this.hivePos);
|
|
||||||
|
|
||||||
return tileentity != null && tileentity.getType() == BlockEntityType.BEEHIVE;
|
|
Loading…
Add table
Reference in a new issue