Updated Upstream (Bukkit/CraftBukkit/Spigot)

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

Bukkit Changes:
9590b610 SPIGOT-6749: Library Loader does not correctly isolate dependencies

CraftBukkit Changes:
11c9299f #940: Fixed a NPE during CraftBlockEntityState#update.
960f3109 #937: Fixes related to unplaced BlockStates and the recent world generation changes.
4faf479e SPIGOT-6754: We ignore any still present TileEntity now when we create a BlockState for a block of type AIR.
a72d5404 SPIGOT-6754: Temporarily restore previous behaviour for tile entities with removed blocks

Spigot Changes:
dc75aca8 Remove redundant 'Log null TileEntity Owner' patch
This commit is contained in:
Shane Freeder 2021-10-15 12:43:19 +01:00
parent 8575248648
commit 4276013833
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
12 changed files with 34 additions and 89 deletions

View File

@ -87,7 +87,7 @@ index f99d60ae4003f953b5680a997e9e43e63c035b0c..c943bd801b54519ba6cf5d45aec593d7
/**
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index e77c616977a3dcaa72bb22c35f6092c1f00b2b85..550225f168160298f4b1bf6c361207a59cf23122 100644
index 657243776c8a2abb5a57e5c407212a8387d649eb..4fa5f7140ea97e1b6a63808b59115bfb1a85cb32 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -44,6 +44,7 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
@ -107,7 +107,7 @@ index e77c616977a3dcaa72bb22c35f6092c1f00b2b85..550225f168160298f4b1bf6c361207a5
try {
Class<?> jarClass;
try {
@@ -224,6 +227,7 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
@@ -229,6 +232,7 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
pluginState = new IllegalStateException("Initial initialization");
this.pluginInit = javaPlugin;

View File

@ -25,7 +25,7 @@ The patch in general terms just loads the class in the plugin's jar
before it starts looking elsewhere for it.
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index ce751577623eaad0f31e2eb7bf0842d1ab73e845..31793f46e5623729dfb4048e901f274082f57826 100644
index dfa44d9a0f0e270fddc4f30b845c2b0e23008033..80236a0934861902db7f15571d0d9b4902e70045 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -51,6 +51,7 @@ import org.yaml.snakeyaml.error.YAMLException;
@ -63,7 +63,7 @@ index ce751577623eaad0f31e2eb7bf0842d1ab73e845..31793f46e5623729dfb4048e901f2740
for (PluginClassLoader loader : loaders) {
try {
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 550225f168160298f4b1bf6c361207a59cf23122..9c2bde2820b92d17bc2241957390f3fb3cc50d98 100644
index 4fa5f7140ea97e1b6a63808b59115bfb1a85cb32..cd1907e8895ece9b780617635b71937596c0f982 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -33,7 +33,7 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
@ -75,7 +75,7 @@ index 550225f168160298f4b1bf6c361207a59cf23122..9c2bde2820b92d17bc2241957390f3fb
private final File dataFolder;
private final File file;
private final JarFile jar;
@@ -118,7 +118,7 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
@@ -123,7 +123,7 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
if (checkGlobal) {
// This ignores the libraries of other plugins, unless they are transitive dependencies.

View File

@ -8,10 +8,10 @@ however, this provides no indication of the owner of the classloader, making
these messages effectively useless, this patch rectifies this
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 9c2bde2820b92d17bc2241957390f3fb3cc50d98..6b5d7c350c216b7a234d96ecacae1d39a1acd814 100644
index cd1907e8895ece9b780617635b71937596c0f982..9e14c95deaca0044a3e9284ceefbb2b5c54ede07 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -230,4 +230,16 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
@@ -235,4 +235,16 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
javaPlugin.logger = this.logger; // Paper - set logger
javaPlugin.init(loader, loader.server, description, dataFolder, file, this);
}

View File

@ -13,7 +13,7 @@ also Avoid NPE during CraftBlockEntityState load if could not get TE
If Tile Entity was null, correct Sign to return empty lines instead of null
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
index 77645019c88d61dde28b7598d8a29b7d0c23c209..560ee4eaa286197a0f8fc0a119ff5e06baca792a 100644
index 27895fbe1cd7ee6ee025ed3e320671e3e971764d..1d1764766d2b4a0b7bf4078ce428bb1474f709df 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -42,6 +42,7 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject {
@ -33,7 +33,7 @@ index 77645019c88d61dde28b7598d8a29b7d0c23c209..560ee4eaa286197a0f8fc0a119ff5e06
net.minecraft.nbt.Tag persistentDataTag = nbt.get("PublicBukkitValues");
if (persistentDataTag instanceof CompoundTag) {
@@ -222,6 +223,11 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject {
@@ -222,10 +223,15 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject {
// CraftBukkit start - add method
public InventoryHolder getOwner() {
@ -43,12 +43,8 @@ index 77645019c88d61dde28b7598d8a29b7d0c23c209..560ee4eaa286197a0f8fc0a119ff5e06
+ public InventoryHolder getOwner(boolean useSnapshot) {
+ // Paper end
if (this.level == null) return null;
// Spigot start
org.bukkit.block.Block block = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ());
@@ -230,7 +236,7 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject {
return null;
}
// Spigot end
if (block.getType() == org.bukkit.Material.AIR) return null;
- org.bukkit.block.BlockState state = block.getState();
+ org.bukkit.block.BlockState state = block.getState(useSnapshot); // Paper
if (state instanceof InventoryHolder) return (InventoryHolder) state;
@ -80,7 +76,7 @@ index e6b8dd52cd503f45ca9bb868891ae4c8b29b3fcb..f1c4c3a3392c2d4d836fa10d7a38558d
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
index fbd52387299c90b85afd79897139cdb879fce74a..aaddbaecc25af87c863fe51098eb322fd5702104 100644
index 2fb445e6edc43eb8e3e169cca3fc3b46ced94202..059a122ef7038f7c4e269b476eb6e013b3eb4531 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
@@ -10,15 +10,26 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft

View File

@ -54,10 +54,10 @@ index 4febad176d8dc7c56e9cb09c8e5ce55f4c9f3288..fd4a0bbd1438bfc94580f29382d0c5f5
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
index 3d8d8e797a08067725924de1d1f07ada75cdb683..b2b41b5c3a6cab44d49a43b6b0db2fea3271c225 100644
index 8f7da903c75feaaf31e368ac8d798af8ed845ebf..db7a6af045364e7b1e9c0449faaf5f49394f6204 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
@@ -153,7 +153,7 @@ public class CraftBlockState implements BlockState {
@@ -166,7 +166,7 @@ public class CraftBlockState implements BlockState {
@Override
public Material getType() {

View File

@ -21,10 +21,10 @@ index 9d0c272b1d89a96b0b63603fa8e4649f11fb6c51..d5fdf4504a0ca76fb0483f4ae5861c93
+ // Paper end - More Lidded Block API
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
index 189674ce35f2da75a70e4a05c77dd022cef469db..2a723bd0850ee1201bb87760647bd4b3a93279fe 100644
index 1290a29e90349222b33c32429347250ce6101817..9806697cb7566c5af1df74b7eaa8088d19ee4fdc 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
@@ -78,4 +78,11 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
@@ -76,4 +76,11 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
}
getTileEntity().openersCounter.opened = false;
}

View File

@ -10,7 +10,7 @@ tile entity type to determine the block state factory and falls back on
the material type of the block at that location.
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77385902a8 100644
index b794e04036df00dd9633b9bd808591f499238387..a20505b6badaf2d709bd95fa01d0617b86b35fe2 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
@@ -19,6 +19,7 @@ import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
@ -21,7 +21,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
@@ -109,6 +110,12 @@ public final class CraftBlockStates {
@@ -110,6 +111,12 @@ public final class CraftBlockStates {
return new CraftBlockState(world, blockPosition, blockData);
}
};
@ -34,7 +34,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
static {
register(
@@ -129,7 +136,7 @@ public final class CraftBlockStates {
@@ -130,7 +137,7 @@ public final class CraftBlockStates {
Material.SPRUCE_WALL_SIGN,
Material.WARPED_SIGN,
Material.WARPED_WALL_SIGN
@ -43,7 +43,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
);
register(
@@ -146,7 +153,7 @@ public final class CraftBlockStates {
@@ -147,7 +154,7 @@ public final class CraftBlockStates {
Material.WITHER_SKELETON_WALL_SKULL,
Material.ZOMBIE_HEAD,
Material.ZOMBIE_WALL_HEAD
@ -52,7 +52,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
);
register(
@@ -154,7 +161,7 @@ public final class CraftBlockStates {
@@ -155,7 +162,7 @@ public final class CraftBlockStates {
Material.COMMAND_BLOCK,
Material.REPEATING_COMMAND_BLOCK,
Material.CHAIN_COMMAND_BLOCK
@ -61,7 +61,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
);
register(
@@ -191,7 +198,7 @@ public final class CraftBlockStates {
@@ -192,7 +199,7 @@ public final class CraftBlockStates {
Material.WHITE_WALL_BANNER,
Material.YELLOW_BANNER,
Material.YELLOW_WALL_BANNER
@ -70,7 +70,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
);
register(
@@ -213,7 +220,7 @@ public final class CraftBlockStates {
@@ -214,7 +221,7 @@ public final class CraftBlockStates {
Material.GREEN_SHULKER_BOX,
Material.RED_SHULKER_BOX,
Material.BLACK_SHULKER_BOX
@ -79,7 +79,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
);
register(
@@ -234,54 +241,51 @@ public final class CraftBlockStates {
@@ -235,54 +242,51 @@ public final class CraftBlockStates {
Material.RED_BED,
Material.WHITE_BED,
Material.YELLOW_BED
@ -165,7 +165,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
}
private static void register(Material blockType, BlockStateFactory<?> factory) {
@@ -290,15 +294,17 @@ public final class CraftBlockStates {
@@ -291,15 +295,17 @@ public final class CraftBlockStates {
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
Material blockType,
@ -184,7 +184,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
Class<B> blockStateType,
BiFunction<World, T, B> blockStateConstructor,
BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
@@ -307,17 +313,35 @@ public final class CraftBlockStates {
@@ -308,17 +314,35 @@ public final class CraftBlockStates {
for (Material blockType : blockTypes) {
CraftBlockStates.register(blockType, factory);
}
@ -220,7 +220,7 @@ index a5c0fe5ba6ca4bed8914edcdcd21275145d11aee..5f497e0b9d2c7b23672f6480aa86aa77
public static BlockState getBlockState(Block block) {
Preconditions.checkNotNull(block, "block is null");
CraftBlock craftBlock = (CraftBlock) block;
@@ -360,7 +384,7 @@ public final class CraftBlockStates {
@@ -361,7 +385,7 @@ public final class CraftBlockStates {
if (world != null && tileEntity == null && CraftBlockStates.isTileEntityOptional(material)) {
factory = CraftBlockStates.DEFAULT_FACTORY;
} else {

View File

@ -5,15 +5,10 @@ Subject: [PATCH] Fix unplaced block states after new chunk gen API
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java
index 489d259d105476092d401f788c88c17c3bed86ff..250afe0acb37e6ea2288a6079160566965b3b2bf 100644
index e00210950cbf005b0e65aed68dfbb7c281aefd87..b4a10c1ef095faaefbedc2a1fd84aea721a4ba98 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java
@@ -60,11 +60,11 @@ public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> impl
@Override
public List<Bee> releaseEntities() {
- Preconditions.checkState(getWorldHandle() instanceof net.minecraft.world.level.Level, "Can't release entities during world generation");
@@ -65,6 +65,7 @@ public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> impl
List<Bee> bees = new ArrayList<>();
if (isPlaced()) {
@ -21,37 +16,12 @@ index 489d259d105476092d401f788c88c17c3bed86ff..250afe0acb37e6ea2288a60791605669
BeehiveBlockEntity beehive = ((BeehiveBlockEntity) this.getTileEntityFromWorld());
for (Entity bee : beehive.releaseBees(this.getHandle(), BeeReleaseStatus.BEE_RELEASED, true)) {
bees.add((Bee) bee.getBukkitEntity());
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
index b2b41b5c3a6cab44d49a43b6b0db2fea3271c225..b17a448a4bb78b0527031815de5adee82d7d7f01 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
@@ -58,12 +58,14 @@ public class CraftBlockState implements BlockState {
public LevelAccessor getWorldHandle() {
if (this.weakWorld == null) {
+ requirePlaced(); // Paper
return this.world.getHandle();
}
LevelAccessor access = this.weakWorld.get();
if (access == null) {
this.weakWorld = null;
+ requirePlaced(); // Paper
return this.world.getHandle();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
index 2a723bd0850ee1201bb87760647bd4b3a93279fe..6bcd71928fee7c4f4e1fd11e52293f641d11b12b 100644
index 9806697cb7566c5af1df74b7eaa8088d19ee4fdc..ad833481414d3b60bdbcf87727b494ecff84f2c3 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
@@ -38,12 +38,12 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
@Override
public Inventory getInventory() {
- Preconditions.checkState(getWorldHandle() instanceof net.minecraft.world.level.Level, "Can't get inventory during world generation, use getBlockInventory() instead");
CraftInventory inventory = (CraftInventory) this.getBlockInventory();
if (!isPlaced()) {
@@ -42,6 +42,7 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
if (!isPlaced() || isWorldGeneration()) {
return inventory;
}
+ Preconditions.checkState(getWorldHandle() instanceof net.minecraft.world.level.Level, "Can't get inventory during world generation, use getBlockInventory() instead"); // Paper - move after placed check

View File

@ -1,21 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Tue, 12 Oct 2021 13:32:52 -0700
Subject: [PATCH] Null check isApplicable for CraftBlockEntityState#update
If the update call removed the TE, then isApplicable would
have NPE'd.
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
index d2ff7e373476aaab0d4d08977c9d9f274fff67bf..a31162bbb37b79cb7f84956c91f2ef9efc4ededc 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
@@ -102,7 +102,7 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
}
protected boolean isApplicable(BlockEntity tileEntity) {
- return this.tileEntity.getClass() == tileEntity.getClass();
+ return tileEntity != null && this.tileEntity.getClass() == tileEntity.getClass(); // Paper - fix NPE if the TE was removed
}
@Override

@ -1 +1 @@
Subproject commit 6be36d3638f97e6e0dc053f3e0fd0e68e8ec93f0
Subproject commit 9590b610cfa705b082c0593b595a7d563a89dc85

@ -1 +1 @@
Subproject commit 1df303e70742418fd30760a750a9545f3dea5b9b
Subproject commit 11c9299fbb8f559c1ba38e8f0e1695c4d33109ba

@ -1 +1 @@
Subproject commit 8e907441bde900ddc564d3a5fac831287a1a8b75
Subproject commit dc75aca85361e65679880f2abd5c92f6db448ae2