Jump to content

How can I make a geckolib entity with an item in his hand?


DoniBobes

Recommended Posts

So far I have made this as my code:

package net.asestefan.mutationcraft.entity.client;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.asestefan.mutationcraft.Mutationcraft;
import net.asestefan.mutationcraft.entity.custom.InvokerEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemInHandRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib3.geo.render.built.GeoBone;
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer;
import software.bernie.geckolib3.util.RenderUtils;

import javax.annotation.Nullable;

public class InvokerRenderer extends GeoEntityRenderer<InvokerEntity> {
InvokerEntity invoker;
public InvokerRenderer(EntityRendererProvider.Context context) {
super(context, new InvokerModel());
this.shadowRadius = 0.2f;
}
@Override
public void renderRecursively(GeoBone bone, PoseStack stack, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
if (bone.getName().equals("item")) {
stack.pushPose();
RenderUtils.translate(bone, stack);
stack.translate(0, -0.10, 0);
stack.scale(0.75f, 0.75f, 0.75f);
ItemStack itemstack = invoker.getMainHandItem();
if(!itemstack.isEmpty()){
Minecraft.getInstance().getItemRenderer().render(itemstack, ItemDisplayContext.THIRT_PERSON_RIGHT_HAND, packedLightIn, OverlayTexture.NO_OVERLAY, stack, bufferIn );
}
}
}






@Override
public ResourceLocation getTextureLocation(InvokerEntity instance) {
return new ResourceLocation(Mutationcraft.MOD_ID, "textures/entity/invoker.png");
}

@Override
public RenderType getRenderType(InvokerEntity animatable, float partialTicks, PoseStack stack,
@Nullable MultiBufferSource renderTypeBuffer,
@Nullable VertexConsumer vertexBuilder, int packedLightIn,
ResourceLocation textureLocation) {
return super.getRenderType(animatable, partialTicks, stack, renderTypeBuffer, vertexBuilder, packedLightIn, textureLocation);
}
}

But the highlighted text keeps giving me errors regardless of what I do, especially the "ItemDisplayContext.THIRD_PERSON_RIGHT_HAND" part. Please help :(

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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