Merge remote-tracking branch 'origin/main' into 1.18
This commit is contained in:
commit
9455b5628e
|
|
@ -3,10 +3,13 @@ package org.embeddedt.modernfix.common.mixin.perf.reduce_blockstate_cache_rebuil
|
|||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import org.embeddedt.modernfix.duck.IBlockState;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Dynamic;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
|
||||
@Mixin(BlockBehaviour.BlockStateBase.class)
|
||||
|
|
@ -23,13 +26,7 @@ public abstract class BlockStateBaseMixin implements IBlockState {
|
|||
cacheInvalid = true;
|
||||
}
|
||||
|
||||
@Redirect(method = "*", at = @At(
|
||||
value = "FIELD",
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;cache:Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase$Cache;",
|
||||
ordinal = 0
|
||||
))
|
||||
private BlockBehaviour.BlockStateBase.Cache initCacheIfNeeded(BlockBehaviour.BlockStateBase base) {
|
||||
private BlockBehaviour.BlockStateBase.Cache generateCache(BlockBehaviour.BlockStateBase base) {
|
||||
if(cacheInvalid) {
|
||||
// Ensure that only one block's cache is built at a time
|
||||
synchronized (BlockBehaviour.BlockStateBase.class) {
|
||||
|
|
@ -50,4 +47,32 @@ public abstract class BlockStateBaseMixin implements IBlockState {
|
|||
}
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
@Redirect(method = "*", at = @At(
|
||||
value = "FIELD",
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;cache:Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase$Cache;",
|
||||
ordinal = 0
|
||||
))
|
||||
private BlockBehaviour.BlockStateBase.Cache dynamicCacheGen(BlockBehaviour.BlockStateBase base) {
|
||||
return generateCache(base);
|
||||
}
|
||||
|
||||
@Dynamic
|
||||
@Inject(method = "getPathNodeType", at = @At("HEAD"), require = 0, remap = false)
|
||||
private void generateCacheLithium(CallbackInfoReturnable<?> cir) {
|
||||
generateCache((BlockBehaviour.BlockStateBase)(Object)this);
|
||||
}
|
||||
|
||||
@Dynamic
|
||||
@Inject(method = "getNeighborPathNodeType", at = @At("HEAD"), require = 0, remap = false)
|
||||
private void generateCacheLithium2(CallbackInfoReturnable<?> cir) {
|
||||
generateCache((BlockBehaviour.BlockStateBase)(Object)this);
|
||||
}
|
||||
|
||||
@Dynamic
|
||||
@Inject(method = "getAllFlags", at = @At("HEAD"), require = 0, remap = false)
|
||||
private void generateCacheLithium3(CallbackInfoReturnable<?> cir) {
|
||||
generateCache((BlockBehaviour.BlockStateBase)(Object)this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user