Posted June 3, 20214 yr I have a class that is supposed to render a block on the players head. I have tried a ton of things starting with copy the way vanilla does it, but I cannot get it to completely rotate with the player's head. It appears on the player's head, and it rotates part of the way with the head, but not full 360. The class rendering it: package com.aylias.minecraft.mods.minewear.renderer; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.IEntityRenderer; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.entity.model.PlayerModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.vector.Vector3f; public class BlockHeadRenderer extends LayerRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> { final ItemStack renderItem; public BlockHeadRenderer(IEntityRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> entityRendererIn, Item renderItem) { super(entityRendererIn); this.renderItem = new ItemStack(renderItem); } @Override public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, AbstractClientPlayerEntity entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { matrixStackIn.push(); matrixStackIn.scale(.8f, .8f, .8f); matrixStackIn.translate(0.0D, 1.9D, 0.0D); //matrixStackIn.rotate(Vector3f.YP.rotationDegrees(180.0F)); matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-entitylivingbaseIn.rotationYaw + entitylivingbaseIn.getRotationYawHead())); matrixStackIn.scale(0.625F, -0.625F, -0.625F); this.getEntityModel().getModelHead().translateRotate(matrixStackIn); Minecraft.getInstance().getFirstPersonRenderer().renderItemSide(entitylivingbaseIn, renderItem, ItemCameraTransforms.TransformType.HEAD, false, matrixStackIn, bufferIn, packedLightIn); matrixStackIn.pop(); } } Edited June 4, 20214 yr by NullDev
June 4, 20214 yr Author So, I even tried extending the HeadLayer class, and just making it use the item input to the class, but it still isn't working... public class BlockHeadRenderer extends HeadLayer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> { final ItemStack itemstack; public BlockHeadRenderer(IEntityRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> entityRendererIn, Item item) { super(entityRendererIn); itemstack = new ItemStack(item); } @Override public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, AbstractClientPlayerEntity entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { if (!itemstack.isEmpty()) { Item item = itemstack.getItem(); matrixStackIn.push(); matrixStackIn.scale(1, 1, 1); boolean flag = false; if (entitylivingbaseIn.isChild()) { float f = 2.0F; float f1 = 1.4F; matrixStackIn.translate(0.0D, 0.03125D, 0.0D); matrixStackIn.scale(0.7F, 0.7F, 0.7F); matrixStackIn.translate(0.0D, 1.0D, 0.0D); } this.getEntityModel().getModelHead().translateRotate(matrixStackIn); if (item instanceof BlockItem && ((BlockItem)item).getBlock() instanceof AbstractSkullBlock) { float f3 = 1.1875F; matrixStackIn.scale(1.1875F, -1.1875F, -1.1875F); if (flag) { matrixStackIn.translate(0.0D, 0.0625D, 0.0D); } GameProfile gameprofile = null; if (itemstack.hasTag()) { CompoundNBT compoundnbt = itemstack.getTag(); if (compoundnbt.contains("SkullOwner", 10)) { gameprofile = NBTUtil.readGameProfile(compoundnbt.getCompound("SkullOwner")); } else if (compoundnbt.contains("SkullOwner", 8)) { String s = compoundnbt.getString("SkullOwner"); if (!StringUtils.isBlank(s)) { gameprofile = SkullTileEntity.updateGameProfile(new GameProfile((UUID)null, s)); compoundnbt.put("SkullOwner", NBTUtil.writeGameProfile(new CompoundNBT(), gameprofile)); } } } matrixStackIn.translate(-0.5D, 0.0D, -0.5D); SkullTileEntityRenderer.render((Direction)null, 180.0F, ((AbstractSkullBlock)((BlockItem)item).getBlock()).getSkullType(), gameprofile, limbSwing, matrixStackIn, bufferIn, packedLightIn); } else if (!(item instanceof ArmorItem) || ((ArmorItem)item).getEquipmentSlot() != EquipmentSlotType.HEAD) { float f2 = 0.625F; matrixStackIn.translate(0.0D, -0.25D, 0.0D); matrixStackIn.rotate(Vector3f.YP.rotationDegrees(180.0F)); matrixStackIn.scale(0.625F, -0.625F, -0.625F); if (flag) { matrixStackIn.translate(0.0D, 0.1875D, 0.0D); } Minecraft.getInstance().getFirstPersonRenderer().renderItemSide(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD, false, matrixStackIn, bufferIn, packedLightIn); } matrixStackIn.pop(); } }
November 1, 20214 yr Hi man, I'm having this issue, do you have the full code on github or somewhere I can see it?
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.