Ok je pense avoir compris le code juste quelques choses que je ne comprend pas c’est :
| public static ArrayList <ianalyzerrecipe>getRecipes() { |
| return recipes; |
| } |
Comment ca plus de sécurité ?
Ensuite pour enregister mes recettes je dois placer ceci alors ?
AnalyzerRecipes.initRecipes();
Si je fais ca j’ai un crash
| |
| This crash report has been saved to: C:\Users\Legrandfifou\Pictures\forge\eclipse\.\crash-reports\crash-2015-08-06_21.01.42-server.txt |
| [21:01:42] [Server thread/INFO]: Stopping server |
| [21:01:42] [Server thread/INFO]: Saving players |
| [21:01:42] [Server thread/INFO]: Saving worlds |
| [21:01:42] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld |
| [21:01:42] [Server thread/INFO]: Saving chunks for level 'New World'/Nether |
| [21:01:42] [Server thread/INFO]: Saving chunks for level 'New World'/The End |
| [21:01:42] [Server thread/INFO] [FML]: Unloading dimension 0 |
| [21:01:42] [Server thread/INFO] [FML]: Unloading dimension -1 |
| [21:01:42] [Server thread/INFO] [FML]: Unloading dimension 1 |
| [21:01:42] [Server thread/INFO] [FML]: Applying holder lookups |
| [21:01:42] [Server thread/INFO] [FML]: Holder lookups applied |
| [21:01:42] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded. |
| [21:01:43] [Client thread/FATAL]: Reported exception thrown! |
| net.minecraft.util.ReportedException: Ticking block entity |
| at net.minecraft.world.World.updateEntities(World.java:2175) ~[World.class:?] |
| at net.minecraft.client.Minecraft.runTick(Minecraft.java:2097) ~[Minecraft.class:?] |
| at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) ~[Minecraft.class:?] |
| at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?] |
| at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] |
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_75] |
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_75] |
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_75] |
| at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_75] |
| at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] |
| at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] |
| at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] |
| at GradleStart.main(Unknown Source) [start/:?] |
| Caused by: java.lang.ArrayIndexOutOfBoundsException: 2 |
| at mod.common.block.AnalyzerSimpleRecipe.matches(AnalyzerSimpleRecipe.java:22) ~[AnalyzerSimpleRecipe.class:?] |
| at mod.common.block.AnalyzerRecipes.getOutput(AnalyzerRecipes.java:24) ~[AnalyzerRecipes.class:?] |
| at mod.common.block.entity.TileEntityAnalyzer.canSmelt(TileEntityAnalyzer.java:164) ~[TileEntityAnalyzer.class:?] |
| at mod.common.block.entity.TileEntityAnalyzer.updateEntity(TileEntityAnalyzer.java:181) ~[TileEntityAnalyzer.class:?] |
| at net.minecraft.world.World.updateEntities(World.java:2160) ~[World.class:?] |
| … 12 more |
| [21:01:43] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ---- |
| |
| |
| Time: 6/08/15 21:01 |
| Description: Ticking block entity |
| |
| java.lang.ArrayIndexOutOfBoundsException: 2 |
| at mod.common.block.AnalyzerSimpleRecipe.matches(AnalyzerSimpleRecipe.java:22) |
| at mod.common.block.AnalyzerRecipes.getOutput(AnalyzerRecipes.java:24) |
| at mod.common.block.entity.TileEntityAnalyzer.canSmelt(TileEntityAnalyzer.java:164) |
| at mod.common.block.entity.TileEntityAnalyzer.updateEntity(TileEntityAnalyzer.java:181) |
| at net.minecraft.world.World.updateEntities(World.java:2160) |
| at net.minecraft.client.Minecraft.runTick(Minecraft.java:2097) |
| at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) |
| at net.minecraft.client.Minecraft.run(Minecraft.java:962) |
| at net.minecraft.client.main.Main.main(Main.java:164) |
| 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 net.minecraft.launchwrapper.Launch.launch(Launch.java:135) |
| at net.minecraft.launchwrapper.Launch.main(Launch.java:28) |
| at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) |
| at GradleStart.main(Unknown Source) |
| |
| A detailed walkthrough of the error, its code path and all known details is as follows: |
| –------------------------------------------------------------------------------------- |
| |
| -- Head -- |
| Stacktrace: |
| at mod.common.block.AnalyzerSimpleRecipe.matches(AnalyzerSimpleRecipe.java:22) |
| at mod.common.block.AnalyzerRecipes.getOutput(AnalyzerRecipes.java:24) |
| at mod.common.block.entity.TileEntityAnalyzer.canSmelt(TileEntityAnalyzer.java:164) |
| at mod.common.block.entity.TileEntityAnalyzer.updateEntity(TileEntityAnalyzer.java:181) |
| |
| -- Block entity being ticked -- |
| Details: |
| Name: entity_analyzer |
| Block type: ID #165 (tile.blockAnalyzer |
| Block data value: 2 / 0x2 / 0b0010 |
| Block location: World: (-160,67,304), Chunk: (at 0,4,0 in -10,19; contains blocks -160,0,304 to -145,255,319), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) |
| Actual block type: ID #165 (tile.blockAnalyzer |
| Actual block data value: 2 / 0x2 / 0b0010 |
| Stacktrace: |
| at net.minecraft.world.World.updateEntities(World.java:2160) |
| |
| -- Affected level -- |
| Details: |
| Level name: MpServer |
| All players: 1 total; [EntityClientPlayerMP['Player734'/209, l='MpServer', x=-161,14, y=68,62, z=306,95]] |
| Chunk stats: MultiplayerChunkCache: 613, 613 |
| Level seed: 0 |
| Level generator: ID 00 - default, ver 1\. Features enabled: false |
| Level generator options: |
| Level spawn location: World: (244,64,228), Chunk: (at 4,4,4 in 15,14; contains blocks 240,0,224 to 255,255,239), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) |
| Level time: 47015 game time, 47015 day time |
| Level dimension: 0 |
| Level storage version: 0x00000 - Unknown? |
| Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) |
| Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false |
| Forced entities: 118 total; [EntitySkeleton['Skeleton'/273, l='MpServer', x=-115,50, y=39,00, z=321,50], EntitySheep['Sheep'/279, l='MpServer', x=-156,47, y=69,00, z=352,97], EntitySheep['Sheep'/277, l='MpServer', x=-148,50, y=73,00, z=357,72], EntitySquid['Squid'/283, l='MpServer', x=-204,75, y=54,66, z=357,31], EntitySquid['Squid'/285, l='MpServer', x=-195,13, y=57,19, z=357,66], EntitySquid['Squid'/259, l='MpServer', x=-208,94, y=56,38, z=321,97], EntitySquid['Squid'/257, l='MpServer', x=-208,25, y=57,00, z=319,50], EntityBat['Bat'/263, l='MpServer', x=-177,31, y=26,81, z=264,31], EntitySheep['Sheep'/264, l='MpServer', x=-186,97, y=64,00, z=269,03], EntitySkeleton['Skeleton'/270, l='MpServer', x=-118,50, y=39,00, z=321,50], EntitySpider['Spider'/306, l='MpServer', x=-201,06, y=24,11, z=271,66], EntitySpider['Spider'/312, l='MpServer', x=-121,28, y=69,00, z=340,84], EntitySpider['Spider'/314, l='MpServer', x=-120,94, y=69,00, z=337,91], EntitySheep['Sheep'/318, l='MpServer', x=-128,50, y=71,00, z=353,91], EntitySquid['Squid'/288, l='MpServer', x=-194,81, y=59,34, z=363,69], EntitySquid['Squid'/292, l='MpServer', x=-209,78, y=59,34, z=353,97], EntitySquid['Squid'/294, l='MpServer', x=-207,75, y=58,31, z=340,81], EntitySquid['Squid'/296, l='MpServer', x=-211,19, y=53,28, z=354,09], EntitySquid['Squid'/298, l='MpServer', x=-208,50, y=55,28, z=347,53], EntityBat['Bat'/343, l='MpServer', x=-94,84, y=30,99, z=299,09], EntitySkeleton['Skeleton'/342, l='MpServer', x=-144,38, y=64,00, z=243,91], EntityBat['Bat'/341, l='MpServer', x=-235,72, y=22,74, z=288,75], EntitySpider['Spider'/340, l='MpServer', x=-101,09, y=65,00, z=306,00], EntityCreeper['Creeper'/339, l='MpServer', x=-101,50, y=52,00, z=307,50], EntitySquid['Squid'/351, l='MpServer', x=-208,75, y=55,31, z=360,13], EntityCreeper['Creeper'/350, l='MpServer', x=-219,50, y=19,00, z=364,50], EntityZombie['Zombie'/349, l='MpServer', x=-157,94, y=25,00, z=382,59], EntitySkeleton['Skeleton'/348, l='MpServer', x=-156,44, y=25,00, z=383,53], EntitySkeleton['Skeleton'/347, l='MpServer', x=-107,13, y=42,00, z=322,63], EntityBat['Bat'/346, l='MpServer', x=-106,97, y=40,12, z=305,31], EntityBat['Bat'/345, l='MpServer', x=-108,34, y=38,00, z=311,78], EntityBat['Bat'/344, l='MpServer', x=-94,66, y=31,15, z=297,84], EntityCreeper['Creeper'/635, l='MpServer', x=-127,50, y=40,00, z=309,50], EntityCreeper['Creeper'/634, l='MpServer', x=-124,69, y=40,00, z=310,92], EntityCreeper['Creeper'/633, l='MpServer', x=-124,11, y=40,00, z=309,99], EntityCreeper['Creeper'/636, l='MpServer', x=-122,75, y=40,00, z=311,13], EntityCreeper['Creeper'/373, l='MpServer', x=-188,72, y=63,00, z=244,47], EntityCreeper['Creeper'/375, l='MpServer', x=-87,50, y=51,00, z=298,50], EntitySpider['Spider'/374, l='MpServer', x=-150,41, y=63,00, z=237,34], EntityCreeper['Creeper'/368, l='MpServer', x=-166,50, y=33,00, z=384,50], EntityZombie['Zombie'/381, l='MpServer', x=-89,50, y=14,00, z=342,50], EntityZombie['Zombie'/380, l='MpServer', x=-193,50, y=63,00, z=238,50], EntityBat['Bat'/383, l='MpServer', x=-91,22, y=25,27, z=342,84], EntityZombie['Zombie'/382, l='MpServer', x=-94,50, y=25,00, z=349,50], EntitySpider['Spider'/379, l='MpServer', x=-192,00, y=63,00, z=235,00], EntitySkeleton['Skeleton'/378, l='MpServer', x=-192,94, y=63,00, z=228,53], EntitySkeleton['Skeleton'/356, l='MpServer', x=-108,38, y=14,00, z=337,94], EntityCow['Cow'/357, l='MpServer', x=-139,78, y=69,00, z=378,38], EntitySheep['Sheep'/352, l='MpServer', x=-126,50, y=71,00, z=352,50], EntitySheep['Sheep'/353, l='MpServer', x=-125,09, y=69,00, z=365,94], EntityBat['Bat'/354, l='MpServer', x=-236,03, y=20,91, z=284,19], EntityBat['Bat'/355, l='MpServer', x=-102,16, y=28,00, z=289,72], EntityCreeper['Creeper'/364, l='MpServer', x=-98,41, y=69,00, z=365,97], EntityCow['Cow'/365, l='MpServer', x=-126,91, y=72,00, z=374,78], EntityZombie['Zombie'/366, l='MpServer', x=-118,50, y=70,00, z=377,50], EntityZombie['Zombie'/367, l='MpServer', x=-112,50, y=72,00, z=379,50], EntitySpider['Spider'/360, l='MpServer', x=-130,41, y=67,00, z=245,30], EntityZombie['Zombie'/361, l='MpServer', x=-99,50, y=63,00, z=265,50], EntityCreeper['Creeper'/362, l='MpServer', x=-95,03, y=15,00, z=305,47], EntityBat['Bat'/363, l='MpServer', x=-107,81, y=32,37, z=367,75], EntitySkeleton['Skeleton'/395, l='MpServer', x=-86,50, y=66,00, z=355,50], EntitySkeleton['Skeleton'/394, l='MpServer', x=-82,50, y=65,00, z=353,50], EntityZombie['Zombie'/393, l='MpServer', x=-121,13, y=64,00, z=230,25], EntityCreeper['Creeper'/396, l='MpServer', x=-93,50, y=68,00, z=366,50], EntityCow['Cow'/385, l='MpServer', x=-137,53, y=68,00, z=386,41], EntityBat['Bat'/432, l='MpServer', x=-235,25, y=37,10, z=238,25], EntityBat['Bat'/433, l='MpServer', x=-229,25, y=38,03, z=235,72], EntitySkeleton['Skeleton'/434, l='MpServer', x=-102,50, y=64,00, z=234,50], EntitySkeleton['Skeleton'/641, l='MpServer', x=-123,34, y=40,00, z=308,72], EntityCreeper['Creeper'/431, l='MpServer', x=-226,69, y=41,00, z=228,34], EntitySquid['Squid'/220, l='MpServer', x=-181,06, y=55,34, z=330,75], EntitySquid['Squid'/221, l='MpServer', x=-188,78, y=58,19, z=338,63], EntitySquid['Squid'/222, l='MpServer', x=-183,09, y=59,19, z=333,66], EntitySkeleton['Skeleton'/460, l='MpServer', x=-95,16, y=64,00, z=235,91], EntitySquid['Squid'/223, l='MpServer', x=-213,19, y=61,34, z=319,06], EntitySkeleton['Skeleton'/459, l='MpServer', x=-95,53, y=64,00, z=236,88], EntitySheep['Sheep'/216, l='MpServer', x=-164,19, y=67,00, z=310,56], EntitySquid['Squid'/217, l='MpServer', x=-185,19, y=61,38, z=330,47], EntitySquid['Squid'/218, l='MpServer', x=-193,84, y=57,13, z=332,41], EntitySquid['Squid'/219, l='MpServer', x=-183,91, y=58,10, z=324,19], EntityZombie['Zombie'/212, l='MpServer', x=-172,06, y=36,00, z=301,59], EntitySkeleton['Skeleton'/213, l='MpServer', x=-171,50, y=62,00, z=294,97], EntityClientPlayerMP['Player734'/209, l='MpServer', x=-161,14, y=68,62, z=306,95], EntityZombie['Zombie'/215, l='MpServer', x=-173,69, y=65,48, z=289,38], EntityBat['Bat'/210, l='MpServer', x=-165,50, y=45,10, z=301,50], EntityZombie['Zombie'/211, l='MpServer', x=-174,34, y=40,00, z=301,09], EntitySquid['Squid'/239, l='MpServer', x=-208,69, y=53,75, z=347,91], EntitySquid['Squid'/238, l='MpServer', x=-200,69, y=56,09, z=344,22], EntitySquid['Squid'/237, l='MpServer', x=-208,53, y=60,38, z=342,06], EntitySquid['Squid'/236, l='MpServer', x=-200,69, y=51,34, z=349,84], EntityBat['Bat'/235, l='MpServer', x=-152,25, y=57,10, z=282,34], EntityBat['Bat'/234, l='MpServer', x=-151,28, y=56,10, z=278,72], EntitySheep['Sheep'/233, l='MpServer', x=-187,75, y=66,00, z=287,41], EntitySheep['Sheep'/232, l='MpServer', x=-184,91, y=68,00, z=288,91], EntitySquid['Squid'/231, l='MpServer', x=-203,28, y=59,31, z=333,78], EntitySquid['Squid'/230, l='MpServer', x=-202,53, y=59,13, z=320,28], EntitySquid['Squid'/229, l='MpServer', x=-179,25, y=58,31, z=339,44], EntitySquid['Squid'/228, l='MpServer', x=-169,47, y=57,00, z=343,25], EntitySheep['Sheep'/227, l='MpServer', x=-172,41, y=71,00, z=275,13], EntitySquid['Squid'/226, l='MpServer', x=-185,65, y=56,53, z=307,21], EntitySquid['Squid'/225, l='MpServer', x=-205,66, y=61,38, z=317,75], EntitySquid['Squid'/224, l='MpServer', x=-196,56, y=58,34, z=316,75], EntitySquid['Squid'/254, l='MpServer', x=-186,66, y=60,34, z=362,84], EntitySquid['Squid'/255, l='MpServer', x=-188,94, y=60,34, z=360,53], EntitySquid['Squid'/252, l='MpServer', x=-187,69, y=56,31, z=361,91], EntitySquid['Squid'/253, l='MpServer', x=-192,22, y=55,13, z=353,19], EntitySheep['Sheep'/250, l='MpServer', x=-162,50, y=71,00, z=363,72], EntitySheep['Sheep'/251, l='MpServer', x=-163,75, y=70,00, z=359,63], EntityBat['Bat'/248, l='MpServer', x=-114,75, y=37,09, z=316,34], EntityBat['Bat'/249, l='MpServer', x=-113,72, y=39,74, z=317,06], EntitySquid['Squid'/246, l='MpServer', x=-209,72, y=60,38, z=313,66], EntitySkeleton['Skeleton'/247, l='MpServer', x=-114,56, y=37,00, z=316,03], EntitySheep['Sheep'/244, l='MpServer', x=-136,75, y=73,00, z=345,63], EntitySquid['Squid'/245, l='MpServer', x=-207,94, y=59,09, z=320,19], EntitySheep['Sheep'/242, l='MpServer', x=-205,06, y=64,00, z=279,03], EntitySheep['Sheep'/243, l='MpServer', x=-139,44, y=75,00, z=337,34], EntitySheep['Sheep'/240, l='MpServer', x=-191,17, y=64,00, z=279,39], EntitySheep['Sheep'/241, l='MpServer', x=-196,16, y=64,00, z=287,09]] |
| Retry entities: 0 total; [] |
| Server brand: fml,forge |
| Server type: Integrated singleplayer server |
| Stacktrace: |
| at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) |
| at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566) |
| at net.minecraft.client.Minecraft.run(Minecraft.java:984) |
| at net.minecraft.client.main.Main.main(Main.java:164) |
| 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 net.minecraft.launchwrapper.Launch.launch(Launch.java:135) |
| at net.minecraft.launchwrapper.Launch.main(Launch.java:28) |
| at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) |
| at GradleStart.main(Unknown Source) |
| |
| – System Details -- |
| Details: |
| Minecraft Version: 1.7.10 |
| Operating System: Windows 8.1 (amd64) version 6.3 |
| Java Version: 1.7.0_75, Oracle Corporation |
| Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation |
| Memory: 756458592 bytes (721 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 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: 13, tallocated: 95 |
| FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 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.1448-1.7.10.jar) |
| UCHIJAAAA Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) |
| UCHIJAAAA modminecraft{1.0} [Mod Minecraft] (bin) |
| GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 353.62' Renderer: 'GeForce GTX 770/PCIe/SSE2' |
| Launched Version: 1.7.10 |
| LWJGL: 2.9.1 |
| OpenGL: GeForce GTX 770/PCIe/SSE2 GL version 4.5.0 NVIDIA 353.62, NVIDIA Corporation |
| GL Caps: Using GL 1.3 multitexturing. |
| Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. |
| Anisotropic filtering is supported and maximum anisotropy is 16. |
| Shaders are available because OpenGL 2.1 is supported. |
| |
| Is Modded: Definitely; Client brand changed to 'fml,forge' |
| Type: Client (map_client.txt) |
| Resource Packs: [] |
| Current Language: English (US) |
| Profiler Position: N/A (disabled) |
| Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used |
| Anisotropic Filtering: Off (1) |
| [21:01:43] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:398]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Legrandfifou\Pictures\forge\eclipse\.\crash-reports\crash-2015-08-06_21.01.43-client.txt |
| AL lib: (EE) alc_cleanup: 1 device not closed |
| |
J’ai un BoundOfException je suppose que c’est la taille de l’inventaire ?
Voici du coup les classes qu’il me reste
| package mod.common.block.entity; |
| |
| import cpw.mods.fml.relauncher.Side; |
| import cpw.mods.fml.relauncher.SideOnly; |
| import mod.common.block.AnalyzerRecipes; |
| import net.minecraft.entity.player.EntityPlayer; |
| import net.minecraft.inventory.IInventory; |
| import net.minecraft.item.ItemStack; |
| import net.minecraft.nbt.NBTTagCompound; |
| import net.minecraft.nbt.NBTTagList; |
| import net.minecraft.tileentity.TileEntity; |
| |
| public class TileEntityAnalyzer extends TileEntity implements IInventory |
| { |
| private ItemStack[] contents = new ItemStack[4]; |
| |
| private int workingTime = 1999; |
| private int workingTimeNeeded = 256; |
| |
| @Override |
| public void writeToNBT(NBTTagCompound compound) { |
| super.writeToNBT(compound); |
| NBTTagList nbttaglist = new NBTTagList(); |
| |
| for (int i = 0; i < this.contents.length; ++i) { |
| if (this.contents* != null) { |
| NBTTagCompound nbttagcompound1 = new NBTTagCompound(); |
| nbttagcompound1.setByte("Slot", (byte) i); |
| this.contents*.writeToNBT(nbttagcompound1); |
| nbttaglist.appendTag(nbttagcompound1); |
| } |
| } |
| |
| compound.setTag("Items", nbttaglist); |
| compound.setShort("workingTime", (short) this.workingTime); |
| |
| compound.setShort("workingTimeNeeded", (short) this.workingTimeNeeded); |
| } |
| |
| @Override |
| public void readFromNBT(NBTTagCompound compound) { |
| super.readFromNBT(compound); |
| |
| NBTTagList nbttaglist = compound.getTagList("Items", 10); |
| this.contents = new ItemStack[this.getSizeInventory()]; |
| |
| for (int i = 0; i < nbttaglist.tagCount(); ++i) |
| |
| { |
| NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); |
| int j = nbttagcompound1.getByte("Slot") & 255; |
| |
| if (j >= 0 && j < this.contents.length) { |
| this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); |
| } |
| } |
| |
| this.workingTime = compound.getShort("workingTime"); |
| |
| this.workingTimeNeeded = compound.getShort("workingTimeNeeded"); |
| } |
| |
| @Override |
| public int getSizeInventory() { |
| return this.contents.length; |
| } |
| |
| @Override |
| public ItemStack getStackInSlot(int slotIndex) { |
| return this.contents[slotIndex]; |
| } |
| |
| @Override |
| public ItemStack decrStackSize(int slotIndex, int amount) { |
| if (this.contents[slotIndex] != null) { |
| ItemStack itemstack; |
| |
| if (this.contents[slotIndex].stackSize <= amount) { |
| itemstack = this.contents[slotIndex]; |
| this.contents[slotIndex] = null; |
| this.markDirty(); |
| return itemstack; |
| } else { |
| itemstack = this.contents[slotIndex].splitStack(amount); |
| |
| if (this.contents[slotIndex].stackSize == 0) { |
| this.contents[slotIndex] = null; |
| } |
| |
| this.markDirty(); |
| return itemstack; |
| } |
| } else { |
| return null; |
| } |
| } |
| |
| @Override |
| public ItemStack getStackInSlotOnClosing(int slotIndex) { |
| if (this.contents[slotIndex] != null) { |
| ItemStack itemstack = this.contents[slotIndex]; |
| this.contents[slotIndex] = null; |
| return itemstack; |
| } else { |
| return null; |
| } |
| } |
| |
| @Override |
| public void setInventorySlotContents(int slotIndex, ItemStack stack) { |
| this.contents[slotIndex] = stack; |
| |
| if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { |
| stack.stackSize = this.getInventoryStackLimit(); |
| } |
| |
| this.markDirty(); |
| } |
| |
| @Override |
| public String getInventoryName() { |
| return "tile.BlockAnalyzer"; |
| } |
| |
| @Override |
| public boolean hasCustomInventoryName() { |
| return false; |
| } |
| |
| @Override |
| public int getInventoryStackLimit() { |
| return 64; |
| } |
| |
| @Override |
| public boolean isUseableByPlayer(EntityPlayer player) { |
| return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D; |
| } |
| |
| @Override |
| public void openInventory() { |
| |
| } |
| |
| @Override |
| public void closeInventory() { |
| |
| } |
| |
| @Override |
| public boolean isItemValidForSlot(int slot, ItemStack stack) { |
| return slot == 2 ? false : true; |
| } |
| |
| public boolean isBurning() { |
| return this.workingTime > 0; |
| } |
| |
| private boolean canSmelt() { |
| if (this.contents[0] == null || this.contents[1] == null) { |
| return false; |
| } else { |
| ItemStack itemstack = AnalyzerRecipes.getOutput(this); |
| |
| if (itemstack == null) return false; |
| if (this.contents[2] == null) return true; |
| |
| if (!this.contents[2].isItemEqual(itemstack)) return false; |
| |
| int result = contents[2].stackSize + itemstack.stackSize; |
| return result <= getInventoryStackLimit() && result <= this.contents[2].getMaxStackSize(); |
| } |
| } |
| |
| @Override |
| public void updateEntity() { |
| if (this.isBurning() && this.canSmelt()) { |
| ++this.workingTime; |
| } |
| if (this.canSmelt() && !this.isBurning()) { |
| this.workingTime = 1; |
| |
| } |
| if (this.canSmelt() && this.workingTime == this.workingTimeNeeded) { |
| this.smeltItem(); |
| this.workingTime = 0; |
| } |
| if (!this.canSmelt()) { |
| this.workingTime = 0; |
| } |
| } |
| |
| public void smeltItem() { |
| if (this.canSmelt()) { |
| ItemStack itemstack = AnalyzerRecipes.getOutput(this); |
| if (this.contents[2] == null) { |
| this.contents[2] = itemstack.copy(); |
| } else if (this.contents[2].getItem() == itemstack.getItem()) { |
| this.contents[2].stackSize += itemstack.stackSize; |
| } |
| |
| –this.contents[0].stackSize; |
| –this.contents[1].stackSize; |
| |
| if (this.contents[0].stackSize <= 0) { |
| this.contents[0] = null; |
| } |
| if (this.contents[1].stackSize <= 0) { |
| this.contents[1] = null; |
| } |
| |
| } |
| } |
| |
| @SideOnly(Side.CLIENT) |
| public int getCookProgress() { |
| return this.workingTime * 33 / this.workingTimeNeeded; |
| } |
| } |
| |
| package mod.common.block; |
| |
| import java.util.ArrayList; |
| import java.util.Collections; |
| import java.util.HashMap; |
| import java.util.Iterator; |
| import java.util.ListIterator; |
| import mod.common.block.entity.TileEntityAnalyzer; |
| import net.minecraft.item.ItemStack; |
| |
| public class AnalyzerRecipes |
| { |
| private static ArrayList <ianalyzerrecipe>recipes = new ArrayList<ianalyzerrecipe>(); |
| |
| |
| |
| |
| |
| public static ItemStack getOutput(TileEntityAnalyzer tile, ItemStack … stacks) { |
| ListIterator <ianalyzerrecipe>ite = recipes.listIterator(); |
| while (ite.hasNext()) { |
| IAnalyzerRecipe r = ite.next(); |
| if (r.matches(tile, tile.getWorldObj())) return r.getOutput(tile, tile.getWorldObj()); |
| } |
| return null; |
| } |
| |
| |
| |
| |
| public static ArrayList <ianalyzerrecipe>getRecipes() { |
| return recipes; |
| } |
| |
| |
| |
| |
| public static void initRecipes() { |
| AnalyzerRecipes.addRecipe(new AnalyzerSimpleRecipe()); |
| } |
| |
| |
| |
| |
| public static void addRecipe(IAnalyzerRecipe recipe) { |
| recipes.add(recipe); |
| } |
| |
| |
| |
| |
| |
| |
| public static boolean corresponds(ItemStack stack, ItemStack stack1) { |
| if (stack == null && stack1 == null) return true; |
| if (stack == null && stack1 != null) return false; |
| if (stack != null && stack1 == null) return false; |
| if (stack.getItem() != stack1.getItem()) return false; |
| if (stack.getItemDamage() != stack1.getItemDamage()) return false; |
| return true; |
| } |
| } |
| |
| package mod.common.block; |
| |
| import java.util.Random; |
| |
| import mod.common.block.entity.TileEntityAnalyzer; |
| import mod.common.item.ItemRegister; |
| import net.minecraft.init.Items; |
| import net.minecraft.item.Item; |
| import net.minecraft.item.ItemStack; |
| import net.minecraft.world.World; |
| |
| public class AnalyzerSimpleRecipe implements IAnalyzerRecipe |
| { |
| public static final Random RNG = new Random(); |
| public static final Item[] matrix = new Item[] { |
| ItemRegister.itemADNofFrog, |
| ItemRegister.itemSevewithmosquito }; |
| |
| @Override |
| public boolean matches(TileEntityAnalyzer tile, World world) { |
| for (int i = 0; i < tile.getSizeInventory(); i++) { |
| if (!AnalyzerSimpleRecipe.corresponds(AnalyzerSimpleRecipe.matrix*, tile.getStackInSlot(i))) return false; |
| } |
| return true; |
| } |
| |
| @Override |
| public ItemStack getOutput(TileEntityAnalyzer tile, World world) { |
| return new ItemStack(ItemRegister.itemAmbre, RNG.nextInt(30)); |
| } |
| |
| public static boolean corresponds(Item item, ItemStack stack) { |
| if (stack == null && item == null) return true; |
| if (stack == null && item != null) return false; |
| if (stack != null && item == null) return false; |
| if (stack.getItem() != item) return false; |
| return true; |
| } |
| } |
Si tu as le temps de vérif pour voir si j’ai pas fait de fautes ^^</ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe>