Clean up some log messages
This commit is contained in:
parent
19d2d8cfc0
commit
e7e065f809
|
|
@ -0,0 +1,22 @@
|
|||
package org.embeddedt.modernfix.common.mixin.perf.dynamic_resources;
|
||||
|
||||
import net.minecraft.client.resources.model.ModelDiscovery;
|
||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ModelDiscovery.class)
|
||||
@ClientOnlyMixin
|
||||
public class ModelDiscoveryMixin {
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason We will show the warning ourselves later when loading the model dynamically, this is just spam since
|
||||
* the models don't exist during early loading
|
||||
*/
|
||||
@Redirect(method = "loadBlockModel", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V"))
|
||||
private void disableMissingModelWarning(Logger instance, String s, Object o) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import net.minecraft.client.renderer.item.ItemModel;
|
|||
import net.minecraft.client.resources.model.AtlasSet;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.BlockStateModelLoader;
|
||||
import net.minecraft.client.resources.model.ClientItemInfoLoader;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
|
@ -58,6 +59,11 @@ public class ModelManagerMixin implements DynamicModelProvider.ModelManagerExten
|
|||
return Map.of();
|
||||
}
|
||||
|
||||
@Redirect(method = "reload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/model/ClientItemInfoLoader;scheduleLoad(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
|
||||
private CompletableFuture<ClientItemInfoLoader.LoadedClientInfos> disableClientItemEarlyLoad(ResourceManager resourceManager, Executor executor) {
|
||||
return CompletableFuture.completedFuture(new ClientItemInfoLoader.LoadedClientInfos(Map.of()));
|
||||
}
|
||||
|
||||
@ModifyArg(method = "reload", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;allOf([Ljava/util/concurrent/CompletableFuture;)Ljava/util/concurrent/CompletableFuture;", ordinal = 1))
|
||||
private CompletableFuture<?>[] createModelProvider(CompletableFuture<?>[] cfs, @Local(ordinal = 0) CompletableFuture<EntityModelSet> entityModelFuture, @Local(ordinal = 0, argsOnly = true) Executor executor, @Local(ordinal = 0) Map<ResourceLocation, CompletableFuture<AtlasSet.StitchResult>> atlasPreparations) {
|
||||
CompletableFuture<Void> makeModelProviderFuture = CompletableFuture.supplyAsync(() -> {
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ public class DynamicModelProvider {
|
|||
private final Map<ResourceLocation, ItemModel> itemStackModelOverrides = new ConcurrentHashMap<>();
|
||||
private final Map<ResourceLocation, BakedModel> standaloneModelOverrides = new ConcurrentHashMap<>();
|
||||
|
||||
private static final boolean DEBUG_DYNAMIC_MODEL_LOADING = Boolean.getBoolean("modernfix.debugDynamicModelLoading");
|
||||
|
||||
public DynamicModelProvider(ResourceManager resourceManager, EntityModelSet entityModelSet,
|
||||
Map<ResourceLocation, AtlasSet.StitchResult> atlasMap) {
|
||||
this.unbakedMissingModel = MissingBlockModel.missingModel();
|
||||
|
|
@ -313,6 +315,9 @@ public class DynamicModelProvider {
|
|||
if(stateDefinition == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
if (DEBUG_DYNAMIC_MODEL_LOADING) {
|
||||
ModernFix.LOGGER.info("Loading blockstate definition '{}'", location);
|
||||
}
|
||||
List<Resource> resources = resourceManager.getResourceStack(ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "blockstates/" + location.getPath() + ".json"));
|
||||
List<BlockStateModelLoader.LoadedBlockModelDefinition> loadedDefinitions = new ArrayList<>(resources.size());
|
||||
for(Resource resource : resources) {
|
||||
|
|
@ -328,6 +333,9 @@ public class DynamicModelProvider {
|
|||
}
|
||||
|
||||
private BakedModel bakeModel(UnbakedModel model, ModelDebugName name) {
|
||||
if (DEBUG_DYNAMIC_MODEL_LOADING) {
|
||||
ModernFix.LOGGER.info("Baking model '{}'", name.get());
|
||||
}
|
||||
synchronized (this) {
|
||||
this.resolver.clearResolver();
|
||||
model.resolveDependencies(this.resolver);
|
||||
|
|
@ -337,6 +345,9 @@ public class DynamicModelProvider {
|
|||
}
|
||||
|
||||
private BakedModel bakeModel(UnbakedBlockStateModel model, ModelDebugName name) {
|
||||
if (DEBUG_DYNAMIC_MODEL_LOADING) {
|
||||
ModernFix.LOGGER.info("Baking model '{}'", name.get());
|
||||
}
|
||||
synchronized (this) {
|
||||
this.resolver.clearResolver();
|
||||
model.resolveDependencies(this.resolver);
|
||||
|
|
@ -379,6 +390,9 @@ public class DynamicModelProvider {
|
|||
}
|
||||
|
||||
private Optional<UnbakedModel> loadBlockModel(ResourceLocation location) {
|
||||
if (DEBUG_DYNAMIC_MODEL_LOADING) {
|
||||
ModernFix.LOGGER.info("Loading block model '{}'", location);
|
||||
}
|
||||
if (location.equals(ItemModelGenerator.GENERATED_ITEM_MODEL_ID)) {
|
||||
return Optional.of(this.itemModelGenerator);
|
||||
}
|
||||
|
|
@ -398,6 +412,9 @@ public class DynamicModelProvider {
|
|||
}
|
||||
|
||||
private Optional<ClientItem> loadClientItemProperties(ResourceLocation location) {
|
||||
if (DEBUG_DYNAMIC_MODEL_LOADING) {
|
||||
ModernFix.LOGGER.info("Loading client item '{}'", location);
|
||||
}
|
||||
var resource = this.resourceManager.getResource(ResourceLocation.fromNamespaceAndPath(location.getNamespace(), "items/" + location.getPath() + ".json"));
|
||||
if(resource.isPresent()) {
|
||||
try(Reader reader = resource.get().openAsReader()) {
|
||||
|
|
@ -414,6 +431,9 @@ public class DynamicModelProvider {
|
|||
}
|
||||
|
||||
private Optional<ItemModel> loadItemModel(ResourceLocation location) {
|
||||
if (DEBUG_DYNAMIC_MODEL_LOADING) {
|
||||
ModernFix.LOGGER.info("Loading item model '{}'", location);
|
||||
}
|
||||
var override = this.itemStackModelOverrides.get(location);
|
||||
if (override != null) {
|
||||
return Optional.of(override);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user