Fix legacy solid property not being set correctly when blockstate cache is invalid
Related: #244
This commit is contained in:
parent
3011e40972
commit
c0815b787e
|
|
@ -30,6 +30,7 @@ public abstract class BlockStateBaseMixin extends StateHolder<Block, BlockState>
|
||||||
@Shadow private BlockBehaviour.BlockStateBase.Cache cache;
|
@Shadow private BlockBehaviour.BlockStateBase.Cache cache;
|
||||||
@Shadow private FluidState fluidState;
|
@Shadow private FluidState fluidState;
|
||||||
@Shadow private boolean isRandomlyTicking;
|
@Shadow private boolean isRandomlyTicking;
|
||||||
|
@Shadow @Deprecated private boolean legacySolid;
|
||||||
|
|
||||||
@Shadow protected abstract BlockState asState();
|
@Shadow protected abstract BlockState asState();
|
||||||
|
|
||||||
|
|
@ -114,4 +115,15 @@ public abstract class BlockStateBaseMixin extends StateHolder<Block, BlockState>
|
||||||
return this.owner.isRandomlyTicking(this.asState());
|
return this.owner.isRandomlyTicking(this.asState());
|
||||||
return this.isRandomlyTicking;
|
return this.isRandomlyTicking;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "*", at = @At(
|
||||||
|
value = "FIELD",
|
||||||
|
opcode = Opcodes.GETFIELD,
|
||||||
|
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;legacySolid:Z",
|
||||||
|
ordinal = 0
|
||||||
|
))
|
||||||
|
private boolean genCacheBeforeCheckingSolid(BlockBehaviour.BlockStateBase base) {
|
||||||
|
mfix$generateCache();
|
||||||
|
return this.legacySolid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ public class BlockStateCacheTest {
|
||||||
BlockState stoneBlock = Blocks.STONE.defaultBlockState();
|
BlockState stoneBlock = Blocks.STONE.defaultBlockState();
|
||||||
assertTrue(((IBlockState)stoneBlock).isCacheInvalid());
|
assertTrue(((IBlockState)stoneBlock).isCacheInvalid());
|
||||||
assertNull(stoneBlock.cache);
|
assertNull(stoneBlock.cache);
|
||||||
|
|
||||||
|
// make sure lazy cache correctly handles solid
|
||||||
|
assertTrue(stoneBlock.isSolid());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user