Hello,
I would like to add a mechanic in my mod where I can render the same entity with different textures based on RNG (Random Number Generation). The concept is similar to Villagers in minecraft and their professions. Here is my code currently (not knowing that the constructor for RenderWanderingPlayer is only called once, not everytime the entity spawned)
package xyz.gatya.itmulti.render;
import java.util.Random;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelPlayer;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.util.ResourceLocation;
import xyz.gatya.itmulti.entity.EntityInformation;
import xyz.gatya.itmulti.entity.EntityWanderingPlayer;
import xyz.gatya.itmulti.util.ModInformation;
public class RenderWanderingPlayer extends RenderLiving<EntityWanderingPlayer> {
private static final ResourceLocation TEXTURES = new ResourceLocation(
ModInformation.MOD_ID +
":textures/entity/" +
EntityInformation.WANDERING_NPC_SKINS[(int) (Math.random() * EntityInformation.WANDERING_NPC_SKINS.length + 1)] + ".png"
);
public RenderWanderingPlayer(RenderManager rendermanagerIn) {
super(rendermanagerIn, new ModelPlayer(0.0F, false), 0.3F);
}
@Override
protected ResourceLocation getEntityTexture(EntityWanderingPlayer entity) {
return TEXTURES;
}
}
Code :
EntityInformation -> Contains some information of the entity i.e id, available skins for the entity and etc.
WANDERING_NPC_SKINS -> Array of strings of possible skins
How do I get it to work? The code is just for demonstration