Skip to content

Commit 7d0fdab

Browse files
committed
Fix block entity initialization issues
1 parent 55742f4 commit 7d0fdab

File tree

1 file changed

+9
-1
lines changed
  • common/src/main/java/net/caffeinemc/mods/lithium/mixin/minimal_nonvanilla/world/block_entity_ticking/support_cache

1 file changed

+9
-1
lines changed

common/src/main/java/net/caffeinemc/mods/lithium/mixin/minimal_nonvanilla/world/block_entity_ticking/support_cache/LevelChunkMixin.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ public abstract class LevelChunkMixin {
3636
)
3737
)
3838
private BlockEntity createBlockEntityWithCachedStateFix(EntityBlock blockEntityProvider, BlockPos pos, BlockState state) {
39-
return blockEntityProvider.newBlockEntity(pos, this.getBlockState(pos));
39+
// Modded EntityBlock objects are not always the same as state.getBlock(), use their object if it is valid.
40+
BlockState blockState = this.getBlockState(pos);
41+
if (state == blockState) {
42+
return blockEntityProvider.newBlockEntity(pos, state);
43+
} else if (blockState.hasBlockEntity()) { // Create our block entity of correct type if applicable
44+
return ((EntityBlock) blockState.getBlock()).newBlockEntity(pos, blockState);
45+
} else {
46+
return null;
47+
}
4048
}
4149

4250
@Inject(

0 commit comments

Comments
 (0)