Skip to content

Commit 6663747

Browse files
Some block state hunks were in the wrong patch (#7308)
1 parent 0c64d40 commit 6663747

12 files changed

+96
-77
lines changed

patches/server/0168-API-to-get-a-BlockState-without-a-snapshot.patch

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,28 @@ index 1e416b23a38458f16add472cea09b0ac5ac91869..6f61fd8224fb4094f38a851300ab55f9
5151
return null;
5252
}
5353
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
54-
index d8b9a8276204ad8a2f045af9fe94185dbf150bc6..3250559589eb4db7b3df828144cee81a19651842 100644
54+
index c0af4b05b5d77aad99487fa7f8d840e797b6554c..40fc3268e7b662cdd45b569224ccd2abfad0a595 100644
5555
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
5656
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
57-
@@ -317,7 +317,20 @@ public class CraftBlock implements Block {
58-
59-
@Override
60-
public BlockState getState() {
61-
+ // Paper start
62-
+ return this.getState(true);
63-
+ }
64-
+
65-
+ @Override
66-
+ public BlockState getState(boolean useSnapshot) {
67-
+ boolean prev = CraftBlockEntityState.DISABLE_SNAPSHOT;
68-
+ CraftBlockEntityState.DISABLE_SNAPSHOT = !useSnapshot;
69-
+ try {
57+
@@ -320,6 +320,13 @@ public class CraftBlock implements Block {
7058
return CraftBlockStates.getBlockState(this);
71-
+ } finally {
72-
+ CraftBlockEntityState.DISABLE_SNAPSHOT = prev;
73-
+ }
74-
+ // Paper end
7559
}
7660

61+
+ // Paper start
62+
+ @Override
63+
+ public BlockState getState(boolean useSnapshot) {
64+
+ return CraftBlockStates.getBlockState(this, useSnapshot);
65+
+ }
66+
+ // Paper end
67+
+
7768
@Override
69+
public Biome getBiome() {
70+
return this.getWorld().getBiome(this.getX(), this.getY(), this.getZ());
7871
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
79-
index 7629a51ec284cab0db7e9238027d6acfa4f3083c..27f38af1eb71dda5dd175dcabc7a467ed772757a 100644
72+
index 7629a51ec284cab0db7e9238027d6acfa4f3083c..c2c0b4bfab64394e55f2832e37e49bccb7e955ab 100644
8073
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
8174
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
82-
@@ -6,19 +6,30 @@ import org.bukkit.World;
83-
import org.bukkit.block.TileState;
84-
import org.bukkit.persistence.PersistentDataContainer;
85-
86-
-public class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockState implements TileState {
87-
+public abstract class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockState implements TileState { // Paper - revert revert
75+
@@ -10,15 +10,26 @@ public class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockStat
8876

8977
private final T tileEntity;
9078
private final T snapshot;
@@ -114,26 +102,40 @@ index 7629a51ec284cab0db7e9238027d6acfa4f3083c..27f38af1eb71dda5dd175dcabc7a467e
114102

115103
public void refreshSnapshot() {
116104
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
117-
index 51ea68c433c4d530f8404d3174c5a121ce808a96..9d0934656bbd27df4b47b816540d02cfbfc80636 100644
105+
index 51ea68c433c4d530f8404d3174c5a121ce808a96..93a8aeb5545c794ac425c35f8af52a443cd060ca 100644
118106
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
119107
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
120-
@@ -105,12 +105,10 @@ public final class CraftBlockStates {
121-
private static final BlockStateFactory<?> DEFAULT_FACTORY = new BlockStateFactory<CraftBlockState>(CraftBlockState.class) {
122-
@Override
123-
public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
124-
- // SPIGOT-6754, SPIGOT-6817: Restore previous behaviour for tile entities with removed blocks (loot generation post-destroy)
125-
- if (tileEntity != null) {
126-
- // block with unhandled TileEntity:
127-
- return new CraftBlockEntityState<>(world, tileEntity);
128-
- }
129-
- Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock()));
130-
+ // Paper start - revert revert
131-
+ // 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.
132-
+ Preconditions.checkState(tileEntity == null || CraftMagicNumbers.getMaterial(blockData.getBlock()) == Material.AIR, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock()));
133-
+ // Paper end
134-
return new CraftBlockState(world, blockPosition, blockData);
135-
}
136-
};
108+
@@ -324,15 +324,30 @@ public final class CraftBlockStates {
109+
}
110+
111+
public static BlockState getBlockState(Block block) {
112+
+ // Paper start
113+
+ return CraftBlockStates.getBlockState(block, true);
114+
+ }
115+
+ public static BlockState getBlockState(Block block, boolean useSnapshot) {
116+
+ // Paper end
117+
Preconditions.checkNotNull(block, "block is null");
118+
CraftBlock craftBlock = (CraftBlock) block;
119+
CraftWorld world = (CraftWorld) block.getWorld();
120+
BlockPos blockPosition = craftBlock.getPosition();
121+
net.minecraft.world.level.block.state.BlockState blockData = craftBlock.getNMS();
122+
BlockEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition);
123+
+ // Paper start - block state snapshots
124+
+ boolean prev = CraftBlockEntityState.DISABLE_SNAPSHOT;
125+
+ CraftBlockEntityState.DISABLE_SNAPSHOT = !useSnapshot;
126+
+ try {
127+
+ // Paper end
128+
CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockPosition, blockData, tileEntity);
129+
blockState.setWorldHandle(craftBlock.getHandle()); // Inject the block's generator access
130+
return blockState;
131+
+ // Paper start
132+
+ } finally {
133+
+ CraftBlockEntityState.DISABLE_SNAPSHOT = prev;
134+
+ }
135+
+ // Paper end
136+
}
137+
138+
public static BlockState getBlockState(Material material, @Nullable CompoundTag blockEntityTag) {
137139
diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
138140
index 3fc3907172f12ee24ea70bd6a1ffbbc6084ed971..2c59f09a9261a1690951161fd856a5848d9885b7 100644
139141
--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java

patches/server/0326-Implement-CraftBlockSoundGroup.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ index 0000000000000000000000000000000000000000..9a516520d975f52169e346adc4ec6d9d
4949
+ }
5050
+}
5151
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
52-
index 1cbc9288cabc0637c0ad6145e7461fef87bfc830..5284b17b77fb714f1b68b2e1ee15b4bf992bd8e1 100644
52+
index 40fc3268e7b662cdd45b569224ccd2abfad0a595..a9f962819c602e801de2d1a1bd069994283e785c 100644
5353
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
5454
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
55-
@@ -607,4 +607,11 @@ public class CraftBlock implements Block {
55+
@@ -601,4 +601,11 @@ public class CraftBlock implements Block {
5656

5757
return iblockdata.canSurvive(world, this.position);
5858
}

patches/server/0333-Show-blockstate-location-if-we-failed-to-read-it.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ Subject: [PATCH] Show blockstate location if we failed to read it
55

66

77
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
8-
index 27f38af1eb71dda5dd175dcabc7a467ed772757a..bae73e3dced68156560997de63db902f6d99a251 100644
8+
index c2c0b4bfab64394e55f2832e37e49bccb7e955ab..d46e3812ef058c119d327cf752e7deaa341736e3 100644
99
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
1010
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
11-
@@ -18,6 +18,7 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
11+
@@ -18,6 +18,7 @@ public class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockStat
1212

1313
this.tileEntity = tileEntity;
1414

1515
+ try { // Paper - show location on failure
1616
// Paper start
1717
this.snapshotDisabled = DISABLE_SNAPSHOT;
1818
if (DISABLE_SNAPSHOT) {
19-
@@ -30,6 +31,14 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
19+
@@ -30,6 +31,14 @@ public class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockStat
2020
this.load(this.snapshot);
2121
}
2222
// Paper end

patches/server/0356-Add-effect-to-block-break-naturally.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Add effect to block break naturally
55

66

77
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
8-
index 5284b17b77fb714f1b68b2e1ee15b4bf992bd8e1..a3eb8cd92c1c7a40175e3dd637c0fd6b8d0dfc67 100644
8+
index a9f962819c602e801de2d1a1bd069994283e785c..a918813a0faf451977686bdd6ee3aff71853f41f 100644
99
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
1010
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
11-
@@ -468,6 +468,18 @@ public class CraftBlock implements Block {
11+
@@ -462,6 +462,18 @@ public class CraftBlock implements Block {
1212

1313
@Override
1414
public boolean breakNaturally(ItemStack item) {
@@ -27,7 +27,7 @@ index 5284b17b77fb714f1b68b2e1ee15b4bf992bd8e1..a3eb8cd92c1c7a40175e3dd637c0fd6b
2727
// Order matters here, need to drop before setting to air so skulls can get their data
2828
net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
2929
net.minecraft.world.level.block.Block block = iblockdata.getBlock();
30-
@@ -477,6 +489,7 @@ public class CraftBlock implements Block {
30+
@@ -471,6 +483,7 @@ public class CraftBlock implements Block {
3131
// Modelled off EntityHuman#hasBlock
3232
if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) {
3333
net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), position, this.world.getBlockEntity(position), null, nmsItem);

patches/server/0500-Add-methods-to-get-translation-keys.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Subject: [PATCH] Add methods to get translation keys
66
Co-authored-by: MeFisto94 <MeFisto94@users.noreply.github.com>
77

88
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
9-
index a3eb8cd92c1c7a40175e3dd637c0fd6b8d0dfc67..980f0ec9d343b4186dfeb07b9b08edfde9efeb33 100644
9+
index a918813a0faf451977686bdd6ee3aff71853f41f..8b65d48606ea422c3e53a25c013540a0eb774648 100644
1010
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
1111
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
12-
@@ -626,5 +626,15 @@ public class CraftBlock implements Block {
12+
@@ -620,5 +620,15 @@ public class CraftBlock implements Block {
1313
public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() {
1414
return new com.destroystokyo.paper.block.CraftBlockSoundGroup(getNMS().getBlock().defaultBlockState().getSoundType());
1515
}

patches/server/0535-Add-Destroy-Speed-API.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Subject: [PATCH] Add Destroy Speed API
66
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
77

88
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
9-
index aa783fb4d77c9edb58c56ff98c604a87d9583767..2144126241450fe2d6e801bd9452d211a03b6f7c 100644
9+
index cdd1b36fa5e856df3eb7d31b3d6a3fbfcbb83be6..90ad83db94e4cfb98470b9a607fe3ddec2e51c6c 100644
1010
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
1111
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
12-
@@ -636,5 +636,26 @@ public class CraftBlock implements Block {
12+
@@ -630,5 +630,26 @@ public class CraftBlock implements Block {
1313
public String translationKey() {
1414
return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this);
1515
}

patches/server/0554-Additional-Block-Material-API-s.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ process to do this in the Bukkit API
99
Adds API for buildable, replaceable, burnable too.
1010

1111
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
12-
index 2144126241450fe2d6e801bd9452d211a03b6f7c..fdf342e6059d967746164f18dc041b4e586f1a20 100644
12+
index 90ad83db94e4cfb98470b9a607fe3ddec2e51c6c..23d243c004af58bd8d37c594ff4bcbd314031604 100644
1313
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
1414
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
15-
@@ -456,6 +456,25 @@ public class CraftBlock implements Block {
15+
@@ -450,6 +450,25 @@ public class CraftBlock implements Block {
1616
return this.getNMS().getMaterial().isLiquid();
1717
}
1818

patches/server/0611-Add-Block-isValidTool.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Add Block#isValidTool
55

66

77
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
8-
index fdf342e6059d967746164f18dc041b4e586f1a20..bdabe194a32e922bbbd73a2a33c3d0f54c46be67 100644
8+
index 23d243c004af58bd8d37c594ff4bcbd314031604..7f9ba247b67c1a8ab54b7d70bdc31b847531e725 100644
99
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
1010
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
11-
@@ -676,5 +676,9 @@ public class CraftBlock implements Block {
11+
@@ -670,5 +670,9 @@ public class CraftBlock implements Block {
1212
}
1313
return speed;
1414
}

patches/server/0684-Fix-return-value-of-Block-applyBoneMeal-always-being.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Fix return value of Block#applyBoneMeal always being false
55

66

77
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
8-
index bdabe194a32e922bbbd73a2a33c3d0f54c46be67..991e73e0f397da265b08ce14bb2f92b251eaff48 100644
8+
index 7f9ba247b67c1a8ab54b7d70bdc31b847531e725..b51c4be42842e747c4f4630709ef40a0e39a34d0 100644
99
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
1010
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
11-
@@ -521,7 +521,7 @@ public class CraftBlock implements Block {
11+
@@ -515,7 +515,7 @@ public class CraftBlock implements Block {
1212
Direction direction = CraftBlock.blockFaceToNotch(face);
1313
UseOnContext context = new UseOnContext(this.getCraftWorld().getHandle(), null, InteractionHand.MAIN_HAND, Items.BONE_MEAL.getDefaultInstance(), new BlockHitResult(Vec3.ZERO, direction, this.getPosition(), false));
1414

patches/server/0726-Add-isCollidable-methods-to-various-places.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Add isCollidable methods to various places
55

66

77
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
8-
index 991e73e0f397da265b08ce14bb2f92b251eaff48..89cfa5093d53e1a249efc64aa1b449755c6eecd9 100644
8+
index b51c4be42842e747c4f4630709ef40a0e39a34d0..bf7d216d9307a96005dcca64696af72a84a68716 100644
99
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
1010
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
11-
@@ -473,6 +473,11 @@ public class CraftBlock implements Block {
11+
@@ -467,6 +467,11 @@ public class CraftBlock implements Block {
1212
public boolean isSolid() {
1313
return getNMS().getMaterial().blocksMotion();
1414
}

0 commit comments

Comments
 (0)