Jump to content

Entity (mob) disappear based on where I look


X_Khan_X

Recommended Posts

I have created a new EntityLiving that is basically an NPC and when I click on it, it talks. The texture works, the animations I don't know (It has no movement), the right click works and the egg spawn too the only problem is when I go far from the entity, it "disappears" or if I'm near it, it "disappears" and if I look the entity again it comes back.

 

My customEntity class

public class CustomEntity extends EntityLiving {

	private boolean persistenceRequired = true;

	public CustomEntity(World worldIn) {
		super(worldIn);
		setEntityInvulnerable(true);
		setHealth(100F);
	}

	public void writeEntityToNBT(NBTTagCompound compound) {
		super.writeEntityToNBT(compound);
		compound.setBoolean("PersistenceRequired", this.persistenceRequired);
	}

	public void readEntityFromNBT(NBTTagCompound compound) {
		super.readEntityFromNBT(compound);

		this.persistenceRequired = compound.getBoolean("PersistenceRequired");
	}

	@Override
	protected boolean processInteract(EntityPlayer player, EnumHand hand) {
		Random r = new Random();
		World worldIn = player.getEntityWorld();
		int phrases = r.nextInt(3);
		if (worldIn.isRemote) {
			switch (phrases) {
			case 0:
				Main.message("&dHello &c" + player.getName() + " how are you?", player);
				break;
			case 1:
				Main.message("&aHello &c" + player.getName() + " Can you help me?", player);
				break;
			case 2:
				Main.message("&bHello &c" + player.getName() + "&b! I forgot where is my house", player);
				break;
			}
		}
		return true;
	}

	@Override
	protected void despawnEntity() {
		if (this.persistenceRequired) {
			this.idleTime = 0;
		}
	}
}

 

My customentity render class

public class RenderCustomEntity extends RenderLiving<CustomEntity> {

	public static final ResourceLocation TEXTURE = new ResourceLocation(
			Reference.MODID + ":textures/entity/customentity.png");

	public RenderCustomEntity(RenderManager rendermanagerIn) {
		super(rendermanagerIn, new ModelCustomEntity(), 0.6F);
	}

	protected ResourceLocation getEntityTexture(CustomEntity entity) {
		return TEXTURE;
	}

	@Override
	protected void applyRotations(CustomEntity entityLiving, float p_77043_2_, float rotationYaw,
			float partialTicks) {
		super.applyRotations(entityLiving, p_77043_2_, rotationYaw, partialTicks);
	}
}

 

and my cutom entity model class (Made with tabula mod)

 

public class ModelMCDolaldCashier extends ModelBase {
    public ModelRenderer field_178736_x;
    public ModelRenderer field_178734_a;
    public ModelRenderer field_178731_d;
    public ModelRenderer field_178732_b;
    public ModelRenderer field_178720_f;
    public ModelRenderer field_178733_c;
    public ModelRenderer field_178723_h;
    public ModelRenderer field_178721_j;
    public ModelRenderer field_78116_c;
    public ModelRenderer field_78115_e;
    public ModelRenderer field_178724_i;
    public ModelRenderer field_178722_k;

    public ModelMCDolaldCashier() {
        this.textureWidth = 64;
        this.textureHeight = 32;
        this.field_178731_d = new ModelRenderer(this, 0, 16);
        this.field_178731_d.setRotationPoint(-1.9F, 12.0F, 0.0F);
        this.field_178731_d.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.25F);
        this.field_178723_h = new ModelRenderer(this, 40, 16);
        this.field_178723_h.setRotationPoint(-5.0F, 2.0F, 0.0F);
        this.field_178723_h.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F);
        this.field_178732_b = new ModelRenderer(this, 40, 32);
        this.field_178732_b.setRotationPoint(-5.0F, 2.0F, 0.0F);
        this.field_178732_b.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, 0.25F);
        this.field_178722_k = new ModelRenderer(this, 0, 16);
        this.field_178722_k.setRotationPoint(1.9F, 12.0F, 0.0F);
        this.field_178722_k.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F);
        this.field_178721_j = new ModelRenderer(this, 0, 16);
        this.field_178721_j.setRotationPoint(-1.899999976158142F, 12.0F, 0.0F);
        this.field_178721_j.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F);
        this.field_178720_f = new ModelRenderer(this, 32, 0);
        this.field_178720_f.setRotationPoint(0.0F, 0.0F, 0.0F);
        this.field_178720_f.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.5F);
        this.field_178736_x = new ModelRenderer(this, 24, 0);
        this.field_178736_x.setRotationPoint(0.0F, 0.0F, 0.0F);
        this.field_178736_x.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, 0.0F);
        this.field_78116_c = new ModelRenderer(this, 0, 0);
        this.field_78116_c.setRotationPoint(0.0F, 0.0F, 0.0F);
        this.field_78116_c.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F);
        this.field_178734_a = new ModelRenderer(this, 48, 48);
        this.field_178734_a.setRotationPoint(5.0F, 2.0F, 0.0F);
        this.field_178734_a.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, 0.25F);
        this.field_178724_i = new ModelRenderer(this, 32, 48);
        this.field_178724_i.setRotationPoint(5.0F, 2.0F, 0.0F);
        this.field_178724_i.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F);
        this.field_178733_c = new ModelRenderer(this, 0, 48);
        this.field_178733_c.setRotationPoint(1.899999976158142F, 12.0F, 0.0F);
        this.field_178733_c.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.25F);
        this.field_78115_e = new ModelRenderer(this, 16, 16);
        this.field_78115_e.setRotationPoint(0.0F, 0.0F, 0.0F);
        this.field_78115_e.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, 0.0F);
    }

    @Override
    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { 
        this.field_178731_d.render(f5);
        this.field_178723_h.render(f5);
        this.field_178732_b.render(f5);
        this.field_178722_k.render(f5);
        this.field_178721_j.render(f5);
        this.field_178720_f.render(f5);
        this.field_178736_x.render(f5);
        this.field_78116_c.render(f5);
        this.field_178734_a.render(f5);
        this.field_178724_i.render(f5);
        this.field_178733_c.render(f5);
        this.field_78115_e.render(f5);
    }

    /**
     * This is a helper function from Tabula to set the rotation of model parts
     */
    public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
        modelRenderer.rotateAngleX = x;
        modelRenderer.rotateAngleY = y;
        modelRenderer.rotateAngleZ = z;
    }
}

 

Link to comment
Share on other sites

Show your registration code, the distance at which a mob is shown is set there

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

12 minutes ago, Cadiboo said:

Show your registration code, the distance at which a mob is shown is set there

That's is all what I have except for this

public class RenderHandler {

	public static void registerEntityRenders() {
		

		RenderingRegistry.registerEntityRenderingHandler(CustomEntity.class, new IRenderFactory<CustomEntity>() {
			@Override
			public Render<? super CustomEntity> createRenderFor(RenderManager manager) {
				return new RenderCustomEntity(manager);
			}
		});
	}
}

 

Link to comment
Share on other sites

Your entity registration code. BTW all that code is unnecessary and can be replaced with RenderingRegistry.registerEntityRenderingHandler(EntityCustomEntity.class, EntityCustomEntityRenderer::new);

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

8 hours ago, Cadiboo said:

Your entity registration code. BTW all that code is unnecessary and can be replaced with RenderingRegistry.registerEntityRenderingHandler(EntityCustomEntity.class, EntityCustomEntityRenderer::new);

Okay changed but I still have the same problem

Link to comment
Share on other sites

Post

11 hours ago, Cadiboo said:

Your entity registration code.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.