13
0
geforkt von Mirrors/Paper

[ci skip] Add more identifying patch comments

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-01-21 12:53:04 +01:00
Ursprung f6609428b6
Commit 0571a6438e
54 geänderte Dateien mit 166 neuen und 206 gelöschten Zeilen

Datei anzeigen

@ -8,14 +8,6 @@ diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.ja
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/Tag.java --- a/src/main/java/org/bukkit/Tag.java
+++ b/src/main/java/org/bukkit/Tag.java +++ b/src/main/java/org/bukkit/Tag.java
@@ -0,0 +0,0 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla tag representing entities which are dismounted when underwater.
*/
Tag<EntityType> ENTITY_TYPES_DISMOUNTS_UNDERWATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("dismounts_underwater"), EntityType.class);
+
/**
* Vanilla tag representing entities which are not controlled by their mount.
*/
@@ -0,0 +0,0 @@ public interface Tag<T extends Keyed> extends Keyed { @@ -0,0 +0,0 @@ public interface Tag<T extends Keyed> extends Keyed {
*/ */
Tag<EntityType> ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class); Tag<EntityType> ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class);

Datei anzeigen

@ -371,7 +371,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- 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);
- if (!iblockdata.isDestroyable()) continue; // Paper - Protect Bedrock and End Portal/Frames from being destroyed - if (!iblockdata.isDestroyable()) continue; // Paper - Protect Bedrock and End Portal/Frames from being destroyed
- FluidState fluid = iblockdata.getFluidState(); // Paper - FluidState fluid = iblockdata.getFluidState(); // Paper - Perf: Optimize call to getFluid for explosions
+ // Paper start - optimise explosions + // Paper start - optimise explosions
+ final int blockX = Mth.floor(d4); + final int blockX = Mth.floor(d4);
+ final int blockY = Mth.floor(d5); + final int blockY = Mth.floor(d5);

Datei anzeigen

