More merging logic + 11 new block + Fix server / client sync #23
@ -57,6 +57,6 @@ public class ReFramedDoubleEntity extends ReFramedEntity {
|
|||||||
public void writeNbt(NbtCompound nbt) {
|
public void writeNbt(NbtCompound nbt) {
|
||||||
super.writeNbt(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);
|
if (nbt.contains(BITFIELD_KEY)) bit_field = nbt.getByte(BITFIELD_KEY);
|
||||||
|
|
||||||
// Force a chunk remesh on the client if the displayed blockstate has changed
|
// 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);
|
ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNbt(NbtCompound nbt) {
|
public void writeNbt(NbtCompound nbt) {
|
||||||
super.writeNbt(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);
|
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) {
|
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;
|
first_state = new_state;
|
||||||
markDirtyAndDispatch();
|
markDirtyAndDispatch();
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,14 @@ public class ReFramedBlueprintWrittenItem extends Item {
|
|||||||
stacks.stream().map(inventory::getSlotWithStack).forEach(index -> inventory.removeStack(index, 1));
|
stacks.stream().map(inventory::getSlotWithStack).forEach(index -> inventory.removeStack(index, 1));
|
||||||
player.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.5f, 0.5f);
|
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);
|
world.playSound(player, player.getBlockPos(), SoundEvents.ITEM_BOOK_PAGE_TURN, SoundCategory.PLAYERS);
|
||||||
|
|
||||||
return ActionResult.SUCCESS;
|
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);
|
world.playSound(player, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, 1f, 1.1f);
|
||||||
}
|
}
|
||||||
frame_entity.setTheme(Blocks.AIR.getDefaultState(), theme_index);
|
frame_entity.setTheme(Blocks.AIR.getDefaultState(), theme_index);
|
||||||
ReFramed.chunkRerenderProxy.accept(world, pos);
|
if (world.isClient) ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class ReFramedScrewdriverItem extends Item {
|
|||||||
case Z -> Direction.Axis.X;
|
case Z -> Direction.Axis.X;
|
||||||
}
|
}
|
||||||
), theme_index);
|
), theme_index);
|
||||||
ReFramed.chunkRerenderProxy.accept(world, pos);
|
if (world.isClient) ReFramed.chunkRerenderProxy.accept(world, pos);
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user