UM3 F0R TH3 W1N Posted December 26, 2018 Share Posted December 26, 2018 Hello fellow modders, I have made some seeds for my crop and I wanted to know how I can get these seeds to be dropped from grass! I know this is possible as I have seen it done before however I am clueless of how it is done. Can anyone help me doing this as I would love to have this in my mod. Many thanks in advance! Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 oh you can? thx, i'll look into it now Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 3 minutes ago, diesieben07 said: You can add drops to other blocks by subscribing to BlockEvent.HarvestDropsEvent. this may sound stupid, but can you remind me of how to do that pls lol, ive took a break from programming and just got back into it, so ive forgotten a lot Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 thx Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 25 minutes ago, diesieben07 said: You can read up on how Forge's events work in the documentation. so what do I need to put inside of my Event class? this is what I currently have: package com.turtywurty.minecraftmadness.events.seeds; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SeedsFromGrassEvent { @SubscribeEvent public void getSeedsFromGrass(HarvestDropsEvent event) { } } Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 22 minutes ago, diesieben07 said: First of all, I doubt you own that domain name. Actually, I know you don't own it, since it's still for sale. what domain name lol Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 (edited) that's my package name not my domain name, I use it for all my mods but ok Edited December 26, 2018 by UM3 F0R TH3 W1N Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 1 minute ago, diesieben07 said: They are the same. well that's not important so ok Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 28 minutes ago, diesieben07 said: Do add your drop, that doesn't make sense anyways ^ Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 (edited) and theres no methods that it lets me use Edited December 26, 2018 by UM3 F0R TH3 W1N Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 so I need to create a method called getDrops()? Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 1 minute ago, diesieben07 said: No. You need to call HarvestDropsEvent#getDrops and add your desired drops to it. it doesn't let me call it Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 2 minutes ago, diesieben07 said: Provide code of what you have tried. package com.turtywurty.minecraftmadness.events.seeds; import java.util.List; import net.minecraft.item.ItemStack; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SeedsFromGrassEvent { public final List<ItemStack> drops; @SubscribeEvent public void getSeedsFromGrass(HarvestDropsEvent event) { } public List<ItemStack> getDrops() { return drops; } } Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 Just now, diesieben07 said: That is nowhere near what I said. Why did you add a field? Why did you add a method? You need to call a method. I tried, it wont let me Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 1 minute ago, diesieben07 said: Again: Show. What. You. Tried. package com.turtywurty.minecraftmadness.events.seeds; import java.util.List; import net.minecraft.item.ItemStack; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SeedsFromGrassEvent { @SubscribeEvent public void getSeedsFromGrass(HarvestDropsEvent event) { getDrops(); } } but getDrops(); has an error saying that I need to create the method Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 Just now, diesieben07 said: Yes, because getDrops is a method on HarvestDropsEvent. You know Java, right? a bit but as I said, I took a break, so ive forgotten a lot of it also: HarvestDropsEvent.getDrops(); doesn't work either Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 (edited) 5 minutes ago, diesieben07 said: It is not a static method... //but HarvestDropEvents h = new HarvestDropEvents(); h.getDrops(); //doesn't work either Edited December 26, 2018 by UM3 F0R TH3 W1N Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 nvm im stupid Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 (edited) so, this works: package com.turtywurty.minecraftmadness.events.seeds; import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SeedsFromGrassEvent { @SubscribeEvent public void getSeedsFromGrass(HarvestDropsEvent event) { event.getDrops(); } } so what do I do now, we're getting somewhere now lol Edited December 26, 2018 by UM3 F0R TH3 W1N Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 hello? Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 11 minutes ago, diesieben07 said: Add your desired item stack to the List you have now obtained. This is not a chat room. alright, thanks soo much for the help, sorry for me being a noob but I've got the hang of it now, i'm currently in the process of testing it and im hoping it works, however don't I need to call this method in my main class or something Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 7 minutes ago, diesieben07 said: You will need to register your event handler to the event bus, refer to the documentation linked above for more information on that. so like this: MinecraftForge.EVENT_BUS.register(SeedsFromGrassEvent.class); Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 Just now, diesieben07 said: That would be for a static event handler method, your code so far has shown a non-static one. so this would work right: SeedsFromGrassEvent seedEvent = new SeedsFromGrassEvent(); MinecraftForge.EVENT_BUS.register(seedEvent); Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 1 minute ago, diesieben07 said: Why don't you try it? ok, it works but they drop every single time, is there a way I can change it to be the exact same as normal seeds? Quote Link to comment Share on other sites More sharing options...
UM3 F0R TH3 W1N Posted December 26, 2018 Author Share Posted December 26, 2018 (edited) 9 minutes ago, diesieben07 said: Tall grass has a drop-chance of 1/8 for seeds. So, generate a random number from 0 through 7 (Random#nextInt(8)) and check if it's 0. You can see this in BlockDoublePlant#getItemDropped. ok thx so much, however it says that HarvestDropsEvent#getDropChance() is a float value not integer Edited December 26, 2018 by UM3 F0R TH3 W1N Quote Link to comment Share on other sites More sharing options...
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.