@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 0, Unit.INSTANCE); // Paper + world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 0, Unit.INSTANCE); // Paper
world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true); world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);
return true; return true;
// Paper end // Paper end - Optimize this method
@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World {
io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(this.getHandle(), x, z, gen, ChunkStatus.FULL, true, priority, (c) -> { io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(this.getHandle(), x, z, gen, ChunkStatus.FULL, true, priority, (c) -> {
net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> {

Datei anzeigen

@ -14,13 +14,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
// CraftBukkit end // CraftBukkit end
+ // Paper start + // Paper start - Add ThrownEggHatchEvent
+ com.destroystokyo.paper.event.entity.ThrownEggHatchEvent event = new com.destroystokyo.paper.event.entity.ThrownEggHatchEvent((org.bukkit.entity.Egg) getBukkitEntity(), hatching, b0, hatchingType); + com.destroystokyo.paper.event.entity.ThrownEggHatchEvent event = new com.destroystokyo.paper.event.entity.ThrownEggHatchEvent((org.bukkit.entity.Egg) getBukkitEntity(), hatching, b0, hatchingType);
+ event.callEvent(); + event.callEvent();
+ hatching = event.isHatching(); + hatching = event.isHatching();
+ b0 = hatching ? event.getNumHatches() : 0; // If hatching is set to false, ensure child count is 0 + b0 = hatching ? event.getNumHatches() : 0; // If hatching is set to false, ensure child count is 0
+ hatchingType = event.getHatchingType(); + hatchingType = event.getHatchingType();
+ // Paper end + // Paper end - Add ThrownEggHatchEvent
for (int i = 0; i < b0; ++i) { for (int i = 0; i < b0; ++i) {
Entity entitychicken = this.level().getWorld().makeEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit Entity entitychicken = this.level().getWorld().makeEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit

Datei anzeigen

@ -307,7 +307,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper start - async chunk io/loading // Paper start - async chunk io/loading
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.pushChunkWait(this.level, x1, z1); // Paper - rewrite chunk system io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.pushChunkWait(this.level, x1, z1); // Paper - rewrite chunk system
// Paper end // Paper end
+ com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x1, z1); // Paper - sync load info + com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x1, z1); // Paper - Add debug for sync chunk loads
this.level.timings.syncChunkLoad.startTiming(); // Paper this.level.timings.syncChunkLoad.startTiming(); // Paper
chunkproviderserver_b.managedBlock(completablefuture::isDone); chunkproviderserver_b.managedBlock(completablefuture::isDone);
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.popChunkWait(); // Paper - async chunk debug // Paper - rewrite chunk system io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.popChunkWait(); // Paper - async chunk debug // Paper - rewrite chunk system

Datei anzeigen

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
BlockState iblockdata = world.getBlockState(blockposition1); BlockState iblockdata = world.getBlockState(blockposition1);
- if (!iblockdata.entityCanStandOn(world, blockposition1, this)) { - if (!iblockdata.entityCanStandOn(world, blockposition1, this)) {
+ if (!iblockdata.entityCanStandOn(world, blockposition1, this) && !this.level().paperConfig().entities.spawning.ironGolemsCanSpawnInAir) { // Paper + if (!iblockdata.entityCanStandOn(world, blockposition1, this) && !this.level().paperConfig().entities.spawning.ironGolemsCanSpawnInAir) { // Paper - Add option to allow iron golems to spawn in air
return false; return false;
} else { } else {
for (int i = 1; i < 3; ++i) { for (int i = 1; i < 3; ++i) {

Datei anzeigen

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public int tick(ServerLevel world, boolean spawnMonsters, boolean spawnAnimals) { public int tick(ServerLevel world, boolean spawnMonsters, boolean spawnAnimals) {
+ if (world.paperConfig().entities.behavior.pillagerPatrols.disable) return 0; // Paper + if (world.paperConfig().entities.behavior.pillagerPatrols.disable) return 0; // Paper - Add option to disable pillager patrols
if (!spawnMonsters) { if (!spawnMonsters) {
return 0; return 0;
} else if (!world.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { } else if (!world.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) {

Datei anzeigen

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper start // Paper start
public long activatedImmunityTick = Integer.MIN_VALUE; // Paper public long activatedImmunityTick = Integer.MIN_VALUE; // Paper
public boolean isTemporarilyActive = false; // Paper public boolean isTemporarilyActive = false; // Paper
+ public boolean fromNetherPortal; // Paper + public boolean fromNetherPortal; // Paper - Add option to nerf pigmen from nether portals
protected int numCollisions = 0; // Paper protected int numCollisions = 0; // Paper
public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one
@javax.annotation.Nullable @javax.annotation.Nullable
@ -42,8 +42,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (entity != null) { if (entity != null) {
entity.setPortalCooldown(); entity.setPortalCooldown();
+ entity.fromNetherPortal = true; // Paper + entity.fromNetherPortal = true; // Paper - Add option to nerf pigmen from nether portals
+ if (world.paperConfig().entities.behavior.nerfPigmenFromNetherPortals) ((net.minecraft.world.entity.Mob) entity).aware = false; // Paper + if (world.paperConfig().entities.behavior.nerfPigmenFromNetherPortals) ((net.minecraft.world.entity.Mob) entity).aware = false; // Paper - Add option to nerf pigmen from nether portals
} }
} }
} }

Datei anzeigen

@ -275,7 +275,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - Add mobcaps commands + // Paper end - Add mobcaps commands
+ +
public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) { public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
// Paper start - add parameters and int ret type // Paper start - Optional per player mob spawns
spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null); spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

Datei anzeigen

@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start + // Paper start
+ private final byte[] oversized = new byte[1024]; + private final byte[] oversized = new byte[1024];
+ private int oversizedCount = 0; + private int oversizedCount;
+ +
+ private synchronized void initOversizedState() throws IOException { + private synchronized void initOversizedState() throws IOException {
+ Path metaFile = getOversizedMetaFile(); + Path metaFile = getOversizedMetaFile();
@ -153,22 +153,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed."); + org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed.");
+ } + }
+ +
+ private static final int DEFAULT_SIZE_THRESHOLD = 1024 * 8;
+ private static final int OVERZEALOUS_TOTAL_THRESHOLD = 1024 * 64;
+ private static final int OVERZEALOUS_THRESHOLD = 1024;
+ private static int SIZE_THRESHOLD = DEFAULT_SIZE_THRESHOLD;
+ private static void resetFilterThresholds() {
+ SIZE_THRESHOLD = Math.max(1024 * 4, Integer.getInteger("Paper.FilterThreshhold", DEFAULT_SIZE_THRESHOLD));
+ }
+ static {
+ resetFilterThresholds();
+ }
+
+ static boolean isOverzealous() {
+ return SIZE_THRESHOLD == OVERZEALOUS_THRESHOLD;
+ }
+
+
+ private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { + private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException {
+ synchronized (regionfile) { + synchronized (regionfile) {
+ try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) { + try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
@ -199,18 +183,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ level.put(key, levelList); + level.put(key, levelList);
+ } + }
+ } + }
+
+ private static int getNBTSize(net.minecraft.nbt.Tag nbtBase) {
+ DataOutputStream test = new DataOutputStream(new org.apache.commons.io.output.NullOutputStream());
+ try {
+ nbtBase.write(test);
+ return test.size();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+ // Paper end + // Paper end
+ +
@Nullable @Nullable

Datei anzeigen

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com> From: kickash32 <kickash32@gmail.com>
Date: Mon, 3 Jun 2019 02:02:39 -0400 Date: Mon, 3 Jun 2019 02:02:39 -0400
Subject: [PATCH] Implement alternative item-despawn-rate Subject: [PATCH] Alternative item-despawn-rate
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public final float bobOffs; public final float bobOffs;
private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
public boolean canMobPickup = true; // Paper public boolean canMobPickup = true; // Paper
+ private int despawnRate = -1; // Paper + private int despawnRate = -1; // Paper - Alternative item-despawn-rate
public ItemEntity(EntityType<? extends ItemEntity> type, Level world) { public ItemEntity(EntityType<? extends ItemEntity> type, Level world) {
super(type, world); super(type, world);
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot - if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot
+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper + if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate
// CraftBukkit start - fire ItemDespawnEvent // CraftBukkit start - fire ItemDespawnEvent
if (CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { if (CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
this.age = 0; this.age = 0;
@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end // CraftBukkit end
- if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot - if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot
+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper + if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate
// CraftBukkit start - fire ItemDespawnEvent // CraftBukkit start - fire ItemDespawnEvent
if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
this.age = 0; this.age = 0;
@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ItemStack itemstack = this.getItem(); ItemStack itemstack = this.getItem();
- return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < 6000 && itemstack.getCount() < itemstack.getMaxStackSize(); - return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < 6000 && itemstack.getCount() < itemstack.getMaxStackSize();
+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - respect despawn rate in pickup check. + return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - Alternative item-despawn-rate
} }
private void tryToMerge(ItemEntity other) { private void tryToMerge(ItemEntity other) {
@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void setItem(ItemStack stack) { public void setItem(ItemStack stack) {
this.getEntityData().set(ItemEntity.DATA_ITEM, stack); this.getEntityData().set(ItemEntity.DATA_ITEM, stack);
+ this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper + this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper - Alternative item-despawn-rate
} }
@Override @Override
@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void makeFakeItem() { public void makeFakeItem() {
this.setNeverPickUp(); this.setNeverPickUp();
- this.age = this.level().spigotConfig.itemDespawnRate - 1; // Spigot - this.age = this.level().spigotConfig.itemDespawnRate - 1; // Spigot
+ this.age = this.despawnRate - 1; // Spigot // Paper + this.age = this.despawnRate - 1; // Spigot // Paper - Alternative item-despawn-rate
} }
public float getSpin(float tickDelta) { public float getSpin(float tickDelta) {

Datei anzeigen

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
super(type, world); super(type, world);
this.remainingCooldownBeforeLocatingNewFlower = Mth.nextInt(this.random, 20, 60); this.remainingCooldownBeforeLocatingNewFlower = Mth.nextInt(this.random, 20, 60);
- this.moveControl = new FlyingMoveControl(this, 20, true); - this.moveControl = new FlyingMoveControl(this, 20, true);
+ // Paper start - apply gravity to bees when they get stuck in the void, fixes MC-167279 + // Paper start - Fix MC-167279
+ class BeeFlyingMoveControl extends FlyingMoveControl { + class BeeFlyingMoveControl extends FlyingMoveControl {
+ public BeeFlyingMoveControl(final Mob entity, final int maxPitchChange, final boolean noGravity) { + public BeeFlyingMoveControl(final Mob entity, final int maxPitchChange, final boolean noGravity) {
+ super(entity, maxPitchChange, noGravity); + super(entity, maxPitchChange, noGravity);
@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ } + }
+ this.moveControl = new BeeFlyingMoveControl(this, 20, true); + this.moveControl = new BeeFlyingMoveControl(this, 20, true);
+ // Paper end + // Paper end - Fix MC-167279
this.lookControl = new Bee.BeeLookControl(this); this.lookControl = new Bee.BeeLookControl(this);
this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, -1.0F); this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, -1.0F);
this.setPathfindingMalus(BlockPathTypes.WATER, -1.0F); this.setPathfindingMalus(BlockPathTypes.WATER, -1.0F);

Datei anzeigen

@ -13,43 +13,42 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start // CraftBukkit start
public void prepareLevels(ChunkProgressListener worldloadlistener, ServerLevel worldserver) { public void prepareLevels(ChunkProgressListener worldloadlistener, ServerLevel worldserver) {
+ ServerChunkCache chunkproviderserver = worldserver.getChunkSource(); // Paper + ServerChunkCache chunkproviderserver = worldserver.getChunkSource(); // Paper - Configurable Keep Spawn Loaded range per world
// WorldServer worldserver = this.overworld(); // WorldServer worldserver = this.overworld();
this.forceTicks = true; this.forceTicks = true;
// CraftBukkit end // CraftBukkit end
+ if (worldserver.getWorld().getKeepSpawnInMemory()) { // Paper + if (worldserver.getWorld().getKeepSpawnInMemory()) { // Paper - Configurable Keep Spawn Loaded range per world
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPos blockposition = worldserver.getSharedSpawnPos(); BlockPos blockposition = worldserver.getSharedSpawnPos();
worldloadlistener.updateSpawnPos(new ChunkPos(blockposition)); worldloadlistener.updateSpawnPos(new ChunkPos(blockposition));
- ServerChunkCache chunkproviderserver = worldserver.getChunkSource(); - ServerChunkCache chunkproviderserver = worldserver.getChunkSource();
+ //ChunkProviderServer chunkproviderserver = worldserver.getChunkProvider(); // Paper - move up + //ChunkProviderServer chunkproviderserver = worldserver.getChunkProvider(); // Paper - Configurable Keep Spawn Loaded range per world; move up
this.nextTickTimeNanos = Util.getNanos(); this.nextTickTimeNanos = Util.getNanos();
- // CraftBukkit start - // CraftBukkit start
- if (worldserver.getWorld().getKeepSpawnInMemory()) { - if (worldserver.getWorld().getKeepSpawnInMemory()) {
- chunkproviderserver.addRegionTicket(TicketType.START, new ChunkPos(blockposition), 11, Unit.INSTANCE); - chunkproviderserver.addRegionTicket(TicketType.START, new ChunkPos(blockposition), 11, Unit.INSTANCE);
- + // Paper start - Configurable Keep Spawn Loaded range per world
- while (chunkproviderserver.getTickingGenerated() != 441) {
- // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
- this.executeModerately();
- }
- }
+ // Paper start - configurable spawn reason
+ int radiusBlocks = worldserver.paperConfig().spawn.keepSpawnLoadedRange * 16; + int radiusBlocks = worldserver.paperConfig().spawn.keepSpawnLoadedRange * 16;
+ int radiusChunks = radiusBlocks / 16 + ((radiusBlocks & 15) != 0 ? 1 : 0); + int radiusChunks = radiusBlocks / 16 + ((radiusBlocks & 15) != 0 ? 1 : 0);
+ int totalChunks = ((radiusChunks) * 2 + 1); + int totalChunks = ((radiusChunks) * 2 + 1);
+ totalChunks *= totalChunks; + totalChunks *= totalChunks;
+ worldloadlistener.setChunkRadius(radiusBlocks / 16); + worldloadlistener.setChunkRadius(radiusBlocks / 16);
+
- while (chunkproviderserver.getTickingGenerated() != 441) {
- // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
- this.executeModerately();
- }
- }
+ worldserver.addTicketsForSpawn(radiusBlocks, blockposition); + worldserver.addTicketsForSpawn(radiusBlocks, blockposition);
+ // Paper end + // Paper end - Configurable Keep Spawn Loaded range per world
// this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS; // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
this.executeModerately(); this.executeModerately();
// Iterator iterator = this.levels.values().iterator(); // Iterator iterator = this.levels.values().iterator();
+ } + } // Paper - Configurable Keep Spawn Loaded range per world
if (true) { if (true) {
ServerLevel worldserver1 = worldserver; ServerLevel worldserver1 = worldserver;
@ -58,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.executeModerately(); this.executeModerately();
// CraftBukkit end // CraftBukkit end
- worldloadlistener.stop(); - worldloadlistener.stop();
+ if (worldserver.getWorld().getKeepSpawnInMemory()) worldloadlistener.stop(); // Paper + if (worldserver.getWorld().getKeepSpawnInMemory()) worldloadlistener.stop(); // Paper - Configurable Keep Spawn Loaded range per world
// CraftBukkit start // CraftBukkit start
// this.updateMobSpawningFlags(); // this.updateMobSpawningFlags();
worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals()); worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());
@ -70,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return ((MapIndex) this.getServer().overworld().getDataStorage().computeIfAbsent(MapIndex.factory(), "idcounts")).getFreeAuxValueForMap(); return ((MapIndex) this.getServer().overworld().getDataStorage().computeIfAbsent(MapIndex.factory(), "idcounts")).getFreeAuxValueForMap();
} }
+ // Paper start - helper function for configurable spawn radius + // Paper start - Configurable Keep Spawn Loaded range per world
+ public void addTicketsForSpawn(int radiusInBlocks, BlockPos spawn) { + public void addTicketsForSpawn(int radiusInBlocks, BlockPos spawn) {
+ // In order to respect vanilla behavior, which is ensuring everything but the spawn border can tick, we add tickets + // In order to respect vanilla behavior, which is ensuring everything but the spawn border can tick, we add tickets
+ // with level 31 for the non-border spawn chunks + // with level 31 for the non-border spawn chunks
@ -135,11 +134,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ chunkproviderserver.removeRegionTicket(TicketType.START, new ChunkPos(spawn.offset(-radiusInBlocks, 0, z)), 1, Unit.INSTANCE); // level 32 + chunkproviderserver.removeRegionTicket(TicketType.START, new ChunkPos(spawn.offset(-radiusInBlocks, 0, z)), 1, Unit.INSTANCE); // level 32
+ } + }
+ } + }
+ // Paper end + // Paper end - Configurable Keep Spawn Loaded range per world
+ +
public void setDefaultSpawnPos(BlockPos pos, float angle) { public void setDefaultSpawnPos(BlockPos pos, float angle) {
- ChunkPos chunkcoordintpair = new ChunkPos(new BlockPos(this.levelData.getXSpawn(), 0, this.levelData.getZSpawn())); - ChunkPos chunkcoordintpair = new ChunkPos(new BlockPos(this.levelData.getXSpawn(), 0, this.levelData.getZSpawn()));
+ // Paper - configurable spawn radius + // Paper start - Configurable Keep Spawn Loaded range per world
+ BlockPos prevSpawn = this.getSharedSpawnPos(); + BlockPos prevSpawn = this.getSharedSpawnPos();
+ //ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c())); + //ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c()));
@ -163,7 +162,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
void stop(); void stop();
+ +
+ void setChunkRadius(int radius); // Paper - allow changing chunk radius + void setChunkRadius(int radius); // Paper - Configurable Keep Spawn Loaded range per world
} }
diff --git a/src/main/java/net/minecraft/server/level/progress/LoggerChunkProgressListener.java b/src/main/java/net/minecraft/server/level/progress/LoggerChunkProgressListener.java diff --git a/src/main/java/net/minecraft/server/level/progress/LoggerChunkProgressListener.java b/src/main/java/net/minecraft/server/level/progress/LoggerChunkProgressListener.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -180,13 +179,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private long nextTickTime = Long.MAX_VALUE; private long nextTickTime = Long.MAX_VALUE;
public LoggerChunkProgressListener(int radius) { public LoggerChunkProgressListener(int radius) {
+ // Paper start - Allow changing radius later for configurable spawn patch + // Paper start - Configurable Keep Spawn Loaded range per world
+ this.setChunkRadius(radius); // Move to method + this.setChunkRadius(radius); // Move to method
+ } + }
+ +
+ @Override + @Override
+ public void setChunkRadius(int radius) { + public void setChunkRadius(int radius) {
+ // Paper end + // Paper end - Configurable Keep Spawn Loaded range per world
int i = radius * 2 + 1; int i = radius * 2 + 1;
this.maxCount = i * i; this.maxCount = i * i;
} }

Datei anzeigen

@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
// Paper end // Paper end - Cache chunk status
public RegionFile(Path file, Path directory, boolean dsync) throws IOException { public RegionFile(Path file, Path directory, boolean dsync) throws IOException {
- this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync); - this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);

Datei anzeigen

@ -21,8 +21,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (world.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { - if (world.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) {
- return flag; - return flag;
- } - }
+ final double fallbackChance = world.getDifficulty() == Difficulty.HARD ? 100d : world.getDifficulty() == Difficulty.NORMAL ? 50d : 0d; // Paper + 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 + 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 // CraftBukkit start
flag = Zombie.zombifyVillager(world, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null; flag = Zombie.zombifyVillager(world, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null;
} }

Datei anzeigen

@ -31,5 +31,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ } + }
// Paper end // Paper end
ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate

Datei anzeigen

@ -21,12 +21,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else { } else {
BlockPos blockPos = pos.relative(directionMapper.apply(state)); BlockPos blockPos = pos.relative(directionMapper.apply(state));
- BlockState blockState = world.getBlockState(blockPos); - BlockState blockState = world.getBlockState(blockPos);
+ // Paper start + // Paper start - Don't load Chunks from Hoppers and other things
+ BlockState blockState = world.getBlockStateIfLoaded(blockPos); + BlockState blockState = world.getBlockStateIfLoaded(blockPos);
+ if (blockState == null) { + if (blockState == null) {
+ return new DoubleBlockCombiner.NeighborCombineResult.Single<>(blockEntity); + return new DoubleBlockCombiner.NeighborCombineResult.Single<>(blockEntity);
+ } + }
+ // Paper end + // Paper end - Don't load Chunks from Hoppers and other things
if (blockState.is(state.getBlock())) { if (blockState.is(state.getBlock())) {
DoubleBlockCombiner.BlockType blockType2 = typeMapper.apply(blockState); DoubleBlockCombiner.BlockType blockType2 = typeMapper.apply(blockState);
if (blockType2 != DoubleBlockCombiner.BlockType.SINGLE && blockType != blockType2 && blockState.getValue(directionProperty) == state.getValue(directionProperty)) { if (blockType2 != DoubleBlockCombiner.BlockType.SINGLE && blockType != blockType2 && blockState.getValue(directionProperty) == state.getValue(directionProperty)) {

Datei anzeigen

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3);
} else { } else {
SignBlockEntity.LOGGER.warn("Player {} just tried to change non-editable sign", player.getName().getString()); SignBlockEntity.LOGGER.warn("Player {} just tried to change non-editable sign", player.getName().getString());
+ if (player.distanceToSqr(this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ()) < 32 * 32) // Paper + if (player.distanceToSqr(this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ()) < 32 * 32) // Paper - Dont send far away sign update
((ServerPlayer) player).connection.send(this.getUpdatePacket()); // CraftBukkit ((ServerPlayer) player).connection.send(this.getUpdatePacket()); // CraftBukkit
} }
} }

Datei anzeigen

@ -63,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entity.discard(); entity.discard();
needsRemoval = true; needsRemoval = true;
} }
+ checkDupeUUID(world, entity); // Paper + checkDupeUUID(world, entity); // Paper - duplicate uuid resolving
return !needsRemoval; return !needsRemoval;
}), position); // Paper - rewrite chunk system }), position); // Paper - rewrite chunk system
// CraftBukkit end // CraftBukkit end
@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
throw new UnsupportedOperationException(); // Paper - rewrite chunk system throw new UnsupportedOperationException(); // Paper - rewrite chunk system
} }
+ // Paper start + // Paper start - duplicate uuid resolving
+ // rets true if to prevent the entity from being added + // rets true if to prevent the entity from being added
+ public static boolean checkDupeUUID(ServerLevel level, Entity entity) { + public static boolean checkDupeUUID(ServerLevel level, Entity entity) {
+ io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode mode = level.paperConfig().entities.spawning.duplicateUuid.mode; + io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode mode = level.paperConfig().entities.spawning.duplicateUuid.mode;
@ -113,7 +113,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ return false; + return false;
+ } + }
+ // Paper end + // Paper end - duplicate uuid resolving
public CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> prepareTickingChunk(ChunkHolder holder) { public CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> prepareTickingChunk(ChunkHolder holder) {
throw new UnsupportedOperationException(); // Paper - rewrite chunk system throw new UnsupportedOperationException(); // Paper - rewrite chunk system
} }

Datei anzeigen

@ -12,10 +12,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else if (this.isInLava() && (!this.onGround() || d3 > d4)) { } else if (this.isInLava() && (!this.onGround() || d3 > d4)) {
this.jumpInLiquid(FluidTags.LAVA); this.jumpInLiquid(FluidTags.LAVA);
} else if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) { } else if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) {
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
this.jumpFromGround(); this.jumpFromGround();
this.noJumpDelay = 10; this.noJumpDelay = 10;
+ } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop + } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
} }
} else { } else {
this.noJumpDelay = 0; this.noJumpDelay = 0;
@ -27,9 +27,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Panda entitypanda = (Panda) iterator.next(); Panda entitypanda = (Panda) iterator.next();
if (!entitypanda.isBaby() && entitypanda.onGround() && !entitypanda.isInWater() && entitypanda.canPerformAction()) { if (!entitypanda.isBaby() && entitypanda.onGround() && !entitypanda.isInWater() && entitypanda.canPerformAction()) {
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
entitypanda.jumpFromGround(); entitypanda.jumpFromGround();
+ } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop + } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
} }
} }
@ -41,9 +41,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
if (!flag && this.onGround()) { if (!flag && this.onGround()) {
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
this.jumpFromGround(); this.jumpFromGround();
+ } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop + } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
} }
} }

