Slimefun / Slimefun4

Slimefun 4 - A unique Spigot/Paper plugin that looks and feels like a modpack. We've been giving you backpacks, jetpacks, reactors and much more since 2013.
GNU General Public License v3.0
960 stars 546 forks source link

Could not pass event BlockBreakEvent to Slimefun v4.1.9 #367

Closed andris155 closed 6 years ago

andris155 commented 7 years ago

Description

Describe your Issue AS DETAILED AS POSSIBLE. Could not pass event BlockBreakEvent to Slimefun v4.1.9

Server Log

Upload your FULL SERVER LOG (/logs/latest.log) to http://pastebin.com/ and paste your link in here. Without this File, we may not be able to help you at all. Send if need

Evidence / Proof

Attach as many Screenshots or Videos if possible. Anything that helps us understand the Issue better, is gonna get your Issue fixed even faster.

[11:30:11] [Server thread/ERROR]: Could not pass event BlockBreakEvent to Slimefun v4.1.9
org.bukkit.event.EventException: null
    at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:46) ~[patched_1.12.jar:git-Paper-1147]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:74) ~[patched_1.12.jar:git-Paper-1147]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.jar:git-Paper-1147]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:514) ~[patched_1.12.jar:git-Paper-1147]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:499) ~[patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.PlayerInteractManager.breakBlock(PlayerInteractManager.java:289) ~[patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.PlayerInteractManager.a(PlayerInteractManager.java:191) ~[patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:871) ~[patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.PacketPlayInBlockDig.a(SourceFile:40) ~[patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.PacketPlayInBlockDig.a(SourceFile:10) ~[patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[patched_1.12.jar:git-Paper-1147]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_131]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_131]
    at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:842) [patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423) [patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:766) [patched_1.12.jar:git-Paper-1147]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:664) [patched_1.12.jar:git-Paper-1147]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
Caused by: java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
    at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[?:1.8.0_131]
    at java.util.ArrayList.get(ArrayList.java:429) ~[?:1.8.0_131]
    at me.mrCookieSlime.Slimefun.Setup.SlimefunSetup$19.onBlockBreak(SlimefunSetup.java:1429) ~[?:?]
    at me.mrCookieSlime.Slimefun.listeners.ToolListener.onBlockBreak(ToolListener.java:223) ~[?:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor641.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:44) ~[patched_1.12.jar:git-Paper-1147]
    ... 18 more

Environment

We need the EXACT VERSIONS of the Software you are using. This includes your Minecraft Version, your CS-CoreLib version and your Slimefun Version. If you cannot figure out what versions you are running, then please run /sf versions and show us the output of that command.

Paper v1_12_R1
CS-CoreLib v1.5.16
Slimefun v4.1.9
Installed Addons (4)
ExtraGear v1.1.1
SlimefunLuckyBlocks v1.1
ExoticGarden v1.6.3
ElectricSpawners v1.0
Poslovitch commented 7 years ago

Did a bit of debug, however could not find a way to fix it.

At https://github.com/TheBusyBiscuit/Slimefun4/blob/master/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java#L1428

{
            @Override
            public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
                if (SlimefunManager.isItemSimiliar(item, SlimefunItems.AUTO_SMELT_PICKAXE, true)) {
                    if (e.getBlock().getType().equals(Material.SKULL)) return true;

                    int j = -1;
                    for (int i = 0; i < e.getBlock().getDrops().size(); i++) {
                        if (((List<ItemStack>) e.getBlock().getDrops()).get(i) != null) {
                            j++;
                            drops.add(e.getBlock().getType().toString().endsWith("_ORE") ? new CustomItem(((List<ItemStack>) e.getBlock().getDrops()).get(i), fortune): ((List<ItemStack>) e.getBlock().getDrops()).get(i));
                            if (RecipeCalculator.getSmeltedOutput(drops.get(i).getType()) != null) {
                                e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
                                drops.set(j, new CustomItem(RecipeCalculator.getSmeltedOutput(drops.get(i).getType()), drops.get(i).getAmount()));
                            }
                        }
                    }

                    return true;
                }
                else return false;
            }
});

Here, the for loop is correct : it does not try to read an index higher or equal to the size of the list.

At https://github.com/TheBusyBiscuit/Slimefun4/blob/master/src/me/mrCookieSlime/Slimefun/listeners/ToolListener.java#L223,

if (!item.getEnchantments().containsKey(Enchantment.SILK_TOUCH) && e.getBlock().getType().toString().endsWith("_ORE")) {
            if (Talisman.checkFor(e, SlimefunItem.getByName("MINER_TALISMAN"))) {
                if (drops.isEmpty()) drops = (List<ItemStack>) e.getBlock().getDrops();
                for (ItemStack drop: new ArrayList<ItemStack>(drops)) {
                    if (!drop.getType().isBlock()) drops.add(new CustomItem(drop, fortune * 2));
                }
            }
}

Here we can see a drop is added.

As those two pieces of code are run this means that this happen with a Smelter's Pickaxe with a Talisman of Miner.

Poslovitch commented 6 years ago

This exception is thrown when mining lapis or diamond, not necessarly with the talisman of miner doubling the drops