Jump to content

[1.16.1] Setting Projectile Model/Renderer


DavidQF555

Recommended Posts

public class ProjRenderer extends EntityRenderer<ProjEntity> implements IEntityRenderer<ProjEntity, ProjModel<ProjEntity>> {

    protected static final ResourceLocation TEXTURE = new ResourceLocation(Test.MOD_ID, "textures/entity/proj_entity.png");
    public static final ProjModel<ProjEntity> MODEL = new ProjModel<>();

    public ProjRenderer(EntityRendererManager renderManagerIn) {
        super(renderManagerIn);
    }

    @Nonnull
    @Override
    public ProjModel<ProjEntity> getEntityModel() {
        return MODEL;
    }

    @Nonnull
    @Override
    public ResourceLocation getEntityTexture(@Nonnull ProjEntity entity) {
        return TEXTURE;
    }

}

public class ProjModel<T extends ProjEntity> extends EntityModel<T> {

    private final ModelRenderer proj;

    public ShinsuModel() {
        textureWidth = 64;
        textureHeight = 64;
        proj = new ModelRenderer(this);
        proj.setRotationPoint(0.0F, 16.0F, 0.0F);
        proj.setTextureOffset(0, 0).addBox(-8.0F, -8.0F, -8.0F, 16.0F, 16.0F, 16.0F, 0.0F, false);
    }

    @Override
    public void setRotationAngles(@Nonnull T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
        proj.rotateAngleX = headPitch * ((float) Math.PI / 180f);
        proj.rotateAngleY = netHeadYaw * ((float) Math.PI / 180f);
    }

    @Override
    public void render(@Nonnull MatrixStack matrixStackIn, @Nonnull IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
        proj.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
    }
}

@SubscribeEvent
	public static void onClientSetup(FMLClientSetupEvent event) {
		RenderingRegistry.registerEntityRenderingHandler(RegistryHandler.PROJ_ENTITY.get(), ProjRenderer::new);
	}

ProjEntity is an instance of DamagingProjectileEntity. For some reason it just appears as an invisible hitbox that is on fire. I'm sure the texture is 64x64 and is at the correct location. What is wrong?

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.