Jump to content

Recommended Posts

Posted

hello@All

 

so as i hear that an Entity cant use the Abilitys of a Sword so i have to make a custom Entity with a sword in hes hand.

 

the problem which i have on it is,

 

"When he hits an enemy" :

 

  protected void onImpact(RayTraceResult result)
  
  {
      if (result.entityHit != null)
      {
          int i = 0;
          if (result.entityHit instanceof EntityLivingBase)
          {
              i = 150;
          }
          result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i);
          worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.8F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F));
      	this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.HitExplosionRadius, true);
      }
      for (int j = 0; j < 1; ++j)
      {
        	this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius, true);
      }
      if (!this.worldObj.isRemote)
      {
          this.setDead();
          worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.7F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F));
      }
  }

 

the problem here is "OnImpact" is for "EntityThrowable" ,

 

so i am searching for a function which works like:

 

"if entity hits the enemy then ...

...

... "

 

 

Posted

Sword

Look up the snowball there is a basic onImpact method there. entity.projectile.

Yeah, that's totally going to work for a sword.

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.

Posted

Sword

Look up the snowball there is a basic onImpact method there. entity.projectile.

Yeah, that's totally going to work for a sword.

 

 

sarcasm? i mean well

 

first i have to search "entity.projectile" , never used it before,

snowball is to throw so .. well i want to make the effect on "hit" not on "throw and hit"  :S

Posted

Does the "EntityMob.class#attackEntityAsMob" help? or already looked at that class?

 

hmm dont looked onto it,

 

any idea how to mix it with the function written above?

Posted

sarcasm? i mean well

 

well i want to make the effect on "hit" not on "throw and hit"  :S

 

I was being sarcastic at gurujive, not you. :)

I was telling him he was being dumb because he was suggesting Solution-A which won't work for Problem-B (he can't even get his own entities working properly, so he's really got no experience helping other people with entities).

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.

Posted

sarcasm? i mean well

 

well i want to make the effect on "hit" not on "throw and hit"  :S

 

I was being sarcastic at gurujive, not you. :)

I was telling him he was being dumb because he was suggesting Solution-A which won't work for Problem-B (he can't even get his own entities working properly, so he's really got no experience helping other people with entities).

 

ye i understand that :D

 

but anyway , i codet a small function:

 

    public boolean attackEntityAsMob(Entity entity) {
        boolean success = super.attackEntityAsMob(entity);
        if (entity instanceof EntityLiving) {
            ((EntityLiving)entity).addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 200));
            success = true;
        }
        return success;
    }

 

 

so now , next mission is to mix that with "attackentityasmob" ,

 

but how can i use "OnImpact" , i mean , is there a function like : "OnEntityHit" or something?

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



×
×
  • Create New...

Important Information

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