Skip to content

Commit

Permalink
polish arrow volley
Browse files Browse the repository at this point in the history
  • Loading branch information
iron431 committed Dec 21, 2023
1 parent 1201d45 commit fc092e6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public void tick() {
arrow.setPos(spawn);
arrow.shoot(motion.add(Utils.getRandomVec3(.04f)));
level.addFreshEntity(arrow);
MagicManager.spawnParticles(level, ParticleTypes.ELECTRIC_SPARK, spawn.x, spawn.y, spawn.z, 3, .1, .1, .1, .05, false);
MagicManager.spawnParticles(level, ParticleTypes.FIREWORK, spawn.x, spawn.y, spawn.z, 2, .1, .1, .1, .05, false);
}
level.playSound(null, position().x, position().y, position().z, SoundEvents.FIREWORK_ROCKET_LAUNCH, SoundSource.NEUTRAL, 3.0f, 1.1f + Utils.random.nextFloat() * .3f);
level.playSound(null, position().x, position().y, position().z, SoundRegistry.BOW_SHOOT.get(), SoundSource.NEUTRAL, 2, Utils.random.nextIntBetweenInclusive(16, 20) * .1f);
} else if (tickCount > rows * delay) {
discard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,19 @@ public void onCast(Level level, int spellLevel, LivingEntity entity, MagicData p
targetLocation = Utils.raycastForEntity(level, entity, 100, true).getLocation();
}
Vec3 backward = new Vec3(targetLocation.x - entity.getX(), 0, targetLocation.z - entity.getZ()).normalize().scale(-4);
Vec3 spawnLocation = Utils.moveToRelativeGroundLevel(level, Utils.moveToRelativeGroundLevel(level, targetLocation, 6).add(backward), 1, 2);
spawnLocation = Utils.raycastForBlock(level, spawnLocation.add(0, 0.25, 0), spawnLocation.add(0, 6, 0), ClipContext.Fluid.NONE).getLocation().add(0, -1, 0);

//Vec3 spawnLocation = Utils.moveToRelativeGroundLevel(level, Utils.moveToRelativeGroundLevel(level, targetLocation, 6).add(backward), 1, 2);
//spawnLocation = Utils.raycastForBlock(level, spawnLocation.add(0, 0.25, 0), spawnLocation.add(0, 6, 0), ClipContext.Fluid.NONE).getLocation().add(0, -1, 0);
Vec3 raycastTarget = Utils.moveToRelativeGroundLevel(level, targetLocation.add(0, 2, 0), 4).add(backward).add(0, 6, 0);
Vec3 spawnLocation = Utils.raycastForBlock(level, targetLocation, raycastTarget, ClipContext.Fluid.NONE).getLocation();
spawnLocation = spawnLocation.subtract(targetLocation).scale(.9f).add(targetLocation);
float dx = Mth.sqrt((float) ((spawnLocation.x - targetLocation.x) * (spawnLocation.x - targetLocation.x) + (spawnLocation.z - targetLocation.z) * (spawnLocation.z - targetLocation.z)));
float arrowAngleX = dx == 0 ? 70 : (float) (Mth.atan2(dx, (spawnLocation.y - targetLocation.y)) * Mth.RAD_TO_DEG);
float arrowAngleY = entity.getX() == targetLocation.x && entity.getZ() == targetLocation.z ? (entity.getYRot() - 90) * Mth.DEG_TO_RAD : Utils.getAngle(entity.getX(), entity.getZ(), targetLocation.x, targetLocation.z);

ArrowVolleyEntity arrowVolleyEntity = new ArrowVolleyEntity(EntityRegistry.ARROW_VOLLEY_ENTITY.get(), level);
arrowVolleyEntity.moveTo(spawnLocation);
arrowVolleyEntity.setYRot(arrowAngleY * Mth.RAD_TO_DEG + 90);
arrowVolleyEntity.setXRot(arrowAngleX + 15);
arrowVolleyEntity.setXRot(arrowAngleX + 25);
arrowVolleyEntity.setDamage(getDamage(spellLevel, entity));
arrowVolleyEntity.setArrowsPerRow(getArrowsPerRow(spellLevel, entity));
arrowVolleyEntity.setRows(getRows(spellLevel, entity));
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit fc092e6

Please sign in to comment.