From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sun, 12 May 2019 01:14:46 -0500
Subject: [PATCH] Pigs give saddle back


diff --git a/src/main/java/net/minecraft/world/entity/animal/Pig.java b/src/main/java/net/minecraft/world/entity/animal/Pig.java
index f4a099e691dce3c57069e76d67859161b459098e..518d28dc0b5b8c04263c93a4347e4c971a1318d8 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Pig.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Pig.java
@@ -173,6 +173,18 @@ public class Pig extends Animal implements ItemSteerable, Saddleable {
 
         if (!flag && this.isSaddled() && !this.isVehicle() && !player.isSecondaryUseActive()) {
             if (!this.level.isClientSide) {
+                // Purpur start
+                if (level.purpurConfig.pigGiveSaddleBack && player.isCrouching()) {
+                    this.steering.setSaddle(false);
+                    if (!player.getAbilities().instabuild) {
+                        ItemStack saddle = new ItemStack(Items.SADDLE);
+                        if (!player.getInventory().add(saddle)) {
+                            player.drop(saddle, false);
+                        }
+                    }
+                    return InteractionResult.SUCCESS;
+                }
+                // Purpur end
                 player.startRiding(this);
             }
 
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 9381e25068d1d75ccfa949307f9cd02794724af4..63b1858a91050ffc0720532ee872e7c458ec5a5d 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -771,6 +771,7 @@ public class PurpurWorldConfig {
     public boolean pigRidable = false;
     public boolean pigRidableInWater = false;
     public double pigMaxHealth = 10.0D;
+    public boolean pigGiveSaddleBack = false;
     private void pigSettings() {
         pigRidable = getBoolean("mobs.pig.ridable", pigRidable);
         pigRidableInWater = getBoolean("mobs.pig.ridable-in-water", pigRidableInWater);
@@ -780,6 +781,7 @@ public class PurpurWorldConfig {
             set("mobs.pig.attributes.max_health", oldValue);
         }
         pigMaxHealth = getDouble("mobs.pig.attributes.max_health", pigMaxHealth);
+        pigGiveSaddleBack = getBoolean("mobs.pig.give-saddle-back", pigGiveSaddleBack);
     }
 
     public boolean piglinRidable = false;
