Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Skyriis

Members
  • Posts

    95
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    Germany

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Skyriis's Achievements

Stone Miner

Stone Miner (3/8)

2

Reputation

  1. I tried -45, -180, 180, 90. Could it be possible that the arm isn't moving but the item in the hand still translates to the point where the player hand would be?
  2. by multiplying the poseStack with Vector3f.ZP.rotationDegrees(-itemTransform.rotation.z())
  3. Changing (translating) the position to where i want isn't the problem. That works like it should but the rotation of the item in the hand isn't. Like i've mentioned here. I still haven't figured out how to avoid the item to rotate on the z-axe. The weird thing is that i can rotate it on X and Y but not on Z
  4. I'm still looking for the method which rotates the item. #Edit 1 The only rotation i've found is in ItemInHandLayer#renderArmWithItem (L45-46). #Edit 2 Overriding the translateToHand method doesn't work. Rotating the matix stack to -armModelPart.zRot doesn't work too.
  5. i'm currently struggling on the rotation for the held item layer. This is how it should look like: This is how it looks after the invisible arm has moved: This is the layer: public class CustomItemInHandLayer<T extends Player, M extends PlayerModel<T>> extends ItemInHandLayer<T, M> { @SuppressWarnings("unchecked") public CustomItemInHandLayer(PlayerRenderer renderer) { super((RenderLayerParent<T, M>) renderer); } @ParametersAreNonnullByDefault @Override public void render(PoseStack stack, MultiBufferSource bufferSource, int light, T player, float p_117208_, float p_117209_, float p_117210_, float p_117211_, float p_117212_, float p_117213_) { if (MinecraftForge.EVENT_BUS.post(new RenderItemInHandEvent.Pre(stack, bufferSource, player, (PlayerRenderer) this.renderer))) return; super.render(stack, bufferSource, light, player, p_117208_, p_117209_, p_117210_, p_117211_, p_117212_, p_117213_); } @ParametersAreNonnullByDefault @Override protected void renderArmWithItem(LivingEntity player, ItemStack itemStack, ItemTransforms.TransformType transformType, HumanoidArm arm, PoseStack stack, MultiBufferSource bufferSource, int light) { if (itemStack.is(Items.SPYGLASS) && player.getUseItem() == itemStack && player.swingTime == 0) { this.renderArmWithSpyglass(player, itemStack, arm, stack, bufferSource, light); } else { if (!itemStack.isEmpty()) { stack.pushPose(); MinecraftForge.EVENT_BUS.post(new RenderItemInHandEvent.ApplyModifier(stack, bufferSource, (Player) player, itemStack, arm, (PlayerRenderer) this.renderer)); this.getParentModel().translateToHand(arm, stack); stack.mulPose(Vector3f.XP.rotationDegrees(-90.0F)); stack.mulPose(Vector3f.YP.rotationDegrees(180.0F)); boolean flag = arm == HumanoidArm.LEFT; stack.translate((flag ? -1d : 1d) / 16.0d, 0.125D, -0.625D); Minecraft.getInstance().getItemInHandRenderer().renderItem(player, itemStack, transformType, flag, stack, bufferSource, light); MinecraftForge.EVENT_BUS.post(new RenderItemInHandEvent.ResetModifier(stack, bufferSource, (Player) player, itemStack, arm, (PlayerRenderer) this.renderer)); stack.popPose(); } } } private void renderArmWithSpyglass(LivingEntity player, ItemStack itemStack, HumanoidArm arm, PoseStack stack, MultiBufferSource bufferSource, int light) { stack.pushPose(); MinecraftForge.EVENT_BUS.post(new RenderItemInHandEvent.ApplyModifier(stack, bufferSource, (Player) player, itemStack, arm, (PlayerRenderer) this.renderer)); ModelPart modelpart = this.getParentModel().getHead(); float f = modelpart.xRot; modelpart.xRot = Mth.clamp(modelpart.xRot, (-(float) Math.PI / 6F), ((float) Math.PI / 2F)); modelpart.translateAndRotate(stack); modelpart.xRot = f; CustomHeadLayer.translateToHead(stack, false); boolean flag = arm == HumanoidArm.LEFT; stack.translate((flag ? -2.5F : 2.5F) / 16.0F, -0.0625D, 0.0D); Minecraft.getInstance().getItemInHandRenderer().renderItem(player, itemStack, ItemTransforms.TransformType.HEAD, false, stack, bufferSource, light); MinecraftForge.EVENT_BUS.post(new RenderItemInHandEvent.ResetModifier(stack, bufferSource, (Player) player, itemStack, arm, (PlayerRenderer) this.renderer)); stack.popPose(); } } i've tried a few things but haven't found a way to prevent the item to move (even if the arm doesn't move the item does).
  6. Here is just the current state of my code. RenderEvent: public static void onPreRenderPlayer(final RenderPlayerEvent.Pre e) { if (!(e.getPlayer() instanceof AbstractClientPlayer)) return; final AbstractClientPlayer player = (AbstractClientPlayer) e.getPlayer(); player.getCapability(Capabilities.BEING).ifPresent(beingCapability -> { final LivingBeing being = beingCapability.getLivingBeing(); being.getModelTexture().ifPresent(textureLocation -> { //Replace Texture with Slime Texture try { player.getPlayerInfo().textureLocations.remove(MinecraftProfileTexture.Type.SKIN); player.getPlayerInfo().textureLocations.put(MinecraftProfileTexture.Type.SKIN, textureLocation); } catch (NullPointerException npe) { //TODO real exception handling OtherLivingBeings.getLogger().fatal("Could not get Player Information."); npe.printStackTrace(); } }); //Replace Model being.getModel(e.getRenderer()).ifPresent(model -> e.getRenderer().model = model); }); } getModel Method: @OnlyIn(Dist.CLIENT) @Override public Optional<PlayerModel<AbstractClientPlayer>> getModel(final PlayerRenderer renderer) { final PlayerModelReplacement replacement = new PlayerModelReplacement( SmallSlimeModel.createHead().bakeRoot(), SmallSlimeModel.createHat().bakeRoot(), SmallSlimeModel.createBody().bakeRoot(), emptyPart, emptyPart, emptyPart, emptyPart, emptyPart, emptyPart, emptyPart, emptyPart, emptyPart, emptyPart, emptyPart); final SmallSlimeModel model = new SmallSlimeModel(replacement.toModelPart()); //Remove Player Model Layers renderer.layers.clear(); //Add Armor Layer renderer.addLayer(new SmallSlimeArmorLayer<>(renderer)); return Optional.of(model); } Test Model (SmallSlimeModel): @OnlyIn(Dist.CLIENT) public class SmallSlimeModel extends PlayerModel<AbstractClientPlayer> { private final ModelPart root; public SmallSlimeModel(ModelPart parent) { super(parent, false); this.root = parent; } public static LayerDefinition createHat() { MeshDefinition meshdefinition = new MeshDefinition(); PartDefinition partdefinition = meshdefinition.getRoot(); partdefinition.addOrReplaceChild("hat", CubeListBuilder.create() .texOffs(32, 0) .addBox(-4.0F, 17.0F, -4.0F, 8.0F, 8.0F, 8.0F, CubeDeformation.NONE), PartPose.ZERO); return LayerDefinition.create(meshdefinition, 64, 32); } public static LayerDefinition createHead() { MeshDefinition meshdefinition = new MeshDefinition(); PartDefinition partdefinition = meshdefinition.getRoot(); partdefinition.addOrReplaceChild("cube", CubeListBuilder.create() .texOffs(0, 16) .addBox(-3.0F, 17.0F, -3.0F, 6.0F, 6.0F, 6.0F), PartPose.ZERO); partdefinition.addOrReplaceChild("right_eye", CubeListBuilder.create().texOffs(32, 0).addBox(-3.25F, 18.0F, -3.5F, 2.0F, 2.0F, 2.0F), PartPose.ZERO); partdefinition.addOrReplaceChild("left_eye", CubeListBuilder.create().texOffs(32, 4).addBox(1.25F, 18.0F, -3.5F, 2.0F, 2.0F, 2.0F), PartPose.ZERO); partdefinition.addOrReplaceChild("mouth", CubeListBuilder.create().texOffs(32, 8).addBox(0.0F, 21.0F, -3.5F, 1.0F, 1.0F, 1.0F), PartPose.ZERO); return LayerDefinition.create(meshdefinition, 64, 32); } public static LayerDefinition createBody() { MeshDefinition meshdefinition = new MeshDefinition(); PartDefinition partdefinition = meshdefinition.getRoot(); partdefinition.addOrReplaceChild("cube", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, 16.0F, -4.0F, 8.0F, 8.0F, 8.0F), PartPose.ZERO); return LayerDefinition.create(meshdefinition, 64, 32); } public ModelPart root() { return this.root; } } Custom armor layer: public class SmallSlimeArmorLayer<T extends LivingEntity, M extends HumanoidModel<T>, A extends HumanoidModel<T>> extends HumanoidArmorLayer<T, M, A> { public SmallSlimeArmorLayer(RenderLayerParent<T, M> parent) { super(parent, (A) new HumanoidModel(PlayerRendererUtils.getEntityRendererContext(parent).bakeLayer(ModelLayers.PLAYER_INNER_ARMOR)), (A) new HumanoidModel(PlayerRendererUtils.getEntityRendererContext(parent).bakeLayer(ModelLayers.PLAYER_OUTER_ARMOR))); } @Override public void render(PoseStack stack, MultiBufferSource bufferSource, int p_117098_, T player, float p_117100_, float p_117101_, float p_117102_, float p_117103_, float p_117104_, float p_117105_) { super.render(stack, bufferSource, p_117098_, player, p_117100_, p_117101_, p_117102_, p_117103_, p_117104_, p_117105_); } }
  7. Okay so basiclly i need to remove all existing layers, extend from HumanoidArmorLayer and override the render method to change the position and then add the layer to the renderer?
  8. okay... i've managed to create a model which rotates with the player rotation and looks like whatever i want. The only problem is that holding items (or weared items) are on the wrong spot. How can i change the position?
  9. i kinda managed to render a Mob instead of the player using @OnlyIn(Dist.CLIENT) @Override public void renderPlayer(final Player player, final PoseStack poseStack, final MultiBufferSource buffer, final int light, final float partialTicks) { final Slime entity = EntityType.SLIME.create(player.level); entity.setSize(0, false); entity.setPos(player.getX(), player.getY(), player.getZ()); entity.setXRot(player.getXRot()); entity.setYRot(player.getYRot()); entity.setYHeadRot(player.getYHeadRot()); entity.setOldPosAndRot(); Minecraft.getInstance().getEntityRenderDispatcher().getRenderer(entity).render(entity, 0F, partialTicks, poseStack, buffer, light); } but the rotations won't be applied. Any ideas how to fix that?
  10. That doesn't seems to work since the RenderPlayerEvent.Pre renderer is a PlayerRenderer and not a LivingEntityRenderer. Which means that the model needs to be a PlayerModel (or extend it) and can't be a normal EntityModel.
  11. As Luis_ST mentioned you could use an accesstransformer to make those fields public and non-final by adding a -f after the public modifier. Edit: Just in case you don't know how to get the SRG names for your at. Join the Forge Discord Server and message the forge-bot with !mcp <field name|method name> (for MCP Mappings) or !moj <field name|method name> (for Official Mappings).
  12. This isn't the gradle subforum ether. Is it? Why would you need to create so much models?
  13. This seems to be an issue of the immersiverailroading. Try reporting it to the mod author
  14. Hello Guys, i'm working on a Mod which allows you to play Minecraft as one of the existing Mobs. i'm currently struggling on the player rendering since the player model should be replaced with the Mob Model. I guess i need to cancel the RenderPlayerEvent, get my capability and then render the mob which i can identify by the value in my capability. Canceling the Event and getting the Capability isn't a thing but how do i render render the Mob? i would be really grateful for help. Thanks in advance!
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.