Mob Won't Attack

Started by BaKonator751 on

Topic category: Help with modding (Java Edition)

Last seen on 00:29, 25. Aug 2019
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Mob Won't Attack

okay so i have a questions, probably answered many times before but when i do custom ai, With prioritys set at different levels, my mobs still won't attack other of my mobs or myself. The priorities for attack player are set at 20 and the priority for other mobs are set at different lower levels and yet they still will refuse to attack. they wander just fine but won't attack :/ here is the code mcreator made for it:

 

package mod.mcreator;

import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
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.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.EnumHand;
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.player.EntityPlayer;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.EnumCreatureType;
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;

@SuppressWarnings("unchecked")
public class mcreator_orc {

    public int mobid = 0;
    public static Object instance;

    public void load(FMLInitializationEvent event) {
    }

    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;
    }

    @SideOnly(Side.CLIENT)
    public void registerRenderers() {
        RenderBiped customRender = new RenderBiped(Minecraft.getMinecraft().getRenderManager(), new ModelBiped(), 0) {
            protected ResourceLocation getEntityTexture(Entity par1Entity) {
                return new ResourceLocation("orc.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(mcreator_orc.Entityorc.class, customRender);

    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
        int entityID = MathHelper.getRandomUUID().hashCode();
        mobid = entityID;
        EntityRegistry.registerModEntity(new ResourceLocation("testenvironmentmod:orc"), mcreator_orc.Entityorc.class, "orc", entityID, instance, 64,
                1, true, (53 << 16) + (75 << 8) + 36, (68 << 16) + (45 << 8) + 11);
        EntityRegistry.addSpawn(mcreator_orc.Entityorc.class, 10, 3, 10, EnumCreatureType.MONSTER, clean(Biome.REGISTRY));

    }

    public static Biome[] clean(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 static class Entityorc extends EntityMob {
        World world = null;

        public Entityorc(World var1) {
            super(var1);
            world = var1;
            experienceValue = 6;
            this.isImmuneToFire = false;
            addRandomArmor();
            setNoAI(!true);

            this.tasks.addTask(8, new EntityAIWander(this, 0.8D));
            this.tasks.addTask(10, new EntityAILookIdle(this));
            this.tasks.addTask(9, new EntityAISwimming(this));
            this.targetTasks.addTask(20, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
            this.targetTasks.addTask(21, new EntityAIHurtByTarget(this, false));
            this.targetTasks.addTask(19, new EntityAINearestAttackableTarget(this, mcreator_baKonatorTheGreat.EntitybaKonatorTheGreat.class, true));
            this.targetTasks.addTask(20, new EntityAIHurtByTarget(this, false));
            this.targetTasks.addTask(18, new EntityAINearestAttackableTarget(this, mcreator_annabella.Entityannabella.class, true));
            this.targetTasks.addTask(19, new EntityAIHurtByTarget(this, false));
            this.targetTasks.addTask(17, new EntityAINearestAttackableTarget(this, mcreator_cecilenceTheWise.EntitycecilenceTheWise.class, true));
            this.targetTasks.addTask(18, new EntityAIHurtByTarget(this, false));
            this.targetTasks.addTask(16, new EntityAINearestAttackableTarget(this, mcreator_sheepMinion.EntitysheepMinion.class, true));
            this.targetTasks.addTask(17, new EntityAIHurtByTarget(this, false));
            this.targetTasks.addTask(15, new EntityAINearestAttackableTarget(this, mcreator_semmonsCatina.EntitysemmonsCatina.class, true));
            this.targetTasks.addTask(16, new EntityAIHurtByTarget(this, false));
            this.targetTasks.addTask(14, new EntityAINearestAttackableTarget(this, EntityPig.class, true));
            this.targetTasks.addTask(15, new EntityAIHurtByTarget(this, false));

        }

        protected void applyEntityAttributes() {
            super.applyEntityAttributes();
            this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D);
            this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10D);
            if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
                this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(5D);
        }

        protected void addRandomArmor() {

            this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.STONE_SWORD));
        }

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

        @Override
        protected Item getDropItem() {
            return new ItemStack(Items.POISONOUS_POTATO).getItem();
        }

        @Override
        protected net.minecraft.util.SoundEvent getAmbientSound() {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.husk.ambient"));
        }

        @Override
        protected net.minecraft.util.SoundEvent getHurtSound() {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.husk.hurt"));
        }

        @Override
        protected net.minecraft.util.SoundEvent getDeathSound() {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.husk.death"));
        }

        @Override
        public void onStruckByLightning(EntityLightningBolt entityLightningBolt) {
            super.onStruckByLightning(entityLightningBolt);
            int i = (int) this.posX;
            int j = (int) this.posY;
            int k = (int) this.posZ;
            Entity entity = this;

        }

        @Override
        public void fall(float l, float d) {
            super.fall(l, d);
            int i = (int) this.posX;
            int j = (int) this.posY;
            int k = (int) this.posZ;
            super.fall(l, d);
            Entity entity = this;

        }

        @Override
        public void onDeath(DamageSource source) {
            super.onDeath(source);
            int i = (int) this.posX;
            int j = (int) this.posY;
            int k = (int) this.posZ;
            Entity entity = this;

        }

        @Override
        public boolean processInteract(EntityPlayer entity, EnumHand hand) {
            super.processInteract(entity, hand);
            int i = (int) this.posX;
            int j = (int) this.posY;
            int k = (int) this.posZ;

            return true;
        }

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

    }

}

Last seen on 23:44, 18. Aug 2019
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Make your mobs have the same
Sun, 04/02/2017 - 14:35

Make your mobs have the same priority for attack on collide and for act aggressively against

Last seen on 20:19, 19. Apr 2019
Joined Sep 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't find attack on…
Sun, 09/23/2018 - 19:06

I can't find attack on collide or act aggresively against