-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch VillagerTrades.EmeraldsForVillagerTypeItem to allow modders to …
…make Custom Villager Types
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
patches/net/minecraft/world/entity/npc/VillagerTrades.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- a/net/minecraft/world/entity/npc/VillagerTrades.java | ||
+++ b/net/minecraft/world/entity/npc/VillagerTrades.java | ||
@@ -1484,9 +_,6 @@ | ||
private final int villagerXp; | ||
|
||
public EmeraldsForVillagerTypeItem(int p_35669_, int p_35670_, int p_35671_, Map<VillagerType, Item> p_35672_) { | ||
- BuiltInRegistries.VILLAGER_TYPE.stream().filter(p_35680_ -> !p_35672_.containsKey(p_35680_)).findAny().ifPresent(p_339515_ -> { | ||
- throw new IllegalStateException("Missing trade for villager type: " + BuiltInRegistries.VILLAGER_TYPE.getKey(p_339515_)); | ||
- }); | ||
this.trades = p_35672_; | ||
this.cost = p_35669_; | ||
this.maxUses = p_35670_; | ||
@@ -1498,6 +_,9 @@ | ||
public MerchantOffer getOffer(Entity p_219685_, RandomSource p_219686_) { | ||
if (p_219685_ instanceof VillagerDataHolder villagerdataholder) { | ||
ItemCost itemcost = new ItemCost(this.trades.get(villagerdataholder.getVillagerData().getType()), this.cost); | ||
+ if (itemcost.itemStack().isEmpty()) { | ||
+ return null; | ||
+ } | ||
return new MerchantOffer(itemcost, new ItemStack(Items.EMERALD), this.maxUses, this.villagerXp, 0.05F); | ||
} else { | ||
return null; |