Jump to content

Recommended Posts

Posted

Hello@All,

 

i got a small problem,

 

i got the mod "CustomNPCs" , i created a custom sword which cause "FireDamage" and when i give the

sword to the NPC to use, when he hits the enemy he dont get the "caused damage by the sword + firedamage isnt there" ,

 

so well the "Sword" dont cause anything ... it is just there as "Dekoration" ,

 

so is it my error or just a custom entity cant use a sword with hes abilities?

 

i mean, i would create easy and custom human and give him the weapon in hes hand, but will it cause the damage given by the sword etc...?

Posted

I suggest you create your own damage source with that custom death message and program it into the mob. I haven't done this my self, but it's the most help I can provide you with.

Posted

I suggest you create your own damage source with that custom death message and program it into the mob. I haven't done this my self, but it's the most help I can provide you with.

 

hmm i prefer to give him an "itemSword" to use and "onleftclick" it does its effect ....

 

isnt that normaly working?

Posted

@terraya

Mobs can't click. If you have a weapon that does something when you hit something else, it won't work when a mob uses it since the mob isn't specifically programmed to do what the sword does. Basically, the swords code only runs if a PLAYER uses it. If you wanted a mob to have the same effect you would have to hard code it into the mob.

Posted

@terraya

Mobs can't click. If you have a weapon that does something when you hit something else, it won't work when a mob uses it since the mob isn't specifically programmed to do what the sword does. Basically, the swords code only runs if a PLAYER uses it. If you wanted a mob to have the same effect you would have to hard code it into the mob.

 

 

thanks i will try it :)

Posted

btw. is there a function like "If EntityHit target" ?

I would use the LivingAttackEvent to check if the entity attacking from the source is an instanceof EntityLiving and specifically EntityPlayer  and then grab the inventory object to see if the item used was yours then apply the effect.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

btw. is there a function like "If EntityHit target" ?

I would use the LivingAttackEvent to check if the entity attacking from the source is an instanceof EntityLiving and specifically EntityPlayer  and then grab the inventory object to see if the item used was yours then apply the effect.

 

 

got some problem on starting my mod, but i got the function writting with big hope that this test thing here will work:

 

  private void tryAbility(EntityLivingBase mob, EntityLivingBase target)
  {
    if ((target == null) || (target.getRidingEntity() != null) || (!mob.canEntityBeSeen(target))) {
      return;
    }
    long time = System.currentTimeMillis();
    if ((time > this.nextAbilityUse) && 
      (mob.getDistanceToEntity(target) > 3.0F) && 
      (target.worldObj.canBlockSeeSky(new BlockPos(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ)))))
    {
      this.nextAbilityUse = (time + 15000L);
      mob.worldObj.addWeatherEffect(new EntityLightningBolt(mob.worldObj, target.posX, target.posY - 1.0D, target.posZ, false));
    }
  }
}

Posted

btw. is there a function like "If EntityHit target" ?

I would use the LivingAttackEvent to check if the entity attacking from the source is an instanceof EntityLiving and specifically EntityPlayer  and then grab the inventory object to see if the item used was yours then apply the effect.

 

 

got some problem on starting my mod, but i got the function writting with big hope that this test thing here will work:

 

  private void tryAbility(EntityLivingBase mob, EntityLivingBase target)
  {
    if ((target == null) || (target.getRidingEntity() != null) || (!mob.canEntityBeSeen(target))) {
      return;
    }
    long time = System.currentTimeMillis();
    if ((time > this.nextAbilityUse) && 
      (mob.getDistanceToEntity(target) > 3.0F) && 
      (target.worldObj.canBlockSeeSky(new BlockPos(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ)))))
    {
      this.nextAbilityUse = (time + 15000L);
      mob.worldObj.addWeatherEffect(new EntityLightningBolt(mob.worldObj, target.posX, target.posY - 1.0D, target.posZ, false));
    }
  }
}

What is the problem? What are you trying to accomplish? Post where the code is being called from.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.