diff --git a/Changelog.txt b/Changelog.txt
index fa1f8671e..3c0de504d 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,7 +1,7 @@
-Version 2.1.175
- Fixed a bug where mcMMO would occasionally give a 65 item stack from a double smelt on a furnace
- Fixed a bug where arrows could be duped when fired from a crossbow with piercing enchantment
- Added setting to enable or disable Green Thumb automatically replanting crops per crop to config.yml under 'Green_Thumb_Replanting_Crops' section
+Version 2.1.176
+ Added another measure to prevent item stacks from reaching 65 from double smelt
+ Updated Adventure (our text dependency) fixes some errors when using color codes in party/admin chat (thanks TheBusyBiscuit)
+ Added some support for negative Y values in anticipation of 1.17 world height changes (thanks t00thpick1)
(API) Many skills with RNG elements now send out a SubSkillEvent (which can be used to modify probability or cancel the results), some skills without RNG still send out this event when activated, this event is cancellable so it can be used to make a skill fail
Treasure drop rate from Shake, Fishing, Hylian, and Excavation now benefit from the Luck perk
Added a setting to chat.yml to toggle sending party or admin chat messages to console
@@ -57,6 +57,11 @@ Version 2.1.175
New Power Level Command
This power level command gives you a view of all your current masteries, it also provides a summary of your power level.
+Version 2.1.175
+ Fixed a bug where mcMMO would occasionally give a 65 item stack from a double smelt on a furnace
+ Fixed a bug where arrows could be duped when fired from a crossbow with piercing enchantment
+ Added setting to enable or disable Green Thumb automatically replanting crops per crop to config.yml under 'Green_Thumb_Replanting_Crops' section
+
Version 2.1.174
Some legacy color codes in our locale file were swapped to &-code equivalents (thanks ViaSnake)
Updated hu_HU locale (thanks andris155)
diff --git a/pom.xml b/pom.xml
index 485f4d7f9..9c3b05df6 100755
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.gmail.nossr50.mcMMO
mcMMO
- 2.1.175-SNAPSHOT
+ 2.1.176-SNAPSHOT
mcMMO
https://github.com/mcMMO-Dev/mcMMO
diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
index c3a0aa838..c110de94c 100644
--- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
@@ -117,7 +117,7 @@ public class InventoryListener implements Listener {
//Profile doesn't exist
if(offlineProfile != null) {
//Process smelting
- offlineProfile.getSmeltingManager().smeltProcessing(event);
+ offlineProfile.getSmeltingManager().smeltProcessing(event, furnace);
}
}
}
diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java
index f9e68e533..c45cb0fbb 100644
--- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java
@@ -10,8 +10,10 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
+import org.bukkit.block.Furnace;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent;
+import org.bukkit.inventory.FurnaceInventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
@@ -109,31 +111,43 @@ public class SmeltingManager extends SkillManager {
}
}
- public void smeltProcessing(@NotNull FurnaceSmeltEvent furnaceSmeltEvent) {
- ItemStack sourceItemStack = furnaceSmeltEvent.getSource();
- ItemStack resultItemStack = furnaceSmeltEvent.getResult();
+ public void smeltProcessing(@NotNull FurnaceSmeltEvent furnaceSmeltEvent, @NotNull Furnace furnace) {
+ applyXpGain(Smelting.getResourceXp(furnaceSmeltEvent.getSource()), XPGainReason.PVE, XPGainSource.PASSIVE); //Add XP
- applyXpGain(Smelting.getResourceXp(sourceItemStack), XPGainReason.PVE, XPGainSource.PASSIVE); //Add XP
- int itemLimit = resultItemStack.getMaxStackSize();
-
- processDoubleSmelt(furnaceSmeltEvent, resultItemStack, itemLimit);
+ processDoubleSmelt(furnaceSmeltEvent, furnace);
}
- private void processDoubleSmelt(@NotNull FurnaceSmeltEvent furnaceSmeltEvent, @NotNull ItemStack resultItemStack, int itemLimit) {
- //TODO: Permission check work around, could store it as NBT on the furnace
- //We don't do permission checks because this can be for an offline player and Bukkit has nothing to grab permissions for offline players
+ private void processDoubleSmelt(@NotNull FurnaceSmeltEvent furnaceSmeltEvent, @NotNull Furnace furnace) {
+ ItemStack resultItemStack = furnaceSmeltEvent.getResult();
+ /*
+ doubleSmeltCondition should be equal to the max
+ */
//Process double smelt
if (Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.SMELTING, resultItemStack.getType())
- && resultItemStack.getAmount() < itemLimit
+ && canDoubleSmeltItemStack(furnace) //Effectively two less than max stack size
&& isSecondSmeltSuccessful()) {
- ItemStack newResult = resultItemStack.clone();
- newResult.setAmount(Math.min(resultItemStack.getAmount() + 1, itemLimit)); //Don't go over max stack limits
- furnaceSmeltEvent.setResult(newResult);
+ ItemStack doubleSmeltStack = resultItemStack.clone(); //TODO: Necessary?
+ doubleSmeltStack.setAmount(resultItemStack.getAmount() + 1); //Add one
+ furnaceSmeltEvent.setResult(doubleSmeltStack); //Set result
}
}
+ private boolean canDoubleSmeltItemStack(@NotNull Furnace furnace) {
+ FurnaceInventory furnaceInventory = furnace.getInventory();
+ ItemStack furnaceResult = furnaceInventory.getResult();
+
+ if(furnaceResult == null)
+ return false;
+
+ int resultAmount = furnaceResult.getAmount(); //Amount before double smelt
+ int itemLimit = furnaceResult.getMaxStackSize();
+ int doubleSmeltCondition = itemLimit - 2; //Don't double smelt if it would cause an illegal stack size
+
+ return resultAmount <= doubleSmeltCondition;
+ }
+
public int vanillaXPBoost(int experience) {
return experience * getVanillaXpMultiplier();
}