Zeher_Monkey Posted March 22, 2021 Posted March 22, 2021 (edited) Hi all, I am attempting to add my own custom Trident into my Mod. I have 90% of things working currently, however the GUI, ItemEntity and ItemFrame (I assume from FIXED) rendering is very strange. Below are picures of the Issue, and any related code. Spoiler The item is supposed to look like this: dimensional_trident.json: Spoiler { "parent": "item/generated", "textures": { "layer0": "dimensionalpocketsii:items/tool/trident" }, "overrides": [ { "predicate": { "throwing": 0 }, "model": "dimensionalpocketsii:item/dimensional_trident__" }, { "predicate": { "throwing": 1 }, "model": "dimensionalpocketsii:item/dimensional_trident_throwing" } ] } dimensional_trident__.json: Spoiler { "parent": "builtin/entity", "gui_light": "front", "textures": { "particle": "dimensionalpocketsii:items/tool/trident" }, "display": { "thirdperson_righthand": { "rotation": [ 0, 60, 0 ], "translation": [ 11, 17, -2 ], "scale": [ 1, 1, 1 ] }, "thirdperson_lefthand": { "rotation": [ 0, 60, 0 ], "translation": [ 3, 17, 12 ], "scale": [ 1, 1, 1 ] }, "firstperson_righthand": { "rotation": [ 0, -90, 25 ], "translation": [ -3, 17, 1], "scale": [ 1, 1, 1 ] }, "firstperson_lefthand": { "rotation": [ 0, 90, -25 ], "translation": [ 13, 17, 1], "scale": [ 1, 1, 1 ] }, "gui": { "rotation": [ 15, -25, -5 ], "translation": [ 2, 3, 0 ], "scale": [ 0.65, 0.65, 0.65 ] }, "fixed": { "rotation": [ 0, 180, 0 ], "translation": [ -2, 4, -5], "scale":[ 0.5, 0.5, 0.5] }, "ground": { "rotation": [ 0, 0, 0 ], "translation": [ 4, 4, 2], "scale":[ 0.25, 0.25, 0.25] } }, "overrides": [ { "predicate": { "throwing": 1 }, "model": "dimensionalpocketsii:item/dimensional_trident_throwing" } ] } dimensional_trident_throwing.json: Spoiler { "parent": "builtin/entity", "gui_light": "front", "textures": { "particle": "dimensionalpocketsii:items/tool/trident" }, "display": { "thirdperson_righthand": { "rotation": [ 0, 90, 180 ], "translation": [ 8, -17, 9 ], "scale": [ 1, 1, 1 ] }, "thirdperson_lefthand": { "rotation": [ 0, 90, 180 ], "translation": [ 8, -17, -7 ], "scale": [ 1, 1, 1 ] }, "firstperson_righthand": { "rotation": [ 0, -90, 25 ], "translation": [ -3, 17, 1], "scale": [ 1, 1, 1 ] }, "firstperson_lefthand": { "rotation": [ 0, 90, -25 ], "translation": [ 13, 17, 1], "scale": [ 1, 1, 1 ] }, "gui": { "rotation": [ 15, -25, -5 ], "translation": [ 2, 3, 0 ], "scale": [ 0.65, 0.65, 0.65 ] }, "fixed": { "rotation": [ 0, 180, 0 ], "translation": [ -2, 4, -5], "scale":[ 0.5, 0.5, 0.5] }, "ground": { "rotation": [ 0, 0, 0 ], "translation": [ 4, 4, 2], "scale":[ 0.25, 0.25, 0.25] } } } ItemStackTileEntityRenderer.class: Spoiler package com.tcn.dimensionalpocketsii.client.renderer; import org.lwjgl.opengl.GL11; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.tcn.dimensionalpocketsii.core.management.CoreModBusManager; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.entity.model.TridentModel; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class TridentItemStackRenderer extends ItemStackTileEntityRenderer { private final DimensionalTridentModel tridentModel = new DimensionalTridentModel(); @Override public void renderByItem(ItemStack stackIn, ItemCameraTransforms.TransformType transformIn, MatrixStack matrixStack, IRenderTypeBuffer typeBuffer, int p_239207_5_, int p_239207_6_) { Item item = stackIn.getItem(); ItemRenderer renderer = Minecraft.getInstance().getItemRenderer(); IBakedModel model = null; if (item == CoreModBusManager.DIMENSIONAL_TRIDENT) { boolean flag = transformIn == ItemCameraTransforms.TransformType.GUI || transformIn == ItemCameraTransforms.TransformType.GROUND || transformIn == ItemCameraTransforms.TransformType.FIXED; if (flag) { model = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation("dimensionalpocketsii:dimensional_trident#inventory")).getBakedModel(); float scale = 1.5F; matrixStack.pushPose(); GL11.glPushMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); //matrixStack.scale(scale, scale, scale); renderer.render(stackIn, transformIn, true, matrixStack, typeBuffer, 0, 0, model); GL11.glPopMatrix(); matrixStack.popPose(); } else { matrixStack.pushPose(); matrixStack.scale(1.0F, -1.0F, -1.0F); IVertexBuilder ivertexbuilder1 = ItemRenderer.getFoilBufferDirect(typeBuffer, this.tridentModel.renderType(TridentModel.TEXTURE), false, stackIn.hasFoil()); this.tridentModel.renderToBuffer(matrixStack, ivertexbuilder1, p_239207_5_, p_239207_6_, 1.0F, 1.0F, 1.0F, 1.0F); matrixStack.popPose(); } } } } Im not sure what the issue is. Ive looked through vanilla code to see if i could locate the source of the issue, no dice. I have also read a few forum posts on the Modder Support Forum, and others have had other issues but none like this. Any help is appreciated! Edited March 24, 2021 by Zeher_Monkey Issue was Solved. Quote
Zeher_Monkey Posted March 22, 2021 Author Posted March 22, 2021 So quick update, The weird scale was caused by the GUI, GROUND, FIXED Inside the dimensional_trident__.json and the dimensional_trident_throwing.json So thats fixed. However the colour is still not correct. Quote
Zeher_Monkey Posted March 24, 2021 Author Posted March 24, 2021 On 3/22/2021 at 8:28 PM, Zeher_Monkey said: So quick update, The weird scale was caused by the GUI, GROUND, FIXED Inside the dimensional_trident__.json and the dimensional_trident_throwing.json So thats fixed. However the colour is still not correct. Okay so I fixed this issue, turns out I wasn't passing in the values int p_239207_5_, int p_239207_6_ Into the renderer.render(stackIn, transformIn, true, matrixStack, typeBuffer, 0 (Should have been p_239207_5_), 0 (Should have been p_239207_6_), model); Function. The item now correctly renders with the correct colour and scale. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.