NuclearCraft

NuclearCraft

31M Downloads

off-by-one error in RecipeStats.java

linuskr opened this issue ยท 1 comments

commented

Rock Crushers currently crash the game due to an ArrayIndexOutOfBoundsException:

    at nc.recipe.RecipeStats.getProcessorMaxBaseProcessTime(RecipeStats.java:28)
    at nc.tile.processor.IProcessor.getCapacity(IProcessor.java:17)
    at nc.tile.processor.TileItemProcessor.<init>(TileItemProcessor.java:50)
    at nc.tile.processor.TileItemProcessor.<init>(TileItemProcessor.java:46)
    at nc.tile.processor.TileProcessor$RockCrusher.<init>(TileProcessor.java:138)
    at nc.enumm.BlockEnums$ProcessorType.getTile(BlockEnums.java:99)
    at nc.block.tile.processor.BlockProcessor.createNewTileEntity(BlockProcessor.java:39)
    at net.minecraft.block.Block.createTileEntity(Block.java:1274)
    at net.minecraft.world.chunk.Chunk.createNewTileEntity(Chunk.java:782)
    at net.minecraft.world.chunk.Chunk.getTileEntity(Chunk.java:800)
    at net.minecraft.world.World.getTileEntity(World.java:2402)
    ...

I believe the problem is https://github.com/turbodiesel4598/NuclearCraft/blob/80961678c1a48a0226e32de5ccd90f5755c6fb8a/src/main/java/nc/recipe/RecipeStats.java#L28, because the IDs in TileProcessor are one-indexed, but the processor_max_base_process_time/power arrays are zero-indexed.

commented

Good spot :P
Fixed for the next version :)