Skip to content

Commit

Permalink
refactor: use BlockType#copyPropertyValuesFrom()
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jan 13, 2025
1 parent af543b0 commit bbabcb8
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.allaymc.api.block.property.type.BlockPropertyType;
import org.allaymc.api.block.type.BlockType;
import org.allaymc.api.block.type.BlockTypes;
import org.allaymc.api.blockentity.component.BlockEntityContainerHolderComponent;
Expand Down Expand Up @@ -130,11 +129,12 @@ public void loadNBT(NbtMap nbt) {
public void setLit(boolean lit) {
var currentBlockState = getDimension().getBlockState(position);
var newBlockType = lit ? getLitBlockType() : getUnlitBlockType();
if (currentBlockState.getBlockType() == newBlockType) return;
if (currentBlockState.getBlockType() == newBlockType) {
return;
}

var propertyValues = currentBlockState.getPropertyValues().values().toArray(BlockPropertyType.BlockPropertyValue<?, ?, ?>[]::new);
getDimension().setBlockState(
position, newBlockType.ofState(propertyValues),
position, newBlockType.copyPropertyValuesFrom(currentBlockState),
0, true, true, false
);
}
Expand Down

0 comments on commit bbabcb8

Please sign in to comment.