Skip to content

Commit

Permalink
Fix block entity initialization issues
Browse files Browse the repository at this point in the history
  • Loading branch information
2No2Name committed Jan 14, 2025
1 parent 55742f4 commit 7d0fdab
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ public abstract class LevelChunkMixin {
)
)
private BlockEntity createBlockEntityWithCachedStateFix(EntityBlock blockEntityProvider, BlockPos pos, BlockState state) {
return blockEntityProvider.newBlockEntity(pos, this.getBlockState(pos));
// Modded EntityBlock objects are not always the same as state.getBlock(), use their object if it is valid.
BlockState blockState = this.getBlockState(pos);
if (state == blockState) {
return blockEntityProvider.newBlockEntity(pos, state);
} else if (blockState.hasBlockEntity()) { // Create our block entity of correct type if applicable
return ((EntityBlock) blockState.getBlock()).newBlockEntity(pos, blockState);
} else {
return null;
}
}

@Inject(
Expand Down

0 comments on commit 7d0fdab

Please sign in to comment.