Custom Mob Models

Issue description

I've searched through previous issues on this and only one post matches my issue it seems, though it hasn't been active for a few months. I'll link the post here.

https://mcreator.net/tracker/issue/53704

So I already have one custom mob in my current project. It works without a problem, however I try to import another separate model and it won't let me import it because it tries to give it the same name it gave the first model (Modelcustom_model.java) and gives me this error message: 

https://drive.google.com/file/d/1fTZqtjRx5hNPYbZMBW4vpuDc0vS0nHqn/view?…

I then had the idea of copying the .java file of my second model into the "models" folder in finder, but whenever I try to save the mob element using that model I get the issue that was given before, where the save mod element button would turn grey but never resolve anything:

https://drive.google.com/file/d/1arkh-paaUswgbiLOq1w2hzRPV6sRqCJF/view?…

Attached to this issue are the files of my models, the grub is the most recent one that caused this issue. If anything else is needed please let me know. Help would be appreciated.

Issue comments

In the video you just copy the file, but the files attached have different names in the code, is this intentional or am I missing something?

I would try renaming Modelcustom_model to something more different such as Modelcustom_model2, MCreator might see

something and Modelsomething as the same models as MCreator adds Model to the name if missing automatically for the code readability.

I thought renaming the Modelcustom_model file would fix the issue as well. However, any time I rename the file, it no longer works. It seems like the only way a mob can function properly in my mod is if its model's name is "Modelcustom_model," as any time I would rename it, it'd pop up this error message immediately after I update the file:

https://drive.google.com/file/d/1R4AD9pYHZd3sp46ZUoTBVdx_lDfdXMRH/view?…

This is what the console says when I clicked on show console tab:

https://drive.google.com/file/d/1BeWiBFaDkIqCLorHSugKwWghMSKVXbAG/view?…

Then this is the code the red text in the console took me to (which was the rat model, aka the first "Modelodelcustom_model").

package net.mcreator.better_drops;

import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.fml.network.FMLPlayMessages;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.Dist;

import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.World;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.DamageSource;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.entity.projectile.PotionEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
import net.minecraft.entity.ai.goal.TemptGoal;
import net.minecraft.entity.ai.goal.SwimGoal;
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
import net.minecraft.entity.ai.goal.PanicGoal;
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
import net.minecraft.entity.ai.goal.MoveTowardsVillageGoal;
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
import net.minecraft.entity.ai.goal.LookAtGoal;
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EntitySpawnPlacementRegistry;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.Entity;
import net.minecraft.entity.CreatureEntity;
import net.minecraft.entity.CreatureAttribute;
import net.minecraft.data.Main;
import net.minecraft.client.renderer.model.ModelBox;
import net.minecraft.client.renderer.entity.model.RendererModel;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.MobRenderer;

@Elementsbetter_drops.ModElement.Tag
public class MCreatorRat extends Elementsbetter_drops.ModElement {
	public static EntityType entity = null;

	public MCreatorRat(Elementsbetter_drops instance) {
		super(instance, 256);
		FMLJavaModLoadingContext.get().getModEventBus().register(this);
	}

	@Override
	public void initElements() {
		entity = (EntityType.Builder.<CustomEntity> create(CustomEntity::new, EntityClassification.CREATURE).setShouldReceiveVelocityUpdates(true)
				.setTrackingRange(64).setUpdateInterval(1).setCustomClientFactory(CustomEntity::new).size(0.6f, 1f)).build("rat").setRegistryName(
				"rat");
		elements.entities.add(() -> entity);
		elements.items.add(() -> new SpawnEggItem(entity, -10066330, -39169, new Item.Properties().group(MCreatorBetterDrops.tab))
				.setRegistryName("rat"));
	}

