mirror of
https://github.com/PaperMC/Folia.git
synced 2025-04-23 04:39:19 +08:00
Make Level#getBlockEntity return null immediately if not tickthread
Otherwise, the world data will be null and we will NPE. The function is supposed to return null for off-thread access, anyways.
This commit is contained in:
parent
74f665b6f5
commit
deae156e59
@ -19270,7 +19270,7 @@ index a213f4098859858a73ddd601bbe8c7511972e0d5..07aa859ccfd3283097c172672c5d8013
|
|||||||
|
|
||||||
static class CacheKey {
|
static class CacheKey {
|
||||||
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
|
||||||
index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..54f50326beaef3985277ff941e40415a671f31fb 100644
|
index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a3b8b63c8 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||||
@@ -116,10 +116,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
@@ -116,10 +116,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
@ -19576,8 +19576,15 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..54f50326beaef3985277ff941e40415a
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
|
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
|
||||||
@@ -1008,7 +1028,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
@@ -1006,9 +1026,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) {
|
public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) {
|
||||||
|
+ // Folia start - region threading
|
||||||
|
+ if (!io.papermc.paper.util.TickThread.isTickThread()) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ // Folia end - region threading
|
||||||
// Paper start - Optimize capturedTileEntities lookup
|
// Paper start - 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) {
|
||||||
@ -19585,7 +19592,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..54f50326beaef3985277ff941e40415a
|
|||||||
return blockEntity;
|
return blockEntity;
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
@@ -1021,8 +1041,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
@@ -1021,8 +1046,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
|
|
||||||
if (!this.isOutsideBuildHeight(blockposition)) {
|
if (!this.isOutsideBuildHeight(blockposition)) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
@ -19596,7 +19603,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..54f50326beaef3985277ff941e40415a
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@@ -1226,13 +1246,30 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
@@ -1226,13 +1251,30 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
|
|
||||||
public void disconnect() {}
|
public void disconnect() {}
|
||||||
|
|
||||||
@ -19629,7 +19636,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..54f50326beaef3985277ff941e40415a
|
|||||||
|
|
||||||
public boolean mayInteract(Player player, BlockPos pos) {
|
public boolean mayInteract(Player player, BlockPos pos) {
|
||||||
return true;
|
return true;
|
||||||
@@ -1438,8 +1475,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
@@ -1438,8 +1480,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
}
|
}
|
||||||
public final BlockPos.MutableBlockPos getRandomBlockPosition(int x, int y, int z, int l, BlockPos.MutableBlockPos out) {
|
public final BlockPos.MutableBlockPos getRandomBlockPosition(int x, int y, int z, int l, BlockPos.MutableBlockPos out) {
|
||||||
// Paper end
|
// Paper end
|
||||||
@ -19639,7 +19646,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..54f50326beaef3985277ff941e40415a
|
|||||||
|
|
||||||
out.set(x + (i1 & 15), y + (i1 >> 16 & l), z + (i1 >> 8 & 15)); // Paper - change to setValues call
|
out.set(x + (i1 & 15), y + (i1 >> 16 & l), z + (i1 >> 8 & 15)); // Paper - change to setValues call
|
||||||
return out; // Paper
|
return out; // Paper
|
||||||
@@ -1470,7 +1506,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
@@ -1470,7 +1511,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long nextSubTickCount() {
|
public long nextSubTickCount() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user