Posted October 28, 201410 yr All my code is on Github: https://github.com/flaghacker/MysteriumCraft I'm trying to add a crop to my mod, in the class "MysteriumCraft / src / main / java / com / flaghacker / mysteriumcraft / init / ModCrops.java". My game crashes when it tries to render my crop. This is the crash report: ---- Minecraft Crash Report ---- // You're mean. Time: 28/10/14 20:31 Description: Unexpected error java.lang.ArrayIndexOutOfBoundsException: 0 at com.flaghacker.mysteriumcraft.blocks.CropMC.getIcon(CropMC.java:58) at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8451) at net.minecraft.client.renderer.RenderBlocks.renderBlockCropsImpl(RenderBlocks.java:4082) at net.minecraft.client.renderer.RenderBlocks.renderBlockCrops(RenderBlocks.java:3850) at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:362) at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:207) at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1618) at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1263) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1087) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1057) at net.minecraft.client.Minecraft.run(Minecraft.java:951) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at GradleStart.bounce(GradleStart.java:107) at GradleStart.startClient(GradleStart.java:100) at GradleStart.main(GradleStart.java:65) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.flaghacker.mysteriumcraft.blocks.CropMC.getIcon(CropMC.java:58) at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8451) at net.minecraft.client.renderer.RenderBlocks.renderBlockCropsImpl(RenderBlocks.java:4082) at net.minecraft.client.renderer.RenderBlocks.renderBlockCrops(RenderBlocks.java:3850) at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:362) at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:207) at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1618) at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1263) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['ForgeDevName'/554, l='MpServer', x=26,25, y=92,62, z=654,92]] Chunk stats: MultiplayerChunkCache: 70, 70 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: World: (32,64,-142), Chunk: (at 0,4,2 in 2,-9; contains blocks 32,0,-144 to 47,255,-129), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1) Level time: 57089 game time, 6000 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: 81 total; [EntityCreeper['Creeper'/558, l='MpServer', x=23,22, y=63,00, z=680,69], EntityZombie['Zombie'/559, l='MpServer', x=19,13, y=59,00, z=672,63], EntitySpider['Spider'/556, l='MpServer', x=26,66, y=61,00, z=663,94], EntitySpider['Spider'/557, l='MpServer', x=25,53, y=62,00, z=656,66], EntitySpider['Spider'/555, l='MpServer', x=16,50, y=30,00, z=671,50], EntitySkeleton['Skeleton'/567, l='MpServer', x=-0,50, y=45,00, z=675,72], EntityCreeper['Creeper'/566, l='MpServer', x=-4,50, y=14,00, z=683,50], EntityCreeper['Creeper'/565, l='MpServer', x=63,50, y=24,00, z=624,50], EntityCow['Cow'/564, l='MpServer', x=-2,28, y=102,00, z=627,53], EntityCow['Cow'/563, l='MpServer', x=-7,53, y=84,00, z=670,41], EntityCow['Cow'/562, l='MpServer', x=3,47, y=83,00, z=672,13], EntityCow['Cow'/561, l='MpServer', x=8,63, y=85,00, z=680,81], EntityCow['Cow'/560, l='MpServer', x=2,53, y=81,00, z=675,81], EntityCow['Cow'/575, l='MpServer', x=-19,78, y=84,00, z=659,63], EntityCow['Cow'/574, l='MpServer', x=72,38, y=81,00, z=641,56], EntityCreeper['Creeper'/573, l='MpServer', x=71,50, y=51,00, z=651,50], EntityBat['Bat'/572, l='MpServer', x=77,56, y=45,03, z=647,53], EntityBat['Bat'/571, l='MpServer', x=-16,84, y=44,09, z=642,88], EntityCreeper['Creeper'/570, l='MpServer', x=-9,50, y=26,00, z=620,50], EntityCreeper['Creeper'/569, l='MpServer', x=-8,50, y=26,00, z=622,50], EntityCow['Cow'/568, l='MpServer', x=-9,25, y=80,00, z=674,31], EntityBat['Bat'/645, l='MpServer', x=85,75, y=30,09, z=728,75], EntityZombie['Zombie'/644, l='MpServer', x=104,50, y=43,00, z=587,09], EntityZombie['Zombie'/646, l='MpServer', x=88,69, y=53,00, z=721,06], EntityChicken['Chicken'/641, l='MpServer', x=-42,50, y=114,00, z=720,50], EntityChicken['Chicken'/640, l='MpServer', x=-38,28, y=110,00, z=721,31], EntitySkeleton['Skeleton'/610, l='MpServer', x=102,16, y=46,00, z=641,50], EntitySkeleton['Skeleton'/611, l='MpServer', x=96,50, y=46,00, z=646,50], EntityCow['Cow'/608, l='MpServer', x=-20,75, y=93,00, z=584,44], EntityZombie['Zombie'/614, l='MpServer', x=99,50, y=46,00, z=638,50], EntityZombie['Zombie'/615, l='MpServer', x=42,50, y=27,00, z=720,50], EntitySkeleton['Skeleton'/612, l='MpServer', x=85,50, y=32,00, z=700,50], EntityZombie['Zombie'/618, l='MpServer', x=40,50, y=27,00, z=721,50], EntityZombie['Zombie'/619, l='MpServer', x=35,34, y=27,00, z=720,34], EntityZombie['Zombie'/616, l='MpServer', x=43,50, y=27,00, z=721,50], EntityZombie['Zombie'/617, l='MpServer', x=42,53, y=28,00, z=721,94], EntityCow['Cow'/622, l='MpServer', x=-53,19, y=74,00, z=609,47], EntityChicken['Chicken'/623, l='MpServer', x=-51,53, y=84,00, z=608,69], EntitySpider['Spider'/620, l='MpServer', x=-15,28, y=76,00, z=721,53], EntitySkeleton['Skeleton'/627, l='MpServer', x=-21,50, y=36,00, z=733,50], EntityChicken['Chicken'/626, l='MpServer', x=-42,50, y=112,00, z=719,50], EntityChicken['Chicken'/625, l='MpServer', x=-40,50, y=106,00, z=718,50], EntityCow['Cow'/630, l='MpServer', x=-52,53, y=83,00, z=606,47], EntityMinecartChest['entity.MinecartChest.name'/635, l='MpServer', x=106,50, y=31,50, z=688,50], EntityCreeper['Creeper'/634, l='MpServer', x=104,50, y=44,00, z=592,50], EntityCreeper['Creeper'/639, l='MpServer', x=-43,63, y=41,00, z=722,97], EntityCreeper['Creeper'/638, l='MpServer', x=-42,50, y=41,00, z=724,50], EntityCreeper['Creeper'/637, l='MpServer', x=-43,50, y=41,00, z=727,50], EntityZombie['Zombie'/636, l='MpServer', x=99,53, y=31,00, z=696,69], EntityCow['Cow'/576, l='MpServer', x=-22,25, y=82,00, z=668,34], EntityCow['Cow'/577, l='MpServer', x=67,81, y=78,00, z=629,50], EntitySkeleton['Skeleton'/578, l='MpServer', x=40,50, y=43,00, z=702,50], EntityCreeper['Creeper'/579, l='MpServer', x=43,97, y=67,00, z=701,47], EntityCreeper['Creeper'/580, l='MpServer', x=-32,00, y=56,00, z=683,16], EntityBat['Bat'/581, l='MpServer', x=67,25, y=47,09, z=622,75], EntityCow['Cow'/582, l='MpServer', x=79,63, y=71,00, z=623,41], EntitySpider['Spider'/583, l='MpServer', x=66,50, y=15,00, z=676,50], EntityWitch['Witch'/584, l='MpServer', x=66,50, y=15,00, z=678,50], EntityClientPlayerMP['ForgeDevName'/554, l='MpServer', x=26,25, y=92,62, z=654,92], EntitySkeleton['Skeleton'/586, l='MpServer', x=61,06, y=32,00, z=695,53], EntityCreeper['Creeper'/587, l='MpServer', x=52,59, y=66,00, z=702,25], EntityZombie['Zombie'/588, l='MpServer', x=90,50, y=27,00, z=640,50], EntityZombie['Zombie'/589, l='MpServer', x=95,97, y=46,00, z=641,41], EntityBat['Bat'/590, l='MpServer', x=83,03, y=45,31, z=649,00], EntityCow['Cow'/591, l='MpServer', x=81,63, y=78,00, z=634,22], EntityZombie['Zombie'/593, l='MpServer', x=39,34, y=27,00, z=719,34], EntityZombie['Zombie'/592, l='MpServer', x=37,50, y=28,00, z=705,50], EntityChicken['Chicken'/595, l='MpServer', x=35,50, y=27,00, z=718,50], EntityZombie['Zombie'/594, l='MpServer', x=35,50, y=27,34, z=718,38], EntityBat['Bat'/597, l='MpServer', x=-34,63, y=41,09, z=681,66], EntityMinecartChest['entity.MinecartChest.name'/596, l='MpServer', x=72,50, y=33,50, z=699,50], EntityZombie['Zombie'/599, l='MpServer', x=-38,72, y=55,00, z=686,16], EntityZombie['Zombie'/598, l='MpServer', x=-37,44, y=56,00, z=686,56], EntityEnderman['Enderman'/601, l='MpServer', x=-47,53, y=62,00, z=683,88], EntityCreeper['Creeper'/600, l='MpServer', x=-38,94, y=54,00, z=682,50], EntityCow['Cow'/603, l='MpServer', x=-39,66, y=90,00, z=617,75], EntityCow['Cow'/602, l='MpServer', x=-34,97, y=86,00, z=672,13], EntityZombie['Zombie'/605, l='MpServer', x=-18,50, y=19,00, z=718,50], EntityZombie['Zombie'/604, l='MpServer', x=62,50, y=30,00, z=577,09], EntityChicken['Chicken'/607, l='MpServer', x=-33,47, y=104,00, z=599,53], EntitySpider['Spider'/606, l='MpServer', x=-34,81, y=58,00, z=688,28]] 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:2556) at net.minecraft.client.Minecraft.run(Minecraft.java:980) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at GradleStart.bounce(GradleStart.java:107) at GradleStart.startClient(GradleStart.java:100) at GradleStart.main(GradleStart.java:65) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_67, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 813252968 bytes (775 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 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: 9, tcache: 0, allocated: 13, tallocated: 95 FML: MCP v9.05 FML v7.10.85.1230 Minecraft Forge 10.13.2.1230 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available FML{7.10.85.1230} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available Forge{10.13.2.1230} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available mysteriumcraft{1.7.10-0.1} [MysteriumCraft] (MysteriumCraft) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: Intel(R) HD Graphics 3000 GL version 3.1.0 - Build 9.17.10.3347, Intel 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) It points to this line: https://github.com/flaghacker/MysteriumCraft/blob/master/src/main/java/com/flaghacker/mysteriumcraft/blocks/CropMC.java#L48 This is a consequence of the fact that my "registerIcons" method is not called. I know that because the log line in the for loop is not logging. Does someone know why my "registerIcons" method is not called?
October 28, 201410 yr Author Thanks, didn't notice that! Now I'm having all sorts of weird problems when I bonemeal my plants. WAILA is showing they're fully grown, when they're actually in stage 0. The log is spammed with "invalid metadata", that comes from one of my debug lines. They don't drop stuff when they have the fully grown texture I think the reason is that the stage count, metadata and growth mechanics are stil set for the 7 stages of wheat. How can I change that?
October 28, 201410 yr Are you already setting the metadata for your crop anywhere? fully grown is somewhat weird i guess
October 28, 201410 yr Uhh and theres that method wich you should override: public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return p_149650_1_ == 7 ? this.func_149865_P() : this.func_149866_i(); }
October 30, 201410 yr Author 1) Do I need to override "public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)"? 2) Is there any method by witch I can get complete control over what items it drops? Because in the BlockCrops class I see a lot of functions that have something to do with drops: protected Item func_149866_i, returning the crop item protected Item func_149865_P, returning the seed item public void dropBlockAsItemWithChance, I guess getting the dropped item? public Item getItemDropped, same as above, I'm confused public int quantityDropped, I'm guessing the amount of dropped crop items, determined by func_149866_i Is there 1 function I can use so I can say: if metedata = 7 drop math.random seeds drop math.random crops else drop 1 seed and clears all drop functions overridden in the BlockCrops class? If not, how should I do this instead, because I'm confused by the amount of "drop" functions and the fact they're not all deobvusticated.
October 30, 201410 yr Author Or should I extends BlockBush and implement IGrowable instead of extending BlockCrops?
October 30, 201410 yr I recommend doing that, since you can control more. Check out my mod, Realms of Chaos, here. If I helped you, be sure to press the "Thank You" button!
October 30, 201410 yr Author I started doing that, and I ran into a "problem". I need to implement 3 functions from IGrowable: public boolean func_149851_a(World world, int x, int y, int z, boolean b) public boolean func_149852_a(World world, Random random, int x, int y, int z) public void func_149853_b(World world, Random random, int x, int y, int z) The variables and function names aren't deobfuscated yet. Looking around in the source code of BlockCrop and testing myself, I came to these conclusions: func_149851_a is called to "ask" if you plant can be bonemealed. Return type is boolean, the arguments are: world, x, y, z, boolean. I have no idea what the boolean is used for, vanilla code seems to ignore it. The function is called twice if I try to bonemeal my crop, first with true, then with false. func_149852_a gets called every time, regardless of the return of the function above. Return type is boolean, the arguments are: world, x, y, z, boolean. I have no idea what this functions is used for, as vanilla code just returns false. func_149853_b gets called when the first function returned true. Return type and arguments the same as above. Vanilla code uses this to actually change the metadata. My crop (the bonemeal part, haven't done rendering and drops yet) works, but there still are a few things I don't understand. These are in bold. Could someone answer these questions? EDIT: I tried overriding canPlaceBlockOn like this: public boolean canPlaceBlockOn(Block block) { LogHelper.info(String.format("canPlaceBlockOn() returned %b", block == Blocks.farmland)); return block == Blocks.farmland; } When I try to place my crop on farmland, the log says: [20:17:45] [Client thread/INFO] [MysteriumCraft]: canPlaceBlockOn() returned true . When I try it on grass or dirt, the log says: [20:17:51] [Client thread/INFO] [MysteriumCraft]: canPlaceBlockOn() returned false . My function is clearly being called, but it doesn't influence the crop placement. The crop can also be placed on dirt & grass.
October 30, 201410 yr The first function in IGrowable is canGrow, so return true if you want bonemeal to work. The next one, is shouldGrow, this is where you check the chance of bonemeal working, etc. So you can return something like random.nextFloat() > 0.5F for example for a 50% chance of it growing every bonemeal use. The void method is doGrow, and is where you actually grow your plant. BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
October 30, 201410 yr Author Thanks! And how about my canPlaceBlockOn not working? And what is the boolean in canBonemeal?
October 31, 201410 yr I have a whole tutorial on custom crops that might help: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-creating-custom.html Check out my tutorials here: http://jabelarminecraft.blogspot.com/
October 31, 201410 yr The boolean in #func_149851_a( is equal to "world.isRemote". When true, (client side), the other functions won't get called. Basically a convenience feature if you want to add particles or whatever. See Block#canSustainPlant(IBlockAccess...): #getPlantType(World...) is also checked when #canPlaceBlockOn(Block) returns false. You might want to override one of those two.
October 31, 201410 yr Author Thanks to everyone in this thread, I managed to get the rendering & growing of my crop working. I got one (maybe even last?) question about crops: Is there a function "getDrops" or something similar where I can say "drop random.nextInt(3) seeds, drop 2 wheat"? Or do I need to use the functions func_149866_i (getSeedItem) and func_149865_P (getCropitem)?
October 31, 201410 yr Yes, there's a method called getDrops in the Block class in which you need to return an ArrayList<ItemStack> containing the ItemStacks that you want to drop. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
October 31, 201410 yr Author Everything is working perfectly, the items drop correctly, the crop grows, ... One problem, WAILA doesn't detect my crop as a crop any more. It doesn't show a percentage when I look at my crop. Is there any way to fix taht?
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.