diff --git a/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java b/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java index 016dc1ab..da7eb18d 100644 --- a/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java +++ b/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java @@ -39,6 +39,7 @@ public class ModernFixEarlyConfig { this.addMixinRule("perf.nuke_empty_chunk_sections", true); this.addMixinRule("perf.flatten_model_predicates", true); this.addMixinRule("perf.deduplicate_location", true); + this.addMixinRule("perf.cache_blockstate_cache_arrays", true); this.addMixinRule("safety", true); this.addMixinRule("launch.transformer_cache", false); this.addMixinRule("launch.class_search_cache", true); diff --git a/src/main/java/org/embeddedt/modernfix/mixin/perf/cache_blockstate_cache_arrays/AbstractBlockStateCacheMixin.java b/src/main/java/org/embeddedt/modernfix/mixin/perf/cache_blockstate_cache_arrays/AbstractBlockStateCacheMixin.java new file mode 100644 index 00000000..0cf2fdc4 --- /dev/null +++ b/src/main/java/org/embeddedt/modernfix/mixin/perf/cache_blockstate_cache_arrays/AbstractBlockStateCacheMixin.java @@ -0,0 +1,23 @@ +package org.embeddedt.modernfix.mixin.perf.cache_blockstate_cache_arrays; + +import net.minecraft.util.BlockVoxelShape; +import net.minecraft.util.Direction; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(targets = { "net/minecraft/block/AbstractBlock$AbstractBlockState$Cache" }) +public class AbstractBlockStateCacheMixin { + private static final BlockVoxelShape[] MF_BLOCK_VOXEL_SHAPES = BlockVoxelShape.values(); + private static final Direction.Axis[] DIRECTION_AXIS_VALUES = Direction.Axis.values(); + + @Redirect(method = "(Lnet/minecraft/block/BlockState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/BlockVoxelShape;values()[Lnet/minecraft/util/BlockVoxelShape;")) + private BlockVoxelShape[] getVoxelShapeValues() { + return MF_BLOCK_VOXEL_SHAPES; + } + + @Redirect(method = "(Lnet/minecraft/block/BlockState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Direction$Axis;values()[Lnet/minecraft/util/Direction$Axis;")) + private Direction.Axis[] getDirectionAxisValues() { + return DIRECTION_AXIS_VALUES; + } +} diff --git a/src/main/resources/modernfix.mixins.json b/src/main/resources/modernfix.mixins.json index db8cb228..e7a36858 100644 --- a/src/main/resources/modernfix.mixins.json +++ b/src/main/resources/modernfix.mixins.json @@ -24,7 +24,8 @@ "perf.deduplicate_location.MixinResourceLocation", "perf.sync_executor_sleep.SyncExecutorMixin", "perf.compress_biome_container.MixinBiomeContainer", - "perf.nuke_empty_chunk_sections.MixinChunk" + "perf.nuke_empty_chunk_sections.MixinChunk", + "perf.cache_blockstate_cache_arrays.AbstractBlockStateCacheMixin" ], "client": [ "feature.measure_time.MinecraftMixin",