Task :compileJava FAILED for custom mob

Status
Resolved
Type
Product/platform
MCreator/Windows
Priority
Normal
Issue description

Hello,
so i was making a custom mob today
and i spotted this error, unfortunately i don't know much about coding, so i have no idea what this meant,
please help me

Here's the error log:

Executing Gradle task: build

Build info: MCreator 2020.2.14217, 1.14.4, 64-bit, 7123 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.2.3_mapped_snapshot_20190719-1.14.3

> Task :compileJava FAILED

C:\Users\***\MCreatorWorkspaces\Over+ Mod\src\main\java\net\mcreator\test\entity\FortressGuardianEntity.java:263: error: invalid method declaration; return type required
    
   public Fortress_Guardian() {

          ^

1 error

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 7s

1 actionable task: 1 executed

BUILD FAILED

Task completed in 9146 milliseconds

Here's my code:

package net.mcreator.test.entity;

import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.fml.network.NetworkHooks;
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.network.IPacket;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.Item;
import net.minecraft.entity.projectile.ArrowEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.ai.goal.SwimGoal;
import net.minecraft.entity.ai.goal.RangedAttackGoal;
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.Pose;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.IRendersAsItem;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EntitySpawnPlacementRegistry;
import net.minecraft.entity.EntitySize;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.Entity;
import net.minecraft.entity.CreatureAttribute;
import net.minecraft.entity.AgeableEntity;
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.SpriteRenderer;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.block.Blocks;

import net.mcreator.test.TestElements;

@TestElements.ModElement.Tag
public class FortressGuardianEntity extends TestElements.ModElement {
    public static EntityType entity = null;
    @ObjectHolder("test:entitybulletfortressguardian")
    public static final EntityType arrow = null;
    public FortressGuardianEntity(TestElements instance) {
        super(instance, 39);
        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).immuneToFire().size(24f, 25f))
                        .build("fortressguardian").setRegistryName("fortressguardian");
        elements.entities.add(() -> entity);
        elements.items.add(() -> new SpawnEggItem(entity, -11525110, -15641275, new Item.Properties().group(ItemGroup.MISC))
                .setRegistryName("fortressguardian"));
        elements.entities.add(() -> (EntityType.Builder.<ArrowCustomEntity>create(ArrowCustomEntity::new, EntityClassification.MISC)
                .setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(1).setCustomClientFactory(ArrowCustomEntity::new)
                .size(0.5f, 0.5f)).build("entitybulletfortressguardian").setRegistryName("entitybulletfortressguardian"));
    }

    @Override
    public void init(FMLCommonSetupEvent event) {
        for (Biome biome : ForgeRegistries.BIOMES.getValues()) {
            boolean biomeCriteria = false;
            if (ForgeRegistries.BIOMES.getKey(biome).equals(new ResourceLocation("nether")))
                biomeCriteria = true;
            if (!biomeCriteria)
                continue;
            biome.getSpawns(EntityClassification.CREATURE).add(new Biome.SpawnListEntry(entity, 10, 1, 4));
        }
        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 ModelFortressGuardian(), 1f) {
                protected ResourceLocation getEntityTexture(Entity entity) {
                    return new ResourceLocation("test:textures/fortress_guardian_finish.png");
                }
            };
        });
        RenderingRegistry.registerEntityRenderingHandler(ArrowCustomEntity.class, renderManager -> {
            return new SpriteRenderer(renderManager, Minecraft.getInstance().getItemRenderer());
        });
    }
    public static class CustomEntity extends AnimalEntity implements IRangedAttackMob {
        public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
            this(entity, world);
        }

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

        @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 LeapAtTargetGoal(this, (float) 0.8));
            this.goalSelector.addGoal(4, new SwimGoal(this));
            this.goalSelector.addGoal(5, new PanicGoal(this, 1.2));
            this.targetSelector.addGoal(6, new HurtByTargetGoal(this).setCallsForHelp(this.getClass()));
            this.goalSelector.addGoal(1, new RangedAttackGoal(this, 1.25D, 20, 10.0F));
        }

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

        @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(Items.NETHER_BRICK, (int) (1)));
        }

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

        @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
        public boolean attackEntityFrom(DamageSource source, float amount) {
            if (source.getImmediateSource() instanceof ArrowEntity)
                return false;
            if (source == DamageSource.FALL)
                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.5);
            if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
                this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(120);
            if (this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
                this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(8);
        }

        public void attackEntityWithRangedAttack(LivingEntity target, float flval) {
            ArrowCustomEntity entityarrow = new ArrowCustomEntity(arrow, this, this.world);
            double d0 = target.posY + (double) target.getEyeHeight() - 1.1;
            double d1 = target.posX - this.posX;
            double d3 = target.posZ - this.posZ;
            entityarrow.shoot(d1, d0 - entityarrow.posY + (double) MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F, d3, 1.6F, 12.0F);
            world.addEntity(entityarrow);
        }

        @Override
        public AgeableEntity createChild(AgeableEntity ageable) {
            return (CustomEntity) entity.create(this.world);
        }

        @Override
        public float getStandingEyeHeight(Pose pose, EntitySize size) {
            return this.isChild() ? size.height : 1.3F;
        }

        @Override
        public boolean isBreedingItem(ItemStack stack) {
            if (stack == null)
                return false;
            if (new ItemStack(Blocks.NETHER_BRICKS, (int) (1)).getItem() == stack.getItem())
                return true;
            return false;
        }
    }

    @OnlyIn(value = Dist.CLIENT, _interface = IRendersAsItem.class)
    public static class ArrowCustomEntity extends AbstractArrowEntity implements IRendersAsItem {
        public ArrowCustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
            super(arrow, world);
        }

        public ArrowCustomEntity(EntityType<? extends ArrowCustomEntity> type, World world) {
            super(type, world);
        }

        public ArrowCustomEntity(EntityType<? extends ArrowCustomEntity> type, double x, double y, double z, World world) {
            super(type, x, y, z, world);
        }

        public ArrowCustomEntity(EntityType<? extends ArrowCustomEntity> type, LivingEntity entity, World world) {
            super(type, entity, world);
        }

        @Override
        public IPacket<?> createSpawnPacket() {
            return NetworkHooks.getEntitySpawningPacket(this);
        }

        @Override
        @OnlyIn(Dist.CLIENT)
        public ItemStack getItem() {
            return new ItemStack(Items.FIRE_CHARGE, (int) (1));
        }

        @Override
        protected ItemStack getArrowStack() {
            return new ItemStack(Items.FIRE_CHARGE, (int) (1));
        }
    }

    public static class ModelFortressGuardian extends EntityModel {
        private final RendererModel fortress_guardian;
        private final RendererModel body;
        private final RendererModel leftlegfront;
        private final RendererModel rightlegfront;
        private final RendererModel leftlegback;
        private final RendererModel rightlegback;
    public Fortress_Guardian() {
        textureWidth = 128;
        textureHeight = 128;
        fortress_guardian = new RendererModel(this);
        fortress_guardian.setRotationPoint(0.0F, 24.0F, 0.0F);
        
        body = new RendererModel(this);
        body.setRotationPoint(0.8925F, -10.8575F, 0.11F);
        fortress_guardian.addChild(body);
        body.cubeList.add(new ModelBox(body, 0, 0, -7.8925F, -5.1425F, -8.11F, 16, 16, 16, 0.0F, false));
        body.cubeList.add(new ModelBox(body, 0, 32, -3.8925F, -1.1425F, -12.11F, 8, 8, 24, 0.0F, false));
        body.cubeList.add(new ModelBox(body, 64, 55, -3.8925F, -1.1425F, -12.11F, 8, 8, 1, 0.0F, false));
        body.cubeList.add(new ModelBox(body, 96, 55, -3.8925F, -1.1425F, 11.89F, 8, 8, 1, 0.0F, false));
        body.cubeList.add(new ModelBox(body, 59, 31, -6.8925F, -6.1425F, -7.11F, 14, 1, 14, 0.0F, false));
        body.cubeList.add(new ModelBox(body, 66, 17, -4.8925F, -10.1425F, -5.11F, 10, 4, 10, 0.0F, false));
        body.cubeList.add(new ModelBox(body, 64, 1, -5.7525F, -10.5025F, -6.23F, 12, 4, 12, 0.0F, false));
        leftlegfront = new RendererModel(this);
        leftlegfront.setRotationPoint(10.1075F, 5.8575F, -7.11F);
        body.addChild(leftlegfront);
        leftlegfront.cubeList.add(new ModelBox(leftlegfront, 8, 32, -2.0F, -1.0F, -2.0F, 4, 10, 4, 0.0F, false));
        rightlegfront = new RendererModel(this);
        rightlegfront.setRotationPoint(-9.8925F, 5.8575F, -7.11F);
        body.addChild(rightlegfront);
        rightlegfront.cubeList.add(new ModelBox(rightlegfront, 8, 32, -2.0F, -1.0F, -2.0F, 4, 10, 4, 0.0F, false));
        leftlegback = new RendererModel(this);
        leftlegback.setRotationPoint(10.1075F, 5.8575F, 6.89F);
        body.addChild(leftlegback);
        leftlegback.cubeList.add(new ModelBox(leftlegback, 40, 32, -2.0F, -1.0F, -2.0F, 4, 10, 4, 0.0F, false));
        rightlegback = new RendererModel(this);
        rightlegback.setRotationPoint(-9.8925F, 5.8575F, 6.89F);
        body.addChild(rightlegback);
        rightlegback.cubeList.add(new ModelBox(rightlegback, 40, 32, -2.0F, -1.0F, -2.0F, 4, 10, 4, 0.0F, false));
    }

        @Override
        public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
            fortress_guardian.render(f5);
            this.body.rotateAngleY = f3 / (180F / (float) Math.PI);
            this.leftlegfront.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
            this.leftlegback.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
            this.rightlegfront.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
            this.rightlegback.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
        }

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

 

 

Issue comments



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.