mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 06:24:29 +01:00
Extra bracket validation #6271
This commit is contained in:
parent
f6dfe7d688
commit
dd7eedd1f0
@ -86,6 +86,10 @@ public class BracketedBlockEntityBehaviour extends BlockEntityBehaviour {
|
|||||||
return bracket != null;
|
return bracket != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBracketValid(BlockState bracketState) {
|
||||||
|
return bracketState.getBlock() instanceof BracketBlock;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public BlockState getBracket() {
|
public BlockState getBracket() {
|
||||||
return bracket;
|
return bracket;
|
||||||
@ -110,7 +114,7 @@ public class BracketedBlockEntityBehaviour extends BlockEntityBehaviour {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(CompoundTag nbt, boolean clientPacket) {
|
public void write(CompoundTag nbt, boolean clientPacket) {
|
||||||
if (isBracketPresent()) {
|
if (isBracketPresent() && isBracketValid(bracket)) {
|
||||||
nbt.put("Bracket", NbtUtils.writeBlockState(bracket));
|
nbt.put("Bracket", NbtUtils.writeBlockState(bracket));
|
||||||
}
|
}
|
||||||
if (clientPacket && reRender) {
|
if (clientPacket && reRender) {
|
||||||
@ -122,8 +126,12 @@ public class BracketedBlockEntityBehaviour extends BlockEntityBehaviour {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(CompoundTag nbt, boolean clientPacket) {
|
public void read(CompoundTag nbt, boolean clientPacket) {
|
||||||
if (nbt.contains("Bracket"))
|
if (nbt.contains("Bracket")) {
|
||||||
bracket = NbtUtils.readBlockState(nbt.getCompound("Bracket"));
|
bracket = null;
|
||||||
|
BlockState readBlockState = NbtUtils.readBlockState(nbt.getCompound("Bracket"));
|
||||||
|
if (isBracketValid(readBlockState))
|
||||||
|
bracket = readBlockState;
|
||||||
|
}
|
||||||
if (clientPacket && nbt.contains("Redraw"))
|
if (clientPacket && nbt.contains("Redraw"))
|
||||||
getWorld().sendBlockUpdated(getPos(), blockEntity.getBlockState(), blockEntity.getBlockState(), 16);
|
getWorld().sendBlockUpdated(getPos(), blockEntity.getBlockState(), blockEntity.getBlockState(), 16);
|
||||||
super.read(nbt, clientPacket);
|
super.read(nbt, clientPacket);
|
||||||
|
Loading…
Reference in New Issue
Block a user