mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Don't set smelt stacks to above item's max stack size
This commit is contained in:
parent
06e38c991a
commit
82b0304091
@ -1,4 +1,5 @@
|
||||
Version 2.1.175
|
||||
Fixed a bug where mcMMO would occasionally give a 65 item stack from a double smelt on a furnace
|
||||
|
||||
Version 2.1.174
|
||||
Some legacy color codes in our locale file were swapped to &-code equivalents (thanks ViaSnake)
|
||||
|
@ -116,7 +116,8 @@ public class InventoryListener implements Listener {
|
||||
|
||||
//Profile doesn't exist
|
||||
if(offlineProfile != null) {
|
||||
event.setResult(offlineProfile.getSmeltingManager().smeltProcessing(smelting, event.getResult()));
|
||||
//Process smelting
|
||||
offlineProfile.getSmeltingManager().smeltProcessing(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,9 @@ import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SmeltingManager extends SkillManager {
|
||||
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
|
||||
@ -108,19 +110,29 @@ public class SmeltingManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack smeltProcessing(ItemStack smelting, ItemStack result) {
|
||||
public void smeltProcessing(@NotNull FurnaceSmeltEvent furnaceSmeltEvent) {
|
||||
ItemStack sourceItemStack = furnaceSmeltEvent.getSource();
|
||||
ItemStack resultItemStack = furnaceSmeltEvent.getResult();
|
||||
|
||||
applyXpGain(Smelting.getResourceXp(smelting), XPGainReason.PVE, XPGainSource.PASSIVE);
|
||||
applyXpGain(Smelting.getResourceXp(sourceItemStack), XPGainReason.PVE, XPGainSource.PASSIVE); //Add XP
|
||||
int itemLimit = resultItemStack.getMaxStackSize();
|
||||
|
||||
if (Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.SMELTING, result.getType())
|
||||
&& isSecondSmeltSuccessful() && result.getAmount() < 64) {
|
||||
ItemStack newResult = result.clone();
|
||||
|
||||
newResult.setAmount(result.getAmount() + 1);
|
||||
return newResult;
|
||||
processDoubleSmelt(furnaceSmeltEvent, resultItemStack, itemLimit);
|
||||
}
|
||||
|
||||
return result;
|
||||
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
|
||||
|
||||
//Process double smelt
|
||||
if (Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.SMELTING, resultItemStack.getType())
|
||||
&& resultItemStack.getAmount() < itemLimit
|
||||
&& isSecondSmeltSuccessful()) {
|
||||
|
||||
ItemStack newResult = resultItemStack.clone();
|
||||
newResult.setAmount(Math.min(resultItemStack.getAmount() + 1, itemLimit)); //Don't go over max stack limits
|
||||
furnaceSmeltEvent.setResult(newResult);
|
||||
}
|
||||
}
|
||||
|
||||
public int vanillaXPBoost(int experience) {
|
||||
|
Loading…
Reference in New Issue
Block a user