Posted April 23, 20223 yr 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
April 23, 20223 yr Author Im so sorry for that stupid question, Im new in forge modding, thank you for your understanding and restraint
April 23, 20223 yr 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
May 3, 20223 yr 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.