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/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 2e67a26419c706d78bd793bd616cbbff704833bb..43d124818c4538bc0d84111dfab25c38aab249c1 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1555,6 +1555,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
                                     this.player.fallDistance = 0.0F;
                                 }
 
+                                // Purpur Start
+                                if (this.player.isSprinting() && this.player.level.purpurConfig.dontRunWithScissors && (this.player.getItemInHand(InteractionHand.MAIN_HAND).getItem() == Items.SHEARS || this.player.getItemInHand(InteractionHand.OFF_HAND).getItem() == Items.SHEARS) && (int) (Math.random() * 10) == 0) {
+                                    this.player.hurt(net.minecraft.world.damagesource.DamageSource.MAGIC, (float) this.player.level.purpurConfig.scissorsRunningDamage);
+                                    if (!net.pl3x.purpur.PurpurConfig.dontRunWithScissors.isBlank()) this.player.sendActionBarMessage(net.pl3x.purpur.PurpurConfig.dontRunWithScissors);
+                                }
+                                // Purpur End
+
                                 this.player.checkMovementStatistics(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5);
                                 this.lastGoodX = this.player.getX();
                                 this.lastGoodY = this.player.getY();
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
index da4d5b05cf2daa31ecd70d2815017bbb6e771313..ccd228aa323eef108526640dfe03b07541041236 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -165,6 +165,7 @@ public class PurpurConfig {
     public static String creditsCommandOutput = "<green>%s has been shown the end credits";
     public static String demoCommandOutput = "<green>%s has been shown the demo screen";
     public static String pingCommandOutput = "<green>%s's ping is %sms";
+    public static String dontRunWithScissors = "<red><italic>Don't run with scissors!";
     private static void messages() {
         cannotRideMob = getString("settings.messages.cannot-ride-mob", cannotRideMob);
         afkBroadcastAway = getString("settings.messages.afk-broadcast-away", afkBroadcastAway);
@@ -174,6 +175,7 @@ public class PurpurConfig {
         creditsCommandOutput = getString("settings.messages.credits-command-output", creditsCommandOutput);
         demoCommandOutput = getString("settings.messages.demo-command-output", demoCommandOutput);
         pingCommandOutput = getString("settings.messages.ping-command-output", pingCommandOutput);
+        dontRunWithScissors = getString("settings.messages.dont-run-with-scissors", dontRunWithScissors);
     }
 
     public static int seedFeatureBamboo = -1;
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index ee84e6aef5c0e747c71c2b345eebfb99da406b8d..7ea2cf4712963cbb2a750ade4d5609ee49be9732 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -156,6 +156,8 @@ public class PurpurWorldConfig {
     public List<Item> itemImmuneToExplosion = new ArrayList<>();
     public List<Item> itemImmuneToFire = new ArrayList<>();
     public List<Item> itemImmuneToLightning = 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 -> {
@@ -193,6 +195,8 @@ public class PurpurWorldConfig {
             Item item = Registry.ITEM.get(new ResourceLocation(key.toString()));
             if (item != Items.AIR) itemImmuneToLightning.add(item);
         });
+        dontRunWithScissors = getBoolean("gameplay-mechanics.item.shears.damage-if-sprinting", dontRunWithScissors);
+        scissorsRunningDamage = getDouble("gameplay-mechanics.item.shears.sprinting-damage", scissorsRunningDamage);
     }
 
     public double minecartMaxSpeed = 0.4D;
