Updated Upstream (Bukkit/CraftBukkit)

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

Bukkit Changes:
ab6e73a2 Correct copied javadoc from previous commit

CraftBukkit Changes:
9fb3aa4c SPIGOT-6817: Revert back to old block state behaviour again
This commit is contained in:
Nassim Jahnke 2021-11-29 13:15:54 +01:00 committed by MiniDigger | Martin
parent 4ab59e1326
commit 903aa737d8
4 changed files with 41 additions and 14 deletions

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 cbda40be6449acbe5a9fb4e5142df3b377c5f207..6f61fd8224fb4094f38a851300ab55f94523c252 100644
index 1e416b23a38458f16add472cea09b0ac5ac91869..6f61fd8224fb4094f38a851300ab55f94523c252 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
@@ -45,6 +45,7 @@ public abstract class BlockEntity implements io.papermc.paper.util.KeyedObject {
@ -33,7 +33,7 @@ index cbda40be6449acbe5a9fb4e5142df3b377c5f207..6f61fd8224fb4094f38a851300ab55f9
net.minecraft.nbt.Tag persistentDataTag = nbt.get("PublicBukkitValues");
if (persistentDataTag instanceof CompoundTag) {
@@ -260,10 +261,15 @@ public abstract class BlockEntity implements io.papermc.paper.util.KeyedObject {
@@ -260,8 +261,15 @@ public abstract class BlockEntity implements io.papermc.paper.util.KeyedObject {
// CraftBukkit start - add method
public InventoryHolder getOwner() {
@ -43,9 +43,9 @@ index cbda40be6449acbe5a9fb4e5142df3b377c5f207..6f61fd8224fb4094f38a851300ab55f9
+ public InventoryHolder getOwner(boolean useSnapshot) {
+ // Paper end
if (this.level == null) return null;
org.bukkit.block.Block block = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ());
if (block.getType() == org.bukkit.Material.AIR) return null;
- org.bukkit.block.BlockState state = block.getState();
- org.bukkit.block.BlockState state = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()).getState();
+ org.bukkit.block.Block block = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ());
+ if (block.getType() == org.bukkit.Material.AIR) return null;
+ org.bukkit.block.BlockState state = block.getState(useSnapshot); // Paper
if (state instanceof InventoryHolder) return (InventoryHolder) state;
return null;
@ -76,10 +76,15 @@ index d8b9a8276204ad8a2f045af9fe94185dbf150bc6..3250559589eb4db7b3df828144cee81a
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
index aa544f8be7d1db6fc6618d38efc40221afe85618..b98d442a8c749c59aff43189c3904ff4fb4cb353 100644
index 7629a51ec284cab0db7e9238027d6acfa4f3083c..27f38af1eb71dda5dd175dcabc7a467ed772757a 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
@@ -6,19 +6,30 @@ import org.bukkit.World;
import org.bukkit.block.TileState;
import org.bukkit.persistence.PersistentDataContainer;
-public class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockState implements TileState {
+public abstract class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockState implements TileState { // Paper - revert revert
private final T tileEntity;
private final T snapshot;
@ -108,6 +113,27 @@ index aa544f8be7d1db6fc6618d38efc40221afe85618..b98d442a8c749c59aff43189c3904ff4
}
public void refreshSnapshot() {
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
index 51ea68c433c4d530f8404d3174c5a121ce808a96..9d0934656bbd27df4b47b816540d02cfbfc80636 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
@@ -105,12 +105,10 @@ public final class CraftBlockStates {
private static final BlockStateFactory<?> DEFAULT_FACTORY = new BlockStateFactory<CraftBlockState>(CraftBlockState.class) {
@Override
public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
- // SPIGOT-6754, SPIGOT-6817: Restore previous behaviour for tile entities with removed blocks (loot generation post-destroy)
- if (tileEntity != null) {
- // block with unhandled TileEntity:
- return new CraftBlockEntityState<>(world, tileEntity);
- }
- Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock()));
+ // Paper start - revert revert
+ // When a block is being destroyed, the TileEntity may temporarily still exist while the block's type has already been set to AIR. We ignore the TileEntity in this case.
+ Preconditions.checkState(tileEntity == null || CraftMagicNumbers.getMaterial(blockData.getBlock()) == Material.AIR, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock()));
+ // Paper end
return new CraftBlockState(world, blockPosition, blockData);
}
};
diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
index e2cb421132471ceb3db236cffea88585fbe3593a..af37bf2b8ef1c06e541fb42d15afdd9833ba93a4 100644
--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java

View File

@ -23,7 +23,7 @@ index 0e37da7227eaba0d089e5bd136eca088ab2b5eb3..5601d0c2fe635a2a4f073c333531e1a8
if (state instanceof InventoryHolder) return (InventoryHolder) state;
return null;
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
index b794e04036df00dd9633b9bd808591f499238387..0356c33bc14bef73a7468d5360ea5cd309d5f623 100644
index 9d0934656bbd27df4b47b816540d02cfbfc80636..a6b47006760e0711e9f667b733efaae6928d27e1 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;
@ -34,12 +34,13 @@ index b794e04036df00dd9633b9bd808591f499238387..0356c33bc14bef73a7468d5360ea5cd3
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
@@ -106,183 +107,54 @@ public final class CraftBlockStates {
@Override
@@ -107,184 +108,55 @@ public final class CraftBlockStates {
public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
// Paper start - revert revert
// When a block is being destroyed, the TileEntity may temporarily still exist while the block's type has already been set to AIR. We ignore the TileEntity in this case.
- Preconditions.checkState(tileEntity == null || CraftMagicNumbers.getMaterial(blockData.getBlock()) == Material.AIR, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock()));
+ Preconditions.checkState(tileEntity == null/* || CraftMagicNumbers.getMaterial(blockData.getBlock()) == Material.AIR*/, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock())); // Paper - don't ignore the TileEntity while its still valid
// Paper end
return new CraftBlockState(world, blockPosition, blockData);
}
};
@ -261,7 +262,7 @@ index b794e04036df00dd9633b9bd808591f499238387..0356c33bc14bef73a7468d5360ea5cd3
}
private static void register(Material blockType, BlockStateFactory<?> factory) {
@@ -290,35 +162,45 @@ public final class CraftBlockStates {
@@ -292,35 +164,45 @@ public final class CraftBlockStates {
}
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
@ -322,7 +323,7 @@ index b794e04036df00dd9633b9bd808591f499238387..0356c33bc14bef73a7468d5360ea5cd3
public static BlockState getBlockState(Block block) {
Preconditions.checkNotNull(block, "block is null");
CraftBlock craftBlock = (CraftBlock) block;
@@ -361,7 +243,7 @@ public final class CraftBlockStates {
@@ -363,7 +245,7 @@ public final class CraftBlockStates {
if (world != null && tileEntity == null && CraftBlockStates.isTileEntityOptional(material)) {
factory = CraftBlockStates.DEFAULT_FACTORY;
} else {

@ -1 +1 @@
Subproject commit 810cb078fd22fde8bf94b5a23ed3329f0b1f68db
Subproject commit ab6e73a20eca8ecd0fef8720edc81e746595dd98

@ -1 +1 @@
Subproject commit 04f8e7e21f574311f67a6b0dd3bff1597630fef1
Subproject commit 9fb3aa4c7ae8086c3c91122d716acc0464b2f300