Topic category: Advanced modding
Hi there, long story short the mod Mocreatures went open source in 1.12.2 so I'm using MCreator to "update it" (remaking from scratch, minus models/textures). My knowledge of coding is minimal, and I think what I'm trying to do requires some custom coding/procedures in my mobs.
Multiple mobs in Mocreatures have multiple textures, of which one is randomly chosen upon initial spawn. As MCreator by default only lets me assign one texture to each mob, I need help knowing how to make it choose one out of x given textures. I know this is probably going to require:
-if/else if/else statement
-switch/case situation
-maybe both
I was looking in the 1.12 code to see if I could use that format, but I'm either doing it wrong or missing some information in there. Here is a snippet example of how 1.12.2 Mocreatures handled wolf textures
@Override
public void selectType()
{
if (getType() == 0)
{
int i = rand.nextInt(100);
if (i <= 25)
{
setType(1);
}
else if (i <= 50)
{
setType(2);
}
else if (i <= 75)
{
setType(5);
}
else
{
setType(4);
}
//health = getMaxHealth();
}
/*if (type == 1)
{
texture = MoCreatures.proxy.MODEL_TEXTURE + "wolfblack.png";
}
if (type == 2)
{
texture = MoCreatures.proxy.MODEL_TEXTURE + "wolfwild.png";
}
if (type == 3)
{
texture = MoCreatures.proxy.MODEL_TEXTURE + "wolftimber.png"; //snow wolf
}
if (type == 4)
{
texture = MoCreatures.proxy.MODEL_TEXTURE + "wolfdark.png";
}
if (type == 5)
{
texture = MoCreatures.proxy.MODEL_TEXTURE + "wolfbright.png";
} */
}
@Override
public String getTexture()
{
switch (getType())
{
case 1:
return MoCreatures.proxy.MODEL_TEXTURE + "wolfblack.png";
case 2:
return MoCreatures.proxy.MODEL_TEXTURE + "wolfwild.png";
case 3:
return MoCreatures.proxy.MODEL_TEXTURE + "wolftimber.png"; //snow wolf
case 4:
return MoCreatures.proxy.MODEL_TEXTURE + "wolfdark.png";
case 5:
return MoCreatures.proxy.MODEL_TEXTURE + "wolfbright.png";
default:
return MoCreatures.proxy.MODEL_TEXTURE + "wolfwild.png";
}
}
I'm currently working on butterflies (there are 7 textures).
What combination of switch/case and if/else would I need to use, and where would it be? Does it go in the code of the entity itself, where it usually pulls the one texture from? Or do I add it as a custom code snippet in the "initial entity spawn" trigger procedure? Or does some of it go in one spot and the rest in another? Thank you for the help, and let me know if you need more information from me.
i was really hoping someone gave you an answer to these questions
Yeah, I've been waiting too. Any updates on if you could figure it out or does anyone else have a solution?
Maybe you can make it an animated texture and make it change to an animation frame on spawn