Paper/patches/unapplied/server/0118-Configurable-Cartographer-Treasure-Maps.patch

47 lines
3.4 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02: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/net/minecraft/world/entity/npc/VillagerTrades.java b/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java
index f95999daa1955dd4d919d0e668fe099901a0481c..770a91fcc351a2d1de4762c0fd9bae2b49c363b5 100644
2021-06-11 14:02:28 +02: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 06:43:03 +01:00
@@ -386,7 +386,8 @@ public class VillagerTrades {
2021-06-11 14:02:28 +02:00
return null;
} else {
ServerLevel serverLevel = (ServerLevel)entity.level;
2022-06-07 21:55:39 +02:00
- BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, entity.blockPosition(), 100, true);
+ if (!serverLevel.paperConfig().environment.treasureMaps.enabled) return null; // Paper
+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, entity.blockPosition(), 100, !serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper
if (blockPos != null) {
ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), (byte)2, true, true);
MapItem.renderBiomePreviewMap(serverLevel, itemStack);
2021-06-11 14:02:28 +02: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
index 321384730cacbdc22eedc53651e4d24f06c73b99..b734c0f9b831c20a239b5341ff3a0b4d6a6c102c 100644
2021-06-11 14:02:28 +02: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 06:43:03 +01:00
@@ -68,7 +68,16 @@ public class ExplorationMapFunction extends LootItemConditionalFunction {
Vec3 vec3 = context.getParamOrNull(LootContextParams.ORIGIN);
if (vec3 != null) {
ServerLevel serverLevel = context.getLevel();
2022-06-07 21:55:39 +02:00
- BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, new BlockPos(vec3), this.searchRadius, this.skipKnownStructures);
2021-06-11 14:02:28 +02:00
+ // Paper start
+ if (!serverLevel.paperConfig().environment.treasureMaps.enabled) {
2021-06-11 14:02:28 +02: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
+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, new BlockPos(vec3), this.searchRadius, serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredLootTable.or(this.skipKnownStructures)); // Paper
if (blockPos != null) {
ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), this.zoom, true, true);
MapItem.renderBiomePreviewMap(serverLevel, itemStack);