Jump to content

[SOLVED]1.7.2 Crash with java.lang.ArrayIndexOutOfBoundsException: 64


Recommended Posts

Posted

Hi there I am getting a weird crash every time I enter a world with the ChemicalWaste item in my inventory when I don't have a Hazmat suit in my inventory or if I take the suit out of the inventory. this forces me to delete the world because it's not joinable with out a crash.

 

ItemChemicalWaste

package info.coremodding.realchemics.items;

import info.coremodding.realchemics.creativetabs.RCCreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

/**
* The chemical waste item class
*/
public class ItemChemicalWaste extends Item {

/**
 * An itemstack of this
 */
public static ItemStack ChemicalWaste = new ItemStack(Items.ChemicalWaste);

public void onUpdate(ItemStack itemstack, World world, Entity par3Entity, int par4, boolean par5) {
	EntityPlayer a = ((EntityPlayer)par3Entity);
	//Searches for the ItemChemicalWaste in the player's inventory
	if (a.inventory.hasItemStack(new ItemStack(Items.ChemicalWaste))){

	//Checks if the player has the Hazmat Suit Boots. I only took boots for testing purposes.	
	if (a.inventory.getStackInSlot(100).equals(new ItemStack(Items.ArmorHazmatSuitBoots))) {
		//Only to see if it give the effect
		System.out.println("Giving Effect");

		//Giving Potion effects
		a.addPotionEffect(new PotionEffect(Potion.poison.id, 1000, 3, false));
		a.addPotionEffect(new PotionEffect(Potion.confusion.id, 1000 , 3 ,false));
		a.addPotionEffect(new PotionEffect(Potion.blindness.id, 1000, 3 , false));
		a.addPotionEffect(new PotionEffect(Potion.hunger.id, 1000, 3 , false));
	}

}

}

{
	/**
	 * Set's the Creative Tab of the Item
	 */
	this.setCreativeTab(RCCreativeTabs.tabRealChem);
	this.setUnlocalizedName("itemChemicalWaste");

}
}

 

 

Log

---- Minecraft Crash Report ----
// Why did you do that?

Time: 2014-04-12 01:56
Description: Ticking player

java.lang.ArrayIndexOutOfBoundsException: 64
at net.minecraft.entity.player.InventoryPlayer.getStackInSlot(InventoryPlayer.java:648)
at info.coremodding.realchemics.items.ItemChemicalWaste.onUpdate(ItemChemicalWaste.java:34)
at net.minecraft.item.ItemStack.updateAnimation(ItemStack.java:477)
at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:349)
at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:625)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1820)
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:342)
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341)
at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:326)
at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37)
at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:271)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232)
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:716)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:604)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at net.minecraft.entity.player.InventoryPlayer.getStackInSlot(InventoryPlayer.java:648)
at info.coremodding.realchemics.items.ItemChemicalWaste.onUpdate(ItemChemicalWaste.java:34)
at net.minecraft.item.ItemStack.updateAnimation(ItemStack.java:477)
at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:349)
at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:625)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1820)
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:342)

-- Player being ticked --
Details:
Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)
Entity ID: 190
Entity Name: Player703
Entity's Exact location: 564,81, 4,00, 196,32
Entity's Block location: World: (564,4,196), Chunk: (at 4,0,4 in 35,12; contains blocks 560,0,192 to 575,255,207), Region: (1,0; contains chunks 32,0 to 63,31, blocks 512,0,0 to 1023,255,511)
Entity's Momentum: 0,00, -0,08, 0,00
Stacktrace:
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341)
at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:326)
at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37)
at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:271)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232)

