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



×
×
  • Create New...

Important Information

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