Datei anzeigen

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
if (worldserver.getWorld().getKeepSpawnInMemory()) worldloadlistener.stop(); // Paper if (worldserver.getWorld().getKeepSpawnInMemory()) worldloadlistener.stop(); // Paper - Configurable Keep Spawn Loaded range per world
// CraftBukkit start // CraftBukkit start
// this.updateMobSpawningFlags(); // this.updateMobSpawningFlags();
- worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals()); - worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());

Datei anzeigen

@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ 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 WorldGenLevel {
public void setDefaultSpawnPos(BlockPos pos, float angle) { public void setDefaultSpawnPos(BlockPos pos, float angle) {
// Paper - configurable spawn radius // Paper start - Configurable Keep Spawn Loaded range per world
BlockPos prevSpawn = this.getSharedSpawnPos(); BlockPos prevSpawn = this.getSharedSpawnPos();
+ Location prevSpawnLoc = this.getWorld().getSpawnLocation(); // Paper - Call SpawnChangeEvent + Location prevSpawnLoc = this.getWorld().getSpawnLocation(); // Paper - Call SpawnChangeEvent
//ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c())); //ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c()));

Datei anzeigen

@ -87,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ ChunkHolder chunkHolder = io.papermc.paper.chunk.system.ChunkSystem.getUnloadingChunkHolder(this.level, chunkX, chunkZ); + ChunkHolder chunkHolder = io.papermc.paper.chunk.system.ChunkSystem.getUnloadingChunkHolder(this.level, chunkX, chunkZ);
+ return chunkHolder == null ? null : chunkHolder.getAvailableChunkNow(); + return chunkHolder == null ? null : chunkHolder.getAvailableChunkNow();
+ } + }
+ // Paper end + // Paper end - Cache chunk status on disk
+ +
boolean anyPlayerCloseEnoughForSpawning(ChunkPos pos) { boolean anyPlayerCloseEnoughForSpawning(ChunkPos pos) {
// Spigot start // Spigot start
@ -122,7 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final int location = getChunkLocation(x, z); + final int location = getChunkLocation(x, z);
+ return this.statuses[location]; + return this.statuses[location];
+ } + }
+ // Paper end + // Paper end - Cache chunk status
+ +
public RegionFile(Path file, Path directory, boolean dsync) throws IOException { public RegionFile(Path file, Path directory, boolean dsync) throws IOException {
this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync); this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
@ -131,7 +131,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return this.getOffset(pos) != 0; return this.getOffset(pos) != 0;
} }
+ private static int getChunkLocation(int x, int z) { return (x & 31) + (z & 31) * 32; } // Paper - OBFHELPER - sort of, mirror of logic below + private static int getChunkLocation(int x, int z) { return (x & 31) + (z & 31) * 32; } // Paper - Cache chunk status; OBFHELPER - sort of, mirror of logic below
private static int getOffsetIndex(ChunkPos pos) { private static int getOffsetIndex(ChunkPos pos) {
return pos.getRegionLocalX() + pos.getRegionLocalZ() * 32; return pos.getRegionLocalX() + pos.getRegionLocalZ() * 32;
} }
@ -139,7 +139,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
synchronized (this) { synchronized (this) {
try { try {
// Paper end // Paper end
+ this.closed = true; // Paper + this.closed = true; // Paper - Cache chunk status
try { try {
this.padToFullSector(); this.padToFullSector();
} finally { } finally {
@ -151,7 +151,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
try { try {
NbtIo.write(nbt, (DataOutput) dataoutputstream); NbtIo.write(nbt, (DataOutput) dataoutputstream);
+ regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - cache status on disk + regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - Cache chunk status
regionfile.setOversized(pos.x, pos.z, false); // Paper - We don't do this anymore, mojang stores differently, but clear old meta flag if it exists to get rid of our own meta file once last oversized is gone regionfile.setOversized(pos.x, pos.z, false); // Paper - We don't do this anymore, mojang stores differently, but clear old meta flag if it exists to get rid of our own meta file once last oversized is gone
} catch (Throwable throwable) { } catch (Throwable throwable) {
if (dataoutputstream != null) { if (dataoutputstream != null) {
@ -180,8 +180,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- return this.isChunkLoaded(x, z) || this.world.getChunkSource().chunkMap.read(new ChunkPos(x, z)).get().isPresent(); - return this.isChunkLoaded(x, z) || this.world.getChunkSource().chunkMap.read(new ChunkPos(x, z)).get().isPresent();
- } catch (InterruptedException | ExecutionException ex) { - } catch (InterruptedException | ExecutionException ex) {
+ return world.getChunkSource().chunkMap.getChunkStatusOnDisk(new ChunkPos(x, z)) == ChunkStatus.FULL; + return world.getChunkSource().chunkMap.getChunkStatusOnDisk(new ChunkPos(x, z)) == ChunkStatus.FULL;
+ // Paper end
+ } catch (java.io.IOException ex) { + } catch (java.io.IOException ex) {
+ // Paper end - Fix this method
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
} }
@ -240,7 +240,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE); + world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
+ world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true); + world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);
+ return true; + return true;
+ // Paper end + // Paper end - Optimize this method
} }
@Override @Override

Datei anzeigen

@ -118,7 +118,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
// Paper end // Paper end - Cache chunk status on disk
- boolean anyPlayerCloseEnoughForSpawning(ChunkPos pos) { - boolean anyPlayerCloseEnoughForSpawning(ChunkPos pos) {
+ public boolean anyPlayerCloseEnoughForSpawning(ChunkPos pos) { // Paper - public + public boolean anyPlayerCloseEnoughForSpawning(ChunkPos pos) { // Paper - public

Datei anzeigen

@ -20,9 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (flag1) { if (flag1) {
blockposition1 = ServerLevel.END_SPAWN_POINT; blockposition1 = ServerLevel.END_SPAWN_POINT;
} else { } else {
+ // Paper start - Ensure spawn chunk is always loaded before calculating Y coordinate + destination.getChunkAt(destination.getSharedSpawnPos()); // Paper - Ensure spawn chunk is always loaded before calculating Y coordinate
+ destination.getChunkAt(destination.getSharedSpawnPos());
+ // Paper end
blockposition1 = destination.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, destination.getSharedSpawnPos()); blockposition1 = destination.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, destination.getSharedSpawnPos());
} }
// CraftBukkit start // CraftBukkit start

Datei anzeigen

@ -2,7 +2,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com> From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Fri, 17 Jan 2020 18:44:55 -0800 Date: Fri, 17 Jan 2020 18:44:55 -0800
Subject: [PATCH] Fix last firework in stack not having effects when dispensed Subject: [PATCH] Fix last firework in stack not having effects when dispensed
- #2871
CB used the resulting item in the dispenser rather than the item CB used the resulting item in the dispenser rather than the item
dispensed. The resulting item would have size == 0 and therefore dispensed. The resulting item would have size == 0 and therefore

Datei anzeigen

@ -82,6 +82,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
TripWireHookBlock.emitState(world, pos, flag4, flag5, flag2, flag3); TripWireHookBlock.emitState(world, pos, flag4, flag5, flag2, flag3);
- if (!flag) { - if (!flag) {
+ if (!beingRemoved) { // Paper - fix tripwire state inconsistency + if (!beingRemoved) { // Paper - fix tripwire state inconsistency
if (world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - validate if (world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - Validate tripwire hook placement before update
world.setBlock(pos, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection), 3); world.setBlock(pos, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection), 3);
if (flag1) { if (flag1) {

Datei anzeigen

@ -108,7 +108,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
CauldronInteraction.bootStrap(); CauldronInteraction.bootStrap();
// Paper start // Paper start
BuiltInRegistries.bootStrap(() -> { BuiltInRegistries.bootStrap(() -> {
+ io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - optional flat bedrock + io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - Flat bedrock generator settings
io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enterBootstrappers(); // Paper - Entrypoint for bootstrapping io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enterBootstrappers(); // Paper - Entrypoint for bootstrapping
}); });
// Paper end // Paper end
@ -121,7 +121,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void buildSurface(WorldGenRegion region, StructureManager structures, RandomState noiseConfig, ChunkAccess chunk) { public void buildSurface(WorldGenRegion region, StructureManager structures, RandomState noiseConfig, ChunkAccess chunk) {
if (!SharedConstants.debugVoidTerrain(chunk.getPos())) { if (!SharedConstants.debugVoidTerrain(chunk.getPos())) {
- WorldGenerationContext worldgenerationcontext = new WorldGenerationContext(this, region); - WorldGenerationContext worldgenerationcontext = new WorldGenerationContext(this, region);
+ WorldGenerationContext worldgenerationcontext = new WorldGenerationContext(this, region, region.getMinecraftWorld()); // Paper + WorldGenerationContext worldgenerationcontext = new WorldGenerationContext(this, region, region.getMinecraftWorld()); // Paper - Flat bedrock generator settings
this.buildSurface(chunk, worldgenerationcontext, noiseConfig, structures, region.getBiomeManager(), region.registryAccess().registryOrThrow(Registries.BIOME), Blender.of(region)); this.buildSurface(chunk, worldgenerationcontext, noiseConfig, structures, region.getBiomeManager(), region.registryAccess().registryOrThrow(Registries.BIOME), Blender.of(region));
} }
@ -130,7 +130,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}); });
Aquifer aquifer = noisechunk.aquifer(); Aquifer aquifer = noisechunk.aquifer();
- CarvingContext carvingcontext = new CarvingContext(this, chunkRegion.registryAccess(), chunk.getHeightAccessorForGeneration(), noisechunk, noiseConfig, ((NoiseGeneratorSettings) this.settings.value()).surfaceRule()); - CarvingContext carvingcontext = new CarvingContext(this, chunkRegion.registryAccess(), chunk.getHeightAccessorForGeneration(), noisechunk, noiseConfig, ((NoiseGeneratorSettings) this.settings.value()).surfaceRule());
+ CarvingContext carvingcontext = new CarvingContext(this, chunkRegion.registryAccess(), chunk.getHeightAccessorForGeneration(), noisechunk, noiseConfig, ((NoiseGeneratorSettings) this.settings.value()).surfaceRule(), chunkRegion.getMinecraftWorld()); // Paper + CarvingContext carvingcontext = new CarvingContext(this, chunkRegion.registryAccess(), chunk.getHeightAccessorForGeneration(), noisechunk, noiseConfig, ((NoiseGeneratorSettings) this.settings.value()).surfaceRule(), chunkRegion.getMinecraftWorld()); // Paper - Flat bedrock generator settings
CarvingMask carvingmask = ((ProtoChunk) chunk).getOrCreateCarvingMask(carverStep); CarvingMask carvingmask = ((ProtoChunk) chunk).getOrCreateCarvingMask(carverStep);
for (int j = -8; j <= 8; ++j) { for (int j = -8; j <= 8; ++j) {
@ -142,14 +142,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public class WorldGenerationContext { public class WorldGenerationContext {
private final int minY; private final int minY;
private final int height; private final int height;
+ private final @javax.annotation.Nullable net.minecraft.world.level.Level level; // Paper + private final @javax.annotation.Nullable net.minecraft.world.level.Level level; // Paper - Flat bedrock generator settings
- public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world) { - public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world) {
+ public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world) { this(generator, world, null); } // Paper + public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world) { this(generator, world, null); } // Paper - Flat bedrock generator settings
+ public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world, @org.jetbrains.annotations.Nullable net.minecraft.world.level.Level level) { // Paper + public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world, @org.jetbrains.annotations.Nullable net.minecraft.world.level.Level level) { // Paper - Flat bedrock generator settings
this.minY = Math.max(world.getMinBuildHeight(), generator.getMinY()); this.minY = Math.max(world.getMinBuildHeight(), generator.getMinY());
this.height = Math.min(world.getHeight(), generator.getGenDepth()); this.height = Math.min(world.getHeight(), generator.getGenDepth());
+ this.level = level; // Paper + this.level = level; // Paper - Flat bedrock generator settings
} }
public int getMinGenY() { public int getMinGenY() {
@ -158,14 +158,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return this.height; return this.height;
} }
+ +
+ // Paper start + // Paper start - Flat bedrock generator settings
+ public net.minecraft.world.level.Level getWorld() { + public net.minecraft.world.level.Level getWorld() {
+ if (this.level == null) { + if (this.level == null) {
+ throw new NullPointerException("WorldGenerationContext was initialized without a Level, but WorldGenerationContext#getWorld was called"); + throw new NullPointerException("WorldGenerationContext was initialized without a Level, but WorldGenerationContext#getWorld was called");
+ } + }
+ return this.level; + return this.level;
+ } + }
+ // Paper end + // Paper end - Flat bedrock generator settings
} }
diff --git a/src/main/java/net/minecraft/world/level/levelgen/carver/CarvingContext.java b/src/main/java/net/minecraft/world/level/levelgen/carver/CarvingContext.java diff --git a/src/main/java/net/minecraft/world/level/levelgen/carver/CarvingContext.java b/src/main/java/net/minecraft/world/level/levelgen/carver/CarvingContext.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -177,8 +177,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- public CarvingContext(NoiseBasedChunkGenerator noiseChunkGenerator, RegistryAccess registryManager, LevelHeightAccessor heightLimitView, NoiseChunk chunkNoiseSampler, RandomState noiseConfig, SurfaceRules.RuleSource materialRule) { - public CarvingContext(NoiseBasedChunkGenerator noiseChunkGenerator, RegistryAccess registryManager, LevelHeightAccessor heightLimitView, NoiseChunk chunkNoiseSampler, RandomState noiseConfig, SurfaceRules.RuleSource materialRule) {
- super(noiseChunkGenerator, heightLimitView); - super(noiseChunkGenerator, heightLimitView);
+ public CarvingContext(NoiseBasedChunkGenerator noiseChunkGenerator, RegistryAccess registryManager, LevelHeightAccessor heightLimitView, NoiseChunk chunkNoiseSampler, RandomState noiseConfig, SurfaceRules.RuleSource materialRule, @javax.annotation.Nullable net.minecraft.world.level.Level level) { // Paper + public CarvingContext(NoiseBasedChunkGenerator noiseChunkGenerator, RegistryAccess registryManager, LevelHeightAccessor heightLimitView, NoiseChunk chunkNoiseSampler, RandomState noiseConfig, SurfaceRules.RuleSource materialRule, @javax.annotation.Nullable net.minecraft.world.level.Level level) { // Paper - Flat bedrock generator settings
+ super(noiseChunkGenerator, heightLimitView, level); // Paper + super(noiseChunkGenerator, heightLimitView, level); // Paper - Flat bedrock generator settings
this.registryAccess = registryManager; this.registryAccess = registryManager;
this.noiseChunk = chunkNoiseSampler; this.noiseChunk = chunkNoiseSampler;
this.randomState = noiseConfig; this.randomState = noiseConfig;
@ -191,7 +191,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public PlacementContext(WorldGenLevel world, ChunkGenerator generator, Optional<PlacedFeature> placedFeature) { public PlacementContext(WorldGenLevel world, ChunkGenerator generator, Optional<PlacedFeature> placedFeature) {
- super(generator, world); - super(generator, world);
+ super(generator, world, world.getLevel()); // Paper + super(generator, world, world.getLevel()); // Paper - Flat bedrock generator settings
this.level = world; this.level = world;
this.generator = generator; this.generator = generator;
this.topFeature = placedFeature; this.topFeature = placedFeature;

Datei anzeigen

@ -61,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ItemEntity extends Entity implements TraceableEntity { @@ -0,0 +0,0 @@ public class ItemEntity extends Entity implements TraceableEntity {
private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
public boolean canMobPickup = true; // Paper public boolean canMobPickup = true; // Paper
private int despawnRate = -1; // Paper private int despawnRate = -1; // Paper - Alternative item-despawn-rate
+ public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API + public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API
public ItemEntity(EntityType<? extends ItemEntity> type, Level world) { public ItemEntity(EntityType<? extends ItemEntity> type, Level world) {

Datei anzeigen

@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos")); + return new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos"));
+ } + }
+ } + }
+ // Paper end + // Paper end - guard against serializing mismatching coordinates
// Paper start // Paper start
public static final class InProgressChunkHolder { public static final class InProgressChunkHolder {
@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public static InProgressChunkHolder loadChunk(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt, boolean distinguish) { public static InProgressChunkHolder loadChunk(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt, boolean distinguish) {
// Paper end // Paper end
- ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); - ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos"));
+ ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate + 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)) { if (!Objects.equals(chunkPos, chunkcoordintpair1)) {
ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", new Object[]{chunkPos, chunkPos, chunkcoordintpair1}); ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", new Object[]{chunkPos, chunkPos, chunkcoordintpair1});
@ -45,13 +45,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper start - async chunk io // Paper start - async chunk io
public void write(ChunkPos chunkPos, CompoundTag nbt) throws IOException { public void write(ChunkPos chunkPos, CompoundTag nbt) throws IOException {
+ // Paper start + // Paper start - guard against serializing mismatching coordinates
+ if (nbt != null && !chunkPos.equals(ChunkSerializer.getChunkCoordinate(nbt))) { + if (nbt != null && !chunkPos.equals(ChunkSerializer.getChunkCoordinate(nbt))) {
+ String world = (this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap)this).level.getWorld().getName() : null; + 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.toString() + throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkPos.toString()
+ + " but compound says coordinate is " + ChunkSerializer.getChunkCoordinate(nbt).toString() + (world == null ? " for an unknown world" : (" for world: " + world))); + + " but compound says coordinate is " + ChunkSerializer.getChunkCoordinate(nbt).toString() + (world == null ? " for an unknown world" : (" for world: " + world)));
+ } + }
+ // Paper end + // Paper end - guard against serializing mismatching coordinates
this.regionFileCache.write(chunkPos, nbt); this.regionFileCache.write(chunkPos, nbt);
// Paper end - Async chunk loading // Paper end - Async chunk loading
if (this.legacyStructureHandler != null) { if (this.legacyStructureHandler != null) {

Datei anzeigen

@ -25,11 +25,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool) { public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool) {
super.playerDestroy(world, player, pos, state, blockEntity, tool); super.playerDestroy(world, player, pos, state, blockEntity, tool);
+ // Paper start + // Paper start - Improve Block#breakNaturally API
+ this.afterDestroy(world, pos, tool); + this.afterDestroy(world, pos, tool);
+ } + }
+ public void afterDestroy(Level world, BlockPos pos, ItemStack tool) { + public void afterDestroy(Level world, BlockPos pos, ItemStack tool) {
+ // Paper end + // Paper end - Improve Block#breakNaturally API
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) == 0) { if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) == 0) {
if (world.dimensionType().ultraWarm()) { if (world.dimensionType().ultraWarm()) {
world.removeBlock(pos, false); world.removeBlock(pos, false);

Datei anzeigen

@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- return entityPlayer.mobCounts[mobCategory.ordinal()]; - return entityPlayer.mobCounts[mobCategory.ordinal()];
+ return entityPlayer.mobCounts[mobCategory.ordinal()] + entityPlayer.mobBackoffCounts[mobCategory.ordinal()]; // Paper - per player mob count backoff + return entityPlayer.mobCounts[mobCategory.ordinal()] + entityPlayer.mobBackoffCounts[mobCategory.ordinal()]; // Paper - per player mob count backoff
} }
// Paper end // Paper end - Optional per player mob spawns
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { @@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length; public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length;
public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper
// Paper end - mob spawning rework // Paper end - Optional per player mob spawns
+ public final int[] mobBackoffCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper - per player mob count backoff + public final int[] mobBackoffCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper - per player mob count backoff
// CraftBukkit start // CraftBukkit start
@ -86,5 +86,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end - per player mob count backoff + // Paper end - per player mob count backoff
if (doSpawning == PreSpawnStatus.ABORT) { if (doSpawning == PreSpawnStatus.ABORT) {
return j; // Paper return j; // Paper - Optional per player mob spawns
} }

Datei anzeigen

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return; return;
} }
+ // Paper start - better java version checks + // Paper start - Improve java version check
+ boolean skip = Boolean.getBoolean("Paper.IgnoreJavaVersion"); + boolean skip = Boolean.getBoolean("Paper.IgnoreJavaVersion");
float javaVersion = Float.parseFloat(System.getProperty("java.class.version")); float javaVersion = Float.parseFloat(System.getProperty("java.class.version"));
- if (javaVersion < 61.0) { - if (javaVersion < 61.0) {
@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (skip && (isOldVersion || isPreRelease)) { + if (skip && (isOldVersion || isPreRelease)) {
+ System.err.println("Unsupported Java detected ("+ javaVersionName + "), but the check was skipped. Proceed with caution! "); + System.err.println("Unsupported Java detected ("+ javaVersionName + "), but the check was skipped. Proceed with caution! ");
+ } + }
+ // Paper end - better java version checks + // Paper end - Improve java version check
+ +
try { try {
// Paper start - Handled by TerminalConsoleAppender // Paper start - Handled by TerminalConsoleAppender

Datei anzeigen

@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
return player != null && player.level() == this ? player : null; return player != null && player.level() == this ? player : null;
} }
// Paper end // Paper end - optimise getPlayerByUUID
+ // Paper start - lag compensation + // Paper start - lag compensation
+ private long lagCompensationTick = net.minecraft.server.MinecraftServer.SERVER_INIT; + private long lagCompensationTick = net.minecraft.server.MinecraftServer.SERVER_INIT;
+ +
@ -95,7 +95,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper use override flag if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
this.useItem = itemstack; this.useItem = itemstack;
- this.useItemRemaining = itemstack.getUseDuration(); - this.useItemRemaining = itemstack.getUseDuration();
+ // Paper start - lag compensate eating + // Paper start - lag compensate eating

Datei anzeigen

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.randomInterval = reducedTickDelay(reciprocalChance); this.randomInterval = reducedTickDelay(reciprocalChance);
this.setFlags(EnumSet.of(Goal.Flag.TARGET)); this.setFlags(EnumSet.of(Goal.Flag.TARGET));
this.targetConditions = TargetingConditions.forCombat().range(this.getFollowDistance()).selector(targetPredicate); this.targetConditions = TargetingConditions.forCombat().range(this.getFollowDistance()).selector(targetPredicate);
+ if (mob.level().paperConfig().entities.entitiesTargetWithFollowRange) this.targetConditions.useFollowRange(); // Paper + if (mob.level().paperConfig().entities.entitiesTargetWithFollowRange) this.targetConditions.useFollowRange(); // Paper - Fix MC-145656
} }
@Override @Override
@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.range > 0.0D) { if (this.range > 0.0D) {
double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D; double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
- double e = Math.max(this.range * d, 2.0D); - double e = Math.max(this.range * d, 2.0D);
+ double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper + double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper - Fix MC-145656
double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ()); double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
if (f > e * e) { if (f > e * e) {
return false; return false;
@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
+ +
+ // Paper start + // Paper start - Fix MC-145656
+ private boolean useFollowRange = false; + private boolean useFollowRange = false;
+ +
+ public TargetingConditions useFollowRange() { + public TargetingConditions useFollowRange() {
@ -46,5 +46,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ net.minecraft.world.entity.ai.attributes.AttributeInstance attributeinstance = entityliving.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.FOLLOW_RANGE); + net.minecraft.world.entity.ai.attributes.AttributeInstance attributeinstance = entityliving.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.FOLLOW_RANGE);
+ return attributeinstance == null ? 16.0D : attributeinstance.getValue(); + return attributeinstance == null ? 16.0D : attributeinstance.getValue();
+ } + }
+ // Paper end + // Paper end - Fix MC-145656
} }

Datei anzeigen

@ -392,7 +392,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private JComponent buildInfoPanel() { private JComponent buildInfoPanel() {
JPanel jpanel = new JPanel(new BorderLayout()); JPanel jpanel = new JPanel(new BorderLayout());
- StatsComponent guistatscomponent = new StatsComponent(this.server); - StatsComponent guistatscomponent = new StatsComponent(this.server);
+ com.destroystokyo.paper.gui.GuiStatsComponent guistatscomponent = new com.destroystokyo.paper.gui.GuiStatsComponent(this.server); // Paper + com.destroystokyo.paper.gui.GuiStatsComponent guistatscomponent = new com.destroystokyo.paper.gui.GuiStatsComponent(this.server); // Paper - Make GUI graph fancier
Collection<Runnable> collection = this.finalizers; // CraftBukkit - decompile error Collection<Runnable> collection = this.finalizers; // CraftBukkit - decompile error
Objects.requireNonNull(guistatscomponent); Objects.requireNonNull(guistatscomponent);

Datei anzeigen

@ -64,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ nbt.putShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay)); + nbt.putShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay));
+ nbt.putShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay)); + nbt.putShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay));
+ // Paper nbt + // Paper end
nbt.putShort("SpawnCount", (short) this.spawnCount); nbt.putShort("SpawnCount", (short) this.spawnCount);
nbt.putShort("MaxNearbyEntities", (short) this.maxNearbyEntities); nbt.putShort("MaxNearbyEntities", (short) this.maxNearbyEntities);
nbt.putShort("RequiredPlayerRange", (short) this.requiredPlayerRange); nbt.putShort("RequiredPlayerRange", (short) this.requiredPlayerRange);

Datei anzeigen

@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { + entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) {
+ continue; + continue;
+ } + }
+ // Paper end + // Paper end - Only count natural spawns
BlockPos blockposition = entity.blockPosition(); BlockPos blockposition = entity.blockPosition();
chunkSource.query(ChunkPos.asLong(blockposition), (chunk) -> { chunkSource.query(ChunkPos.asLong(blockposition), (chunk) -> {

Datei anzeigen

@ -52,10 +52,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable {
NbtIo.write(nbt, (DataOutput) dataoutputstream); NbtIo.write(nbt, (DataOutput) dataoutputstream);
regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - cache status on disk regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - Cache chunk status
regionfile.setOversized(pos.x, pos.z, false); // Paper - We don't do this anymore, mojang stores differently, but clear old meta flag if it exists to get rid of our own meta file once last oversized is gone regionfile.setOversized(pos.x, pos.z, false); // Paper - We don't do this anymore, mojang stores differently, but clear old meta flag if it exists to get rid of our own meta file once last oversized is gone
+ dataoutputstream.close(); // Paper - only write if successful + dataoutputstream.close(); // Paper - only write if successful
+ // Paper start - don't write garbage data to disk if writing serialization fails + // Paper start - don't write garbage data to disk if writing serialization fails
+ } catch (RegionFileSizeException e) { + } catch (RegionFileSizeException e) {
+ attempts = 5; // Don't retry + attempts = 5; // Don't retry
+ regionfile.clear(pos); + regionfile.clear(pos);

Datei anzeigen

@ -20,8 +20,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- -
- if (l >= 0 && l < this.sections.length) { - if (l >= 0 && l < this.sections.length) {
- LevelChunkSection chunksection = this.sections[l]; - LevelChunkSection chunksection = this.sections[l];
+ // try { // Paper - remove try catch + // Paper start - Perf: Optimise Chunk#getFluid
+ // Paper start - reduce the number of ops in this call + // try { // Remove try catch
+ int index = this.getSectionIndex(y); + int index = this.getSectionIndex(y);
+ if (index >= 0 && index < this.sections.length) { + if (index >= 0 && index < this.sections.length) {
+ LevelChunkSection chunksection = this.sections[index]; + LevelChunkSection chunksection = this.sections[index];
@ -29,12 +29,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (!chunksection.hasOnlyAir()) { if (!chunksection.hasOnlyAir()) {
- return chunksection.getFluidState(x & 15, y & 15, z & 15); - return chunksection.getFluidState(x & 15, y & 15, z & 15);
+ return chunksection.states.get((y & 15) << 8 | (z & 15) << 4 | x & 15).getFluidState(); + return chunksection.states.get((y & 15) << 8 | (z & 15) << 4 | x & 15).getFluidState();
+ // Paper end + // Paper end - Perf: Optimise Chunk#getFluid
} }
} }
return Fluids.EMPTY.defaultFluidState(); return Fluids.EMPTY.defaultFluidState();
+ /* // Paper - remove try catch + /* // Paper - Perf: Optimise Chunk#getFluid
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Getting fluid state"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Getting fluid state");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Block being got"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Block being got");
@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}); });
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
} }
+ */ // Paper - remove try catch + */ // Paper - Perf: Optimise Chunk#getFluid
} }
// CraftBukkit start // CraftBukkit start
@ -55,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public FluidState getFluidState(int x, int y, int z) { public FluidState getFluidState(int x, int y, int z) {
- return ((BlockState) this.states.get(x, y, z)).getFluidState(); - return ((BlockState) this.states.get(x, y, z)).getFluidState();
+ return this.states.get(x, y, z).getFluidState(); // Paper - diff on change - we expect this to be effectively just getType(x, y, z).getFluid(). If this changes we need to check other patches that use IBlockData#getFluid. + return this.states.get(x, y, z).getFluidState(); // Paper - Perf: Optimise Chunk#getFluid; diff on change - we expect this to be effectively just getType(x, y, z).getFluid(). If this changes we need to check other patches that use IBlockData#getFluid.
} }
public void acquire() { public void acquire() {

Datei anzeigen

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final Player player = this.getServer().getPlayerList().getPlayer(uuid); + final Player player = this.getServer().getPlayerList().getPlayer(uuid);
+ return player != null && player.level() == this ? player : null; + return player != null && player.level() == this ? player : null;
+ } + }
+ // Paper end + // Paper end - optimise getPlayerByUUID
+ +
// 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) {

Datei anzeigen

@ -132,7 +132,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
// Paper end // Paper end - Optional per player mob spawns
- private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { - private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) {
+ public static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { // Paper - optimise chunk iteration; public + public static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { // Paper - optimise chunk iteration; public

Datei anzeigen

@ -14,12 +14,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return this.getChunk(x, z, leastStatus, create); return this.getChunk(x, z, leastStatus, create);
}, this.mainThreadProcessor).join(); }, this.mainThreadProcessor).join();
} else { } else {
+ // Paper start - optimise for loaded chunks + // Paper start - Perf: Optimise getChunkAt calls for loaded chunks
+ LevelChunk ifLoaded = this.getChunkAtIfLoadedMainThread(x, z); + LevelChunk ifLoaded = this.getChunkAtIfLoadedMainThread(x, z);
+ if (ifLoaded != null) { + if (ifLoaded != null) {
+ return ifLoaded; + return ifLoaded;
+ } + }
+ // Paper end + // Paper end - Perf: Optimise getChunkAt calls for loaded chunks
ProfilerFiller gameprofilerfiller = this.level.getProfiler(); ProfilerFiller gameprofilerfiller = this.level.getProfiler();
gameprofilerfiller.incrementCounter("getChunk"); gameprofilerfiller.incrementCounter("getChunk");
@ -60,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- return null; - return null;
- } - }
- } - }
+ return this.getChunkAtIfLoadedMainThread(chunkX, chunkZ); // Paper - optimise for loaded chunks + return this.getChunkAtIfLoadedMainThread(chunkX, chunkZ); // Paper - Perf: Optimise getChunkAt calls for loaded chunks
} }
} }

