mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 08:20:51 +01:00
de04cbced5
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: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
155 lines
9.4 KiB
Diff
155 lines
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 c0aa370367856a159412dd141f683b7d51e11c8b..363d1f469862c2e980624ff69f74be015c19412d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -508,6 +508,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
|
|
while (iterator.hasNext()) {
|
|
MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
|
|
+ if (merchantrecipe.ignoreDiscounts) continue; // Paper
|
|
|
|
merchantrecipe.addToSpecialPriceDiff(-Mth.floor((float) i * merchantrecipe.getPriceMultiplier()));
|
|
}
|
|
@@ -520,6 +521,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
|
|
while (iterator1.hasNext()) {
|
|
MerchantOffer merchantrecipe1 = (MerchantOffer) iterator1.next();
|
|
+ if (merchantrecipe1.ignoreDiscounts) continue; // Paper
|
|
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 1d755d04515f20dbd69931084b4cc894e52d35c9..4f7457578ab3118d10e0d5dfc23d79c9b20c2f44 100644
|
|
--- a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
|
+++ b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
|
@@ -19,6 +19,7 @@ public class MerchantOffer {
|
|
public int demand;
|
|
public float priceMultiplier;
|
|
public int xp;
|
|
+ public boolean ignoreDiscounts; // Paper
|
|
// CraftBukkit start
|
|
private CraftMerchantRecipe bukkitHandle;
|
|
|
|
@@ -31,7 +32,15 @@ public class MerchantOffer {
|
|
}
|
|
|
|
public MerchantOffer(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, int demand, CraftMerchantRecipe bukkit) {
|
|
- this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, demand);
|
|
+ // Paper start - add ignoreDiscounts param
|
|
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, demand, false, bukkit);
|
|
+ }
|
|
+ public MerchantOffer(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, boolean ignoreDiscounts, CraftMerchantRecipe bukkit) {
|
|
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, 0, ignoreDiscounts, bukkit);
|
|
+ }
|
|
+ public MerchantOffer(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, int demand, boolean ignoreDiscounts, CraftMerchantRecipe bukkit) {
|
|
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, demand, ignoreDiscounts);
|
|
+ // Paper end
|
|
this.bukkitHandle = bukkit;
|
|
}
|
|
// CraftBukkit end
|
|
@@ -63,6 +72,7 @@ public class MerchantOffer {
|
|
|
|
this.specialPriceDiff = nbt.getInt("specialPrice");
|
|
this.demand = nbt.getInt("demand");
|
|
+ this.ignoreDiscounts = nbt.getBoolean("Paper.IgnoreDiscounts"); // Paper
|
|
}
|
|
|
|
public MerchantOffer(ItemStack buyItem, ItemStack sellItem, int maxUses, int merchantExperience, float priceMultiplier) {
|
|
@@ -74,10 +84,19 @@ public class MerchantOffer {
|
|
}
|
|
|
|
public MerchantOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier) {
|
|
- this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, merchantExperience, priceMultiplier, 0);
|
|
+ // Paper start - add ignoreDiscounts param
|
|
+ this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, merchantExperience, priceMultiplier, false);
|
|
+ }
|
|
+ public MerchantOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier, boolean ignoreDiscounts) {
|
|
+ this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, merchantExperience, priceMultiplier, 0, ignoreDiscounts);
|
|
}
|
|
|
|
public MerchantOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier, int demandBonus) {
|
|
+ this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, merchantExperience, priceMultiplier, demandBonus, false);
|
|
+ }
|
|
+ public MerchantOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier, int demandBonus, boolean ignoreDiscounts) {
|
|
+ this.ignoreDiscounts = ignoreDiscounts;
|
|
+ // Paper end
|
|
this.rewardExp = true;
|
|
this.xp = 1;
|
|
this.baseCostA = firstBuyItem;
|
|
@@ -210,6 +229,7 @@ public class MerchantOffer {
|
|
nbttagcompound.putFloat("priceMultiplier", this.priceMultiplier);
|
|
nbttagcompound.putInt("specialPrice", this.specialPriceDiff);
|
|
nbttagcompound.putInt("demand", this.demand);
|
|
+ nbttagcompound.putBoolean("Paper.IgnoreDiscounts", this.ignoreDiscounts); // Paper
|
|
return nbttagcompound;
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
|
|
index c015b34d2b13a759783da7c0c06dd0563d35fc88..5741a233fb1dd8ad0f83a09b44476a4b88e6aa16 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
|
|
@@ -18,11 +18,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(
|
|
net.minecraft.world.item.ItemStack.EMPTY,
|
|
net.minecraft.world.item.ItemStack.EMPTY,
|
|
@@ -32,6 +40,7 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
|
experience,
|
|
priceMultiplier,
|
|
demand,
|
|
+ ignoreDiscounts, // Paper - add ignoreDiscounts param
|
|
this
|
|
);
|
|
this.setSpecialPrice(specialPrice);
|
|
@@ -108,6 +117,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");
|
|
@@ -122,7 +143,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;
|