Jump to content

[Solved] [1.16.5] Custom Trident, issues with in GUI, GROUND and FIXED ItemCameraTransform rendering


Zeher_Monkey

Recommended Posts

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

2021-03-22_20_11.42_.png.c19c07d21cd4dbc55a435a7410a1098e.png

2021-03-22_20_12.16_.png.868d5a11c9156d4a28d3f5ba4885e56a.png

The item is supposed to look like this:

trident.png.a9d0bb6d5da7ecfc0d2b01a89e65faad.png

 

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 by Zeher_Monkey
Issue was Solved.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Zeher_Monkey changed the title to [Solved] [1.16.5] Custom Trident, issues with in GUI, GROUND and FIXED ItemCameraTransform rendering

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
    • Update your drivers: https://www.amd.com/en/support/graphics/amd-radeon-r9-series/amd-radeon-r9-200-series/amd-radeon-r9-280x
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.