Jump to content

[1.12.2] Get a consistent texture from array for mobs


DecentChicken

Recommended Posts

I'm trying to make new types of parrots for 1.12 to enjoy some diversity. I've tried looking at the original code for parrots, which gave me some sense of the direction to go into, but currently, it changes the textures pretty much every time I restart the game/world or chunks are reloaded.

 

Not sure how to fix it at this point. 

 

Here is the GitHub link: https://github.com/DecentChicken/ExtendedParrots

And here is the relevant code:

Entity:

 
 
 
 
Spoiler

package chicken.chicken.extendedparrots.entity;

import java.util.Random;

import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.passive.EntityParrot;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.World;

public class EntityLovebird extends EntityParrot 
{
	private static int VARIANTS_AMNT = 2;
	Random rand = new Random();
	public int rndTexture = rand.nextInt(VARIANTS_AMNT);

	public EntityLovebird(World worldIn) {
		super(worldIn);
	}
}

 

Renderer:

 
 
 
 
Spoiler

package chicken.chicken.extendedparrots.entity.render;

import chicken.chicken.extendedparrots.entity.EntityLovebird;
import chicken.chicken.extendedparrots.entity.model.ModelLovebird;
import chicken.chicken.extendedparrots.util.Reference;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;

public class RenderLovebird extends RenderLiving<EntityLovebird>
{
	public static final ResourceLocation[] TEXTURES = new ResourceLocation[] {new ResourceLocation(Reference.MOD_ID + ":textures/entity/lovebird_fischeri.png"), new ResourceLocation(Reference.MOD_ID + ":textures/entity/lovebird_personata_azul.png")};
	public RenderLovebird(RenderManager manager) {
		super(manager, new ModelLovebird(), 0.2f);
	}

	@Override
	protected ResourceLocation getEntityTexture(EntityLovebird entity) {
		return TEXTURES[entity.rndTexture];
	}

	@Override
	protected float handleRotationFloat(EntityLovebird livingBase, float partialTicks) {
		return getCustomBob(livingBase, partialTicks);
	}
	
	private float getCustomBob(EntityLovebird lovebird, float nr)
	{
		float f = lovebird.oFlap + (lovebird.flap - lovebird.oFlap) * nr;
        float f1 = lovebird.oFlapSpeed + (lovebird.flapSpeed - lovebird.oFlapSpeed) * nr;
        return (MathHelper.sin(f) + 1.0F) * f1;
	}
}

 

Screenshots attached for testing reference. It does happen in the RegentParakeet classes as well, but that code is identical, therefore not included.

 

1.jpg

2.jpg

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.



×
×
  • Create New...

Important Information

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