2021-06-11 12:02:28 +00:00
|
|
|
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
|
2022-03-11 20:13:46 +00:00
|
|
|
index 7320f07beffee60fe3c49016daf7a98658879a27..5183c756289db3600d04d473c20d08768af91ea9 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2022-03-11 20:13:46 +00:00
|
|
|
@@ -355,4 +355,14 @@ public class PaperWorldConfig {
|
2021-06-11 12:02:28 +00:00
|
|
|
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/world/entity/npc/VillagerTrades.java b/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java
|
2022-03-01 05:43:03 +00:00
|
|
|
index 7eda0af21ce7662e9bb6d47c79e175a060a8bb13..52382b5b8149351ecf981d5414a0a50025f181c7 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -386,7 +386,8 @@ public class VillagerTrades {
|
2021-06-11 12:02:28 +00:00
|
|
|
return null;
|
|
|
|
} else {
|
2021-06-12 07:24:28 +00:00
|
|
|
ServerLevel serverLevel = (ServerLevel)entity.level;
|
|
|
|
- BlockPos blockPos = serverLevel.findNearestMapFeature(this.destination, entity.blockPosition(), 100, true);
|
|
|
|
+ if (!serverLevel.paperConfig.enableTreasureMaps) return null; // Paper
|
|
|
|
+ BlockPos blockPos = serverLevel.findNearestMapFeature(this.destination, entity.blockPosition(), 100, !serverLevel.paperConfig.treasureMapsAlreadyDiscovered); // Paper
|
|
|
|
if (blockPos != null) {
|
|
|
|
ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), (byte)2, true, true);
|
|
|
|
MapItem.renderBiomePreviewMap(serverLevel, itemStack);
|
2021-06-11 12:02:28 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java b/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java
|
2022-03-01 05:43:03 +00:00
|
|
|
index 385cae45ef8cbaf9f09472585e6f639eea3e0331..722930d400a35140542b742ae8ae1784ecfa0e33 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -68,7 +68,16 @@ public class ExplorationMapFunction extends LootItemConditionalFunction {
|
2021-06-12 07:24:28 +00:00
|
|
|
Vec3 vec3 = context.getParamOrNull(LootContextParams.ORIGIN);
|
|
|
|
if (vec3 != null) {
|
|
|
|
ServerLevel serverLevel = context.getLevel();
|
|
|
|
- BlockPos blockPos = serverLevel.findNearestMapFeature(this.destination, new BlockPos(vec3), this.searchRadius, this.skipKnownStructures);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ // Paper start
|
2021-06-12 07:24:28 +00:00
|
|
|
+ if (!serverLevel.paperConfig.enableTreasureMaps) {
|
2021-06-11 12:02:28 +00:00
|
|
|
+ /*
|
|
|
|
+ * NOTE: I fear users will just get a plain map as their "treasure"
|
|
|
|
+ * This is preferable to disrespecting the config.
|
|
|
|
+ */
|
|
|
|
+ return stack;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2021-06-12 07:24:28 +00:00
|
|
|
+ BlockPos blockPos = serverLevel.findNearestMapFeature(this.destination, new BlockPos(vec3), this.searchRadius, !serverLevel.paperConfig.treasureMapsAlreadyDiscovered && this.skipKnownStructures); // Paper
|
|
|
|
if (blockPos != null) {
|
|
|
|
ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), this.zoom, true, true);
|
|
|
|
MapItem.renderBiomePreviewMap(serverLevel, itemStack);
|