Paper/Spigot-Server-Patches/0129-Configurable-Cartographer-Treasure-Maps.patch
Techcable 87e3c18093
Make enableTreasureMaps apply to shipwreck loot generation
Fixes #3480
Previously it only controlled whether villagers could trade treasure maps.
Now it should apply to loot generated in treasure maps.

We don't unregister treasure maps from the loot table,
since this option is per-world and the table is global.
Instead I just replaced the implementation with a NOP.
2020-06-20 15:26:38 -04:00

64 lines
3.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 20 Dec 2016 15:26:27 -0500
Subject: [PATCH] Configurable Cartographer Treasure Maps
Allow configuring for cartographers to return the same map location
Also allow turning off treasure maps all together as they can eat up Map ID's
which are limited in quantity.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index bff2e9d26dc8057c3950d1b57ee2e7469e7f943c..f164844f339793860e773c499443ce160d0a6830 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -312,4 +312,14 @@ public class PaperWorldConfig {
Bukkit.getLogger().warning("Spawn Egg and Armor Stand NBT filtering disabled, this is a potential security risk");
}
}
+
+ public boolean enableTreasureMaps = true;
+ public boolean treasureMapsAlreadyDiscovered = false;
+ private void treasureMapsAlreadyDiscovered() {
+ enableTreasureMaps = getBoolean("enable-treasure-maps", true);
+ treasureMapsAlreadyDiscovered = getBoolean("treasure-maps-return-already-discovered", false);
+ if (treasureMapsAlreadyDiscovered) {
+ log("Treasure Maps will return already discovered locations");
+ }
+ }
}
diff --git a/src/main/java/net/minecraft/server/LootItemFunctionExplorationMap.java b/src/main/java/net/minecraft/server/LootItemFunctionExplorationMap.java
index 5fe0da76bd172c2c552b2dd210e89be214c4385c..f7220f057e313ad137fe01397e43c4a42afbccc1 100644
--- a/src/main/java/net/minecraft/server/LootItemFunctionExplorationMap.java
+++ b/src/main/java/net/minecraft/server/LootItemFunctionExplorationMap.java
@@ -42,6 +42,15 @@ public class LootItemFunctionExplorationMap extends LootItemFunctionConditional
if (blockposition != null) {
WorldServer worldserver = loottableinfo.c();
+ // Paper start
+ if (!worldserver.paperConfig.enableTreasureMaps) {
+ /*
+ * NOTE: I fear users will just get a plain map as their "treasure"
+ * This is preferable to disrespecting the config.
+ */
+ return itemstack;
+ }
+ // Paper end
BlockPosition blockposition1 = worldserver.a(this.d, blockposition, this.g, this.h);
if (blockposition1 != null) {
diff --git a/src/main/java/net/minecraft/server/VillagerTrades.java b/src/main/java/net/minecraft/server/VillagerTrades.java
index 3bcf0b385d1f707176dae9c3ee49370e2e6dd481..4764ffef77bf0a73018017a07103186a9ce55b8f 100644
--- a/src/main/java/net/minecraft/server/VillagerTrades.java
+++ b/src/main/java/net/minecraft/server/VillagerTrades.java
@@ -92,7 +92,8 @@ public class VillagerTrades {
return null;
} else {
WorldServer worldserver = (WorldServer) entity.world;
- BlockPosition blockposition = worldserver.a(this.b, new BlockPosition(entity), 100, true);
+ if (!worldserver.paperConfig.enableTreasureMaps) return null; //Paper
+ BlockPosition blockposition = worldserver.a(this.b, new BlockPosition(entity), 100, !worldserver.paperConfig.treasureMapsAlreadyDiscovered); //Paper
if (blockposition != null) {
ItemStack itemstack = ItemWorldMap.createFilledMapView(worldserver, blockposition.getX(), blockposition.getZ(), (byte) 2, true, true);