JohnnyMccurm Posted February 20, 2015 Posted February 20, 2015 Hey guys I wondered if there was any way to make a Block drop multiple Items and at different quantities when it is destroyed by the user. What I mean by this is, I'd like, for example a Cheese Block that drops: A high chance of Cheese Chunks, (1+ 0-3 per destruction) A moderate chance of Cheese Slices, (0-2) and has a very rare chance to contain a Mouse. (0-1) How would I achieve this with a Custom block OR an Official Minecraft block? I thought about using an if or case construct and I figured they weren't completely random (I preset limited outcomes) and I'd like a better way of achieving this result. Quote Think Java is tough? try BrainFuck!
Draco18s Posted February 21, 2015 Posted February 21, 2015 Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) Quote 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.
JohnnyMccurm Posted February 21, 2015 Author Posted February 21, 2015 I am a massive noob when it comes to modding, I only started last week, can you guys provide a practical example? I'd be grateful. And thanks for the help, I appreciate the quick response, this is going to be the core functionality of the mod I seek to create. **Update** @Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { ArrayList<ItemStack> drops = new ArrayList<ItemStack>(); drops.add(new ItemStack(Items.coal, world.rand.nextInt(3) + 1)); drops.add(new ItemStack(Items.iron_ingot, world.rand.nextInt(2) + 1)); if (world.rand.nextFloat() < 0.5F) drops.add(new ItemStack(Items.diamond)); return drops; } Typed this up fast to see if it would work. **Update 2** I'm incredibly surprised that it worked, but it did apparently, just need to play around with the code a little. How would I do this for vanilla blocks then? Pic related, two custom face items I made dropping from a single block and in different quantities Quote Think Java is tough? try BrainFuck!
Draco18s Posted February 21, 2015 Posted February 21, 2015 [nobbc] code here [/nobbc] Also, define "doesn't work" Quote 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.
JohnnyMccurm Posted February 21, 2015 Author Posted February 21, 2015 [nobbc] code here [/nobbc] Also, define "doesn't work" I need to type in the html formatting/styles myself and I can't click any of the GUI buttons in the editor. I suppose it is just an issue on my end and not a global issue, no big deal. Quote Think Java is tough? try BrainFuck!
jabelar Posted February 21, 2015 Posted February 21, 2015 How would I do this for vanilla blocks then? You need to handle the HarvestDropsEvent. If you haven't used events before, you might want to check my tutorial here: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html Events are actually really easy once you figure them out, and are actually the best way to modify most vanilla behavior. So it is worth while taking the time to figure them out. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Recommended Posts
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.