Pigs give saddle back

This commit is contained in:
William Blake Galbreath
2025-01-05 14:36:00 -08:00
committed by granny
parent ae7a31be29
commit 628a35f045
3 changed files with 24 additions and 48 deletions

View File

@@ -1,48 +0,0 @@
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/net/minecraft/world/entity/animal/Pig.java b/net/minecraft/world/entity/animal/Pig.java
index b7e4e4bbb85a44e0f2cd49a1419216ca3c526cd7..f9efd4c1fc30f2bbb061d31ded6e45c546b0bfa8 100644
--- a/net/minecraft/world/entity/animal/Pig.java
+++ b/net/minecraft/world/entity/animal/Pig.java
@@ -181,6 +181,17 @@ public class Pig extends Animal implements ItemSteerable, Saddleable {
public InteractionResult mobInteract(Player player, InteractionHand hand) {
boolean flag = this.isFood(player.getItemInHand(hand));
+ if (level().purpurConfig.pigGiveSaddleBack && player.isSecondaryUseActive() && !flag && isSaddled() && !isVehicle()) {
+ 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;
+ }
+
if (!flag && this.isSaddled() && !this.isVehicle() && !player.isSecondaryUseActive()) {
if (!this.level().isClientSide) {
player.startRiding(this);
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 6eb25a9b4bb634e57f6de015c9a9f2fc78d0b86f..419ebb012056d131d6d1b10c8bd72511a1c4df74 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1016,6 +1016,7 @@ public class PurpurWorldConfig {
public boolean pigControllable = true;
public double pigMaxHealth = 10.0D;
public double pigScale = 1.0D;
+ public boolean pigGiveSaddleBack = false;
private void pigSettings() {
pigRidable = getBoolean("mobs.pig.ridable", pigRidable);
pigRidableInWater = getBoolean("mobs.pig.ridable-in-water", pigRidableInWater);
@@ -1027,6 +1028,7 @@ public class PurpurWorldConfig {
}
pigMaxHealth = getDouble("mobs.pig.attributes.max_health", pigMaxHealth);
pigScale = Mth.clamp(getDouble("mobs.pig.attributes.scale", pigScale), 0.0625D, 16.0D);
+ pigGiveSaddleBack = getBoolean("mobs.pig.give-saddle-back", pigGiveSaddleBack);
}
public boolean piglinRidable = false;

View File

@@ -0,0 +1,22 @@
--- a/net/minecraft/world/entity/animal/Pig.java
+++ b/net/minecraft/world/entity/animal/Pig.java
@@ -132,6 +_,19 @@
@Override
public InteractionResult mobInteract(Player player, InteractionHand hand) {
boolean isFood = this.isFood(player.getItemInHand(hand));
+ // Purpur start - Pigs give saddle back
+ if (level().purpurConfig.pigGiveSaddleBack && player.isSecondaryUseActive() && !isFood && isSaddled() && !isVehicle()) {
+ 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 - Pigs give saddle back
+
if (!isFood && this.isSaddled() && !this.isVehicle() && !player.isSecondaryUseActive()) {
if (!this.level().isClientSide) {
player.startRiding(this);

View File

@@ -1002,6 +1002,7 @@ public class PurpurWorldConfig {
public boolean pigControllable = true;
public double pigMaxHealth = 10.0D;
public double pigScale = 1.0D;
public boolean pigGiveSaddleBack = false;
private void pigSettings() {
pigRidable = getBoolean("mobs.pig.ridable", pigRidable);
pigRidableInWater = getBoolean("mobs.pig.ridable-in-water", pigRidableInWater);
@@ -1013,6 +1014,7 @@ public class PurpurWorldConfig {
}
pigMaxHealth = getDouble("mobs.pig.attributes.max_health", pigMaxHealth);
pigScale = Mth.clamp(getDouble("mobs.pig.attributes.scale", pigScale), 0.0625D, 16.0D);
pigGiveSaddleBack = getBoolean("mobs.pig.give-saddle-back", pigGiveSaddleBack);
}
public boolean piglinRidable = false;