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
|
2024-01-22 19:01:10 +01:00
|
|
|
index 43fb44b8cd164b0815335a32f04879b301a54728..318b7c7cb2a88e8d4dc4456154431fe7bfe2e0dc 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
|
2023-09-21 22:35:39 +02:00
|
|
|
@@ -451,7 +451,8 @@ public class VillagerTrades {
|
2021-06-11 14:02:28 +02:00
|
|
|
return null;
|
|
|
|
} else {
|
2023-06-07 21:19:26 +02:00
|
|
|
ServerLevel serverLevel = (ServerLevel)entity.level();
|
2022-06-07 21:55:39 +02:00
|
|
|
- BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, entity.blockPosition(), 100, true);
|
2024-01-22 19:01:10 +01:00
|
|
|
+ if (!serverLevel.paperConfig().environment.treasureMaps.enabled) return null; // Paper - Configurable cartographer treasure maps
|
|
|
|
+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, entity.blockPosition(), 100, !serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper - Configurable cartographer treasure maps
|
2021-06-12 09:24:28 +02:00
|
|
|
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
|
2024-01-22 19:01:10 +01:00
|
|
|
index dcc6da6641e78cd80bd148ba644475811a1fbf4d..76b6544e75e52f931bed5bd9b25eda41957beaf7 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
|
2023-09-21 22:35:39 +02:00
|
|
|
@@ -75,7 +75,16 @@ public class ExplorationMapFunction extends LootItemConditionalFunction {
|
2021-06-12 09:24:28 +02:00
|
|
|
Vec3 vec3 = context.getParamOrNull(LootContextParams.ORIGIN);
|
|
|
|
if (vec3 != null) {
|
|
|
|
ServerLevel serverLevel = context.getLevel();
|
2023-03-14 19:36:39 +01:00
|
|
|
- BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, BlockPos.containing(vec3), this.searchRadius, this.skipKnownStructures);
|
2024-01-22 19:01:10 +01:00
|
|
|
+ // Paper start - Configurable cartographer treasure maps
|
2022-06-09 10:51:45 +02:00
|
|
|
+ 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;
|
|
|
|
+ }
|
2024-01-22 19:01:10 +01:00
|
|
|
+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, BlockPos.containing(vec3), this.searchRadius, !serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredLootTable.or(!this.skipKnownStructures));
|
|
|
|
+ // Paper end - Configurable cartographer treasure maps
|
2021-06-12 09:24:28 +02:00
|
|
|
if (blockPos != null) {
|
|
|
|
ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), this.zoom, true, true);
|
|
|
|
MapItem.renderBiomePreviewMap(serverLevel, itemStack);
|