mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-04 01:39:54 +01:00
835bc39b03
Updated Upstream (Bukkit/CraftBukkit/Spigot) Bukkit Changes: 2dcc44dc SPIGOT-4307: Fix hacky API for banners on shields e0fc6572 SPIGOT-4309: Add "forced" display of particles efeeab2f Add index to README.md for easier navigation f502bc6f Update to Minecraft 1.13.1 CraftBukkit Changes:d0bb0a1d
Fix some tests randomly failing997d378d
Fix client stall in specific teleportation scenariosb3dc2366
SPIGOT-4307: Fix hacky API for banners on shields2a271162
SPIGOT-4301: Fix more invalid enchants5d0d83bb
SPIGOT-4309: Add "forced" display of particlesa6772578
Add additional tests for CraftBlockDatace1af0c3
Update to Minecraft 1.13.1 Spigot Changes: 2440e189 Rebuild patches 4ecffced Update to Minecraft 1.13.1
136 lines
5.3 KiB
Diff
136 lines
5.3 KiB
Diff
From ebb2afdc3c8ca00cf538b5b2afe82908db6df9bf Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Mon, 6 Nov 2017 21:08:22 -0500
|
|
Subject: [PATCH] API to get a BlockState without a snapshot
|
|
|
|
This allows you to get a BlockState without creating a snapshot, operating
|
|
on the real tile entity.
|
|
|
|
This is useful for where performance is needed
|
|
|
|
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/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
|
index b3c5766a27..29fe031d85 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
|
@@ -206,7 +206,12 @@ public abstract class TileEntity implements KeyedObject { // Paper
|
|
}
|
|
|
|
// CraftBukkit start - add method
|
|
+ // Paper start
|
|
public InventoryHolder getOwner() {
|
|
+ return getOwner(true);
|
|
+ }
|
|
+ public InventoryHolder getOwner(boolean useSnapshot) {
|
|
+ // Paper end
|
|
if (world == null) return null;
|
|
// Spigot start
|
|
org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
|
|
@@ -215,7 +220,7 @@ public abstract class TileEntity implements KeyedObject { // Paper
|
|
return null;
|
|
}
|
|
// Spigot end
|
|
- org.bukkit.block.BlockState state = block.getState();
|
|
+ org.bukkit.block.BlockState state = block.getState(useSnapshot); // Paper
|
|
if (state instanceof InventoryHolder) return (InventoryHolder) state;
|
|
return null;
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
index 370a222f83..f493ebc4f3 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
@@ -267,6 +267,20 @@ public class CraftBlock implements Block {
|
|
}
|
|
|
|
public BlockState getState() {
|
|
+ // Paper start - allow disabling the use of snapshots
|
|
+ return getState(true);
|
|
+ }
|
|
+ public BlockState getState(boolean useSnapshot) {
|
|
+ boolean prev = CraftBlockEntityState.DISABLE_SNAPSHOT;
|
|
+ CraftBlockEntityState.DISABLE_SNAPSHOT = !useSnapshot;
|
|
+ try {
|
|
+ return getState0();
|
|
+ } finally {
|
|
+ CraftBlockEntityState.DISABLE_SNAPSHOT = prev;
|
|
+ }
|
|
+ }
|
|
+ public BlockState getState0() {
|
|
+ // Paper end
|
|
Material material = getType();
|
|
|
|
switch (material) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
|
|
index 0558cafe31..d4d9c5fc50 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
|
|
@@ -23,20 +23,40 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
|
|
CraftWorld world = (CraftWorld) this.getWorld();
|
|
this.tileEntity = tileEntityClass.cast(world.getTileEntityAt(this.getX(), this.getY(), this.getZ()));
|
|
|
|
+ // Paper start
|
|
+ this.snapshotDisabled = DISABLE_SNAPSHOT;
|
|
+ if (DISABLE_SNAPSHOT) {
|
|
+ this.snapshot = this.tileEntity;
|
|
+ } else {
|
|
+ this.snapshot = this.createSnapshot(this.tileEntity, world.getHandle());
|
|
+ }
|
|
// copy tile entity data:
|
|
- this.snapshot = this.createSnapshot(tileEntity, world.getHandle());
|
|
- this.load(snapshot);
|
|
+ if(this.snapshot != null) {
|
|
+ this.load(this.snapshot);
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
+ public final boolean snapshotDisabled; // Paper
|
|
+ public static boolean DISABLE_SNAPSHOT = false; // Paper
|
|
+
|
|
public CraftBlockEntityState(Material material, T tileEntity) {
|
|
super(material);
|
|
|
|
this.tileEntityClass = (Class<T>) tileEntity.getClass();
|
|
this.tileEntity = tileEntity;
|
|
-
|
|
+ // Paper start
|
|
+ this.snapshotDisabled = DISABLE_SNAPSHOT;
|
|
+ if (DISABLE_SNAPSHOT) {
|
|
+ this.snapshot = this.tileEntity;
|
|
+ } else {
|
|
+ this.snapshot = this.createSnapshot(this.tileEntity, null);
|
|
+ }
|
|
// copy tile entity data:
|
|
- this.snapshot = this.createSnapshot(tileEntity, null);
|
|
- this.load(snapshot);
|
|
+ if(this.snapshot != null) {
|
|
+ this.load(this.snapshot);
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
private T createSnapshot(T tileEntity, World world) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
|
index 7a8d445299..97b4e6910d 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
|
@@ -14,10 +14,12 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
|
|
|
|
public CraftSign(final Block block) {
|
|
super(block, TileEntitySign.class);
|
|
+ if (lines == null) { lines = new String[]{"", "", "", ""}; } // Paper
|
|
}
|
|
|
|
public CraftSign(final Material material, final TileEntitySign te) {
|
|
super(material, te);
|
|
+ if (lines == null) { lines = new String[]{"", "", "", ""}; } // Paper
|
|
}
|
|
|
|
@Override
|
|
--
|
|
2.18.0
|
|
|