Skip to content

Commit

Permalink
fix(1.21): Re-enable model loading code on Fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jun 8, 2024
1 parent 2de849e commit 31ce793
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.datafixers.util.Either;
import com.mojang.math.Transformation;
import net.blay09.mods.balm.api.DeferredObject;
import net.blay09.mods.balm.mixin.ModelBakeryAccessor;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.ItemTransforms;
Expand Down Expand Up @@ -55,7 +56,7 @@ default UnbakedModel retexture(ModelBakery bakery, ModelResourceLocation identif
Collections.emptyList());

// We have to resolve parents as that is usually done during stitching, which we're already past
// TODO 1.21 blockModel.resolveParents(bakery::getModel);
blockModel.resolveParents(it -> ((ModelBakeryAccessor) bakery).callGetModel(it));

return blockModel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.blay09.mods.balm.fabric.network.FabricBalmNetworking;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
// TODO 1.21 import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;

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

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

// TODO 1.21 ModelLoadingPlugin.register((FabricBalmModels) BalmClient.getModels());
ModelLoadingPlugin.register((FabricBalmModels) BalmClient.getModels());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.mojang.math.Transformation;
import net.blay09.mods.balm.api.DeferredObject;
import net.blay09.mods.balm.api.client.rendering.BalmModels;
// TODO 1.21 import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.blay09.mods.balm.mixin.ModelBakeryAccessor;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.MappingResolver;
import net.minecraft.client.renderer.RenderType;
Expand All @@ -25,7 +25,7 @@
import java.util.function.Function;
import java.util.function.Supplier;

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

private static abstract class DeferredModel extends DeferredObject<BakedModel> {
public DeferredModel(ModelResourceLocation identifier) {
Expand All @@ -45,10 +45,10 @@ public void set(BakedModel object) {
public final List<Pair<Supplier<Block>, Supplier<BakedModel>>> overrides = Collections.synchronizedList(new ArrayList<>());
private ModelBakery modelBakery;

// TODO 1.21 @Override
// TODO 1.21 public void onInitializeModelLoader(Context context) {
// TODO 1.21 context.addModels(additionalModels);
// TODO 1.21 }
@Override
public void onInitializeModelLoader(Context context) {
context.addModels(additionalModels.stream().map(ModelResourceLocation::id).toList());
}

public void onBakeModels(ModelBakery modelBakery, ModelBakery.TextureGetter textureGetter) {
this.modelBakery = modelBakery;
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ modrinth_release_type = release
modrinth_project_id = MBAkmtvl

# Minecraft
minecraft_version = 1.21-pre3
minecraft_versions = 1.21-pre3
minecraft_version_range = 1.21-beta.3
minecraft_version = 1.21-pre4
minecraft_versions = 1.21-pre4
minecraft_version_range = 1.21-beta.4
pack_format_number = 18
java_version = 21

Expand All @@ -36,7 +36,7 @@ neoforge_version_range = [20.6,)
neoforge_loader_version_range = [1,)

# Fabric
fabric_version = 0.99.5+1.21
fabric_version = 0.100.0+1.21
fabric_loader_version = 0.15.11

# Dependencies
Expand Down

0 comments on commit 31ce793

Please sign in to comment.