From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JustDoom <justdoomdev@gmail.com>
Date: Fri, 5 Mar 2021 14:23:16 -0500
Subject: [PATCH] Dont run with scissors!


diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
index 0fc053def9e632543c3ba54e5a700518efba95d8..7abd1e47b6f3bed48228ed6dc2a6a27a877e03c2 100644
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
@@ -1547,6 +1547,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
                                     this.player.fallDistance = 0.0F;
                                 }
 
+                                // Purpur Start
+                                if (this.player.isSprinting() && this.player.getWorldServer().purpurConfig.dontRunWithScissors && (this.player.getItemInHand(EnumHand.MAIN_HAND).getItem() == Items.SHEARS || this.player.getItemInHand(EnumHand.OFF_HAND).getItem() == Items.SHEARS) && (int) (Math.random() * 10) == 0) {
+                                    this.player.damageEntity(net.minecraft.world.damagesource.DamageSource.MAGIC, (float) this.player.getWorldServer().purpurConfig.scissorsRunningDamage);
+                                }
+                                // Purpur End
+
                                 this.player.checkMovement(this.player.locX() - d0, this.player.locY() - d1, this.player.locZ() - d2);
                                 this.o = this.player.locX();
                                 this.p = this.player.locY();
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 7afc05f54f4b2fda3b250cb8fd1973247be5933f..bd3a7b45746ec2981cd4f6373e7af11ac668bba6 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -168,6 +168,8 @@ public class PurpurWorldConfig {
     public List<Item> itemImmuneToCactus = new ArrayList<>();
     public List<Item> itemImmuneToExplosion = new ArrayList<>();
     public List<Item> itemImmuneToFire = new ArrayList<>();
+    public boolean dontRunWithScissors = false;
+    public double scissorsRunningDamage = 1D;
     private void itemSettings() {
         itemImmuneToCactus.clear();
         getList("gameplay-mechanics.item.immune.cactus", new ArrayList<>()).forEach(key -> {
@@ -196,6 +198,8 @@ public class PurpurWorldConfig {
             Item item = IRegistry.ITEM.get(new MinecraftKey(key.toString()));
             if (item != Items.AIR) itemImmuneToFire.add(item);
         });
+        dontRunWithScissors = getBoolean("gameplay-mechanics.item.shears.damage-if-sprinting", dontRunWithScissors);
+        scissorsRunningDamage = getDouble("gameplay-mechanics.item.shears.sprinting-damage", scissorsRunningDamage);
     }
 
     public boolean idleTimeoutKick = true;
