|
1 | 1 | --- a/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java |
2 | 2 | +++ b/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java |
3 | | -@@ -83,9 +_,17 @@ |
| 3 | +@@ -83,9 +_,25 @@ |
4 | 4 | Vec3 lootPos = context.getOptionalParameter(LootContextParams.ORIGIN); |
5 | 5 | if (lootPos != null) { |
6 | 6 | ServerLevel level = context.getLevel(); |
7 | 7 | + // Paper start - Configurable cartographer treasure maps |
| 8 | ++ // Simple heuristic for determining if this function is running in the context of a villager selecting |
| 9 | ++ // an item for its offers. Technically other callers could satisfiy this but this minimises the diff and |
| 10 | ++ // works for all plain vanilla usecases. |
| 11 | ++ final boolean runningForVillagerTrade = context.hasParameter(LootContextParams.ADDITIONAL_COST_COMPONENT_ALLOWED) |
| 12 | ++ && context.getOptionalParameter(LootContextParams.THIS_ENTITY) instanceof net.minecraft.world.entity.npc.villager.AbstractVillager; |
8 | 13 | + if (!level.paperConfig().environment.treasureMaps.enabled) { |
9 | 14 | + /* |
10 | 15 | + * NOTE: I fear users will just get a plain map as their "treasure" |
11 | 16 | + * This is preferable to disrespecting the config. |
12 | 17 | + */ |
13 | | -+ return itemStack; |
| 18 | ++ return runningForVillagerTrade ? net.minecraft.world.item.ItemStack.EMPTY : itemStack; |
14 | 19 | + } |
| 20 | ++ final boolean shouldSkipKnownStructures = runningForVillagerTrade |
| 21 | ++ ? !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager |
| 22 | ++ : !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredLootTable.or(!this.skipKnownStructures); |
15 | 23 | + // Paper end - Configurable cartographer treasure maps |
16 | 24 | BlockPos nearestMapStructure = level.findNearestMapStructure( |
17 | 25 | - this.destination, BlockPos.containing(lootPos), this.searchRadius, this.skipKnownStructures |
18 | 26 | - ); |
19 | | -+ this.destination, BlockPos.containing(lootPos), this.searchRadius, !level.paperConfig().environment.treasureMaps.findAlreadyDiscoveredLootTable.or(!this.skipKnownStructures)); // Paper - Configurable cartographer treasure maps |
| 27 | ++ this.destination, BlockPos.containing(lootPos), this.searchRadius, shouldSkipKnownStructures); // Paper - Configurable cartographer treasure maps |
20 | 28 | if (nearestMapStructure != null) { |
21 | 29 | ItemStack map = MapItem.create(level, nearestMapStructure.getX(), nearestMapStructure.getZ(), this.zoom, true, true); |
22 | 30 | MapItem.renderBiomePreviewMap(level, map); |
0 commit comments