From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Mon, 5 Oct 2020 12:15:14 -0500
Subject: [PATCH] Stonecutter damage


diff --git a/src/main/java/net/minecraft/world/level/block/BlockStonecutter.java b/src/main/java/net/minecraft/world/level/block/BlockStonecutter.java
index 54c9586cd7f8c9691a1c7ded9c9c96b0f316b0b6..988204918854e982e334eb2417b83914b58cbcf6 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockStonecutter.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockStonecutter.java
@@ -10,6 +10,9 @@ import net.minecraft.world.EnumHand;
 import net.minecraft.world.EnumInteractionResult;
 import net.minecraft.world.ITileInventory;
 import net.minecraft.world.TileInventory;
+import net.minecraft.world.damagesource.DamageSource;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.EntityLiving;
 import net.minecraft.world.entity.player.EntityHuman;
 import net.minecraft.world.inventory.ContainerAccess;
 import net.minecraft.world.inventory.ContainerStonecutter;
@@ -94,4 +97,16 @@ public class BlockStonecutter extends Block {
     public boolean a(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition, PathMode pathmode) {
         return false;
     }
+
+    // Purpur start
+    @Override
+    public void stepOn(World world, BlockPosition pos, Entity entity) {
+        if (world.purpurConfig.stonecutterDamage > 0.0F && entity instanceof EntityLiving) {
+            org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
+            entity.damageEntity(DamageSource.CACTUS, world.purpurConfig.stonecutterDamage);
+            org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null;
+        }
+        super.stepOn(world, pos, entity);
+    }
+    // Purpur end
 }
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathfinderNormal.java b/src/main/java/net/minecraft/world/level/pathfinder/PathfinderNormal.java
index 7b92a54cfb64fb77af99e6bf66eacbdb9e769dc1..9d08094165cf18d99116b5c721fff888f3cb42e2 100644
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathfinderNormal.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathfinderNormal.java
@@ -503,7 +503,7 @@ public class PathfinderNormal extends PathfinderAbstract {
                             return iblockdata.neighbourOverridePathType = PathType.DANGER_CACTUS; // Tuinity - reduce pathfinder branching
                         }
 
-                        if (iblockdata.a(Blocks.SWEET_BERRY_BUSH)) {
+                        if (iblockdata.a(Blocks.SWEET_BERRY_BUSH) || iblockdata.a(Blocks.STONECUTTER)) { // Purpur
                             return iblockdata.neighbourOverridePathType = PathType.DANGER_OTHER; // Tuinity - reduce pathfinder branching
                         }
 
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index c14fcd0c46b1f5ca6b827632cb37dd5f7e3eb6cd..8dda3c6aab016c52cf8cc2ee663087cbe9099681 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -395,6 +395,11 @@ public class PurpurWorldConfig {
         spawnerDeactivateByRedstone = getBoolean("blocks.spawner.deactivate-by-redstone", spawnerDeactivateByRedstone);
     }
 
+    public float stonecutterDamage = 0.0F;
+    private void stonecutterSettings() {
+        stonecutterDamage = (float) getDouble("blocks.stonecutter.damage", stonecutterDamage);
+    }
+
     public boolean turtleEggsBreakFromExpOrbs = true;
     public boolean turtleEggsBreakFromItems = true;
     public boolean turtleEggsBreakFromMinecarts = true;
