Jump to content

1.7.10 Entity Won't Move or Attack


Evil Looply

Recommended Posts

I'm trying to create a custom entity that follows you around until you go in water and then attacks you.

 

However, I can't seem to figure out how to move my entity and get it to attack in a task i made.  The entity will just stand there and not move or attack at all.

I know that the everything is reached because i debugged it with some System.out.print's but they still won't do anything.

 

Entity Registry (or whatever it's called) :

Spoiler

package com.example.mob;

import com.example.tutorial.Main;
import com.sun.xml.internal.stream.Entity;

import cpw.mods.fml.common.registry.EntityRegistry;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;

public class EntityWatcher {
    
    public static void mainRegistry(){
        registerEntity();
    }
    
    public static void registerEntity(){
        createEntity(EntityWatcherMob.class, "Watcher", 0x0004FF, 0xFF00E1);
    }

    public static void createEntity(Class entityClass, String entityName, int solidColor, int spotColor){
        int randId = EntityRegistry.findGlobalUniqueEntityId();
        EntityRegistry.registerGlobalEntityID(entityClass, entityName, randId);
        EntityRegistry.registerModEntity(entityClass, entityName, randId, Main.instance, 60, 1, true);
        EntityRegistry.addSpawn(entityClass, 2, 0, 1, EnumCreatureType.creature, BiomeGenBase.hell);
        
        createEgg(randId,solidColor,spotColor);
    }
    
    private static void createEgg(int rId, int sC, int spC){
    EntityList.entityEggs.put(Integer.valueOf(rId), new EntityList.EntityEggInfo(rId, sC, spC));
    }
    
}
 

 

My Mob Class:

Spoiler

package com.example.mob;

import javax.swing.text.html.parser.Entity;

import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class EntityWatcherMob extends EntityCreature{

    public EntityWatcherMob(World par1W) {
        super(par1W);
        this.setSize(0.4F, 0.7F);
        this.tasks.addTask(0, new EntityWatcherAI(this));
        this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true));
        //this.tasks.addTask(1, new EntityAIWander(this,0.5));
        
    }
    
    @Override
    protected boolean isAIEnabled()
    {
       return true;
    }
    
    protected void applyEntityAttributes(){
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(16);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(64);
    }
    
}

 

My AI part:

Spoiler

package com.example.mob;

import com.mojang.realmsclient.dto.PlayerInfo;
import com.sun.media.jfxmedia.events.PlayerStateEvent.PlayerState;

import ibxm.Player;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.player.EntityPlayer;

public class EntityWatcherAI extends EntityAIBase{

    public EntityWatcherMob watcher;
    //EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    //EntityPlayer player = watcher.worldObj.getClosestPlayerToEntity(watcher, 64.0D);
    
    public EntityWatcherAI(EntityWatcherMob d){
        watcher=d;
        setMutexBits(1);
    }
    
    @Override
    public boolean shouldExecute(){
        EntityPlayer vic = watcher.worldObj.getClosestPlayerToEntity(watcher, 32);
        if(watcher.isEntityAlive()){
            return true;
        }
        return false;
    }
    
    @Override
    public void startExecuting()
    {
        EntityPlayer player = watcher.worldObj.getClosestPlayerToEntity(watcher, 32);
        if(player!=null){
            if(!(player.isInWater())){
            watcher.getNavigator().tryMoveToEntityLiving(player, watcher.getAIMoveSpeed());
            }
            else{
            watcher.attackEntityAsMob(player);
            }
        }
    }
    
    @Override
    public boolean continueExecuting(){
        EntityPlayer player = watcher.worldObj.getClosestPlayerToEntity(watcher, 32);
        if(player!=null){
            if(!(player.isInWater())){
            watcher.getNavigator().tryMoveToEntityLiving(player, watcher.getAIMoveSpeed());}
            else{
            watcher.attackEntityAsMob(player);}
            return true;
        }
        return false;
    }
    
}
 

 

 

I'm kinda new to modding, (besides some items), so if anyone could help me, that'd be great ! 

Link to comment
Share on other sites

3 hours ago, KeeganDeathman said:

