Custom Mob Models Cause Compiler Errors

Status
Works as designed
Type
Product/platform
Not applicable
Priority
Normal
Issue description

I make a custom model for my mob, and the console says it causes errors. I run it without the model and it works perfectly. When I look at the console log after failure, I see this:

:clean
:deobfCompileDummyTask
:deobfProvidedDummyTask
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJavaC
:\Pylo\MCreator180\forge\build\sources\main\java\mod\mcreator\mcreator_mushroomGuardian.java:50: error: cannot find symbol
RenderLiving customRender = new RenderLiving(Minecraft.getMinecraft().getRenderManager(), new Model(), 0) {
                                                                                              ^

symbol: class Model
location: class mcreator_mushroomGuardian
1 error
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 28.941 secs
C:\Pylo\MCreator180\forge>
Task completed with return code 0 in 30628 milliseconds

 

Attachment Size
The .java file I used.5.96 KB 5.96 KB

Issue comments

Could you please attach the mob model .java file you used to import the model in MCreator? Thanks!

I am also getting issues with a mob with custom models, my log seems a little diff tho, I made my own ticked with my log and model java attatched

The model you are importing is not actual Java model. It seems like you changed the extension to look like .java model. You need ACTUAL java model for this to work. Make one using Techne or Tabula and export .java model file.

somebody help I tried to use a custom model for my entity it was made using Blockbench and it is .java but it does not compile

package net.mcreator.powerarmor.entity;

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.ResourceLocation;
import net.minecraft.util.DamageSource;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.Item;
import net.minecraft.entity.passive.AnimalEntity;
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.LookRandomlyGoal;
import net.minecraft.entity.ai.goal.LeapAtTargetGoal;
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
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.client.renderer.entity.model.RendererModel;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.MobRenderer;

import net.mcreator.powerarmor.PowerarmorElements;

@PowerarmorElements.ModElement.Tag
public class PorgEntity extends PowerarmorElements.ModElement {
	public static EntityType entity = null;
	public PorgEntity(PowerarmorElements instance) {
		super(instance, 31);
		FMLJavaModLoadingContext.get().getModEventBus().register(this);
	}

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

	@Override
	public void init(FMLCommonSetupEvent event) {
		for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
			biome.getSpawns(EntityClassification.CREATURE).add(new Biome.SpawnListEntry(entity, 20, 3, 30));
		}
		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 Modelnp(), 0.5f) {
				protected ResourceLocation getEntityTexture(Entity entity) {
					return new ResourceLocation("powerarmor:textures/porg.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);
		}

		@Override
		protected void registerGoals() {
			super.registerGoals();
			this.goalSelector.addGoal(1, new RandomWalkingGoal(this, 1));
			this.goalSelector.addGoal(2, new LookRandomlyGoal(this));
			this.goalSelector.addGoal(3, new SwimGoal(this));
			this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, (float) 0.8));
			this.goalSelector.addGoal(5, new PanicGoal(this, 1.2));
			this.targetSelector.addGoal(6, new HurtByTargetGoal(this));
		}

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

		protected void dropSpecialItems(DamageSource source, int looting, boolean recentlyHitIn) {
			super.dropSpecialItems(source, looting, recentlyHitIn);
		}

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

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

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

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

		@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.3);
			if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
				this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10);
			if (this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
				this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3);
		}
	}

	public static class Modelnp extends EntityModel<Entity> {
	public porg() {
		textureWidth = 64;
		textureHeight = 32;
		
	}

		@Override
		public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
				float alpha) {
		}

		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 is the code somebody tell me what is wrong

static class Modelnp extends EntityModel<Entity> {

public porg() {

class name and constructors don't match...

https://www.youtube.com/watch?v=g0MuAEV7zIA&list=PLAeL-oIFIEngE6jRgFYeFMfuj8WQsO3Ei&index=71&t=0s

I highly suggest you check our tutorials collection playlist on our YouTube channel which contains many examples and tutorials that can help you get started with MCreator: https://www.youtube.com/playlist?list=PLAeL-oIFIEngE6jRgFYeFMfuj8WQsO3Ei

it says that there is a error on the line were it says public port

Thank you very much for your help. I'll watch the tutorials. I'm sure they'll help. 

The tutorials did not tell me how to fix it. do you have anything else that will help? 

Ey. I have similar problem. I need fast help

Build info: MCreator 2020.1.05419, 1.14.4, 64-

bit, 8156 MB, Windows 10, JVM 1.8.0_232, JAVA_HOME: C:\Program Files\Pylo\MCreator\jdk
> Configure project :
New Dep: net.minecraftforge:forge:1.14.4-28.1.117_mapped_snapshot_20190719-1.14.3
> Task :compileJava FAILED
C:\Users\XXXXXX\MCreatorWorkspaces\matiascraft\src\main\java\net\mcreator\matiascraft\MCreatorAdultEnderman.java:251: error: illegal start of expression
       = new RendererModel(this, 0, 0);
       ^
C:\Users\XXXXXX\MCreatorWorkspaces\matiascraft\src\main\java\net\mcreator\matiascraft\MCreatorAdultEnderman.java:252: error: illegal start of expression
      .addBox(0F, 0F, 0F, 1, 1, 1);
      ^
C:\Users\XXXXXX\MCreatorWorkspaces\matiascraft\src\main\java\net\mcreator\matiascraft\MCreatorAdultEnderman.java:253: error: illegal start of expression
      .setRotationPoint(0F, -19F, 0F);
      ^
C:\Users\XXXXXX\MCreatorWorkspaces\matiascraft\src\main\java\net\mcreator\matiascraft\MCreatorAdultEnderman.java:254: error: illegal start of expression
      .setTextureSize(64, 32);
      ^
C:\Users\XXXXXX\MCreatorWorkspaces\matiascraft\src\main\java\net\mcreator\matiascraft\MCreatorAdultEnderman.java:255: error: illegal start of expression
      .mirror = true;
      ^
C:\Users\XXXXXX\MCreatorWorkspaces\matiascraft\src\main\java\net\mcreator\matiascraft\MCreatorAdultEnderman.java:256: error: illegal start of expression
      setRotation(, 0F, 0F, 0F);
                  ^
C:\Users\XXXXXX\MCreatorWorkspaces\matiascraft\src\main\java\net\mcreator\matiascraft\MCreatorAdultEnderman.java:318: error: illegal start of expression
    .render(f5);
    ^
7 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:c…
BUILD FAILED in 3s
1 actionable task: 1 executed
BUILD FAILED
Task completed in 5821 millisecond



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.