Posted May 3, 20223 yr Hello I have a mod which wearing some model to player. I have capability and renderer for it, but idk how to connect it to each other. Each player must have his own model (which he chooses in the GUI, but it doesn't matter). I have created with the id of the model that will be rendered on the player, however I don't quite understand how to set up the RenderLayer for each player individually Renderer 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_) { int itemId = InfCust.capabilityUtil.getCapabilityHatId(); CustItem item = null; if (itemId != -1) { 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); 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(); } Capability util (handling to capability faster) public void updateCapabilityHatId(int id) { ClientPlayerEntity player = Minecraft.getInstance().player; player.getCapability(HatCapability.PLAYER_HAT_ID).ifPresent((Data) -> Data.setValue(id)); } public int getCapabilityHatId() { ClientPlayerEntity player = Minecraft.getInstance().player; int id = player.getCapability(HatCapability.PLAYER_HAT_ID) .map(capa -> capa.getValue()) .orElse(0); return id; } Sorry for shit code I know that I have to use packet system, but Im actually dont know what my renderer have to do
May 3, 20223 yr you can handle this via a Capability which is synced between server and all clients, for example, the Player "x" select Model "y" in your Gui, then send a Packet to the server which sets the Model of Player "x" on server to "y", after that sync the Capability update to all clients means all clients know now that Player "x" use Model "y" last but not least render the Player "x" with the selected Model "y" Edited May 3, 20223 yr by Luis_ST
May 3, 20223 yr Author Thanks, Luis! Im already unerstand this, but I just don't know how to tell my renderer that for individual players it is necessary to set the model of the corresponding capability. But diesieben07 says that renderer is one global for all
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.