Skip to content

Commit

Permalink
We do a bit of model rendering, yeah
Browse files Browse the repository at this point in the history
  • Loading branch information
DawnKiro committed Jan 5, 2025
1 parent 7c74d1c commit 1650803
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/dev/jaegerwald/voidlings/item/Renderers.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -22,6 +21,7 @@ public static void register() {
RENDERERS.put(ModItems.SURGEONS_BLADE, Map.of((stack, modelTransformationMode) -> {
return modelTransformationMode != ModelTransformationMode.GUI && modelTransformationMode != ModelTransformationMode.GROUND && modelTransformationMode != ModelTransformationMode.FIXED; // The condition to apply the model
}, forceLoad("surgeons_blade_in_hand")));

}

public static void apply(ItemStack stack, ModelTransformationMode mode, Consumer<ModelIdentifier> consumer) {
Expand All @@ -38,6 +38,6 @@ private static ModelIdentifier forceLoad(String path) {
}

private static ModelIdentifier modelID(String path) {
return new ModelIdentifier(new Identifier(Voidlings.MOD_ID, path), "inventory");
return new ModelIdentifier(Voidlings.MOD_ID, path, "inventory");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class ItemRendererMixin {
@Final
private ItemModels models;

@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V"))
@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V", ordinal = 0))
private void interruptModelRendering(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci, @Local(argsOnly = true) LocalRef<BakedModel> modelRef) {
//Renderers.apply(stack, renderMode, (modelIdentifier) -> modelRef.set(models.getModelManager().getModel(modelIdentifier)));
Renderers.apply(stack, renderMode, (modelIdentifier) -> modelRef.set(models.getModelManager().getModel(modelIdentifier)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@

@Mixin(ModelLoader.class)
public abstract class ModelLoaderMixin {
// @Shadow protected abstract void loadItemModel(ModelIdentifier id);
@Shadow
protected abstract void addModel(ModelIdentifier modelId);

// @Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/ModelLoader;loadItemModel(Lnet/minecraft/client/util/ModelIdentifier;)V", ordinal = 0))
// private void loadForcedModels() {Renderers.FORCELOAD.forEach(this::loadItemModel);}
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 3))
private void loadForcedModels(BlockColors blockColors, Profiler profiler, Map<Identifier, JsonUnbakedModel> jsonUnbakedModels, Map<Identifier, List<ModelLoader.SourceTrackedData>> blockStates, CallbackInfo ci) {
Renderers.FORCELOAD.forEach(this::addModel);
}
}

0 comments on commit 1650803

Please sign in to comment.