Jump to content

[1.7.10] Problems with entity attacking


Waabbuffet

Recommended Posts

I created this entity warrior that follows you and attacks whatever you attack. The only problem is when he attacks he goes super sonic, and runs circles around the target hes attacking. The code for the class is here. How do i fix this?

 

 

public class IamAWarrior extends EntityTameable{

 

 

EntityPlayer player = Minecraft.getMinecraft().thePlayer;

 

 

 

public IamAWarrior(World par1World)

{

super(par1World);

this.setSize(0.6F, 0.8F);

        this.getNavigator().setAvoidsWater(true);

        this.tasks.addTask(1, new EntityAISwimming(this));

        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 4.0D, true));

        this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));

        this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

        this.tasks.addTask(9, new EntityAILookIdle(this));

        this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));

        this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));

        this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));

        this.setTamed(true);

     

}

 

protected void applyEntityAttributes(){

super.applyEntityAttributes();

this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23D);

this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D);

//this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);

}

 

@Override

protected boolean isAIEnabled()

{

return true;

 

}

@Override

protected boolean canDespawn()

{

return false;

}

 

@Override

public boolean attackEntityAsMob(Entity p_70652_1_)

  {

        int i = 10;

        return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float)i);

  }

 

 

@Override

    public void writeEntityToNBT(NBTTagCompound cmp)

    {

        super.writeEntityToNBT(cmp);

        cmp.setString("Owners Name", player.getUniqueID().toString());

       

    }

 

    @Override

    public void readEntityFromNBT(NBTTagCompound cmp)

    {

        super.readEntityFromNBT(cmp);

        this.func_152115_b(cmp.getString("Owners Name"));

       

    }

 

    @Override

public EntityAgeable createChild(EntityAgeable entityageable)

{

return null;

 

}

 

 

}

 

 

Link to comment
Share on other sites

OHH lol ok thanks for the quick reply. One more thing how do i make him hold a iron sword?

There's a whole topic about it that may help, but basically:

 

1. Set your entity's held item to what you want (use addRandomArmor or whatever else you need upon spawning)

 

2. To make your life easy, extend both RenderBiped and ModelBiped where appropriate

 

3. Make sure whatever attack AI you are using calls #swingItem when attacking - EntityAIAttackOnCollide does this.

 

4. Make sure you call updateArmSwingProgress() from your entity's onLivingUpdate method, otherwise the swing animation won't work despite your entity holding the sword

Link to comment
Share on other sites

Alright thanks ill take a look, last thing xD. The entity doesnt seem to remember that i am the owner when i log out completely and come back, how do i fix this?

Are you logging in with the same name each time? The default development environment settings log you in with a new user name each time - you need to set it in the run-time configuration: --username Me. You can even add your password (if the username is your real one) to log in using your actual account, if you want.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You shouldn't be extracting the mod .jar, just place it in your mods folder.
    • so basically another rundown of my probelm. Im the admin of a 1.20.1 modded server. Were using forge 47.2.0 but tested this issue in other forge versions too on sevrer and client side. so the forge version isnt the issue. The bug happens in following instances. Were using the attacks of the jujutsucraft mod by orca normally. And for everyone that stands there nothing changes. But everyone who wasnt in the chunks before or who relogins again those chunks will appear invisible for the most part. I tried fixing this be removing and adding following mods in many combinations. Embeddium, canary, memoryleakfix, ai improvements, Krypton reforges, better chunkloading, radium reforged, embeddium plus, farsight, betterchunkloading, oculus I tested most of these mods alone and in differents combinations with each other and without the mods. What i noticed is zhat when i removed  . most invisible chunks will return or semi return. and only ine or two chunks stay invisible. I rechanged those mids mostly on the cöient side but also some in the serveside. Ir most likely isnt an issue with another non performance mod since i noticed this thing with embeddium. Ans also the problem wasnt there im the beginning of the server. Granted since then we updated some of the mods that add content and their lib mod. But i went to every big mods discord and community that we have and i didnt find someone else havinf that chunk problem. Heres the link to a video of the Problem. https://streamable.com/9v1if2     heres the link to the modlist: https://ibb.co/myF8dtX     Pleaee im foghting for months with this problem. All the performance mods kn the modlist are for sure not the issue i tested without all of them.
    • It looks like you're only setting the health if the thing you are hitting is a player.  
    • It sounds like you accidentally have two items that are both named "orange". Ensure that you give items unique names in the string when you register them. That's one of the more annoying errors to track down if you don't know what's causing it, though.
    • when i tried downloading blockfront from curseforge for version 1.20.1 i get the winrar file  and that i extract and i just get the "manifest.json" file no mod when exctracted
  • Topics

×
×
  • Create New...

Important Information

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