Posted March 24, 20214 yr Hello, I have made enchantment that accelerates arrow fired by crossbow, but not only this increases speed, this also increases damage, I want it to have the same damage as before, how can i make damage the same? What i'm doing is when firing arrow, detect it using EntityJoinWorld event and changing its velocity if(enchants.containsKey(TCombatEnchants.SNIPE.get())){ double damage = abstractArrowEntity.getBaseDamage(); Vector3d vector3d1 = shooter.getUpVector(1.0F); Quaternion quaternion = new Quaternion(new Vector3f(vector3d1), 0, true); Vector3d vector3d = shooter.getViewVector(1.0F); Vector3f vector3f = new Vector3f(vector3d); vector3f.transform(quaternion); Vector3d originalVector = abstractArrowEntity.getDeltaMovement(); double length = originalVector.length() * 10; abstractArrowEntity.setDeltaMovement(vector3f.x()*length, vector3f.y()*length, vector3f.z()*length); abstractArrowEntity.hurtMarked = true; abstractArrowEntity.setBaseDamage(damage); } Edit:I have solved it by saving length of original velocity and setting damage when it hit entity to its base damage multiplied by saved length Edited March 24, 20214 yr by tmvkrpxl0 solved
March 24, 20214 yr 28 minutes ago, tmvkrpxl0 said: how can i make damage the same? I think that's not possible because the damage from the arrow depends on the arrow velocity that mean if you increase the speed of the arrow, the damage is also increased Edit: check out the method onEntityHit in the AbstractArrowEntity class for more information Edited March 24, 20214 yr by Luis_ST
March 24, 20214 yr Author I have succeed by saving length of original velocity and setting damage when arrow hit something to arrow's base damage multiplied by saved length
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.