Updated Upstream (CraftBukkit) (#6504)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
5be41fb8 SPIGOT-6720: Fix bed explosion checks
09b99daf SPIGOT-6722: Close entity manager when unloading world
3a9561bf SPIGOT-6686: Changes in MaximumRepairCost for Anvil Rename cause inconsistency
This commit is contained in:
Nassim Jahnke 2021-08-27 11:51:18 +02:00
parent 7247c2b0ab
commit cc4e273b07
6 changed files with 10 additions and 79 deletions

View file

@ -14,13 +14,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> { player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> {
+ // Paper start - PlayerBedFailEnterEvent + // Paper start - PlayerBedFailEnterEvent
+ if (entityhuman_enumbedresult != null) { + if (entityhuman_enumbedresult != null) {
+ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.VALUES[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), entityhuman_enumbedresult == Player.BedSleepingProblem.NOT_POSSIBLE_HERE, io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage())); + io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.VALUES[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), !world.dimensionType().bedWorks(), io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage()));
+ if (!event.callEvent()) { + if (!event.callEvent()) {
+ return; + return;
+ } + }
+ // Paper end + // Paper end
// CraftBukkit start - handling bed explosion from below here // CraftBukkit start - handling bed explosion from below here
- if (entityhuman_enumbedresult == Player.BedSleepingProblem.NOT_POSSIBLE_HERE) { - if (!world.dimensionType().bedWorks()) {
+ if (event.getWillExplode()) { // Paper + if (event.getWillExplode()) { // Paper
this.explodeBed(finaliblockdata, world, finalblockposition); this.explodeBed(finaliblockdata, world, finalblockposition);
} else } else

View file

@ -178,7 +178,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return false; + return false;
+ } + }
+ // Paper end + // Paper end
LOGGER.warn("UUID of added entity already exists: {}", (Object)entity); PersistentEntitySectionManager.LOGGER.warn("UUID of added entity already exists: {}", entity);
+ // Paper start + // Paper start
+ if (net.minecraft.world.level.Level.DEBUG_ENTITIES && ((Entity) entity).level.paperConfig.duplicateUUIDMode != com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode.NOTHING) { + if (net.minecraft.world.level.Level.DEBUG_ENTITIES && ((Entity) entity).level.paperConfig.duplicateUUIDMode != com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode.NOTHING) {
+ if (((Entity) entity).addedToWorldStack != null) { + if (((Entity) entity).addedToWorldStack != null) {
@ -190,39 +190,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return false; return false;
} else { } else {
return true; return true;
@@ -0,0 +0,0 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
}
private void processUnloads() {
- this.chunksToUnload.removeIf((pos) -> {
+ this.chunksToUnload.removeIf((java.util.function.LongPredicate) (pos) -> { // Paper - decompile fix
return this.chunkVisibility.get(pos) != Visibility.HIDDEN ? true : this.processChunkUnload(pos);
});
}
@@ -0,0 +0,0 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
}
public void autoSave() {
- this.getAllChunksToSave().forEach((pos) -> {
+ this.getAllChunksToSave().forEach((java.util.function.LongConsumer) (pos) -> { // Paper - decompile fix
boolean bl = this.chunkVisibility.get(pos) == Visibility.HIDDEN;
if (bl) {
this.processChunkUnload(pos);
@@ -0,0 +0,0 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
while(!longSet.isEmpty()) {
this.permanentStorage.flush(false);
this.processPendingLoads();
- longSet.removeIf((pos) -> {
+ longSet.removeIf((java.util.function.LongPredicate) (pos) -> { // Paper - decompile fix
boolean bl = this.chunkVisibility.get(pos) == Visibility.HIDDEN;
return bl ? this.processChunkUnload(pos) : this.storeChunkSections(pos, (entityAccess) -> {
});
@@ -0,0 +0,0 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
public void dumpSections(Writer writer) throws IOException {
CsvOutput csvOutput = CsvOutput.builder().addColumn("x").addColumn("y").addColumn("z").addColumn("visibility").addColumn("load_status").addColumn("entity_count").build(writer);
- this.sectionStorage.getAllChunksWithExistingSections().forEach((chunkPos) -> {
+ this.sectionStorage.getAllChunksWithExistingSections().forEach((java.util.function.LongConsumer) (chunkPos) -> { // Paper - decompile fix
PersistentEntitySectionManager.ChunkLoadStatus chunkLoadStatus = this.chunkLoadStatuses.get(chunkPos);
this.sectionStorage.getExistingSectionPositionsInChunk(chunkPos).forEach((sectionPos) -> {
EntitySection<T> entitySection = this.sectionStorage.getSection(sectionPos);

View file

@ -1,33 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Doc <nachito94@msn.com>
Date: Fri, 6 Aug 2021 11:23:13 -0400
Subject: [PATCH] Fix bed handling for custom dimensions
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
// CraftBukkit start - moved bed result checks from below into separate method
private Either<Player.BedSleepingProblem, Unit> getBedResult(BlockPos blockposition, Direction enumdirection) {
if (!this.isSleeping() && this.isAlive()) {
- if (!this.level.dimensionType().natural()) {
+ if (!this.level.dimensionType().natural() || !this.level.dimensionType().bedWorks()) { // Paper - check if dimension allows beds (moved from BedBlock#canSetSpawn)
return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_HERE);
} else if (!this.bedInRange(blockposition, enumdirection)) {
return Either.left(Player.BedSleepingProblem.TOO_FAR_AWAY);
diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/BedBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java
@@ -0,0 +0,0 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock
player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> {
// Paper start - PlayerBedFailEnterEvent
if (entityhuman_enumbedresult != null) {
- io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.VALUES[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), entityhuman_enumbedresult == Player.BedSleepingProblem.NOT_POSSIBLE_HERE, io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage()));
+ boolean bedWillExplode = !world.dimensionType().bedWorks(); // Paper - Handle explode flag
+ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.VALUES[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), bedWillExplode, io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage())); // Paper
if (!event.callEvent()) {
return;
}

View file

@ -1123,13 +1123,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java --- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
@@ -0,0 +0,0 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A @@ -0,0 +0,0 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
this.addEntity(entity, true); this.addEntity(entityaccess, true);
}); });
this.chunkLoadStatuses.put(chunkEntities.getPos().toLong(), PersistentEntitySectionManager.ChunkLoadStatus.LOADED); this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.ChunkLoadStatus.LOADED);
+ // Paper start - rewrite ServerTickList + // Paper start - rewrite ServerTickList
+ final net.minecraft.server.level.ServerLevel level = ((net.minecraft.world.level.chunk.storage.EntityStorage) this.permanentStorage).level; + final net.minecraft.server.level.ServerLevel level = ((net.minecraft.world.level.chunk.storage.EntityStorage) this.permanentStorage).level;
+ if (level.chunkSource.isPositionTickingReady(chunkEntities.getPos().longKey)) { + if (level.chunkSource.isPositionTickingReady(chunkentities.getPos().longKey)) {
+ level.onChunkSetTicking(chunkEntities.getPos().x, chunkEntities.getPos().z); + level.onChunkSetTicking(chunkentities.getPos().x, chunkentities.getPos().z);
+ } + }
+ // Paper end + // Paper end
} }

View file

@ -60,5 +60,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end + // Paper end
public boolean isPositionTicking(BlockPos blockPos) { public boolean isPositionTicking(BlockPos blockposition) {
return this.chunkVisibility.get(ChunkPos.asLong(blockPos)).isTicking(); return ((Visibility) this.chunkVisibility.get(ChunkPos.asLong(blockposition))).isTicking();

@ -1 +1 @@
Subproject commit a0a37f416ca6c9be007f65e1b8ef5efea9b50cb5 Subproject commit 5be41fb80fa84c15359d271c38b52a1e815ea9f9