	@Override
	public void init(FMLCommonSetupEvent event) {
		for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
			boolean biomeCriteria = false;
			if (ForgeRegistries.BIOMES.getKey(biome).equals(new ResourceLocation("desert")))
				biomeCriteria = true;
			if (ForgeRegistries.BIOMES.getKey(biome).equals(new ResourceLocation("swamp")))
				biomeCriteria = true;
			if (ForgeRegistries.BIOMES.getKey(biome).equals(new ResourceLocation("plains")))
				biomeCriteria = true;
			if (ForgeRegistries.BIOMES.getKey(biome).equals(new ResourceLocation("jungle_edge")))
				biomeCriteria = true;
			if (!biomeCriteria)
				continue;
			biome.getSpawns(EntityClassification.CREATURE).add(new Biome.SpawnListEntry(entity, 3, 3, 5));
		}
		EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
				AnimalEntity::func_223315_a);
	}

	@SubscribeEvent
	@OnlyIn(Dist.CLIENT)
	public void registerModels(ModelRegistryEvent event) {
		RenderingRegistry.registerEntityRenderingHandler(CustomEntity.class, renderManager -> {
			return new MobRenderer(renderManager, new h(), 0.35f) {
				protected ResourceLocation getEntityTexture(Entity entity) {
					return new ResourceLocation("better_drops:textures/rat_texture.png");
				}
			};
		});
	}

	public static class CustomEntity extends CreatureEntity {
		public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
			this(entity, world);
		}

		public CustomEntity(EntityType<CustomEntity> type, World world) {
			super(type, world);
			experienceValue = 5;
			setNoAI(false);
			enablePersistence();
		}

		@Override
		protected void registerGoals() {
			this.goalSelector.addGoal(1, new PanicGoal(this, 1.2));
			this.goalSelector.addGoal(2, new TemptGoal(this, 1, Ingredient.fromItems(new ItemStack(Items.ROTTEN_FLESH, (int) (1)).getItem()), false));
			this.goalSelector.addGoal(3, new RandomWalkingGoal(this, 0.5));
			this.goalSelector.addGoal(4, new WaterAvoidingRandomWalkingGoal(this, 0.5));
			this.goalSelector.addGoal(5, new LookRandomlyGoal(this));
			this.goalSelector.addGoal(6, new SwimGoal(this));
			this.goalSelector.addGoal(7, new AvoidEntityGoal(this, CatEntity.class, (float) 10, 1, 1.2));
			this.goalSelector.addGoal(8, new LookAtGoal(this, PlayerEntity.class, (float) 10));
			this.targetSelector.addGoal(9, new NearestAttackableTargetGoal(this, MCreatorGrub.CustomEntity.class, false, true));
			this.goalSelector.addGoal(10, new MoveTowardsVillageGoal(this, 0.5));
		}

		@Override
		public CreatureAttribute getCreatureAttribute() {
			return CreatureAttribute.UNDEFINED;
		}

		@Override
		public boolean canDespawn(double distanceToClosestPlayer) {
			return false;
		}

		protected void dropSpecialItems(DamageSource source, int looting, boolean recentlyHitIn) {
			super.dropSpecialItems(source, looting, recentlyHitIn);
			this.entityDropItem(new ItemStack(MCreatorRawRat.block, (int) (1)));
		}

		@Override
		public net.minecraft.util.SoundEvent getAmbientSound() {
			return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("better_drops:sqeak"));
		}

		@Override
		public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
			return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.rabbit.hurt"));
		}

		@Override
		public net.minecraft.util.SoundEvent getDeathSound() {
			return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.rabbit.death"));
		}

		@Override
		protected float getSoundVolume() {
			return 1.0F;
		}

		@Override
		public boolean attackEntityFrom(DamageSource source, float amount) {
			if (source.getImmediateSource() instanceof PotionEntity)
				return false;
			if (source == DamageSource.DROWN)
				return false;
			return super.attackEntityFrom(source, amount);
		}

		@Override
		protected void registerAttributes() {
			super.registerAttributes();
			if (this.getAttribute(SharedMonsterAttributes.ARMOR) != null)
				this.getAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0);
			if (this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
				this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.75);
			if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
				this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(3);
			if (this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
				this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(2);
		}
	}

	// Made with Blockbench
	// Paste this code into your mod.
	public static class Modelcustom_model extends EntityModel<Entity> {
		private final RendererModel Main;
		private final RendererModel Tail;
		private final RendererModel Head;
		private final RendererModel Ear1;
		private final RendererModel Ear2;

		public Modelcustom_model() {
			textureWidth = 32;
			textureHeight = 32;
			Main = new RendererModel(this);
			Main.setRotationPoint(0.0F, 24.0F, 0.0F);
			Main.cubeList.add(new ModelBox(Main, 0, 0, -3.0F, -5.0F, -3.0F, 6, 5, 6, 0.0F, false));
			Tail = new RendererModel(this);
			Tail.setRotationPoint(0.0F, -0.5F, 2.0F);
			Main.addChild(Tail);
			Tail.cubeList.add(new ModelBox(Tail, 0, 11, -0.5F, -0.75F, 0.0F, 1, 1, 6, 0.0F, false));
			Head = new RendererModel(this);
			Head.setRotationPoint(0.0F, -2.0F, -3.0F);
			Main.addChild(Head);
			Head.cubeList.add(new ModelBox(Head, 0, 18, -1.0F, -0.5F, -3.5F, 2, 1, 1, 0.0F, false));
			Head.cubeList.add(new ModelBox(Head, 14, 11, -1.5F, -1.5F, -3.0F, 3, 3, 4, 0.0F, false));
			Ear1 = new RendererModel(this);
			Ear1.setRotationPoint(-1.0F, -1.0F, -0.5F);
			setRotationAngle(Ear1, 0.0F, -0.7854F, 0.0F);
			Head.addChild(Ear1);
			Ear1.cubeList.add(new ModelBox(Ear1, 10, 18, -2.0F, -2.5F, 0.0F, 2, 2, 0, 0.0F, false));
			Ear2 = new RendererModel(this);
			Ear2.setRotationPoint(1.0F, -1.0F, -0.5F);
			setRotationAngle(Ear2, 0.0F, 0.7854F, 0.0F);
			Head.addChild(Ear2);
			Ear2.cubeList.add(new ModelBox(Ear2, 6, 18, 0.0F, -2.5F, 0.0F, 2, 2, 0, 0.0F, false));
		}

		@Override
		public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
			Main.render(f5);
		}

		public void setRotationAngle(RendererModel modelRenderer, float x, float y, float z) {
			modelRenderer.rotateAngleX = x;
			modelRenderer.rotateAngleY = y;
			modelRenderer.rotateAngleZ = z;
		}

		public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4, float f5) {
			super.setRotationAngles(e, f, f1, f2, f3, f4, f5);
			this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
			this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
			this.Tail.rotateAngleY = f4 / (180F / (float) Math.PI);
			this.Ear1.rotateAngleY = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
			this.Ear2.rotateAngleY = MathHelper.cos(f * 0.6662F) * f1;
		}
	}
}

I really hoped it was as simple as renaming the files but that is not the case.

It seems that you renamed it after importing in the mob code? Or did you rename it in model code and then imported it?

You should do the latter. If you already did, please paste the model code before you import it in MCreator.

Ahh okay I got it fixed now! I didn't realize that in the blockbench code, it by default names the model "custom_model." Now that I know that I can now change that and import as many custom models as I want. Thank you for the assistance Klemen! 

You are welcome! Next time, try setting the name in Blockbench properly before exporting, it is easier :D