Skip to content

Commit

Permalink
fix #172
Browse files Browse the repository at this point in the history
  • Loading branch information
MoriyaShiine committed Apr 8, 2024
1 parent 7a32947 commit 807e665
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,40 @@ private static void shoot(World world, LivingEntity shooter, Hand hand, ItemStac

@ModifyVariable(method = "shoot", at = @At("HEAD"), ordinal = 1, argsOnly = true)
private static float enchancement$scatterSpeed(float value, World world, LivingEntity shooter, Hand hand, ItemStack crossbow, ItemStack projectile) {
if (toShoot == 0 && EnchancementUtil.hasEnchantment(ModEnchantments.SCATTER, crossbow)) {
if (toShoot == 0) {
if (projectile.isOf(Items.AMETHYST_SHARD) || !(shooter instanceof PlayerEntity)) {
return value / 2;
if (EnchancementUtil.hasEnchantment(ModEnchantments.SCATTER, crossbow)) {
return value / 2;
}
}
}
return value;
}

@ModifyVariable(method = "shoot", at = @At("HEAD"), ordinal = 2, argsOnly = true)
private static float enchancement$scatterDivergence(float value, World world, LivingEntity shooter, Hand hand, ItemStack crossbow, ItemStack projectile) {
if (toShoot == 0 && EnchancementUtil.hasEnchantment(ModEnchantments.SCATTER, crossbow)) {
if (toShoot == 0) {
if (projectile.isOf(Items.AMETHYST_SHARD) || !(shooter instanceof PlayerEntity)) {
return 16;
if (EnchancementUtil.hasEnchantment(ModEnchantments.SCATTER, crossbow)) {
return 16;
}
}
}
return value;
}

@Inject(method = "shoot", at = @At("TAIL"))
private static void enchancement$scatter(World world, LivingEntity shooter, Hand hand, ItemStack crossbow, ItemStack projectile, float soundPitch, boolean creative, float speed, float divergence, float simulated, CallbackInfo ci) {
if (toShoot == 0 && projectile.isOf(Items.AMETHYST_SHARD)) {
int level = EnchantmentHelper.getLevel(ModEnchantments.SCATTER, crossbow);
if (level > 0) {
if (shooter instanceof PlayerEntity player) {
player.getItemCooldownManager().set(crossbow.getItem(), 20);
}
for (toShoot = MathHelper.nextInt(world.random, level * 6, level * 8) - 1; toShoot > 0; toShoot--) {
shoot(world, shooter, hand, crossbow, projectile, soundPitch, creative, speed, divergence, simulated);
if (toShoot == 0) {
if (projectile.isOf(Items.AMETHYST_SHARD) || !(shooter instanceof PlayerEntity)) {
int level = EnchantmentHelper.getLevel(ModEnchantments.SCATTER, crossbow);
if (level > 0) {
if (shooter instanceof PlayerEntity player) {
player.getItemCooldownManager().set(crossbow.getItem(), 20);
}
for (toShoot = MathHelper.nextInt(world.random, level * 6, level * 8) - 1; toShoot > 0; toShoot--) {
shoot(world, shooter, hand, crossbow, projectile, soundPitch, creative, speed, divergence, simulated);
}
}
}
}
Expand Down

0 comments on commit 807e665

Please sign in to comment.