Skip to content

Commit 00de7e1

Browse files
committed
Add comments
1 parent 6e07ecf commit 00de7e1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/main/java/org/embeddedt/modernfix/common/mixin/perf/dynamic_resources/MixinBlockStateModelLoader.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.llamalad7.mixinextras.sugar.Local;
44
import net.minecraft.client.resources.model.BlockStateModelLoader;
5-
import net.minecraft.client.resources.model.UnbakedModel;
65
import net.minecraft.resources.Identifier;
76
import net.minecraft.server.packs.resources.Resource;
87
import net.minecraft.world.level.block.Block;
@@ -14,7 +13,6 @@
1413
import org.spongepowered.asm.mixin.Shadow;
1514
import org.spongepowered.asm.mixin.injection.At;
1615
import org.spongepowered.asm.mixin.injection.ModifyArg;
17-
import org.spongepowered.asm.mixin.injection.Redirect;
1816

1917
import java.util.List;
2018
import java.util.Map;
@@ -30,6 +28,10 @@ public abstract class MixinBlockStateModelLoader {
3028
throw new AssertionError();
3129
}
3230

31+
/**
32+
* @author embeddedt
33+
* @reason Load blockstate model definitions dynamically instead of all at once
34+
*/
3335
@ModifyArg(method = "loadBlockStates", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;thenCompose(Ljava/util/function/Function;)Ljava/util/concurrent/CompletableFuture;"))
3436
private static Function<Map<Identifier, List<Resource>>, ? extends CompletionStage<BlockStateModelLoader.LoadedModels>> skipAOTBlockStateLoad(Function<Map<Identifier, List<Resource>>, ? extends CompletionStage<Map<Identifier, BlockStateModelLoader.LoadedModels>>> original, @Local(ordinal = 0) Function<Identifier, StateDefinition<Block, BlockState>> mapper) {
3537
return resourceMap -> CompletableFuture.completedFuture(DynamicModelSystem.createDynamicBlockStateLoadedModels(resourceMap, (id, resources) -> {

src/main/java/org/embeddedt/modernfix/common/mixin/perf/dynamic_resources/MixinModelBakery.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
@Mixin(ModelBakery.class)
1616
@ClientOnlyMixin
1717
public class MixinModelBakery {
18+
/**
19+
* @author embeddedt
20+
* @reason Create dynamic baked registry with cache instead of baking all entries from the input map at once
21+
*/
1822
@Redirect(method = "bakeModels", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/thread/ParallelMapTransform;schedule(Ljava/util/Map;Ljava/util/function/BiFunction;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
1923
private <K, U, V> CompletableFuture<Map<K, V>> dynamicallyBake(Map<K, U> input, BiFunction<K, U, V> baker, Executor executor) {
2024
return CompletableFuture.completedFuture(DynamicModelSystem.createDynamicBakedRegistry(input, baker));

0 commit comments

Comments
 (0)