Datei anzeigen

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sat, 6 Apr 2019 10:16:48 -0400 Date: Sat, 6 Apr 2019 10:16:48 -0400
Subject: [PATCH] Optimize Captured TileEntity Lookup Subject: [PATCH] Optimize Captured BlockEntity Lookup
upstream was doing a containsKey/get pattern, and always doing it at that. upstream was doing a containsKey/get pattern, and always doing it at that.
that scenario is only even valid if were in the middle of a block place. that scenario is only even valid if were in the middle of a block place.
@ -19,12 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) { public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) {
- if (this.capturedTileEntities.containsKey(blockposition)) { - if (this.capturedTileEntities.containsKey(blockposition)) {
- return this.capturedTileEntities.get(blockposition); - return this.capturedTileEntities.get(blockposition);
+ // Paper start - Optimize capturedTileEntities lookup + // Paper start - Perf: Optimize capturedTileEntities lookup
+ net.minecraft.world.level.block.entity.BlockEntity blockEntity; + net.minecraft.world.level.block.entity.BlockEntity blockEntity;
+ if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(blockposition)) != null) { + if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(blockposition)) != null) {
+ return blockEntity; + return blockEntity;
} }
+ // Paper end + // Paper end - Perf: Optimize capturedTileEntities lookup
// CraftBukkit end // CraftBukkit end
return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && !io.papermc.paper.util.TickThread.isTickThread() ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); // Paper - rewrite chunk system return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && !io.papermc.paper.util.TickThread.isTickThread() ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); // Paper - rewrite chunk system
} }

