Jump to content

How to get my item to be dropped from grass? - 1.12.2


UM3 F0R TH3 W1N

Recommended Posts

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)
    {
        
    }
}

Link to comment
Share on other sites

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; 
    }
}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by UM3 F0R TH3 W1N
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by UM3 F0R TH3 W1N
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.