Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Greetings! I have my custom layer render class which changes something with player by using gui. However, if you use it on the server, then if one player changes what they have, then everyone will have it, although in theory everything should be individual for each. In addition, it only manifests itself in the person who has changed. I believe that it is necessary here with packets, but something is not clear what is sent to the server for me

  • Author

Im so sorry for that stupid question, Im new in forge modding, thank you for your understanding and restraint

  • Author

So there is my render layer
 

@Override
    public void render(MatrixStack mstack, IRenderTypeBuffer p_225628_2_, int p_225628_3_, T p_225628_4_, float p_225628_5_, float p_225628_6_, float p_225628_7_, float p_225628_8_, float p_225628_9_, float p_225628_10_) {

        CustItem item = InfCust.itemsHandler.getCurrentItem();

        ItemStack itemstack = p_225628_4_.getItemBySlot(EquipmentSlotType.HEAD);

        float f = MathHelper.lerp(p_225628_7_, p_225628_4_.yRotO, p_225628_4_.yRot) - MathHelper.lerp(p_225628_7_, p_225628_4_.yBodyRotO, p_225628_4_.yBodyRot);
        float f1 = MathHelper.lerp(p_225628_7_, p_225628_4_.xRotO, p_225628_4_.xRot);

        mstack.pushPose();

        mstack.mulPose(Vector3f.YP.rotationDegrees(f));
        mstack.mulPose(Vector3f.XP.rotationDegrees(f1));
        mstack.translate(0.0D, 0.5D, 0.0D);
        mstack.scale(1F, 1F, 1F);
        
        if(item != null) {
            IVertexBuilder ivertexbuilder = ItemRenderer.getArmorFoilBuffer(p_225628_2_, RenderType.armorCutoutNoCull(item.getModelTexture()), false, itemstack.hasFoil());
            item.getModel().renderToBuffer(mstack, ivertexbuilder, p_225628_3_, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
           
        }

        mstack.mulPose(Vector3f.XP.rotationDegrees(-f1));
        mstack.mulPose(Vector3f.YP.rotationDegrees(-f));

        mstack.popPose();


    }

And GUI

Item and CustItem its class which have information about my model (need for gui and etc). It has model, texture path and something like this. Every frame Im updating current model which will render on my player. If I want to change it I have to use gui and special button in it, which updating model that requested getCurrrentItem() method

  • 2 weeks later...
  • Author

Well I figured out the capability and now I have a cap that stores the id of some model that will be rendered. Have I edit the render method correctly now?

 

 		int itemId = InfCust.capabilityUtil.getCapabilityHatId();
        CustItem item = InfCust.itemsHandler.getItemByIndex(itemId);

        ItemStack itemstack = p_225628_4_.getItemBySlot(EquipmentSlotType.HEAD);

        float f = MathHelper.lerp(p_225628_7_, p_225628_4_.yRotO, p_225628_4_.yRot) - MathHelper.lerp(p_225628_7_, p_225628_4_.yBodyRotO, p_225628_4_.yBodyRot);
        float f1 = MathHelper.lerp(p_225628_7_, p_225628_4_.xRotO, p_225628_4_.xRot);

        mstack.pushPose();

        mstack.mulPose(Vector3f.YP.rotationDegrees(f));
        mstack.mulPose(Vector3f.XP.rotationDegrees(f1));
        mstack.translate(0.0D, 0.5D, 0.0D);
        mstack.scale(1F, 1F, 1F);
        //this.getParentModel().copyPropertiesTo(this.elytraModel);
        //this.elytraModel.setupAnim(p_225628_4_, p_225628_5_, p_225628_6_, p_225628_8_, p_225628_9_, p_225628_10_);
        if(item != null) {
            IVertexBuilder ivertexbuilder = ItemRenderer.getArmorFoilBuffer(p_225628_2_, RenderType.armorCutoutNoCull(item.getModelTexture()), false, itemstack.hasFoil());
            item.getModel().renderToBuffer(mstack, ivertexbuilder, p_225628_3_, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
            //hh.renderToBuffer(mstack, ivertexbuilder, p_225628_3_, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
        }

        mstack.mulPose(Vector3f.XP.rotationDegrees(-f1));
        mstack.mulPose(Vector3f.YP.rotationDegrees(-f));

        mstack.popPose();

getCapabilityHatId method

 

public int getCapabilityHatId()
    {
        int id = Minecraft.getInstance().player.getCapability(HatCapability.PLAYER_HAT_ID)
                .map(capa -> capa.getValue())
                .orElse(0);
        return id;
    }

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.