fix: made frames properly update on every client when using blueprint/screwdriver/hammer
This commit is contained in:
parent
d325e3c5a5
commit
48c7c4e538
@ -57,6 +57,6 @@ public class ReFramedDoubleEntity extends ReFramedEntity {
|
||||
public void writeNbt(NbtCompound nbt) {
|
||||
super.writeNbt(nbt);
|
||||
|
||||
if(second_state != Blocks.AIR.getDefaultState()) nbt.put(BLOCKSTATE_KEY + 2, NbtHelper.fromBlockState(second_state));
|
||||
nbt.put(BLOCKSTATE_KEY + 2, NbtHelper.fromBlockState(second_state));
|
||||
}
|
||||
}
|
||||
|
@ -52,16 +52,15 @@ public class ReFramedEntity extends BlockEntity implements ThemeableBlockEntity
|
||||
if (nbt.contains(BITFIELD_KEY)) bit_field = nbt.getByte(BITFIELD_KEY);
|
||||
|
||||
// Force a chunk remesh on the client if the displayed blockstate has changed
|
||||
if(world != null && world.isClient && !Objects.equals(rendered_state, first_state)) {
|
||||
if(world != null && world.isClient && !Objects.equals(rendered_state, first_state))
|
||||
ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNbt(NbtCompound nbt) {
|
||||
super.writeNbt(nbt);
|
||||
|
||||
if(first_state != Blocks.AIR.getDefaultState()) nbt.put(BLOCKSTATE_KEY + 1, NbtHelper.fromBlockState(first_state));
|
||||
nbt.put(BLOCKSTATE_KEY + 1, NbtHelper.fromBlockState(first_state));
|
||||
if(bit_field != SOLIDITY_MASK) nbt.putByte(BITFIELD_KEY, bit_field);
|
||||
}
|
||||
|
||||
@ -113,7 +112,7 @@ public class ReFramedEntity extends BlockEntity implements ThemeableBlockEntity
|
||||
}
|
||||
|
||||
public void setTheme(BlockState new_state, int i) {
|
||||
if(!Objects.equals(first_state, new_state)) {
|
||||
if(!Objects.equals(first_state, new_state) && i == 1) {
|
||||
first_state = new_state;
|
||||
markDirtyAndDispatch();
|
||||
}
|
||||
|
@ -74,7 +74,14 @@ public class ReFramedBlueprintWrittenItem extends Item {
|
||||
stacks.stream().map(inventory::getSlotWithStack).forEach(index -> inventory.removeStack(index, 1));
|
||||
player.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.5f, 0.5f);
|
||||
}
|
||||
frame_entity.readNbt(tag);
|
||||
for (int i = 1; tag.contains(BLOCKSTATE_KEY + i); i++) {
|
||||
BlockState state = NbtHelper.toBlockState(
|
||||
Registries.BLOCK.getReadOnlyWrapper(),
|
||||
tag.getCompound(BLOCKSTATE_KEY + i)
|
||||
);
|
||||
frame_entity.setTheme(state, i);
|
||||
}
|
||||
if (world.isClient) ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||
world.playSound(player, player.getBlockPos(), SoundEvents.ITEM_BOOK_PAGE_TURN, SoundCategory.PLAYERS);
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
|
@ -43,7 +43,7 @@ public class ReFramedHammerItem extends Item {
|
||||
world.playSound(player, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, 1f, 1.1f);
|
||||
}
|
||||
frame_entity.setTheme(Blocks.AIR.getDefaultState(), theme_index);
|
||||
ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||
if (world.isClient) ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class ReFramedScrewdriverItem extends Item {
|
||||
case Z -> Direction.Axis.X;
|
||||
}
|
||||
), theme_index);
|
||||
ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||
if (world.isClient) ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user