*yelling from the back of the auditorium* update your mod to 1.10.2 at least! 1.7.10 is no longer supported by forge and 1.10.2 is where the majority of the fanbase resides!

1.10 is already 2 versions old, update to 1.12 !!!! And no, 1.7 got still at least as many players as 1.10.

 

 

Spoiler
4 hours ago, Evil Looply said:

I'm trying to create a custom entity that follows you around until you go in water and then attacks you.

 

However, I can't seem to figure out how to move my entity and get it to attack in a task i made.  The entity will just stand there and not move or attack at all.

I know that the everything is reached because i debugged it with some System.out.print's but they still won't do anything.

 

Entity Registry (or whatever it's called) :

  Hide contents

package com.example.mob;

import com.example.tutorial.Main;
import com.sun.xml.internal.stream.Entity;

import cpw.mods.fml.common.registry.EntityRegistry;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;

public class EntityWatcher {
    
    public static void mainRegistry(){
        registerEntity();
    }
    
    public static void registerEntity(){
        createEntity(EntityWatcherMob.class, "Watcher", 0x0004FF, 0xFF00E1);
    }

    public static void createEntity(Class entityClass, String entityName, int solidColor, int spotColor){
        int randId = EntityRegistry.findGlobalUniqueEntityId();
        EntityRegistry.registerGlobalEntityID(entityClass, entityName, randId);
        EntityRegistry.registerModEntity(entityClass, entityName, randId, Main.instance, 60, 1, true);
        EntityRegistry.addSpawn(entityClass, 2, 0, 1, EnumCreatureType.creature, BiomeGenBase.hell);
        
        createEgg(randId,solidColor,spotColor);
    }
    
    private static void createEgg(int rId, int sC, int spC){
    EntityList.entityEggs.put(Integer.valueOf(rId), new EntityList.EntityEggInfo(rId, sC, spC));
    }
    
}
 

 

My Mob Class:

  Hide contents

package com.example.mob;

import javax.swing.text.html.parser.Entity;

import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class EntityWatcherMob extends EntityCreature{

    public EntityWatcherMob(World par1W) {
        super(par1W);
        this.setSize(0.4F, 0.7F);
        this.tasks.addTask(0, new EntityWatcherAI(this));
        this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true));
        //this.tasks.addTask(1, new EntityAIWander(this,0.5));
        
    }
    
    @Override
    protected boolean isAIEnabled()
    {
       return true;
    }
    
    protected void applyEntityAttributes(){
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(16);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(64);
    }
    
}

 

My AI part:

  Hide contents

package com.example.mob;

import com.mojang.realmsclient.dto.PlayerInfo;
import com.sun.media.jfxmedia.events.PlayerStateEvent.PlayerState;

import ibxm.Player;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.player.EntityPlayer;

public class EntityWatcherAI extends EntityAIBase{

    public EntityWatcherMob watcher;
    //EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    //EntityPlayer player = watcher.worldObj.getClosestPlayerToEntity(watcher, 64.0D);
    
    public EntityWatcherAI(EntityWatcherMob d){
        watcher=d;
        setMutexBits(1);
    }
    
    @Override
    public boolean shouldExecute(){
        EntityPlayer vic = watcher.worldObj.getClosestPlayerToEntity(watcher, 32);
        if(watcher.isEntityAlive()){
            return true;
        }
        return false;
    }
    
    @Override
    public void startExecuting()
    {
        EntityPlayer player = watcher.worldObj.getClosestPlayerToEntity(watcher, 32);
        if(player!=null){
            if(!(player.isInWater())){
            watcher.getNavigator().tryMoveToEntityLiving(player, watcher.getAIMoveSpeed());
            }
            else{
            watcher.attackEntityAsMob(player);
            }
        }
    }
    
    @Override
    public boolean continueExecuting(){
        EntityPlayer player = watcher.worldObj.getClosestPlayerToEntity(watcher, 32);
        if(player!=null){
            if(!(player.isInWater())){
            watcher.getNavigator().tryMoveToEntityLiving(player, watcher.getAIMoveSpeed());}
            else{
            watcher.attackEntityAsMob(player);}
            return true;
        }
        return false;
    }
    
}
 

 

 

