July 21, 201312 yr Use this. @Override public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { super.onUpdate(stack, world, entity, par4, par5); if(((EntityPlayer)entity).getItemInUse() != stack) return; entity.fallDistance = 0; double x = entity.posX, y = entity.posY, z = entity.posZ; if(!(entity instanceof EntityPlayer)||entity.motionX*entity.motionX + entity.motionY*entity.motionY + entity.motionZ*entity.motionZ < 0.01)/*you may want to play with this number*/ return; AxisAlignedBB box = AxisAlignedBB.getBoundingBox(x - 0.5D, y-1.0D, z-0.5D, x + 0.5D, y+1.0D, z+0.5D); List<Entity> entList = world.getEntitiesWithinAABBExcludingEntity(null, box); for(Entity ent: entList) { if(ent instanceof EntityLiving) { /*may need an if(!world.isRemote) here*/ ((EntityLiving)ent).attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)entity), 1); } } }
July 21, 201312 yr Use this. @Override public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { super.onUpdate(stack, world, entity, par4, par5); if(((EntityPlayer)entity).getItemInUse() != stack) return; entity.fallDistance = 0; double x = entity.posX, y = entity.posY, z = entity.posZ; if(!(entity instanceof EntityPlayer)||entity.motionX*entity.motionX + entity.motionY*entity.motionY + entity.motionZ*entity.motionZ < 0.01)/*you may want to play with this number*/ return; AxisAlignedBB box = AxisAlignedBB.getBoundingBox(x - 0.5D, y-1.0D, z-0.5D, x + 0.5D, y+1.0D, z+0.5D); List<Entity> entList = world.getEntitiesWithinAABBExcludingEntity(null, box); for(Entity ent: entList) { if(ent instanceof EntityLiving) { /*may need an if(!world.isRemote) here*/ ((EntityLiving)ent).attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)entity), 1); } } } may I ask why you decided to copy paste my code from earlier into a context to make it seem like your own? even after the topic has been effectively finished, and the code you pasted changed. github
July 21, 201312 yr He said the fall damage was still being negates this is your code but it fixes that.
July 21, 201312 yr The fall damage was fixed, that's what we added the event for. we removed the fall damage statement from the on update method as it was not wanted, and is a messier way of doing it, as other mods may set fall damage after it, based on speed or whatever. using the event will guarantee that the fall damage is negated, without having problems with other mods. github
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.