Skip to content

Commit

Permalink
Fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Aug 24, 2021
1 parent 9468847 commit 8d6f311
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ yarn_mappings=1.17.1+build.43
loader_version=0.11.6

# Mod Properties
mod_version=1.0
mod_version=1.1
maven_group=dev.cammiescorner
archives_base_name=fireworkfix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ public void explodePreDamage(CallbackInfo info, float damage, double d, Vec3d po
}

@Inject(method = "explode", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;damage(Lnet/minecraft/entity/damage/DamageSource;F)Z", ordinal = 1), locals = LocalCapture.CAPTURE_FAILSOFT)
public void explodePostDamage(CallbackInfo info, float damage, double d, Vec3d pos, List list, Iterator iterator, LivingEntity entity) {
public void explodePostDamage(CallbackInfo info, float damage, double d, Vec3d pos, List<LivingEntity> list, Iterator<LivingEntity> iterator, LivingEntity entity) {
if(FireworkFix.config.allowRocketJumping && hasExplosionEffects()) {
Vec3d vec3d = new Vec3d(entity.getX(), entity.getEyeY(), entity.getZ());
double inverseDistance = getPos().distanceTo(vec3d) != 0 ? 1 / getPos().distanceTo(vec3d) : 1;
double multiplier = (dataTracker.get(ITEM).getSubNbt("Fireworks").getList("Explosions", 10).size() / 3.5D) * FireworkFix.config.rocketJumpMultiplier;
for(LivingEntity target : list) {
Vec3d targetPos = new Vec3d(target.getX(), target.getY() + (target.getHeight() / 2), target.getZ());
Vec3d velocityDirection = new Vec3d(target.getX() - getX(), targetPos.getY() - getY(), target.getZ() - getZ());
double inverseDistance = getPos().distanceTo(targetPos) != 0 ? 1 / getPos().distanceTo(targetPos) : 1;
double multiplier = (dataTracker.get(ITEM).getSubNbt("Fireworks").getList("Explosions", 10).size() / 5D) * FireworkFix.config.rocketJumpMultiplier;

entity.knockbackVelocity = 0F;
entity.setVelocity(getVelocity().multiply(-inverseDistance * multiplier));
entity.velocityModified = true;
target.knockbackVelocity = 0F;
target.setVelocity(target.getVelocity().getX(), Math.abs(target.getVelocity().getY()), target.getVelocity().getZ());
target.setVelocity(target.getVelocity().add(velocityDirection).multiply(inverseDistance * multiplier));
target.velocityModified = true;
}
}

if(entity == getOwner())
Expand Down

0 comments on commit 8d6f311

Please sign in to comment.