Datei anzeigen

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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);
- FluidState fluid = this.level.getFluidState(blockposition); - FluidState fluid = this.level.getFluidState(blockposition);
+ FluidState fluid = iblockdata.getFluidState(); // Paper + FluidState fluid = iblockdata.getFluidState(); // Paper - Perf: Optimize call to getFluid for explosions
if (!this.level.isInWorldBounds(blockposition)) { if (!this.level.isInWorldBounds(blockposition)) {
break; break;

Datei anzeigen

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com> From: kickash32 <kickash32@gmail.com>
Date: Mon, 19 Aug 2019 01:27:58 +0500 Date: Mon, 19 Aug 2019 01:27:58 +0500
Subject: [PATCH] implement optional per player mob spawns Subject: [PATCH] Optional per player mob spawns
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}); });
} }
+ // Paper start + // Paper start - Optional per player mob spawns
+ public void updatePlayerMobTypeMap(Entity entity) { + public void updatePlayerMobTypeMap(Entity entity) {
+ if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { + if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) {
+ return; + return;
@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public int getMobCountNear(ServerPlayer entityPlayer, net.minecraft.world.entity.MobCategory mobCategory) { + public int getMobCountNear(ServerPlayer entityPlayer, net.minecraft.world.entity.MobCategory mobCategory) {
+ return entityPlayer.mobCounts[mobCategory.ordinal()]; + return entityPlayer.mobCounts[mobCategory.ordinal()];
+ } + }
+ // Paper end + // Paper end - Optional per player mob spawns
+ +
private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) {
double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8); double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8);
@ -47,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.level.timings.countNaturalMobs.startTiming(); // Paper - timings this.level.timings.countNaturalMobs.startTiming(); // Paper - timings
int k = this.distanceManager.getNaturalSpawnChunkCount(); int k = this.distanceManager.getNaturalSpawnChunkCount();
- NaturalSpawner.SpawnState spawnercreature_d = NaturalSpawner.createState(k, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap)); - NaturalSpawner.SpawnState spawnercreature_d = NaturalSpawner.createState(k, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap));
+ // Paper start - per player mob spawning + // Paper start - Optional per player mob spawns
+ int naturalSpawnChunkCount = k; + int naturalSpawnChunkCount = k;
+ NaturalSpawner.SpawnState spawnercreature_d; // moved down + NaturalSpawner.SpawnState spawnercreature_d; // moved down
+ if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled + if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } else { + } else {
+ spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); + spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false);
+ } + }
+ // Paper end + // Paper end - Optional per player mob spawns
this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings
this.lastSpawnState = spawnercreature_d; this.lastSpawnState = spawnercreature_d;
@ -71,10 +71,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public boolean queueHealthUpdatePacket = false; public boolean queueHealthUpdatePacket = false;
public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket;
// Paper end // Paper end
+ // Paper start - mob spawning rework + // Paper start - Optional per player mob spawns
+ public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length; + public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length;
+ public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper + public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper
+ // Paper end - mob spawning rework + // Paper end - Optional per player mob spawns
// CraftBukkit start // CraftBukkit start
public String displayName; public String displayName;
@ -86,12 +86,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private NaturalSpawner() {} private NaturalSpawner() {}
public static NaturalSpawner.SpawnState createState(int spawningChunkCount, Iterable<Entity> entities, NaturalSpawner.ChunkGetter chunkSource, LocalMobCapCalculator densityCapper) { public static NaturalSpawner.SpawnState createState(int spawningChunkCount, Iterable<Entity> entities, NaturalSpawner.ChunkGetter chunkSource, LocalMobCapCalculator densityCapper) {
+ // Paper start - add countMobs parameter + // Paper start - Optional per player mob spawns
+ return createState(spawningChunkCount, entities, chunkSource, densityCapper, false); + return createState(spawningChunkCount, entities, chunkSource, densityCapper, false);
+ } + }
+ +
+ public static NaturalSpawner.SpawnState createState(int spawningChunkCount, Iterable<Entity> entities, NaturalSpawner.ChunkGetter chunkSource, LocalMobCapCalculator densityCapper, boolean countMobs) { + public static NaturalSpawner.SpawnState createState(int spawningChunkCount, Iterable<Entity> entities, NaturalSpawner.ChunkGetter chunkSource, LocalMobCapCalculator densityCapper, boolean countMobs) {
+ // Paper end + // Paper end - Optional per player mob spawns
PotentialCalculator spawnercreatureprobabilities = new PotentialCalculator(); PotentialCalculator spawnercreatureprobabilities = new PotentialCalculator();
Object2IntOpenHashMap<MobCategory> object2intopenhashmap = new Object2IntOpenHashMap(); Object2IntOpenHashMap<MobCategory> object2intopenhashmap = new Object2IntOpenHashMap();
Iterator iterator = entities.iterator(); Iterator iterator = entities.iterator();
@ -100,16 +100,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- if (entity instanceof Mob) { - if (entity instanceof Mob) {
+ if (densityCapper != null && entity instanceof Mob) { // Paper + if (densityCapper != null && entity instanceof Mob) { // Paper - Optional per player mob spawns
densityCapper.addMob(chunk.getPos(), enumcreaturetype); densityCapper.addMob(chunk.getPos(), enumcreaturetype);
} }
object2intopenhashmap.addTo(enumcreaturetype, 1); object2intopenhashmap.addTo(enumcreaturetype, 1);
+ // Paper start + // Paper start - Optional per player mob spawns
+ if (countMobs) { + if (countMobs) {
+ chunk.level.getChunkSource().chunkMap.updatePlayerMobTypeMap(entity); + chunk.level.getChunkSource().chunkMap.updatePlayerMobTypeMap(entity);
+ } + }
+ // Paper end + // Paper end - Optional per player mob spawns
}); });
} }
} }
@ -118,7 +118,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- if ((spawnAnimals || !enumcreaturetype.isFriendly()) && (spawnMonsters || enumcreaturetype.isFriendly()) && (rareSpawn || !enumcreaturetype.isPersistent()) && info.canSpawnForCategory(enumcreaturetype, chunk.getPos(), limit)) { - if ((spawnAnimals || !enumcreaturetype.isFriendly()) && (spawnMonsters || enumcreaturetype.isFriendly()) && (rareSpawn || !enumcreaturetype.isPersistent()) && info.canSpawnForCategory(enumcreaturetype, chunk.getPos(), limit)) {
+ // Paper start - only allow spawns upto the limit per chunk and update count afterwards + // Paper start - Optional per player mob spawns; only allow spawns upto the limit per chunk and update count afterwards
+ int currEntityCount = info.mobCategoryCounts.getInt(enumcreaturetype); + int currEntityCount = info.mobCategoryCounts.getInt(enumcreaturetype);
+ int k1 = limit * info.getSpawnableChunkCount() / NaturalSpawner.MAGIC_NUMBER; + int k1 = limit * info.getSpawnableChunkCount() / NaturalSpawner.MAGIC_NUMBER;
+ int difference = k1 - currEntityCount; + int difference = k1 - currEntityCount;
@ -136,18 +136,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ difference = (minDiff == Integer.MAX_VALUE) ? 0 : minDiff; + difference = (minDiff == Integer.MAX_VALUE) ? 0 : minDiff;
+ } + }
+ if ((spawnAnimals || !enumcreaturetype.isFriendly()) && (spawnMonsters || enumcreaturetype.isFriendly()) && (rareSpawn || !enumcreaturetype.isPersistent()) && difference > 0) { + if ((spawnAnimals || !enumcreaturetype.isFriendly()) && (spawnMonsters || enumcreaturetype.isFriendly()) && (rareSpawn || !enumcreaturetype.isPersistent()) && difference > 0) {
+ // Paper end + // Paper end - Optional per player mob spawns
// CraftBukkit end // CraftBukkit end
Objects.requireNonNull(info); Objects.requireNonNull(info);
NaturalSpawner.SpawnPredicate spawnercreature_c = info::canSpawn; NaturalSpawner.SpawnPredicate spawnercreature_c = info::canSpawn;
Objects.requireNonNull(info); Objects.requireNonNull(info);
- NaturalSpawner.spawnCategoryForChunk(enumcreaturetype, world, chunk, spawnercreature_c, info::afterSpawn); - NaturalSpawner.spawnCategoryForChunk(enumcreaturetype, world, chunk, spawnercreature_c, info::afterSpawn);
+ // Paper start + // Paper start - Optional per player mob spawns
+ int spawnCount = NaturalSpawner.spawnCategoryForChunk(enumcreaturetype, world, chunk, spawnercreature_c, info::afterSpawn, + int spawnCount = NaturalSpawner.spawnCategoryForChunk(enumcreaturetype, world, chunk, spawnercreature_c, info::afterSpawn,
+ difference, world.paperConfig().entities.spawning.perPlayerMobSpawns ? world.getChunkSource().chunkMap::updatePlayerMobTypeMap : null); + difference, world.paperConfig().entities.spawning.perPlayerMobSpawns ? world.getChunkSource().chunkMap::updatePlayerMobTypeMap : null);
+ info.mobCategoryCounts.mergeInt(enumcreaturetype, spawnCount, Integer::sum); + info.mobCategoryCounts.mergeInt(enumcreaturetype, spawnCount, Integer::sum);
+ // Paper end + // Paper end - Optional per player mob spawns
} }
} }
@ -155,18 +155,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) { public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
+ // Paper start - add parameters and int ret type + // Paper start - Optional per player mob spawns
+ spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null); + spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null);
+ } + }
+ public static int spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer<Entity> trackEntity) { + public static int spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer<Entity> trackEntity) {
+ // Paper end - add parameters and int ret type + // Paper end - Optional per player mob spawns
BlockPos blockposition = NaturalSpawner.getRandomPosWithin(world, chunk); BlockPos blockposition = NaturalSpawner.getRandomPosWithin(world, chunk);
if (blockposition.getY() >= world.getMinBuildHeight() + 1) { if (blockposition.getY() >= world.getMinBuildHeight() + 1) {
- NaturalSpawner.spawnCategoryForPosition(group, world, chunk, blockposition, checker, runner); - NaturalSpawner.spawnCategoryForPosition(group, world, chunk, blockposition, checker, runner);
+ return NaturalSpawner.spawnCategoryForPosition(group, world, chunk, blockposition, checker, runner, maxSpawns, trackEntity); // Paper + return NaturalSpawner.spawnCategoryForPosition(group, world, chunk, blockposition, checker, runner, maxSpawns, trackEntity); // Paper - Optional per player mob spawns
} }
+ return 0; // Paper + return 0; // Paper - Optional per player mob spawns
} }
@VisibleForDebug @VisibleForDebug
@ -174,22 +174,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}); });
} }
+ // Paper start - add maxSpawns parameter and return spawned mobs + // Paper start - Optional per player mob spawns
public static void spawnCategoryForPosition(MobCategory group, ServerLevel world, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) { public static void spawnCategoryForPosition(MobCategory group, ServerLevel world, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
+ spawnCategoryForPosition(group, world,chunk, pos, checker, runner, Integer.MAX_VALUE, null); + spawnCategoryForPosition(group, world,chunk, pos, checker, runner, Integer.MAX_VALUE, null);
+ } + }
+ public static int spawnCategoryForPosition(MobCategory group, ServerLevel world, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer<Entity> trackEntity) { + public static int spawnCategoryForPosition(MobCategory group, ServerLevel world, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer<Entity> trackEntity) {
+ // Paper end - add maxSpawns parameter and return spawned mobs + // Paper end - Optional per player mob spawns
StructureManager structuremanager = world.structureManager(); StructureManager structuremanager = world.structureManager();
ChunkGenerator chunkgenerator = world.getChunkSource().getGenerator(); ChunkGenerator chunkgenerator = world.getChunkSource().getGenerator();
int i = pos.getY(); int i = pos.getY();
BlockState iblockdata = world.getBlockStateIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn BlockState iblockdata = world.getBlockStateIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn
+ int j = 0; // Paper - moved up + int j = 0; // Paper - Optional per player mob spawns; moved up
if (iblockdata != null && !iblockdata.isRedstoneConductor(chunk, pos)) { // Paper - don't load chunks for mob spawn if (iblockdata != null && !iblockdata.isRedstoneConductor(chunk, pos)) { // Paper - don't load chunks for mob spawn
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
- int j = 0; - int j = 0;
+ //int j = 0; // Paper - moved up + //int j = 0; // Paper - Optional per player mob spawns; moved up
int k = 0; int k = 0;
while (k < 3) { while (k < 3) {
@ -198,7 +198,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
PreSpawnStatus doSpawning = isValidSpawnPostitionForType(world, group, structuremanager, chunkgenerator, biomesettingsmobs_c, blockposition_mutableblockposition, d2); PreSpawnStatus doSpawning = isValidSpawnPostitionForType(world, group, structuremanager, chunkgenerator, biomesettingsmobs_c, blockposition_mutableblockposition, d2);
if (doSpawning == PreSpawnStatus.ABORT) { if (doSpawning == PreSpawnStatus.ABORT) {
- return; - return;
+ return j; // Paper + return j; // Paper - Optional per player mob spawns
} }
if (doSpawning == PreSpawnStatus.SUCCESS && checker.test(biomesettingsmobs_c.type, blockposition_mutableblockposition, chunk)) { if (doSpawning == PreSpawnStatus.SUCCESS && checker.test(biomesettingsmobs_c.type, blockposition_mutableblockposition, chunk)) {
// Paper end // Paper end
@ -206,7 +206,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (entityinsentient == null) { if (entityinsentient == null) {
- return; - return;
+ return j; // Paper + return j; // Paper - Optional per player mob spawns
} }
entityinsentient.moveTo(d0, (double) i, d1, world.random.nextFloat() * 360.0F, 0.0F); entityinsentient.moveTo(d0, (double) i, d1, world.random.nextFloat() * 360.0F, 0.0F);
@ -214,17 +214,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
++j; ++j;
++k1; ++k1;
runner.run(entityinsentient, chunk); runner.run(entityinsentient, chunk);
+ // Paper start + // Paper start - Optional per player mob spawns
+ if (trackEntity != null) { + if (trackEntity != null) {
+ trackEntity.accept(entityinsentient); + trackEntity.accept(entityinsentient);
+ } + }
+ // Paper end + // Paper end - Optional per player mob spawns
} }
// CraftBukkit end // CraftBukkit end
- if (j >= entityinsentient.getMaxSpawnClusterSize()) { - if (j >= entityinsentient.getMaxSpawnClusterSize()) {
- return; - return;
+ if (j >= entityinsentient.getMaxSpawnClusterSize() || j >= maxSpawns) { // Paper + if (j >= entityinsentient.getMaxSpawnClusterSize() || j >= maxSpawns) { // Paper - Optional per player mob spawns
+ return j; // Paper + return j; // Paper - Optional per player mob spawns
} }
if (entityinsentient.isMaxGroupSizeReached(k1)) { if (entityinsentient.isMaxGroupSizeReached(k1)) {
@ -232,7 +232,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
+ return j; // Paper + return j; // Paper - Optional per player mob spawns
} }
private static boolean isRightDistanceToPlayerAndSpawnPoint(ServerLevel world, ChunkAccess chunk, BlockPos.MutableBlockPos pos, double squaredDistance) { private static boolean isRightDistanceToPlayerAndSpawnPoint(ServerLevel world, ChunkAccess chunk, BlockPos.MutableBlockPos pos, double squaredDistance) {
@ -241,7 +241,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.mobCategoryCounts.addTo(enumcreaturetype, 1); this.mobCategoryCounts.addTo(enumcreaturetype, 1);
- this.localMobCapCalculator.addMob(new ChunkPos(blockposition), enumcreaturetype); - this.localMobCapCalculator.addMob(new ChunkPos(blockposition), enumcreaturetype);
+ if (this.localMobCapCalculator != null) this.localMobCapCalculator.addMob(new ChunkPos(blockposition), enumcreaturetype); // Paper + if (this.localMobCapCalculator != null) this.localMobCapCalculator.addMob(new ChunkPos(blockposition), enumcreaturetype); // Paper - Optional per player mob spawns
} }
public int getSpawnableChunkCount() { public int getSpawnableChunkCount() {
@ -249,7 +249,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
int i = limit * this.spawnableChunkCount / NaturalSpawner.MAGIC_NUMBER; int i = limit * this.spawnableChunkCount / NaturalSpawner.MAGIC_NUMBER;
// CraftBukkit end // CraftBukkit end
+ if (this.localMobCapCalculator == null) return this.mobCategoryCounts.getInt(enumcreaturetype) < i; // Paper + if (this.localMobCapCalculator == null) return this.mobCategoryCounts.getInt(enumcreaturetype) < i; // Paper - Optional per player mob spawns
return this.mobCategoryCounts.getInt(enumcreaturetype) >= i ? false : this.localMobCapCalculator.canSpawn(enumcreaturetype, chunkcoordintpair); return this.mobCategoryCounts.getInt(enumcreaturetype) >= i ? false : this.localMobCapCalculator.canSpawn(enumcreaturetype, chunkcoordintpair);
} }
} }

Datei anzeigen

@ -29,8 +29,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public int tick(ServerLevel world, boolean spawnMonsters, boolean spawnAnimals) { public int tick(ServerLevel world, boolean spawnMonsters, boolean spawnAnimals) {
- if (world.paperConfig().entities.behavior.pillagerPatrols.disable) return 0; // Paper - if (world.paperConfig().entities.behavior.pillagerPatrols.disable) return 0; // Paper - Add option to disable pillager patrols
+ if (world.paperConfig().entities.behavior.pillagerPatrols.disable || world.paperConfig().entities.behavior.pillagerPatrols.spawnChance == 0) return 0; // Paper - Pillager patrol spawn settings and per player options + if (world.paperConfig().entities.behavior.pillagerPatrols.disable || world.paperConfig().entities.behavior.pillagerPatrols.spawnChance == 0) return 0; // Paper - Add option to disable pillager patrols & Pillager patrol spawn settings and per player options
if (!spawnMonsters) { if (!spawnMonsters) {
return 0; return 0;
} else if (!world.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { } else if (!world.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) {

Datei anzeigen

@ -12,15 +12,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
public void startUsingItem(InteractionHand hand) { public void startUsingItem(InteractionHand hand) {
+ // Paper start - forwarder to method with forceUpdate parameter + // Paper start - Prevent consuming the wrong itemstack
+ this.startUsingItem(hand, false); + this.startUsingItem(hand, false);
+ } + }
+ public void startUsingItem(InteractionHand hand, boolean forceUpdate) { + public void startUsingItem(InteractionHand hand, boolean forceUpdate) {
+ // Paper end + // Paper end - Prevent consuming the wrong itemstack
ItemStack itemstack = this.getItemInHand(hand); ItemStack itemstack = this.getItemInHand(hand);
- if (!itemstack.isEmpty() && !this.isUsingItem()) { - if (!itemstack.isEmpty() && !this.isUsingItem()) {
+ if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper use override flag + if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
this.useItem = itemstack; this.useItem = itemstack;
this.useItemRemaining = itemstack.getUseDuration(); this.useItemRemaining = itemstack.getUseDuration();
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.releaseUsingItem(); this.releaseUsingItem();
} else { } else {
if (!this.useItem.isEmpty() && this.isUsingItem()) { if (!this.useItem.isEmpty() && this.isUsingItem()) {
+ this.startUsingItem(this.getUsedItemHand(), true); // Paper + this.startUsingItem(this.getUsedItemHand(), true); // Paper - Prevent consuming the wrong itemstack
this.triggerItemUseEffects(this.useItem, 16); this.triggerItemUseEffects(this.useItem, 16);
// CraftBukkit start - fire PlayerItemConsumeEvent // CraftBukkit start - fire PlayerItemConsumeEvent
ItemStack itemstack; ItemStack itemstack;

Datei anzeigen

@ -13,8 +13,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- BlockState blockState = world.getBlockState(globalPos.pos()); - BlockState blockState = world.getBlockState(globalPos.pos());
+ BlockState blockState = world.getBlockStateIfLoaded(globalPos.pos()); // Paper + BlockState blockState = world.getBlockStateIfLoaded(globalPos.pos()); // Paper - Prevent sync chunk loads when villagers try to find beds
+ if (blockState == null) { return false; } // Paper + if (blockState == null) { return false; } // Paper - Prevent sync chunk loads when villagers try to find beds
return globalPos.pos().closerToCenterThan(entity.position(), 2.0D) && blockState.is(BlockTags.BEDS) && !blockState.getValue(BedBlock.OCCUPIED); return globalPos.pos().closerToCenterThan(entity.position(), 2.0D) && blockState.is(BlockTags.BEDS) && !blockState.getValue(BedBlock.OCCUPIED);
} }
} }

Datei anzeigen

@ -88,7 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- super.playerDestroy(world, player, pos, state, blockEntity, tool); - super.playerDestroy(world, player, pos, state, blockEntity, tool);
+ public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool, boolean includeDrops, boolean dropExp) { // Paper - fix drops not preventing stats/food exhaustion + public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool, boolean includeDrops, boolean dropExp) { // Paper - fix drops not preventing stats/food exhaustion
+ super.playerDestroy(world, player, pos, state, blockEntity, tool, includeDrops, dropExp); // Paper - fix drops not preventing stats/food exhaustion + super.playerDestroy(world, player, pos, state, blockEntity, tool, includeDrops, dropExp); // Paper - fix drops not preventing stats/food exhaustion
// Paper start // Paper start - Improve Block#breakNaturally API
this.afterDestroy(world, pos, tool); this.afterDestroy(world, pos, tool);
} }
diff --git a/src/main/java/net/minecraft/world/level/block/TurtleEggBlock.java b/src/main/java/net/minecraft/world/level/block/TurtleEggBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/TurtleEggBlock.java b/src/main/java/net/minecraft/world/level/block/TurtleEggBlock.java

Datei anzeigen

@ -21,7 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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);
+ if (!iblockdata.isDestroyable()) continue; // Paper - Protect Bedrock and End Portal/Frames from being destroyed + if (!iblockdata.isDestroyable()) continue; // Paper - Protect Bedrock and End Portal/Frames from being destroyed
FluidState fluid = iblockdata.getFluidState(); // Paper FluidState fluid = iblockdata.getFluidState(); // Paper - Perf: Optimize call to getFluid for explosions
if (!this.level.isInWorldBounds(blockposition)) { if (!this.level.isInWorldBounds(blockposition)) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java

Datei anzeigen

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
+ try { // Paper - show location on failure + try { // Paper - Show blockstate location if we failed to read it
// Paper start // Paper start
this.snapshotDisabled = DISABLE_SNAPSHOT; this.snapshotDisabled = DISABLE_SNAPSHOT;
if (DISABLE_SNAPSHOT) { if (DISABLE_SNAPSHOT) {
@ -20,14 +20,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.load(this.snapshot); this.load(this.snapshot);
} }
// Paper end // Paper end
+ // Paper start - show location on failure + // Paper start - Show blockstate location if we failed to read it
+ } catch (Throwable thr) { + } catch (Throwable thr) {
+ if (thr instanceof ThreadDeath) { + if (thr instanceof ThreadDeath) {
+ throw (ThreadDeath)thr; + throw (ThreadDeath)thr;
+ } + }
+ throw new RuntimeException("Failed to read BlockState at: world: " + this.getWorld().getName() + " location: (" + this.getX() + ", " + this.getY() + ", " + this.getZ() + ")", thr); + throw new RuntimeException("Failed to read BlockState at: world: " + this.getWorld().getName() + " location: (" + this.getX() + ", " + this.getY() + ", " + this.getZ() + ")", thr);
+ } + }
+ // Paper end + // Paper end - Show blockstate location if we failed to read it
} }
protected CraftBlockEntityState(CraftBlockEntityState<T> state) { protected CraftBlockEntityState(CraftBlockEntityState<T> state) {

Datei anzeigen

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
TripWireHookBlock.emitState(world, pos, flag4, flag5, flag2, flag3); TripWireHookBlock.emitState(world, pos, flag4, flag5, flag2, flag3);
if (!flag) { if (!flag) {
+ if (world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - validate + if (world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - Validate tripwire hook placement before update
world.setBlock(pos, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection), 3); world.setBlock(pos, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection), 3);
if (flag1) { if (flag1) {
TripWireHookBlock.notifyNeighbors(block, world, pos, enumdirection); TripWireHookBlock.notifyNeighbors(block, world, pos, enumdirection);

Datei anzeigen

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return entity instanceof HangingEntity; return entity instanceof HangingEntity;
}; };
- private int checkInterval; - private int checkInterval;
+ private int checkInterval; { this.checkInterval = this.getId() % this.level().spigotConfig.hangingTickFrequency; } // Paper + private int checkInterval; { this.checkInterval = this.getId() % this.level().spigotConfig.hangingTickFrequency; } // Paper - Perf: offset item frame ticking
public BlockPos pos; public BlockPos pos;
protected Direction direction; protected Direction direction;