Files
Purpur/patches/server-unmapped/0183-Add-config-for-villager-trading.patch
2021-06-14 17:32:55 -04:00

69 lines
4.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ben Kerllenevich <me@notom3ga.me>
Date: Thu, 18 Mar 2021 07:23:27 -0400
Subject: [PATCH] Add config for villager trading
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
index b36f62b38888d6eb64d46ac67c89a4189aafcfc4..66863b31687a41f84f722c611064f7ad31e02488 100644
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
@@ -369,7 +369,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
return tryRide(entityhuman, enumhand); // Purpur
} else {
if (world.purpurConfig.villagerRidable && itemstack.isEmpty()) return tryRide(entityhuman, enumhand); // Purpur
- if (!this.world.isClientSide && !this.trades.isEmpty()) {
+ if (!this.world.isClientSide && this.world.purpurConfig.villagerAllowTrading && !this.trades.isEmpty()) { // Purpur
this.h(entityhuman);
}
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java
index f6e0a92037d22de102c42cc1953ea90919bd3a34..03e811e854034c6ca9cd11d35ed0a2dbd14c6097 100644
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java
@@ -146,7 +146,7 @@ public class EntityVillagerTrader extends EntityVillagerAbstract {
return tryRide(entityhuman, enumhand); // Purpur
} else {
if (world.purpurConfig.villagerTraderRidable && itemstack.isEmpty()) return tryRide(entityhuman, enumhand); // Purpur
- if (!this.world.isClientSide) {
+ if (!this.world.isClientSide && this.world.purpurConfig.villagerTraderAllowTrading) {
this.setTradingPlayer(entityhuman);
this.openTrade(entityhuman, this.getScoreboardDisplayName(), 1);
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index c87ce9aed539f382e91fcfae956339068a618b79..c2314380e7064459dd104b09b900c5a28b592b71 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1772,6 +1772,7 @@ public class PurpurWorldConfig {
public boolean villagerClericsFarmWarts = false;
public boolean villagerClericFarmersThrowWarts = true;
public double villagerMaxHealth = 20.0D;
+ public boolean villagerAllowTrading = true;
private void villagerSettings() {
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
@@ -1799,6 +1800,7 @@ public class PurpurWorldConfig {
set("mobs.villager.attributes.max_health", oldValue);
}
villagerMaxHealth = getDouble("mobs.villager.attributes.max_health", villagerMaxHealth);
+ villagerAllowTrading = getBoolean("mobs.villager.allow-trading", villagerAllowTrading);
}
public boolean villagerTraderRidable = false;
@@ -1806,6 +1808,7 @@ public class PurpurWorldConfig {
public boolean villagerTraderCanBeLeashed = false;
public boolean villagerTraderFollowEmeraldBlock = false;
public double villagerTraderMaxHealth = 20.0D;
+ public boolean villagerTraderAllowTrading = true;
private void villagerTraderSettings() {
villagerTraderRidable = getBoolean("mobs.wandering_trader.ridable", villagerTraderRidable);
villagerTraderRidableInWater = getBoolean("mobs.wandering_trader.ridable-in-water", villagerTraderRidableInWater);
@@ -1817,6 +1820,7 @@ public class PurpurWorldConfig {
set("mobs.wandering_trader.attributes.max_health", oldValue);
}
villagerTraderMaxHealth = getDouble("mobs.wandering_trader.attributes.max_health", villagerTraderMaxHealth);
+ villagerTraderAllowTrading = getBoolean("mobs.wandering_trader.allow-trading", villagerTraderAllowTrading);
}
public boolean vindicatorRidable = false;