-- Ticking connection --
Details:
Connection: net.minecraft.network.NetworkManager@5880cefe
Stacktrace:
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:716)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:604)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 8 (amd64) version 6.2
Java Version: 1.7.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 954064056 bytes (909 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 3297 (184632 bytes; 0 MB) allocated, 3083 (172648 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.01-pre FML v7.2.156.1056 Minecraft Forge 10.12.0.1056 4 mods loaded, 4 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.2.156.1056} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1056.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.0.1056} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1056.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
CoreModding_RealChemics{Not Even A Version Yet!} [Real Chemics] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Profiler Position: N/A (disabled)
Vec3 Pool Size: 436 (24416 bytes; 0 MB) allocated, 402 (22512 bytes; 0 MB) used
Player Count: 1 / 8; [EntityPlayerMP['Player703'/190, l='New World', x=564,81, y=4,00, z=196,32]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
#@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2014-04-12_01.56.07-server.txt
[01:56:08] [Client Shutdown Thread/INFO]: Stopping server
[01:56:08] [Client Shutdown Thread/INFO]: Saving players
AL lib: (EE) alc_cleanup: 1 device not closed

Posted

Hi

 

Where does this magic number 100 come from in this line?

if (a.inventory.getStackInSlot(100).equals(new ItemStack(Items.ArmorHazmatSuitBoots))) {

 

Tracing through getStackInSlot I find

    public ItemStack getStackInSlot(int par1)
    {
        ItemStack[] aitemstack = this.mainInventory;

        if (par1 >= aitemstack.length)
        {
            par1 -= aitemstack.length;
            aitemstack = this.armorInventory;
        }

        return aitemstack[par1];
    }

The definition of InventoryPlayer.mainInventory and armorInventory are

    /**
     * An array of 36 item stacks indicating the main player inventory (including the visible bar).
     */
    public ItemStack[] mainInventory = new ItemStack[36];

    /** An array of 4 item stacks containing the currently worn armor pieces. */
    public ItemStack[] armorInventory = new ItemStack[4];

So your error index 64 comes from 100 - 36 = 64 which is bigger than the size of armorInventory.

 

-TGG

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Minecraft 1.21.4 requires a new model definition file for each item, which you don't have. These can be created through Data Generation, specifically the ModelProvider, BlockModelGenerators and ItemModelGenerators classes.
    • Hi,  I'm using Forge 47.3.0 for Minecraft 1.20.1 I apologise if this is obvious I am very new to modding for Minecraft. I sucessfully made a mod that launched without errors or crashes (without it doing anything) but in order to add the features I need, I need to add "Custom Portal API [Forge]" as a dependency. However no matter the way I've tried to acheive this, it crashes. I am pretty sure it's not the way I'm putting it in the repositories, the dependencies or the way I'm refrencing it, as I've a hundred diffrent combinations and multiple Maven methods. And on all those diffrent variations I still get this crash: pastebin.com/UhumzZCZ Any tips would be invaluable as I've been loosing my mind over this!
    • Hi, i'm really having problems trying to set the texture to my custom item. I thought i'm doing everything correctly, but all i see is the missing texture block for my item. I am trying this for over a week now and getting really frustrated. The only time i could make the texture work, was when i used an older Forge version (52.0.1) for Minecraft (1.21.4). Was there a fundamental change for textures and models somewhere between versions that i'm missing? I started with Forge 54.1.0 and had this problem, so in my frustration i tried many things: Upgrading to Forge 54.1.1, created multiple new projects, workspaces, redownloaded everything and setting things up multiple times, as it was suggested in an older thread. Therea are no errors in the console logs, but maybe i'm blind, so i pasted the console logs to pastebin anyway: https://pastebin.com/zAM8RiUN The only time i see an error is when i change the models JSON file to an incorrect JSON which makes sense and that suggests to me it is actually reading the JSON file.   I set the github repository to public, i would be so thankful if anyone could take a look and tell me what i did wrong: https://github.com/xLorkin/teleport_pug_forge   As a note: i'm pretty new to modding, this is my first mod ever. But i'm used to programming. I had some up and downs, but through reading the documentation, using google and experimenting, i could solve all other problems. I only started modding for Minecraft because my son is such a big fan and wanted this mod.
    • Please read the FAQ (link in orange bar at top of page), and post logs as described there.
    • Hello fellow Minecrafters! I recently returned to Minecraft and realized I needed a wiki that displays basic information easily and had great user navigation. That’s why I decided to build: MinecraftSearch — a site by a Minecraft fan, for Minecraft fans. Key Features So Far Straight-to-the-Point Info: No extra fluff; just the essentials on items, mobs, recipes, loot and more. Clean & Intuitive Layout: Easy navigation so you spend less time scrolling and more time playing. Optimized Search: Search for anything—items, mobs, blocks—and get results instantly. What I’m Thinking of Adding More data/information: Catch chances for fishing rod, traveling villager trades, biomes info and a lot more. The website is still under development and need a lot more data added. Community Contributions: Potential for user-uploaded tips for items/mobs/blocks in the future. Feature Requests Welcome: Your ideas could shape how the wiki evolves! You can see my roadmap at the About page https://minecraftsearch.com/about I’d love for you to check out MinecraftSearch and see if it helps you find the info you need faster. Feedback is crucial—I want to develop this further based on what the community needs most, so please let me know what you think. Thanks, and happy crafting!
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.