Files
Purpur/patches/server/0266-Add-skeleton-bow-accuracy-option.patch
granny 7377ee97fe Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@862299b "Downgrade" Vineflower to 1.10.1 release (#10423)
PaperMC/Paper@9e886c4 Remove dead code (LegacyResult) (#10411)
PaperMC/Paper@3b078f8 Add API for ticking fluids (#10435)
PaperMC/Paper@908b814 Fix inventory desync with PlayerLeashEntityEvent (#10436)
PaperMC/Paper@3af1346 Allow setting player list name early
PaperMC/Paper@a033033 Added chunk view API (#10398)
PaperMC/Paper@c5f68ff Add CartographyItemEvent and get/setResult for CartographyInventory (#10396)
PaperMC/Paper@fc53ff5 Add Configuration for finding Structures outside World Border (#10437)
PaperMC/Paper@a6b6ecd More Raid API (#7537)
2024-04-21 14:39:56 -07:00

52 lines
3.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Fri, 2 Sep 2022 13:04:53 -0500
Subject: [PATCH] Add skeleton bow accuracy option
diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
index cb378b343f721c16868a6673aba59856574c7133..a00646bc8a9caefe56e48b7682e8fb0c464b81fa 100644
--- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
@@ -182,7 +182,7 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
double d2 = target.getZ() - this.getZ();
double d3 = Math.sqrt(d0 * d0 + d2 * d2);
- entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level().getDifficulty().getId() * 4));
+ entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, this.level().purpurConfig.skeletonBowAccuracyMap.getOrDefault(this.level().getDifficulty().getId(), (float) (14 - this.level().getDifficulty().getId() * 4))); // Purpur
// CraftBukkit start
org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), entityarrow.getPickupItem(), entityarrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true); // Paper
if (event.isCancelled()) {
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index d790f742b47093f4e393cc7d60fc7c5c13c20fd1..5b12c08a1d8e6f62c5653c95071a1d36d735d039 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -2502,6 +2502,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);
@@ -2516,6 +2518,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;