|
19 | 19 | import org.embeddedt.modernfix.annotation.ClientOnlyMixin; |
20 | 20 | import org.embeddedt.modernfix.duck.IExtendedModelBakery; |
21 | 21 | import org.embeddedt.modernfix.duck.IExtendedModelManager; |
| 22 | +import org.embeddedt.modernfix.util.CacheUtil; |
22 | 23 | import org.embeddedt.modernfix.util.LambdaMap; |
23 | 24 | import org.spongepowered.asm.mixin.Mixin; |
24 | 25 | import org.spongepowered.asm.mixin.Shadow; |
@@ -57,12 +58,14 @@ private void injectDummyBakedRegistry(CallbackInfo ci) { |
57 | 58 |
|
58 | 59 | @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;")) |
59 | 60 | private CompletableFuture<Map<ResourceLocation, BlockModel>> deferBlockModelLoad(ResourceManager manager, Executor executor) { |
60 | | - return CompletableFuture.completedFuture(new LambdaMap<>(location -> loadSingleBlockModel(manager, location))); |
| 61 | + var cache = CacheUtil.<ResourceLocation, BlockModel>simpleCacheForLambda(location -> loadSingleBlockModel(manager, location), 100L); |
| 62 | + return CompletableFuture.completedFuture(new LambdaMap<>(location -> cache.getUnchecked(location))); |
61 | 63 | } |
62 | 64 |
|
63 | 65 | @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;")) |
64 | 66 | private CompletableFuture<Map<ResourceLocation, List<BlockStateModelLoader.LoadedJson>>> deferBlockStateLoad(ResourceManager manager, Executor executor) { |
65 | | - return CompletableFuture.completedFuture(new LambdaMap<>(location -> loadSingleBlockState(manager, location))); |
| 67 | + var cache = CacheUtil.<ResourceLocation, List<BlockStateModelLoader.LoadedJson>>simpleCacheForLambda(location -> loadSingleBlockState(manager, location), 100L); |
| 68 | + return CompletableFuture.completedFuture(new LambdaMap<>(location -> cache.getUnchecked(location))); |
66 | 69 | } |
67 | 70 |
|
68 | 71 | @Redirect(method = "loadModels", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/StateDefinition;getPossibleStates()Lcom/google/common/collect/ImmutableList;")) |
|
0 commit comments