Jump to content

Recommended Posts

Posted

so as you guys probably know from previous posts, I am constantly trying to make an attack animation for my ranged mob. the problem is, Im not sure how to implement an attack timer for a ranged mob so, yeah can someone explain it to me please.

 

here is my current code:

package com.OlympiansMod.entity;

import com.OlympiansMod.Item.ModItems;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveTowardsTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.boss.BossStatus;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.monster.EntityGolem;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityWitch;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityPotion;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class Zeus extends EntityGolem implements IBossDisplayData, IRangedAttackMob{  
 private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F);
 private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private int attackTimer;

    private static final String __OBFID = "CL_00001697";


public Zeus(World world) { 
	super(world);
	 {
	   this.isImmuneToFire = true;
	   this.setHealth(this.getMaxHealth());
	   this.experienceValue = 10000;
	   this.setSize(1.1F, 2F);	  
	   this.getNavigator().setAvoidsWater(true);    
	   this.tasks.addTask(1, new EntityAISwimming(this));
	   this.tasks.addTask(2, new EntityAIWander(this, 0.5D));
	   this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 1.0F));
	   this.tasks.addTask(3, new EntityAILookIdle(this));
	   this.tasks.addTask(5, new EntityAIMoveTowardsTarget(this, 0.7D, 100.0F));
	   this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
	   this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
	   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector));
	   
        
	   if (world != null && !world.isRemote)
        {
            this.setCombatTask();
        }
    }
	    } 
 public void onLivingUpdate()
 {
	super.onLivingUpdate();
  BossStatus.setBossStatus(this, true);

  if (!this.worldObj.isRemote)
  {
      if (this.getAggressive())
      {
         if (this.attackTimer-- <= 0)
        	 this.attackTimer = 1;
        	 
          {
  

 }
      }}
         
    


 }   	   

public boolean isAIEnabled(){

	return true;
}
@Override
protected void entityInit() {
	super.entityInit();
	dataWatcher.addObject(21, (byte) 0);
}


public void setAggressive(boolean par2)
    {
        this.getDataWatcher().updateObject(21, Byte.valueOf((byte)(par2 ? 1 : 0)));
    }

   
    public boolean getAggressive()
    {
        return this.getDataWatcher().getWatchableObjectByte(21) == 1;
    }
   // protected void addRandomArmor()
    //{
       // super.addRandomArmor();
        //this.setCurrentItemOrArmor(0, new ItemStack(ModItems.MasterBolt));
    //}

	    protected void applyEntityAttributes(){
	        super.applyEntityAttributes();
	        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(70.0D);
	        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(5000.0D);
	        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D);
	       
	    }
	    
	    
	public void setCombatTask()
	 {
	   
	      {
	      this.tasks.addTask(4, this.aiArrowAttack);
	      }
	     
	      {
	      this.tasks.addTask(4, this.aiAttackOnCollide);
	      }
	 }
   


@Override 
   public void attackEntityWithRangedAttack(EntityLivingBase entity, float par1)
    {
        if (!this.getAggressive())
        {
        	
            EntityMasterBolt Bolt = new EntityMasterBolt(this.worldObj, this);
            Bolt.rotationPitch -= -20.0F;
            double d0 = entity.posX + entity.motionX - this.posX;
            double d1 = entity.posY + (double)entity.getEyeHeight() - 1.900000023841858D - this.posY;
            double d2 = entity.posZ + entity.motionZ - this.posZ;
            float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2);

            
            Bolt.setThrowableHeading(d0, d1 + (double)(f1 * 0.2F), d2, 0.75F, 8.0F);
            this.worldObj.spawnEntityInWorld(Bolt);
        }
    } 

 @SideOnly(Side.CLIENT)
    public void handleHealthUpdate(byte p_70103_1_)
    
    {
        if (p_70103_1_ == 15)
        	
        {
        	 this.attackTimer = 1;
            for (int i = 0; i < this.rand.nextInt(35) + 10; ++i)
            {
                this.worldObj.spawnParticle("witchMagic", this.posX + this.rand.nextGaussian() * 0.12999999523162842D, this.boundingBox.maxY + 0.5D + this.rand.nextGaussian() * 0.12999999523162842D, this.posZ + this.rand.nextGaussian() * 0.12999999523162842D, 0.0D, 0.0D, 0.0D);
            }
        }
        else
        {
            super.handleHealthUpdate(p_70103_1_);
        }
    }	
       
        @SideOnly(Side.CLIENT)
        public int  getattackTimer()
        {
            return this.attackTimer;

        }
         
protected void dropFewItems(boolean par1, int par2)
{
    this.dropItem(ModItems.MasterBolt, 1);

}
}


        










 

 

thanks

Im serious don't look at it!!

Posted
  On 7/5/2015 at 1:41 PM, diesieben07 said:

  Quote

also how to you call on the entitys health when they get to a certain health.

What?

 

I think he means to ask "how to execute something when Entity has certain HP". Again, onUpdate() is your friend.

If my post helped you, please press that "Thank You"-button to show your appreciation.

 

Also if you don't know Java, I would suggest you read the official tutorials by Oracle to get an idea of how to do this. Thanks, and good modding!

 

Also if you haven't, set up a Git repo for your mod not only for convinience but also to make it easier to help you.

Posted

And getHealth()

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

×
×
  • Create New...

Important Information

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