|
13 | 13 | import net.minecraft.world.level.block.state.StateDefinition; |
14 | 14 | import org.embeddedt.modernfix.ModernFix; |
15 | 15 | import org.embeddedt.modernfix.annotation.ClientOnlyMixin; |
| 16 | +import org.embeddedt.modernfix.util.CacheUtil; |
16 | 17 | import org.embeddedt.modernfix.util.LambdaMap; |
17 | 18 | import org.spongepowered.asm.mixin.Mixin; |
18 | 19 | import org.spongepowered.asm.mixin.Shadow; |
@@ -45,12 +46,14 @@ private void injectDummyBakedRegistry(CallbackInfo ci) { |
45 | 46 |
|
46 | 47 | @Redirect(method = "reload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/model/ModelManager;loadBlockModels(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) |
47 | 48 | private CompletableFuture<Map<ResourceLocation, BlockModel>> deferBlockModelLoad(ResourceManager manager, Executor executor) { |
48 | | - return CompletableFuture.completedFuture(new LambdaMap<>(location -> loadSingleBlockModel(manager, location))); |
| 49 | + var cache = CacheUtil.<ResourceLocation, BlockModel>simpleCacheForLambda(location -> loadSingleBlockModel(manager, location), 100L); |
| 50 | + return CompletableFuture.completedFuture(new LambdaMap<>(location -> cache.getUnchecked(location))); |
49 | 51 | } |
50 | 52 |
|
51 | 53 | @Redirect(method = "reload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/model/ModelManager;loadBlockStates(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) |
52 | 54 | private CompletableFuture<Map<ResourceLocation, List<ModelBakery.LoadedJson>>> deferBlockStateLoad(ResourceManager manager, Executor executor) { |
53 | | - return CompletableFuture.completedFuture(new LambdaMap<>(location -> loadSingleBlockState(manager, location))); |
| 55 | + var cache = CacheUtil.<ResourceLocation, List<ModelBakery.LoadedJson>>simpleCacheForLambda(location -> loadSingleBlockState(manager, location), 100L); |
| 56 | + return CompletableFuture.completedFuture(new LambdaMap<>(location -> cache.getUnchecked(location))); |
54 | 57 | } |
55 | 58 |
|
56 | 59 | @Redirect(method = "loadModels", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/StateDefinition;getPossibleStates()Lcom/google/common/collect/ImmutableList;")) |
|
0 commit comments