Résolu Crash au lancement de la map
-
Bonjour a tous ,
j’ai un problème, mon mod crash mais je comprend pas pour quoi , voici le code :package com.Albanninou.Testmod.Blocks.TileEntity; import com.Albanninou.Testmod.Blocks.LampForGrowth; import com.Albanninou.Testmod.Items.DropOfBlood; import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class TileEntityLampOfGrowth extends TileEntity implements IInventory { private ItemStack[] inventory = new ItemStack[27]; private String customName; public Block block; public Material Materiaux; public int a = 4; public int temp = 0; @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.inventory.length; ++i) { if (this.inventory* != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); this.inventory*.writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } compound.setTag("Items", nbttaglist); if (this.hasCustomInventoryName()) { compound.setString("CustomName", this.customName); } } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("Items", 10); this.inventory = new ItemStack[this.getSizeInventory()]; if (compound.hasKey("CustomName", 8)) { this.customName = compound.getString("CustomName"); } for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; if (j >= 0 && j < this.inventory.length) { this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound); } public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); } @Override public void updateEntity() { super.updateEntity(); int x = this.xCoord; int y = this.yCoord; int z = this.zCoord; World world = this.getWorldObj(); if (temp == 30) { for (a = -4; a != 5; a++) { for (int c = -4; c != 5; c++) { block = world.getBlock(x + a, y, z + c); Materiaux = block.getMaterial(); if (Materiaux == Material.plants) { // fonction pour faire poussez la plante if (block instanceof IGrowable) { IGrowable igrowable = (IGrowable) block; if (igrowable.func_149851_a(world, x + a, y, z + c, world.isRemote)) { if (!world.isRemote) { if (this.inventory != null && igrowable.func_149852_a(world, world.rand, x + a, y, z + c)) { for (int i = 1; i <= 27; i++) { if (this.inventory* != null) { ItemStack stack = this.inventory*; if (stack.getItem() == DropOfBlood.DropOfBlood) { igrowable.func_149853_b(world, world.rand, x + a, y, z + c); igrowable.func_149853_b(world, world.rand, x + a, y, z + c); igrowable.func_149853_b(world, world.rand, x + a, y, z + c); decrStackSize(i, 1); i = 27; } } } } } } } } } } temp = 0; } temp++; } @Override public void closeInventory() { } @Override public String getInventoryName() { return this.hasCustomInventoryName() ? this.customName : "Lamp For Growth"; } @Override public int getInventoryStackLimit() { return 64; } @Override public int getSizeInventory() { return this.inventory.length; } @Override public ItemStack getStackInSlot(int slotId) { return this.inventory[slotId]; } @Override public ItemStack decrStackSize(int slotIndex, int amount) { if (this.inventory[slotIndex] != null) { ItemStack itemstack; if (this.inventory[slotIndex].stackSize <= amount) { itemstack = this.inventory[slotIndex]; this.inventory[slotIndex] = null; this.markDirty(); return itemstack; } else { itemstack = this.inventory[slotIndex].splitStack(amount); if (this.inventory[slotIndex].stackSize == 0) { this.inventory[slotIndex] = null; } this.markDirty(); return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int slodIndex) { if (this.inventory[slodIndex] != null) { ItemStack itemstack = this.inventory[slodIndex]; this.inventory[slodIndex] = null; return itemstack; } else { return null; } } @Override public void setInventorySlotContents(int slotIndex, ItemStack stack) { this.inventory[slotIndex] = stack; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public boolean hasCustomInventoryName() { return this.customName != null && !this.customName.isEmpty(); } public void setCustomName(String customName) { this.customName = customName; } @Override public boolean isItemValidForSlot(int side, ItemStack stack) { return stack != null && (stack.getItem() == DropOfBlood.DropOfBlood || (stack.getItem() == Items.dye && stack.getItemDamage() == 15)); } @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public void openInventory() { } }
et voila le rapport de crash :
[11:55:46] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking block entity at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:709) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.ArrayIndexOutOfBoundsException: 27 at com.Albanninou.Testmod.Blocks.TileEntity.TileEntityLampOfGrowth.updateEntity(TileEntityLampOfGrowth.java:113) ~[TileEntityLampOfGrowth.class:?] at net.minecraft.world.World.updateEntities(World.java:2160) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) ~[WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) ~[MinecraftServer.class:?] … 4 more [11:55:46] [Server thread/ERROR]: This crash report has been saved to: C:\Users\Jeune\Desktop\forge-1.7.10-10.13.4.1481-1.7.10-src\eclipse\.\crash-reports\crash-2015-07-14_11.55.46-server.txt [11:55:46] [Server thread/INFO]: Stopping server [11:55:46] [Server thread/INFO]: Saving players [11:55:46] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ---- // Ouch. That hurt :( Time: 14/07/15 11:55 Description: Ticking block entity java.lang.ArrayIndexOutOfBoundsException: 27 at com.Albanninou.Testmod.Blocks.TileEntity.TileEntityLampOfGrowth.updateEntity(TileEntityLampOfGrowth.java:113) at net.minecraft.world.World.updateEntities(World.java:2160) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.Albanninou.Testmod.Blocks.TileEntity.TileEntityLampOfGrowth.updateEntity(TileEntityLampOfGrowth.java:113) -- Block entity being ticked -- Details: Name: TestMod:Test Mod // com.Albanninou.Testmod.Blocks.TileEntity.TileEntityLampOfGrowth Block type: ID #167 (tile.LampForGrowth // com.Albanninou.Testmod.Blocks.LampForGrowth) Block data value: 0 / 0x0 / 0b0000 Block location: World: (65,4,-345), Chunk: (at 1,0,7 in 4,-22; contains blocks 64,0,-352 to 79,255,-337), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1) Actual block type: ID #167 (tile.LampForGrowth // com.Albanninou.Testmod.Blocks.LampForGrowth) Actual block data value: 0 / 0x0 / 0b0000 Stacktrace: at net.minecraft.world.World.updateEntities(World.java:2160) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) -- Affected level -- Details: Level name: uiiui All players: 1 total; [EntityPlayerMP['Albanninou'/229, l='uiiui', x=68,27, y=4,00, z=-347,58]] Chunk stats: ServerChunkCache: 284 Drop: 0 Level seed: 7707778288352647411 Level generator: ID 01 - flat, ver 0\. Features enabled: true Level generator options: Level spawn location: World: (66,4,-341), Chunk: (at 2,0,11 in 4,-22; contains blocks 64,0,-352 to 79,255,-337), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1) Level time: 2283 game time, 2283 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 50051 (now: false), thunder time: 32944 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) – System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 8.1 (amd64) version 6.3 Java Version: 1.7.0_67, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 945392336 bytes (901 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1481 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1481-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1481} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1481-1.7.10.jar) UCHIJAAAA TestMod{1.0.0} [Test Mod] (bin) GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Albanninou'/229, l='uiiui', x=68,27, y=4,00, z=-347,58]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' [11:55:46] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2015-07-14_11.55.46-server.txt [11:55:46] [Client thread/INFO] [FML]: Waiting for the server to terminate/save. [11:55:46] [Server thread/INFO]: Saving worlds [11:55:46] [Server thread/INFO]: Saving chunks for level 'uiiui'/Overworld [11:55:46] [Server thread/INFO]: Saving chunks for level 'uiiui'/Nether [11:55:46] [Server thread/INFO]: Saving chunks for level 'uiiui'/The End [11:55:47] [Server thread/INFO] [FML]: Unloading dimension 0 [11:55:47] [Server thread/INFO] [FML]: Unloading dimension -1 [11:55:47] [Server thread/INFO] [FML]: Unloading dimension 1 [11:55:47] [Server thread/INFO] [FML]: Applying holder lookups [11:55:47] [Server thread/INFO] [FML]: Holder lookups applied [11:55:47] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded. [11:55:47] [Client thread/INFO] [FML]: Server terminated. AL lib: (EE) alc_cleanup: 1 device not closed
Voila en espèrent que qu’elle qu’un est la réponse , sur bonne programmation a tous .
-
Ligne 113 de ton tileentity tu dépasse la taille du tableau.
Dans ta boucle for avec i il faut mettre i < 27 et non i <= 27 -
Merci sa marche