mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-26 15:06:42 +01:00
Fix changing bogey style not updating the block properly (#6273)
* Fix bogey block's placing the wrong block * Clean the code up a bit * Fix bitflag
This commit is contained in:
parent
7d3d4a1e7c
commit
41f957a94d
1 changed files with 16 additions and 10 deletions
|
@ -227,15 +227,21 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyBlockEntity> ext
|
|||
sbbe.setBogeyData(sbbe.getBogeyData().merge(defaultData));
|
||||
|
||||
if (size == getSize()) {
|
||||
if (state.getBlock() != style.getBlockOfSize(size)) {
|
||||
CompoundTag oldData = sbbe.getBogeyData();
|
||||
level.setBlock(pos, copyProperties(state, getStateOfSize(sbbe, size)), Block.UPDATE_ALL);
|
||||
if (!(level.getBlockEntity(pos) instanceof AbstractBogeyBlockEntity bogeyBlockEntity))
|
||||
return InteractionResult.FAIL;
|
||||
bogeyBlockEntity.setBogeyData(oldData);
|
||||
}
|
||||
player.displayClientMessage(Lang.translateDirect("bogey.style.updated_style")
|
||||
.append(": ").append(style.displayName), true);
|
||||
} else {
|
||||
CompoundTag oldData = sbbe.getBogeyData();
|
||||
level.setBlock(pos, this.getStateOfSize(sbbe, size), 3);
|
||||
BlockEntity newBlockEntity = level.getBlockEntity(pos);
|
||||
if (!(newBlockEntity instanceof AbstractBogeyBlockEntity newBlockEntity1))
|
||||
level.setBlock(pos, this.getStateOfSize(sbbe, size), Block.UPDATE_ALL);
|
||||
if (!(level.getBlockEntity(pos) instanceof AbstractBogeyBlockEntity bogeyBlockEntity))
|
||||
return InteractionResult.FAIL;
|
||||
newBlockEntity1.setBogeyData(oldData);
|
||||
bogeyBlockEntity.setBogeyData(oldData);
|
||||
player.displayClientMessage(Lang.translateDirect("bogey.style.updated_style_and_size")
|
||||
.append(": ").append(style.displayName), true);
|
||||
}
|
||||
|
@ -312,18 +318,18 @@ public abstract class AbstractBogeyBlock<T extends AbstractBogeyBlockEntity> ext
|
|||
return target;
|
||||
}
|
||||
|
||||
public BlockState getNextSize(AbstractBogeyBlockEntity sbte) {
|
||||
public BlockState getNextSize(AbstractBogeyBlockEntity sbbe) {
|
||||
BogeySizes.BogeySize size = this.getSize();
|
||||
BogeyStyle style = sbte.getStyle();
|
||||
BogeyStyle style = sbbe.getStyle();
|
||||
BlockState nextBlock = style.getNextBlock(size).defaultBlockState();
|
||||
nextBlock = copyProperties(sbte.getBlockState(), nextBlock);
|
||||
nextBlock = copyProperties(sbbe.getBlockState(), nextBlock);
|
||||
return nextBlock;
|
||||
}
|
||||
|
||||
public BlockState getStateOfSize(AbstractBogeyBlockEntity sbte, BogeySizes.BogeySize size) {
|
||||
BogeyStyle style = sbte.getStyle();
|
||||
public BlockState getStateOfSize(AbstractBogeyBlockEntity sbbe, BogeySizes.BogeySize size) {
|
||||
BogeyStyle style = sbbe.getStyle();
|
||||
BlockState state = style.getBlockOfSize(size).defaultBlockState();
|
||||
return copyProperties(sbte.getBlockState(), state);
|
||||
return copyProperties(sbbe.getBlockState(), state);
|
||||
}
|
||||
|
||||
public BogeyStyle getNextStyle(Level level, BlockPos pos) {
|
||||
|
|
Loading…
Reference in a new issue