Skip to content

Commit c0815b7

Browse files
committed
Fix legacy solid property not being set correctly when blockstate cache is invalid
Related: #244
1 parent 3011e40 commit c0815b7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/reduce_blockstate_cache_rebuilds/BlockStateBaseMixin.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ protected BlockStateBaseMixin(Block object, ImmutableMap<Property<?>, Comparable
3030
@Shadow private BlockBehaviour.BlockStateBase.Cache cache;
3131
@Shadow private FluidState fluidState;
3232
@Shadow private boolean isRandomlyTicking;
33+
@Shadow @Deprecated private boolean legacySolid;
3334

3435
@Shadow protected abstract BlockState asState();
3536

@@ -114,4 +115,15 @@ private boolean genCacheBeforeGettingTicking(BlockBehaviour.BlockStateBase base)
114115
return this.owner.isRandomlyTicking(this.asState());
115116
return this.isRandomlyTicking;
116117
}
118+
119+
@Redirect(method = "*", at = @At(
120+
value = "FIELD",
121+
opcode = Opcodes.GETFIELD,
122+
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;legacySolid:Z",
123+
ordinal = 0
124+
))
125+
private boolean genCacheBeforeCheckingSolid(BlockBehaviour.BlockStateBase base) {
126+
mfix$generateCache();
127+
return this.legacySolid;
128+
}
117129
}

fabric/src/test/java/net/minecraft/world/level/block/state/BlockStateCacheTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public void testCacheNullInitially() {
2828
BlockState stoneBlock = Blocks.STONE.defaultBlockState();
2929
assertTrue(((IBlockState)stoneBlock).isCacheInvalid());
3030
assertNull(stoneBlock.cache);
31+
32+
// make sure lazy cache correctly handles solid
33+
assertTrue(stoneBlock.isSolid());
3134
}
3235

3336
/**

0 commit comments

Comments
 (0)