SPIGOT-5482: Structure Block setUsageMode encounters NullpointerException

This commit is contained in:
md_5 2019-12-25 10:09:20 +11:00
parent 82322fe06c
commit edcb0a4b6a
2 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/server/TileEntityStructure.java
+++ b/net/minecraft/server/TileEntityStructure.java
@@ -18,7 +18,7 @@
public BlockPosition size;
public EnumBlockMirror mirror;
public EnumBlockRotation rotation;
- private BlockPropertyStructureMode usageMode;
+ public BlockPropertyStructureMode usageMode;
public boolean ignoreEntities;
private boolean powered;
public boolean showAir;

View File

@ -105,7 +105,7 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
@Override
public void setUsageMode(UsageMode mode) {
getSnapshot().setUsageMode(BlockPropertyStructureMode.valueOf(mode.name()));
getSnapshot().usageMode = BlockPropertyStructureMode.valueOf(mode.name());
}
@Override
@ -177,6 +177,14 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
return getSnapshot().metadata;
}
@Override
protected void applyTo(TileEntityStructure tileEntity) {
super.applyTo(tileEntity);
// Ensure block type is correct
tileEntity.setUsageMode(tileEntity.getUsageMode());
}
private static boolean isBetween(int num, int min, int max) {
return num >= min && num <= max;
}