Skip to content

Commit

Permalink
fix(1.21.4): Re-add loadModel
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Dec 1, 2024
1 parent df49e59 commit a5cc29b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package net.blay09.mods.balm.fabric.client;

import net.blay09.mods.balm.api.Balm;
import net.blay09.mods.balm.api.client.BalmClient;
import net.blay09.mods.balm.api.event.client.DisconnectedFromServerEvent;
import net.blay09.mods.balm.fabric.client.rendering.FabricBalmModels;
import net.blay09.mods.balm.fabric.network.FabricBalmNetworking;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;

public class FabricBalmClient implements ClientModInitializer {
@Override
Expand All @@ -13,6 +16,6 @@ public void onInitializeClient() {

Balm.getEvents().onEvent(DisconnectedFromServerEvent.class, event -> Balm.getConfig().resetToBackingConfigs());

// TODO ModelLoadingPlugin.register((FabricBalmModels) BalmClient.getModels());
ModelLoadingPlugin.register((FabricBalmModels) BalmClient.getModels());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@

import net.blay09.mods.balm.api.DeferredObject;
import net.blay09.mods.balm.api.client.rendering.BalmModels;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.*;
import net.minecraft.resources.ResourceLocation;

import java.util.*;

public class FabricBalmModels implements BalmModels/*, TODO ModelLoadingPlugin*/ {
public class FabricBalmModels implements BalmModels, ModelLoadingPlugin {

private final List<ResourceLocation> additionalModels = Collections.synchronizedList(new ArrayList<>());

/*TODO@Override
@Override
public void initialize(Context context) {
context.addModels(additionalModels);
}*/
}

@Override
public DeferredObject<BakedModel> loadModel(final ResourceLocation identifier) {
// fabric_resource is what Fabric uses as variant for additional models
final var modelResourceLocation = new ModelResourceLocation(identifier, "fabric_resource");
final var deferredObject = new DeferredObject<BakedModel>(identifier) {
@Override
public BakedModel resolve() {
// TODO return ((ModelBakeryAccessor) modelBakery).getBakedCache().get(modelResourceLocation);
return null;
return Minecraft.getInstance().getModelManager().getModel(identifier);
}

@Override
public boolean canResolve() {
// TODO return ((ModelBakeryAccessor) modelBakery).getBakedCache().containsKey(modelResourceLocation);
return false;
final var modelManager = Minecraft.getInstance().getModelManager();
final var foundModel = modelManager.getModel(identifier);
return foundModel != modelManager.getMissingModel();
}
};
additionalModels.add(identifier);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ neoforge_version_range = [21.2.0-beta,)
neoforge_loader_version_range = [1,)

# Fabric
fabric_version = 0.109.1+1.21.4
fabric_version = 0.110.3+1.21.4
fabric_loader_version = 0.16.9

# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,20 @@

import com.mojang.datafixers.util.Pair;
import com.mojang.logging.LogUtils;
import com.mojang.math.Transformation;
import net.blay09.mods.balm.api.DeferredObject;
import net.blay09.mods.balm.api.client.rendering.BalmModels;
import net.blay09.mods.balm.mixin.ModelBakeryAccessor;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.BlockModelShaper;
import net.minecraft.client.resources.model.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.neoforge.client.event.ModelEvent;
import net.neoforged.neoforge.client.model.SimpleModelState;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import org.slf4j.Logger;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Supplier;

public class NeoForgeBalmModels implements BalmModels {
Expand Down

0 comments on commit a5cc29b

Please sign in to comment.