geforkt von Mirrors/Paper
77a5779e24
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2ec53f49 PR-1050: Fix empty result check for Complex Recipes 10671012 PR-1044: Add CrafterCraftEvent 4d87ffe0 Use correct method in JavaDoc ae5e5817 SPIGOT-7850: Add API for Bogged shear state 46b6d445 SPIGOT-7837: Support data pack banner patterns d5d0cefc Fix JavaDoc error b3c2b83d PR-1036: Add API for InventoryView derivatives 1fe2c75a SPIGOT-7809: Add ShieldMeta CraftBukkit Changes: 8ee6fd1b8 SPIGOT-7857: Improve ItemMeta block data deserialization 8f26c30c6 SPIGOT-7857: Fix spurious internal NBT tag when deserializing BlockStateMeta 759061b93 SPIGOT-7855: Fire does not spread or burn blocks 00fc9fb64 SPIGOT-7853: AnvilInventory#getRepairCost() always returns 0 7501e2e04 PR-1450: Add CrafterCraftEvent 8c51673e7 SPIGOT-5731: PortalCreateEvent#getEntity returns null for nether portals ignited by flint and steel d53d0d0b1 PR-1456: Fix inverted logic in CraftCrafterView#setSlotDisabled 682a678c8 SPIGOT-7850: Add API for Bogged shear state fccf5243a SPIGOT-7837: Support data pack banner patterns 9c3bd4390 PR-1431: Add API for InventoryView derivatives 0cc6acbc4 SPIGOT-7849: Fix FoodComponent serialize with "using-converts-to" using null 2c5474952 Don't rely on tags for CraftItemMetas 20d107e46 SPIGOT-7846: Fix ItemMeta for hanging signs 76f59e315 Remove redundant clone in Dropper InventoryMoveItemEvent e61a53d25 SPIGOT-7817: Call InventoryMoveItemEvent for Crafters 894682e2d SPIGOT-7839: Remove redundant Java version checks 2c12b2187 SPIGOT-7809: Add ShieldMeta and fix setting shield base colours Spigot Changes: fb8fb722 Rebuild patches 34bd42b7 SPIGOT-7835: Fix issue with custom hopper settings
151 Zeilen
9.4 KiB
Diff
151 Zeilen
9.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Mariell Hoversholm <proximyst@proximyst.com>
|
|
Date: Mon, 9 Nov 2020 20:44:51 +0100
|
|
Subject: [PATCH] Add ignore discounts API
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
index e23674dd5db3c429efd3b7c71fe36b420494c03a..9d5a5a7fff7f75871e167f83edb0e9d5348748d7 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -493,6 +493,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
|
|
while (iterator.hasNext()) {
|
|
MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
|
|
+ if (merchantrecipe.ignoreDiscounts) continue; // Paper - Add ignore discounts API
|
|
|
|
merchantrecipe.addToSpecialPriceDiff(-Mth.floor((float) i * merchantrecipe.getPriceMultiplier()));
|
|
}
|
|
@@ -505,6 +506,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
|
|
while (iterator1.hasNext()) {
|
|
MerchantOffer merchantrecipe1 = (MerchantOffer) iterator1.next();
|
|
+ if (merchantrecipe1.ignoreDiscounts) continue; // Paper - Add ignore discounts API
|
|
double d0 = 0.3D + 0.0625D * (double) j;
|
|
int k = (int) Math.floor(d0 * (double) merchantrecipe1.getBaseCostA().getCount());
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
|
index 89982d25f60c8b60ba91e559ef88278f338fe215..0efc8d997b34302c3e0a5d7ec73a11a940dbeefe 100644
|
|
--- a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
|
+++ b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
|
@@ -33,6 +33,10 @@ public class MerchantOffer {
|
|
return merchantrecipe.priceMultiplier;
|
|
}), Codec.INT.lenientOptionalFieldOf("xp", 1).forGetter((merchantrecipe) -> {
|
|
return merchantrecipe.xp;
|
|
+ // Paper start
|
|
+ }), Codec.BOOL.lenientOptionalFieldOf("Paper.IgnoreDiscounts", false).forGetter((merchantrecipe) -> {
|
|
+ return merchantrecipe.ignoreDiscounts;
|
|
+ // Paper end
|
|
})).apply(instance, MerchantOffer::new);
|
|
});
|
|
public static final StreamCodec<RegistryFriendlyByteBuf, MerchantOffer> STREAM_CODEC = StreamCodec.of(MerchantOffer::writeToStream, MerchantOffer::createFromStream);
|
|
@@ -46,6 +50,7 @@ public class MerchantOffer {
|
|
public int demand;
|
|
public float priceMultiplier;
|
|
public int xp;
|
|
+ public boolean ignoreDiscounts; // Paper - Add ignore discounts API
|
|
// CraftBukkit start
|
|
private CraftMerchantRecipe bukkitHandle;
|
|
|
|
@@ -53,13 +58,14 @@ public class MerchantOffer {
|
|
return (this.bukkitHandle == null) ? this.bukkitHandle = new CraftMerchantRecipe(this) : this.bukkitHandle;
|
|
}
|
|
|
|
- public MerchantOffer(ItemCost baseCostA, Optional<ItemCost> costB, ItemStack result, int uses, int maxUses, int experience, float priceMultiplier, int demand, CraftMerchantRecipe bukkit) {
|
|
+ public MerchantOffer(ItemCost baseCostA, Optional<ItemCost> costB, ItemStack result, int uses, int maxUses, int experience, float priceMultiplier, int demand, final boolean ignoreDiscounts, CraftMerchantRecipe bukkit) { // Paper
|
|
this(baseCostA, costB, result, uses, maxUses, experience, priceMultiplier, demand);
|
|
+ this.ignoreDiscounts = ignoreDiscounts; // Paper
|
|
this.bukkitHandle = bukkit;
|
|
}
|
|
// CraftBukkit end
|
|
|
|
- private MerchantOffer(ItemCost firstBuyItem, Optional<ItemCost> secondBuyItem, ItemStack sellItem, int uses, int maxUses, boolean rewardingPlayerExperience, int specialPrice, int demandBonus, float priceMultiplier, int merchantExperience) {
|
|
+ private MerchantOffer(ItemCost firstBuyItem, Optional<ItemCost> secondBuyItem, ItemStack sellItem, int uses, int maxUses, boolean rewardingPlayerExperience, int specialPrice, int demandBonus, float priceMultiplier, int merchantExperience, final boolean ignoreDiscounts) { // Paper
|
|
this.baseCostA = firstBuyItem;
|
|
this.costB = secondBuyItem;
|
|
this.result = sellItem;
|
|
@@ -70,6 +76,7 @@ public class MerchantOffer {
|
|
this.demand = demandBonus;
|
|
this.priceMultiplier = priceMultiplier;
|
|
this.xp = merchantExperience;
|
|
+ this.ignoreDiscounts = ignoreDiscounts; // Paper
|
|
}
|
|
|
|
public MerchantOffer(ItemCost buyItem, ItemStack sellItem, int maxUses, int merchantExperience, float priceMultiplier) {
|
|
@@ -85,11 +92,11 @@ public class MerchantOffer {
|
|
}
|
|
|
|
public MerchantOffer(ItemCost firstBuyItem, Optional<ItemCost> secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier, int demandBonus) {
|
|
- this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, true, 0, demandBonus, priceMultiplier, merchantExperience);
|
|
+ this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, true, 0, demandBonus, priceMultiplier, merchantExperience, false); // Paper
|
|
}
|
|
|
|
private MerchantOffer(MerchantOffer offer) {
|
|
- this(offer.baseCostA, offer.costB, offer.result.copy(), offer.uses, offer.maxUses, offer.rewardExp, offer.specialPriceDiff, offer.demand, offer.priceMultiplier, offer.xp);
|
|
+ this(offer.baseCostA, offer.costB, offer.result.copy(), offer.uses, offer.maxUses, offer.rewardExp, offer.specialPriceDiff, offer.demand, offer.priceMultiplier, offer.xp, offer.ignoreDiscounts); // Paper
|
|
}
|
|
|
|
public ItemStack getBaseCostA() {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
|
|
index 3bf9b5c016fa638fd0377d2a031a7359430b79ce..a18088125254178d362fdd283bff704a9ccdd0a7 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
|
|
@@ -22,11 +22,19 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
|
|
|
@Deprecated
|
|
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier) {
|
|
- this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0);
|
|
+ // Paper start - add ignoreDiscounts param
|
|
+ this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0, false);
|
|
+ }
|
|
+ public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, boolean ignoreDiscounts) {
|
|
+ this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0, ignoreDiscounts);
|
|
}
|
|
|
|
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, int demand, int specialPrice) {
|
|
- super(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice);
|
|
+ this(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice, false);
|
|
+ }
|
|
+ public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, int demand, int specialPrice, boolean ignoreDiscounts) {
|
|
+ super(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice, ignoreDiscounts);
|
|
+ // Paper end
|
|
this.handle = new net.minecraft.world.item.trading.MerchantOffer(
|
|
new ItemCost(Items.AIR),
|
|
Optional.empty(),
|
|
@@ -36,6 +44,7 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
|
experience,
|
|
priceMultiplier,
|
|
demand,
|
|
+ ignoreDiscounts, // Paper - add ignoreDiscounts param
|
|
this
|
|
);
|
|
this.setSpecialPrice(specialPrice);
|
|
@@ -112,6 +121,18 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
|
this.handle.priceMultiplier = priceMultiplier;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public boolean shouldIgnoreDiscounts() {
|
|
+ return this.handle.ignoreDiscounts;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setIgnoreDiscounts(boolean ignoreDiscounts) {
|
|
+ this.handle.ignoreDiscounts = ignoreDiscounts;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public net.minecraft.world.item.trading.MerchantOffer toMinecraft() {
|
|
List<ItemStack> ingredients = this.getIngredients();
|
|
Preconditions.checkState(!ingredients.isEmpty(), "No offered ingredients");
|
|
@@ -128,7 +149,7 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
|
if (recipe instanceof CraftMerchantRecipe) {
|
|
return (CraftMerchantRecipe) recipe;
|
|
} else {
|
|
- CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier(), recipe.getDemand(), recipe.getSpecialPrice());
|
|
+ CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier(), recipe.getDemand(), recipe.getSpecialPrice(), recipe.shouldIgnoreDiscounts()); // Paper - shouldIgnoreDiscounts
|
|
craft.setIngredients(recipe.getIngredients());
|
|
|
|
return craft;
|