Invalidate blockstate cache in place of initCache

This commit is contained in:
embeddedt 2023-12-06 20:43:54 -05:00
parent cb09af7e86
commit 46127b50f3
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -3,6 +3,7 @@ package org.embeddedt.modernfix.common.mixin.perf.reduce_blockstate_cache_rebuil
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import org.embeddedt.modernfix.blockstate.BlockStateCacheHandler;
import org.embeddedt.modernfix.duck.IBlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
@ -21,6 +22,7 @@ public class BlocksMixin {
// require = 0 due to Forge removing the BLOCK_STATE_REGISTRY init here
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;initCache()V"), require = 0)
private static void skipCacheInit(BlockState state) {
/* no-op, our dynamic logic handles everything properly (including the 1.19.4+ fluidState, etc. caching) */
// Mark the cache as invalid
((IBlockState)state).clearCache();
}
}