fix issue where turning on the back of the screen would break both sides of the screen

This commit is contained in:
GiantLuigi4 2023-06-05 16:57:47 -04:00
parent 78160917eb
commit 5ce9e4574d
2 changed files with 19 additions and 17 deletions

View File

@ -103,6 +103,8 @@ public class BlockScreen extends BaseEntityBlock {
@Override
public void onRemove(BlockState p_60515_, Level p_60516_, BlockPos p_60517_, BlockState p_60518_, boolean p_60519_) {
// TODO: make this also get called on client?
if (p_60518_.getBlock() == p_60515_.getBlock()) return;
for (BlockSide value : BlockSide.values()) {
Vector3i vec = new Vector3i(p_60517_.getX(), p_60517_.getY(), p_60517_.getZ());
Multiblock.findOrigin(p_60516_, vec, value, null);

View File

@ -285,6 +285,23 @@ public class TileEntityScreen extends BlockEntity {
screens.add(Screen.deserialize(list.getCompound(i)));
}
@Override
public CompoundTag getUpdateTag() {
CompoundTag tag = new CompoundTag();
saveAdditional(tag);
return tag;
}
@Override
public void handleUpdateTag(CompoundTag tag) {
load(tag);
for (Screen screen : screens) {
if (screen.browser == null) screen.createBrowser(false);
if (screen.browser != null) screen.browser.loadURL(screen.url);
}
updateAABB();
}
@Override
protected void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
@ -653,23 +670,6 @@ public class TileEntityScreen extends BlockEntity {
}
}
@Override
public CompoundTag getUpdateTag() {
CompoundTag tag = new CompoundTag();
saveAdditional(tag);
return tag;
}
@Override
public void handleUpdateTag(CompoundTag tag) {
load(tag);
for (Screen screen : screens) {
if (screen.browser == null) screen.createBrowser(false);
if (screen.browser != null) screen.browser.loadURL(screen.url);
}
updateAABB();
}
@Override
public void onChunkUnloaded() {
if (level.isClientSide) {