@@ -6,32 +6,35 @@ Subject: [PATCH] Dont run with scissors!
6
6
inspired by https://modrinth.com/mod/dont-run-with-scissors
7
7
8
8
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
9
- index b4cd58ae2c89cb3875cff2bcbe60511d94a926d4..10757591f1318222f79ff4e3df4c59bacfc41dee 100644
9
+ index b4cd58ae2c89cb3875cff2bcbe60511d94a926d4..c8cf05ac72a7b30e8d2239c4e07c9cc52d5990e2 100644
10
10
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
11
11
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
12
12
@@ -1721,6 +1721,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
13
13
this.player.tryResetCurrentImpulseContext();
14
14
}
15
15
16
16
+ // Purpur Start
17
- + if (this.player.level ().purpurConfig.dontRunWithScissors && this.player.isSprinting() && !(this.player.level ().purpurConfig.ignoreScissorsInWater && this.player.isInWater()) && !(this.player.level ().purpurConfig.ignoreScissorsInLava && this.player.isInLava()) && (isScissor (this.player.getItemInHand(InteractionHand.MAIN_HAND)) || isScissor (this.player.getItemInHand(InteractionHand.OFF_HAND))) && (int) (Math.random() * 10) == 0) {
18
- + this.player.hurt (this.player.damageSources().scissors(), (float) this.player.level ().purpurConfig.scissorsRunningDamage);
17
+ + if (this.player.serverLevel ().purpurConfig.dontRunWithScissors && this.player.isSprinting() && !(this.player.serverLevel ().purpurConfig.ignoreScissorsInWater && this.player.isInWater()) && !(this.player.serverLevel ().purpurConfig.ignoreScissorsInLava && this.player.isInLava()) && (isScissors (this.player.getItemInHand(InteractionHand.MAIN_HAND)) || isScissors (this.player.getItemInHand(InteractionHand.OFF_HAND))) && (int) (Math.random() * 10) == 0) {
18
+ + this.player.hurtServer (this.player.serverLevel(), this.player. damageSources().scissors(), (float) this.player.serverLevel ().purpurConfig.scissorsRunningDamage);
19
19
+ if (!org.purpurmc.purpur.PurpurConfig.dontRunWithScissors.isBlank()) this.player.sendActionBarMessage(org.purpurmc.purpur.PurpurConfig.dontRunWithScissors);
20
20
+ }
21
21
+ // Purpur End
22
22
+
23
23
this.player.checkMovementStatistics(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5);
24
24
this.lastGoodX = this.player.getX();
25
25
this.lastGoodY = this.player.getY();
26
- @@ -1760,6 +1767,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
26
+ @@ -1760,6 +1767,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
27
27
}
28
28
}
29
29
30
30
+ // Purpur start
31
- + public boolean isScissor (ItemStack stack) {
31
+ + public boolean isScissors (ItemStack stack) {
32
32
+ if (!stack.is(Items.SHEARS)) return false;
33
- + net.minecraft.world.item.component.CustomModelData customModelData = stack.get(net.minecraft.core.component.DataComponents.CUSTOM_MODEL_DATA);
34
- + return customModelData == null || customModelData.strings().contains("purpurmc:scissors");
33
+ +
34
+ + ResourceLocation itemModelReference = stack.get(net.minecraft.core.component.DataComponents.ITEM_MODEL);
35
+ + if (itemModelReference != null && itemModelReference.equals(this.player.serverLevel().purpurConfig.dontRunWithScissorsItemModelReference)) return true;
36
+ +
37
+ + return stack.getOrDefault(DataComponents.CUSTOM_MODEL_DATA, net.minecraft.world.item.component.CustomModelData.EMPTY).equals(net.minecraft.world.item.component.CustomModelData.EMPTY);
35
38
+ }
36
39
+ // Purpur end
37
40
+
@@ -149,25 +152,27 @@ index 64c84cb6cc647ca37a0664b83eb24e7202aeb1e2..28800c519ab8a6648d632a577ffbecae
149
152
150
153
public static String serverModName = io.papermc.paper.ServerBuildInfo.buildInfo().brandName();
151
154
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
152
- index 066a6407ed76a3a2b77541f24d4c3429d3a1a189..a980b4d3e1e4df4e2e2d7ecedafe23abe434fccb 100644
155
+ index 066a6407ed76a3a2b77541f24d4c3429d3a1a189..2fd0df56e94dca5ce91d0db29b56fa4bd5a2d1f2 100644
153
156
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
154
157
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
155
- @@ -191,6 +191,10 @@ public class PurpurWorldConfig {
158
+ @@ -191,6 +191,11 @@ public class PurpurWorldConfig {
156
159
public List<Item> itemImmuneToExplosion = new ArrayList<>();
157
160
public List<Item> itemImmuneToFire = new ArrayList<>();
158
161
public List<Item> itemImmuneToLightning = new ArrayList<>();
159
162
+ public boolean dontRunWithScissors = false;
163
+ + public ResourceLocation dontRunWithScissorsItemModelReference = ResourceLocation.parse("purpurmc:scissors");
160
164
+ public boolean ignoreScissorsInWater = false;
161
165
+ public boolean ignoreScissorsInLava = false;
162
166
+ public double scissorsRunningDamage = 1D;
163
167
private void itemSettings() {
164
168
itemImmuneToCactus.clear();
165
169
getList("gameplay-mechanics.item.immune.cactus", new ArrayList<>()).forEach(key -> {
166
- @@ -228,6 +232,10 @@ public class PurpurWorldConfig {
170
+ @@ -228,6 +233,11 @@ public class PurpurWorldConfig {
167
171
Item item = BuiltInRegistries.ITEM.getValue(ResourceLocation.parse(key.toString()));
168
172
if (item != Items.AIR) itemImmuneToLightning.add(item);
169
173
});
170
174
+ dontRunWithScissors = getBoolean("gameplay-mechanics.item.shears.damage-if-sprinting", dontRunWithScissors);
175
+ + dontRunWithScissorsItemModelReference = ResourceLocation.parse(getString("gameplay-mechanics.item.shears.damage-if-sprinting-item-model", "purpurmc:scissors"));
171
176
+ ignoreScissorsInWater = getBoolean("gameplay-mechanics.item.shears.ignore-in-water", ignoreScissorsInWater);
172
177
+ ignoreScissorsInLava = getBoolean("gameplay-mechanics.item.shears.ignore-in-lava", ignoreScissorsInLava);
173
178
+ scissorsRunningDamage = getDouble("gameplay-mechanics.item.shears.sprinting-damage", scissorsRunningDamage);
0 commit comments