Jump to content

1.19.2 - creating a custom item renderer!


Recommended Posts

 

According to the website: https://forge.gemwire.uk/wiki/BlockEntityWithoutLevelRenderer. I should create a BEWLRInstance. However, I do exactly as described on the website except for the BakedModel#isCustomRenderer(I want to edit the model created by json, but without creating a model from ZERO like TridentModel). Could anyone help me with this?

Minecraft completely ignores edits made in the Item Custom Renderer. That is, it does not increase the item's scale by 3x for example. he doesn't do anything!

Item Registering:

Spoiler
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ModCraft.MOD_ID);

    public static RegistryObject<Item> CUSTOM_RENDER_ITEM;

    static {
        CUSTOM_RENDER_ITEM = ITEMS.register("custom_render_item", () -> new CustomRenderItem(Tiers.IRON,5,5F,new Item.Properties().tab(MOD_TAB_ICON)));
    }

    public static void register(IEventBus eventBus) {
        ITEMS.register(eventBus);
    }

 

Custom Item Class:

Spoiler
public class CustomRenderItem extends SwordItem {

    public CustomRenderItem(Tier tier, int i, float v, Properties properties) {
        super(tier, i, v, properties);
    }

    @Override
    public boolean canPerformAction(ItemStack stack, ToolAction toolAction) {
        return true;
    }

    @Override
    public void initializeClient(Consumer<IClientItemExtensions> consumer) {
        consumer.accept(new IClientItemExtensions() {
            @Override
            public BlockEntityWithoutLevelRenderer getCustomRenderer() {
                //return IClientItemExtensions.super.getCustomRenderer();
                return new CustomItemRenderer();
            }

            @Override
            public @Nullable Font getFont(ItemStack stack, FontContext context) {
                return IClientItemExtensions.super.getFont(stack, context);
            }

        });
    }

}

 

Custom item Renderer:

Spoiler
public class CustomItemRenderer extends BlockEntityWithoutLevelRenderer {

    public CustomItemRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher, EntityModelSet modelSet) {
        super(blockEntityRenderDispatcher, modelSet);
    }

    public CustomItemRenderer() {
        super(Minecraft.getInstance().getBlockEntityRenderDispatcher(), Minecraft.getInstance().getEntityModels());
        //super(null, null);
    }

    @Override
    public void renderByItem(ItemStack itemStack, ItemTransforms.TransformType type, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int i1) {
        if(itemStack.getItem() == ModItem.CUSTOM_RENDER_ITEM.get()) {
            poseStack.pushPose();

            poseStack.scale(3, 3, 3);

            poseStack.popPose();
        }
        super.renderByItem(itemStack, type, poseStack, multiBufferSource, i, i1);
    }

}

 

 

  • Sad 1
Link to comment
Share on other sites

  • 1 month later...

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.



×
×
  • Create New...

Important Information

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