My mob has a very small hitbox

Status
Duplicate
Product/platform
MCreator/Windows
Priority
Normal
Issue description

Hey guys. I am a new user of MCreator and I've been trying unsuccessfully for days to make a mob. It has a very small hitbox (so small that the mob can't be hit). Here is the code : 

package mod.mcreator;

import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

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.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.init.Items;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIOpenDoor;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIMoveIndoors;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.Minecraft;

import java.util.Random;
import java.util.Iterator;
import java.util.ArrayList;
import net.minecraft.entity.ai.EntityAIHurtByTarget;

public class mcreator_byzantine {

    public static Object instance;
    public static int mobid = 1;
    public static int mobid2 = 2;

    public void preInit(FMLPreInitializationEvent event) {
        EntityRegistry.registerModEntity(new ResourceLocation("testenvironmentmod:byzantine"), Entitybyzantine.class, "byzantine", mobid, instance,
                64, 1, true, -26368, -6710887);
        Biome[] spawnBiomes = allbiomes(Biome.REGISTRY);
        EntityRegistry.addSpawn(Entitybyzantine.class, 20, 3, 8, EnumCreatureType.MONSTER, spawnBiomes);
    }

    private Biome[] allbiomes(net.minecraft.util.registry.RegistryNamespaced<ResourceLocation, Biome> in) {
        Iterator<Biome> itr = in.iterator();
        ArrayList<Biome> ls = new ArrayList<Biome>();
        while (itr.hasNext()) {
            ls.add(itr.next());
        }
        return ls.toArray(new Biome[ls.size()]);
    }

    public void load(FMLInitializationEvent event) {
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void registerRenderers() {
        RenderBiped customRender = new RenderBiped(Minecraft.getMinecraft().getRenderManager(), new ModelBiped(), 0) {

            protected ResourceLocation getEntityTexture(Entity par1Entity) {
                return new ResourceLocation("skin_2013012620043159225.png");
            }
        };
        customRender.addLayer(new net.minecraft.client.renderer.entity.layers.LayerHeldItem(customRender));
        customRender.addLayer(new net.minecraft.client.renderer.entity.layers.LayerBipedArmor(customRender) {

            protected void initArmor() {
                this.modelLeggings = new ModelBiped();
                this.modelArmor = new ModelBiped();
            }
        });
        RenderingRegistry.registerEntityRenderingHandler(Entitybyzantine.class, customRender);
    }

    public void generateNether(World world, Random random, int chunkX, int chunkZ) {
    }

    public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
    }

    public int addFuel(ItemStack fuel) {
        return 0;
    }

    public static class Entitybyzantine extends EntityAnimal {

        public Entitybyzantine(World world) {
            super(world);
            addRandomArmor();
            experienceValue = 10;
            this.isImmuneToFire = false;
            setNoAI(!true);
            this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityZombie.class, true, true));
            this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityZombie.class, (float) 6));
            this.tasks.addTask(3, new EntityAIAttackMelee(this, 1.2, true));
            this.tasks.addTask(4, new EntityAIWander(this, 0.8));
            this.tasks.addTask(5, new EntityAILookIdle(this));
            this.tasks.addTask(6, new EntityAISwimming(this));
            this.tasks.addTask(7, new EntityAIOpenDoor(this, true));
            this.tasks.addTask(8, new EntityAIOpenDoor(this, false));
            this.tasks.addTask(9, new EntityAIMoveIndoors(this));
            this.tasks.addTask(3, new EntityAIMate(this, 1.0D));
        }

        @Override
        protected Item getDropItem() {
            return new ItemStack(Items.COOKED_CHICKEN, (int) (1)).getItem();
        }

        @Override
        public net.minecraft.util.SoundEvent getAmbientSound() {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
        }

        @Override
        public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
        }

        @Override
        public net.minecraft.util.SoundEvent getDeathSound() {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
        }

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

        @Override
        protected void applyEntityAttributes() {
            super.applyEntityAttributes();
            this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
            this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20D);
            if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
                this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(10D);
        }

        protected void addRandomArmor() {
            this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(mcreator_gkcfghty.block, (int) (1)));
        }

        @Override
        public Entitybyzantine createChild(EntityAgeable ageable) {
            return new Entitybyzantine(world);
        }

        @Override
        public float getEyeHeight() {
            return this.isChild() ? this.height : 1.3F;
        }

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

        protected void dropRareDrop(int par1) {
            this.dropItem(new ItemStack(Items.GOLD_INGOT, (int) (1)).getItem(), 1);
        }
    }
}

Please, I am in desperate need of your help!

Thank you,

A random user

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.