Posted November 22, 20168 yr 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 ... ... ... "
November 22, 20168 yr Look up the snowball there is a basic onImpact method there. entity.projectile.
November 22, 20168 yr 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.
November 22, 20168 yr Author 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"
November 22, 20168 yr Does the "EntityMob.class#attackEntityAsMob" help? or already looked at that class? Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
November 22, 20168 yr Author 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?
November 22, 20168 yr sarcasm? i mean well well i want to make the effect on "hit" not on "throw and hit" 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.
November 22, 20168 yr Author sarcasm? i mean well well i want to make the effect on "hit" not on "throw and hit" 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 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.