Skip to content

Commit d1ffa79

Browse files
committed
Add game rule for predictable projectiles
Signed-off-by: notstevy <notstevy@ultrabuildmc.de>
1 parent 9a6d604 commit d1ffa79

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: notstevy <notstevy@ultrabuildmc.de>
3+
Date: Thu, 2 Oct 2025 21:37:23 +0200
4+
Subject: [PATCH] Predictable Projectiles
5+
6+
Signed-off-by: notstevy <notstevy@ultrabuildmc.de>
7+
8+
diff --git a/src/main/java/org/bukkit/GameRule.java b/src/main/java/org/bukkit/GameRule.java
9+
index 6f99ed5815d42f7daf7b92e8514d78eb31e21889..e00b0c9e1fbdd0d75d70d5818f4051ae8d0dc416 100644
10+
--- a/src/main/java/org/bukkit/GameRule.java
11+
+++ b/src/main/java/org/bukkit/GameRule.java
12+
@@ -316,6 +316,13 @@ public final class GameRule<T> implements net.kyori.adventure.translation.Transl
13+
*/
14+
public static final GameRule<Boolean> PREDICTABLE_ENCHANTMENTS = new GameRule<>("predictableEnchantments", Boolean.class);
15+
// kitpvp end - Predictable Enchantments
16+
+ // kitpvp start - Predictable Projectiles
17+
+ /**
18+
+ * KitPvP: Configures whether projectiles should have a random deviation
19+
+ */
20+
+ public static final GameRule<Boolean> PREDICTABLE_PROJECTILES = new GameRule<>("predictableProjectiles", Boolean.class);
21+
+ // kitpvp end - Predictable Projectiles
22+
+
23+
24+
// All GameRules instantiated above this for organizational purposes
25+
private final String name;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: notstevy <notstevy@ultrabuildmc.de>
3+
Date: Thu, 2 Oct 2025 21:37:23 +0200
4+
Subject: [PATCH] Predictable Projectiles
5+
6+
Signed-off-by: notstevy <notstevy@ultrabuildmc.de>
7+
8+
diff --git a/net/minecraft/world/entity/projectile/Projectile.java b/net/minecraft/world/entity/projectile/Projectile.java
9+
index dae6619f4670c6f68dae7e4b10b0b6a8bbe6dc2e..a85f9745e61a5b05752beceacca34bc9cbbc0b04 100644
10+
--- a/net/minecraft/world/entity/projectile/Projectile.java
11+
+++ b/net/minecraft/world/entity/projectile/Projectile.java
12+
@@ -139,6 +139,12 @@ public abstract class Projectile extends Entity implements TraceableEntity {
13+
}
14+
15+
public Vec3 getMovementToShoot(double x, double y, double z, float velocity, float inaccuracy) {
16+
+ // kitpvp start - Predictable Projectiles
17+
+ if(((ServerLevel) this.level()).getGameRules().getBoolean(GameRules.RULE_PREDICATBLE_PROJECTILES)) {
18+
+ inaccuracy = 0;
19+
+ }
20+
+ // kitpvp end - Predictable Projectiles
21+
+
22+
return new Vec3(x, y, z)
23+
.normalize()
24+
.add(
25+
diff --git a/net/minecraft/world/level/GameRules.java b/net/minecraft/world/level/GameRules.java
26+
index ff5ac5d7aa0346c6598ed097cfb10b0e2991642e..4420ce80c8dff106c1f497c63161649eb8c37c06 100644
27+
--- a/net/minecraft/world/level/GameRules.java
28+
+++ b/net/minecraft/world/level/GameRules.java
29+
@@ -245,6 +245,11 @@ public class GameRules {
30+
"predictableEnchantments", GameRules.Category.MISC, GameRules.BooleanValue.create(false)
31+
);
32+
// kitpvp end - Predicatable Enchantments
33+
+ // kitpvp start - Predicatable Projectiles
34+
+ public static final GameRules.Key<GameRules.BooleanValue> RULE_PREDICATBLE_PROJECTILES = register(
35+
+ "predictableProjectiles", GameRules.Category.MISC, GameRules.BooleanValue.create(false)
36+
+ );
37+
+ // kitpvp end - Predicatable Projectiles
38+
private final Map<GameRules.Key<?>, GameRules.Value<?>> rules;
39+
private final FeatureFlagSet enabledFeatures;
40+
private final GameRules.Value<?>[] gameruleArray; // Paper - Perf: Use array for gamerule storage

0 commit comments

Comments
 (0)