Add skeleton bow accuracy option

This commit is contained in:
BillyGalbreath
2025-01-12 16:17:35 -08:00
committed by granny
parent fff1bdc2b8
commit 6f99e5fe62
3 changed files with 23 additions and 51 deletions

View File

@@ -12,3 +12,12 @@
this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN));
this.armorDropChances[EquipmentSlot.HEAD.getIndex()] = 0.0F;
}
@@ -217,7 +_,7 @@
if (event.getProjectile() == arrow.getBukkitEntity()) {
// CraftBukkit end
Projectile.spawnProjectileUsingShoot(
- arrow, serverLevel, projectile, d, d1 + squareRoot * 0.2F, d2, 1.6F, 14 - serverLevel.getDifficulty().getId() * 4
+ arrow, serverLevel, projectile, d, d1 + squareRoot * 0.2F, d2, 1.6F, serverLevel.purpurConfig.skeletonBowAccuracyMap.getOrDefault(serverLevel.getDifficulty().getId(), (float) (14 - serverLevel.getDifficulty().getId() * 4)) // Purpur - skeleton bow accuracy option
);
} // CraftBukkit
}

View File

@@ -2608,6 +2608,8 @@ public class PurpurWorldConfig {
public boolean skeletonAlwaysDropExp = false;
public double skeletonHeadVisibilityPercent = 0.5D;
public int skeletonFeedWitherRoses = 0;
public String skeletonBowAccuracy = "14 - difficulty * 4";
public Map<Integer, Float> skeletonBowAccuracyMap = new HashMap<>();
private void skeletonSettings() {
skeletonRidable = getBoolean("mobs.skeleton.ridable", skeletonRidable);
skeletonRidableInWater = getBoolean("mobs.skeleton.ridable-in-water", skeletonRidableInWater);
@@ -2623,6 +2625,18 @@ public class PurpurWorldConfig {
skeletonAlwaysDropExp = getBoolean("mobs.skeleton.always-drop-exp", skeletonAlwaysDropExp);
skeletonHeadVisibilityPercent = getDouble("mobs.skeleton.head-visibility-percent", skeletonHeadVisibilityPercent);
skeletonFeedWitherRoses = getInt("mobs.skeleton.feed-wither-roses", skeletonFeedWitherRoses);
final String defaultSkeletonBowAccuracy = skeletonBowAccuracy;
skeletonBowAccuracy = getString("mobs.skeleton.bow-accuracy", skeletonBowAccuracy);
for (int i = 1; i < 4; i++) {
final float divergence;
try {
divergence = ((Number) Entity.scriptEngine.eval("let difficulty = " + i + "; " + skeletonBowAccuracy)).floatValue();
} catch (javax.script.ScriptException e) {
e.printStackTrace();
break;
}
skeletonBowAccuracyMap.put(i, divergence);
}
}
public boolean skeletonHorseRidable = false;