Metalhurgy Crusher

Post a reply

:
Complete the task
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: Metalhurgy Crusher

Re: Metalhurgy Crusher

Post by CombatZAK » Thu Nov 20, 2014 12:00 am

I looked at your code on GitHub and I think I found your issue. This is from the Crusher.java file:

: [Select all] [/] [] ()
private static void removeFromInput(ItemStack input, ItemStack output) {
        boolean switched = false;
        ItemStack[] inputList = MetallurgyHelper.crusherInputList.get(output.getUnlocalizedName());
        ItemStack[] newList = new ItemStack[inputList.length - 1];
        if (newList.length >= 1) {
            for (int i = 0; i < inputList.length; i++) {
                if (switched || (areEqual(inputList[i], input))) {
                    switched = true;
                    newList[i] = inputList[i + 1];
                } else newList[i] = inputList[i];
            }
        } else newList = null;

        inputList = newList;
        if (inputList == null || inputList.length <= 0) {
            MetallurgyHelper.crusherInputList.remove(output.getUnlocalizedName());
        } else {
            MetallurgyHelper.crusherInputList.put(output.getUnlocalizedName(), inputList);
        }
    }
GeSHi © Codebox Plus


That line here: newList[i] = inputList[i + 1];... looks like once you find the item you're looking for you index i+1, but your loop variable goes to the end of the list. So the last item will be equal to the list length - an invalid index. One way to fix it would be to loop till i-1. If switched isn't true, you could either assume that the last element was the one to be removed, or check it explicitly and perform some sort of error handling if it doesn't match. I didn't check too closely to see if you look for the presence of the element anywhere else in the code.

Hope this helps.

Re: Metalhurgy Crusher

Post by CombatZAK » Wed Nov 19, 2014 11:35 pm

I think I hit the same issue. Here is my stack trace:

java.lang.ArrayIndexOutOfBoundsException: 14
at modtweaker.mods.metallurgy.handlers.Crusher.removeFromInput(Crusher.java:102)
at modtweaker.mods.metallurgy.handlers.Crusher.access$100(Crusher.java:15)
at modtweaker.mods.metallurgy.handlers.Crusher$Remove.apply(Crusher.java:64)
at minetweaker.runtime.MTTweaker.apply(MTTweaker.java:65)
at minetweaker.MineTweakerAPI.apply(MineTweakerAPI.java:173)
at modtweaker.mods.metallurgy.handlers.Crusher.removeRecipe(Crusher.java:48)
at FixCopper.__script__(fixCopper.zs:82)
at __ZenMain__.run(fixCopper.zs)
at minetweaker.runtime.MTTweaker.load(MTTweaker.java:157)
at minetweaker.MineTweakerImplementationAPI.reload(MineTweakerImplementationAPI.java:624)
at minetweaker.MineTweakerImplementationAPI.onServerStart(MineTweakerImplementationAPI.java:555)
at minetweaker.mc1710.MineTweakerMod.onServerAboutToStart(MineTweakerMod.java:166)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at cpw.mods.fml.common.Loader.serverAboutToStart(Loader.java:809)
at cpw.mods.fml.common.FMLCommonHandler.handleServerAboutToStart(FMLCommonHandler.java:273)
at net.minecraft.server.integrated.IntegratedServer.func_71197_b(IntegratedServer.java:91)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:387)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)


Here is the script I used (trimmed down)

: [Select all] [/] [] ()
import mods.metallurgy.Crusher;

Crusher.removeRecipe(<TConstruct:materials:9>);
Crusher.addRecipe(<TConstruct:materials:9>, <ThermalFoundation:material:32>);

GeSHi © Codebox Plus


Basically I was trying to set a recipe so that copper ingots would always crush to Thermal Foundation pulverized copper. It blew out on the removeRecipe call though. I can provide more info if you need it.

Re: Metalhurgy Crusher

Post by goreae » Sat Nov 08, 2014 4:19 pm

Yeah, it's kind of impossible to figyure out what caused the crash without the thing that caused the crash.

Re: Metalhurgy Crusher

Post by joshie » Sat Nov 01, 2014 8:39 am

What was the script, so I can test it.

Metalhurgy Crusher

Post by Nerdy » Fri Oct 31, 2014 10:17 am

: [Select all] [/] [] ()
[06:12:13] [Server thread/ERROR] [FML]: Caught exception from MineTweaker3
java.lang.ArrayIndexOutOfBoundsException: 2
at modtweaker.mods.metallurgy.handlers.Crusher.removeFromInput(Crusher.java:102) ~[Crusher.class:?]
at modtweaker.mods.metallurgy.handlers.Crusher.access$100(Crusher.java:15) ~[Crusher.class:?]
at modtweaker.mods.metallurgy.handlers.Crusher$Add.undo(Crusher.java:39) ~[Crusher$Add.class:?]
at minetweaker.runtime.MTTweaker.rollback(MTTweaker.java:83) ~[MTTweaker.class:?]
at minetweaker.MineTweakerImplementationAPI.reload(MineTweakerImplementationAPI.java:589) ~[MineTweakerImplementationAPI.class:?]
at minetweaker.MineTweakerImplementationAPI.onServerStart(MineTweakerImplementationAPI.java:555) ~[MineTweakerImplementationAPI.class:?]
at minetweaker.mc1710.MineTweakerMod.onServerAboutToStart(MineTweakerMod.java:166) ~[MineTweakerMod.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_09]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_09]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_09]
at java.lang.reflect.Method.invoke(Method.java:601) ~[?:1.7.0_09]
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) ~[forge-1.7.10-10.13.2.1231-universal.jar:?]
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_09]
at java.lang.reflect.Method.invoke(Method.java:601) ~[?:1.7.0_09]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-16.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-16.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-16.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-16.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-16.0.jar:?]
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[forge-1.7.10-10.13.2.1231-universal.jar:?]
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[forge-1.7.10-10.13.2.1231-universal.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_09]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_09]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_09]
at java.lang.reflect.Method.invoke(Method.java:601) ~[?:1.7.0_09]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-16.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-16.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-16.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-16.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-16.0.jar:?]
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?]
at cpw.mods.fml.common.Loader.serverAboutToStart(Loader.java:809) [Loader.class:?]
at cpw.mods.fml.common.FMLCommonHandler.handleServerAboutToStart(FMLCommonHandler.java:273) [FMLCommonHandler.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_09]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_09]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_09]
at java.lang.reflect.Method.invoke(Method.java:601) ~[?:1.7.0_09]
at Reflector.callBoolean(Reflector.java:332) [Reflector.class:?]
at net.minecraft.server.integrated.IntegratedServer.func_71197_b(IntegratedServer.java:150) [bsx.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:387) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [?:?]
GeSHi © Codebox Plus


Just a snippet from the log.
The game doesnt crash, however, I cant use "mt reload" or switch worlds without it looping back to the main menu.
Using Modtweaker 6.22, the last updated one in the dev builds.
The curse forum topic is dead, your github looks dead, and these forums are pretty slow.
Whatever.

Top

cron