I'm kinda new to modding, (besides some items), so if anyone could help me, that'd be great ! 

 

 

1.7.10 posts usually will get closed soon. Look at how vanilla code for following works (wolves) and try to copy that. For attacking you might need an own task.

 

Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thanks again for your anwsers, I tested without practical_plushies_mobs, practical_plushies_animals and dark-waters and now red forge loading screen appears however few seconds later it crashed again.  How I could put my file codes in my minecraft folder?
    • I have a modded mob that when I try to spawn it, it won't spawn and a crash happens (doesn't crash whole game though) and it says "Duplicate id value for 16!" and points to the mob's defineSynchedData method. Anyone know what's going on?
    • Click Here -- Official Website -- Order Now ➡️● For Order Official Website - https://sale365day.com/get-restore-cbd-gummies ➡️● Item Name: — Restore CBD Gummies ➡️● Ingredients: — All Natural ➡️● Incidental Effects: — NA ➡️● Accessibility: — Online ✅HUGE DISCOUNT ! HURRY UP! ORDER NOW!✅ ✅HUGE DISCOUNT ! HURRY UP! ORDER NOW!✅ ✅HUGE DISCOUNT ! HURRY UP! ORDER NOW!✅   Restore CBD Gummies is a strong contender for the top gummy of the year. Due to its strong concentration of CBD and purity, you will achieve excellent results while using it if you stick with this solution. Most people who suffer from constant pain, anxiety, depression, and insomnia are currently solving these problems, and you can be the next one. All you need to do is give Restore CBD Gummies a chance and let this fantastic product change your life. Visit the official website to order your Restore CBD Gummies today! After reading Restore CBD Gummies reviews, we now know that knee replacement surgeries are not the only option to treat knee pain, inflammation, joint discomfort, and stiffness. These CBD gummies can heal your joints and provide you relief from pain and stress so that you can lead a happy life. Prosper Wellness Restore CBD Gummies can improve joint mobility and improve knee health so that you can remain healthy. Exclusive Details: *Restore CBD Gummies* Read More Details on Official Website #USA! https://www.facebook.com/claritox.pro.unitedstates https://www.facebook.com/illudermaUCAAU https://www.facebook.com/awakenxtusa https://groups.google.com/a/chromium.org/g/chromium-reviews/c/8NMUVKgd-FA https://groups.google.com/g/microsoft.public.project/c/0UZQQKOZF58 https://groups.google.com/g/comp.editors/c/r_BcRRrvGhs https://medium.com/@illuderma/illuderma-reviews-fda-approved-breakthrough-or-clever-skincare-scam-36088ae82c3e https://medium.com/@claritoxpros/claritox-pro-reviews-legitimate-or-deceptive-dr-warns-of-potential-dangers-d5ff3867b34d https://medium.com/@thedetoxall17/detoxall-17-reviews-scam-alert-or-legit-detox-solution-customer-report-inside-1fd4c6920c9e https://groups.google.com/a/chromium.org/g/chromium-reviews/c/RONgLAl6vwM https://groups.google.com/g/microsoft.public.project/c/TgtOMRFt6nQ https://groups.google.com/g/comp.editors/c/fUfg0L2YfzU https://crediblehealths.blogspot.com/2023/12/revitalize-with-restore-cbd-gummies.html https://community.weddingwire.in/forum/restore-cbd-gummies-uncovered-fda-approved-breakthrough-or-deceptive-wellness-scam--t206896 https://restorecbdgummies.bandcamp.com/album/restore-cbd-gummies-uncovered-fda-approved https://my-restore-cb.clubeo.com/page/restore-cbd-gummies-reviews-customer-alert-drs-warning-genuine-or-wellness-hoax.html https://my-restore-cb.clubeo.com/page/restore-cbd-gummies-reviews-scam-alert-or-legit-relief-solution-customer-report-inside.html https://medium.com/@restorecbdgum/restore-cbd-gummies-reviews-warning-2023-update-real-or-a-powerful-relief-hoax-caution-350b61472a3f https://devfolio.co/@restorecbdgum https://restore-cbd-gummies-9.jimdosite.com/ https://devfolio.co/project/new/restore-cbd-gummies-reviews-scam-or-legit-custo-7bd6 https://groups.google.com/a/chromium.org/g/chromium-reviews/c/R0enUCvfs8s https://groups.google.com/g/microsoft.public.project/c/miJma2yOMDQ https://groups.google.com/g/comp.os.vms/c/S_HG94aaKFo https://groups.google.com/g/mozilla.dev.platform/c/qb6WpMUYLu0 https://hellobiz.in/restore-cbd-gummies-reviews-warning-2023-update-genuine-wellness-or-another-hoax-caution-211948390 https://pdfhost.io/v/ir5l.cseV_Restore_CBD_Gummies_Reviews_WARNING_2023_Update_Genuine_Wellness_or_Another_Hoax_Caution https://odoe.powerappsportals.us/en-US/forums/general-discussion/7c8b3f62-6d96-ee11-a81c-001dd8066f2b https://gamma.app/public/Restore-CBD-Gummies-ssh57nprs2l6xgq https://restorecbdgummies.quora.com/ https://www.facebook.com/RestoreCBDGummiesUS https://groups.google.com/g/restorecbdgum/c/9KHVNp3oy3E https://sites.google.com/view/restorecbdgummiesreviewsfdaapp/home https://experiment.com/projects/pjyhtzvpcvllopsglcph/methods https://lookerstudio.google.com/reporting/e5e9f52d-ae52-4c84-96c6-96b97932215f/page/XtkkD https://restore-cbd-gummies-reviews-is-it-a-sca.webflow.io/ https://colab.research.google.com/drive/1xZoc6E2H-jliBSZRVl0vnVqrkc3ix4YU https://soundcloud.com/restore-cbd-gummies-821066674/restore-cbd-gummies https://www.eventcreate.com/e/restore-cbd-gummies-reviews https://restorecbdgummies.godaddysites.com/ https://sketchfab.com/3d-models/restore-cbd-gummies-reviews-fda-approved-7cfe1fb8b003481c81689dd9489d2812 https://www.scoop.it/topic/restore-cbd-gummies-by-restore-cbd-gummies-9 https://events.humanitix.com/restore-cbd-gummies https://communityforums.atmeta.com/t5/General-Development/Restore-CBD-Gummies/m-p/1113602
    • Click Here -- Official Website -- Order Now ➡️● For Order Official Website - https://sale365day.com/get-restore-cbd-gummies ➡️● Item Name: — Restore CBD Gummies ➡️● Ingredients: — All Natural ➡️● Incidental Effects: — NA ➡️● Accessibility: — Online ✅HUGE DISCOUNT ! HURRY UP! ORDER NOW!✅ ✅HUGE DISCOUNT ! HURRY UP! ORDER NOW!✅ ✅HUGE DISCOUNT ! HURRY UP! ORDER NOW!✅   Restore CBD Gummies is a strong contender for the top gummy of the year. Due to its strong concentration of CBD and purity, you will achieve excellent results while using it if you stick with this solution. Most people who suffer from constant pain, anxiety, depression, and insomnia are currently solving these problems, and you can be the next one. All you need to do is give Restore CBD Gummies a chance and let this fantastic product change your life. Visit the official website to order your Restore CBD Gummies today! After reading Restore CBD Gummies reviews, we now know that knee replacement surgeries are not the only option to treat knee pain, inflammation, joint discomfort, and stiffness. These CBD gummies can heal your joints and provide you relief from pain and stress so that you can lead a happy life. Prosper Wellness Restore CBD Gummies can improve joint mobility and improve knee health so that you can remain healthy. Exclusive Details: *Restore CBD Gummies* Read More Details on Official Website #USA! https://www.facebook.com/claritox.pro.unitedstates https://www.facebook.com/illudermaUCAAU https://www.facebook.com/awakenxtusa https://groups.google.com/a/chromium.org/g/chromium-reviews/c/8NMUVKgd-FA https://groups.google.com/g/microsoft.public.project/c/0UZQQKOZF58 https://groups.google.com/g/comp.editors/c/r_BcRRrvGhs https://medium.com/@illuderma/illuderma-reviews-fda-approved-breakthrough-or-clever-skincare-scam-36088ae82c3e https://medium.com/@claritoxpros/claritox-pro-reviews-legitimate-or-deceptive-dr-warns-of-potential-dangers-d5ff3867b34d https://medium.com/@thedetoxall17/detoxall-17-reviews-scam-alert-or-legit-detox-solution-customer-report-inside-1fd4c6920c9e https://groups.google.com/a/chromium.org/g/chromium-reviews/c/RONgLAl6vwM https://groups.google.com/g/microsoft.public.project/c/TgtOMRFt6nQ https://groups.google.com/g/comp.editors/c/fUfg0L2YfzU https://crediblehealths.blogspot.com/2023/12/revitalize-with-restore-cbd-gummies.html https://community.weddingwire.in/forum/restore-cbd-gummies-uncovered-fda-approved-breakthrough-or-deceptive-wellness-scam--t206896 https://restorecbdgummies.bandcamp.com/album/restore-cbd-gummies-uncovered-fda-approved https://my-restore-cb.clubeo.com/page/restore-cbd-gummies-reviews-customer-alert-drs-warning-genuine-or-wellness-hoax.html https://my-restore-cb.clubeo.com/page/restore-cbd-gummies-reviews-scam-alert-or-legit-relief-solution-customer-report-inside.html https://medium.com/@restorecbdgum/restore-cbd-gummies-reviews-warning-2023-update-real-or-a-powerful-relief-hoax-caution-350b61472a3f https://devfolio.co/@restorecbdgum https://restore-cbd-gummies-9.jimdosite.com/ https://devfolio.co/project/new/restore-cbd-gummies-reviews-scam-or-legit-custo-7bd6 https://groups.google.com/a/chromium.org/g/chromium-reviews/c/R0enUCvfs8s https://groups.google.com/g/microsoft.public.project/c/miJma2yOMDQ https://groups.google.com/g/comp.os.vms/c/S_HG94aaKFo https://groups.google.com/g/mozilla.dev.platform/c/qb6WpMUYLu0 https://hellobiz.in/restore-cbd-gummies-reviews-warning-2023-update-genuine-wellness-or-another-hoax-caution-211948390 https://pdfhost.io/v/ir5l.cseV_Restore_CBD_Gummies_Reviews_WARNING_2023_Update_Genuine_Wellness_or_Another_Hoax_Caution https://odoe.powerappsportals.us/en-US/forums/general-discussion/7c8b3f62-6d96-ee11-a81c-001dd8066f2b https://gamma.app/public/Restore-CBD-Gummies-ssh57nprs2l6xgq https://restorecbdgummies.quora.com/ https://www.facebook.com/RestoreCBDGummiesUS https://groups.google.com/g/restorecbdgum/c/9KHVNp3oy3E https://sites.google.com/view/restorecbdgummiesreviewsfdaapp/home https://experiment.com/projects/pjyhtzvpcvllopsglcph/methods https://lookerstudio.google.com/reporting/e5e9f52d-ae52-4c84-96c6-96b97932215f/page/XtkkD https://restore-cbd-gummies-reviews-is-it-a-sca.webflow.io/ https://colab.research.google.com/drive/1xZoc6E2H-jliBSZRVl0vnVqrkc3ix4YU https://soundcloud.com/restore-cbd-gummies-821066674/restore-cbd-gummies https://www.eventcreate.com/e/restore-cbd-gummies-reviews https://restorecbdgummies.godaddysites.com/ https://sketchfab.com/3d-models/restore-cbd-gummies-reviews-fda-approved-7cfe1fb8b003481c81689dd9489d2812 https://www.scoop.it/topic/restore-cbd-gummies-by-restore-cbd-gummies-9 https://events.humanitix.com/restore-cbd-gummies https://communityforums.atmeta.com/t5/General-Development/Restore-CBD-Gummies/m-p/1113602
    • i use fabric 1.20.1 i used alot of mods like all the trims, bobby, better stats, and more but i encounter a problem when i try to enter my world it force me to be in safe mode and when i click on safe mode it just crash minecraft
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.