mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Add another measure to stop item stacks from becoming illegal sizes from double smelt
This commit is contained in:
parent
4eecd34494
commit
ac618cf48a
@ -1,3 +1,6 @@
|
||||
Version 2.1.176
|
||||
Added another measure to prevent item stacks from reaching 65 from double smelt
|
||||
|
||||
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
|
||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.175</version>
|
||||
<version>2.1.176-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -110,23 +111,40 @@ public class SmeltingManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void smeltProcessing(@NotNull FurnaceSmeltEvent furnaceSmeltEvent) {
|
||||
public void smeltProcessing(@NotNull FurnaceSmeltEvent furnaceSmeltEvent, @NotNull Furnace furnace) {
|
||||
ItemStack sourceItemStack = furnaceSmeltEvent.getSource();
|
||||
ItemStack resultItemStack = furnaceSmeltEvent.getResult();
|
||||
|
||||
applyXpGain(Smelting.getResourceXp(sourceItemStack), XPGainReason.PVE, XPGainSource.PASSIVE); //Add XP
|
||||
int itemLimit = resultItemStack.getMaxStackSize();
|
||||
|
||||
processDoubleSmelt(furnaceSmeltEvent, resultItemStack, itemLimit);
|
||||
|
||||
processDoubleSmelt(furnaceSmeltEvent, resultItemStack, furnace);
|
||||
}
|
||||
|
||||
private void processDoubleSmelt(@NotNull FurnaceSmeltEvent furnaceSmeltEvent, @NotNull ItemStack resultItemStack, @NotNull Furnace furnace) {
|
||||
int itemLimit = resultItemStack.getMaxStackSize();
|
||||
|
||||
//Check for viewers
|
||||
if(furnace.getInventory().getViewers().size() > 0) {
|
||||
itemLimit = itemLimit - 1; //Lower max size to prevent exploit, the exploit involves an open window and a stack at 63 which is about to double smelt, instructions to replicate below
|
||||
/*
|
||||
Momshroom02/26/2021
|
||||
1) have max (or close to it) smelting.
|
||||
2) put more than half a stack of an ore in a furnace and wait for it to smelt.
|
||||
3) have your inv full except for one items worth of whatever the furnace product is. (so like a stack of 63 iron and the rest of your inv is full).
|
||||
4) shift click on the furnace output to remove only one item-- leaving 63.
|
||||
5) let one more item smelt so the furnace appears to have 64
|
||||
6) manually drag (don't shift click) the stack of product out of the furnace- it'll be 65 items
|
||||
when you drop that and pick it up with only one free space in your inv, it'll look like there's more than one left on the ground, but for me, there was only one, and the "dupe" was visual only-- idk about VK's player.
|
||||
*/
|
||||
}
|
||||
|
||||
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
|
||||
&& resultItemStack.getAmount() < itemLimit //We take away 1 because there's a certain "exploit" when certain plugins are used in combination
|
||||
&& isSecondSmeltSuccessful()) {
|
||||
|
||||
ItemStack newResult = resultItemStack.clone();
|
||||
|
Loading…
Reference in New Issue
Block a user