Posted December 21, 201410 yr Hello, I got a bit of a problem with my crop. I wanted that my plant (when its fully grown) drops 1 --> 2 seeds and 1 --> 3 "strawberry's", the only problem that I have is when I add public int quantityDropped (Random random) { return 1+r.nextInt(3); } It counts for both, as well the strawberry's and seeds. I wanted to have a quantitydropped for my strawberry's, and one for my seeds. How do I do that? Thanks. Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
December 21, 201410 yr Author http://pastebin.com/WhLqyp3e Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
December 21, 201410 yr Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) instead Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 21, 201410 yr Author What do i return then? Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
December 21, 201410 yr Look at the function in Item.java You return an ArrayList of ItemStacks Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 22, 201410 yr Author I think I know what it getDrops is now, But I have some trouble with my stages. I now got multiple items at the last stage, but I want "green paprika" at stage 5, "yellow paprika" at stage 6, "red paprika" at stage 7. Otherwise, just the seeds. Here's my code: http://pastebin.com/rwVCQdny Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
December 22, 201410 yr Hi I guess you got a little confused by 'stage' and 'meta'. You want to check the meta data before adding ItemStacks to the ArrayList in getDrops. The metadata is given, so something like: switch(metadata){ case 5: //add desired paprika to ret break; case 6: //the other paprika break; case 7: //the last one break; default: //add seeds to the list break; } Hope that helped. Sincerely -pick Since English is not my mother tongue, my sentences may are confusing. I'm coding java for a long time now - just MC and forge stop me sometimes.
December 23, 201410 yr Author Ok, I have my crop dropping '3' at stage 5, 6 and 7. and 1 seed at the other stages. But I have still a problem: Sometimes my log says my plant that is fully grown has stage 0 (or other) what means that I get sometimes seeds when its fully grown. Thanks. I tried your switch and break, case thing, but my break gives an error, "Unreacheble code" but, This is my code: http://pastebin.com/jtMQB3Vs Thanks. Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
December 23, 201410 yr Hi Uh, it looks like you did not understand one core mechanic in minecraft: Each item and each block as only ONE SINGLE object at run time (guess why). So your 'bufferstage' thingy will never work! I'd recommend you the follwing changes to your code: 1. Rewrite the getItemDropped method and always return 1 (or any number of 'default' seed amount). 2. Rewrite the getItemDropped method to return the default output (e.g. seeds) 3. Write the getDrops method as following: 3.1 If metadata equals the 'green-Stage', then add (maybe multiple times) the green paprika to the output ArrayList. 3.2 If 'metadata' equals 'red-Stage', then add (maybe multiple times) the green paprika to the output ArrayList 3.3 If 'metadata' equals 'yellow-Stage', then add (maybe multiple times) the yellow paprika. 3.4 For any other 'metadata' add your seed item to the ArrayList. An example for the getDrops method body(please just don't copy paste it'): ArrayList<ItemStack> result = new ArrayList<ItemStack>; int amount = world.rand.nextInt(MAX_DROPS) + 1; int bonusMultiplier = 2; int bonusChance = world.rand.nextInt(10); if(bonusChance < fortune){ //so the fortune level equals the chance to get the double //amount of drops in %, multipied with 10 (e.g. fortune I => 10% chance) //double drops. amount *= bonusMultiplier; } for(int i=0; i<amount; i++){ switch(metadata){ case GREEN_STAGE: result.add(ModItems.greenPaprikaItem);//the object of your item break; case RED_STAGE: result.add(ModItems.redPaprikaItem);//red one break; case YELLOW_STAGE: result.add(ModItems.yellowPaprikaItem);//yellow break; } } if(metadata != GREEN_STAGE || metadata != RED_STAGE || metadata != YELLOW_STAGE){ result.add(ModItems.paprikaSeeds);//Or in a for loop if you want several seeds } return result; But to get back to one of your questions: If you have a construct like switch(someValue){ case 1: return something; break; } The break -statement is unreachable, because you return a line before it. May this reply is helpful Sincerely -pick Since English is not my mother tongue, my sentences may are confusing. I'm coding java for a long time now - just MC and forge stop me sometimes.
December 24, 201410 yr Author This reply is very helpful! Thanks, it now works fine and I now understand much more about the java code. Thank you for helping! Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
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.