Jump to content

Making a vanilla block drop a second item


TheCrudNation

Recommended Posts

I found something on another post from Forge 1.11.2 

@SubscribeEvent
	public void yourPlayerHarvestEvent(HarvestDropsEvent event) {
		if (event.getHarvester() != null) {
			
			if (event.getState() == Blocks.QUARTZ_ORE.getDefaultState()) {
				event.setDropChance(0.1f);
				event.getDrops().add(new ItemStack(ItemRegistry.herkimer_diamond, 1));
			}
			
		}
	}

Has it really changed that much in so little versions or is there a simpler way of doing it?

Link to comment
Share on other sites

  

Just now, TheCrudNation said:

HarvestDropsEvent event

Doesn't exist any more. Has been replaced by Global Loot Modifiers

 

If you don't want to use them then do it this way:

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderfarming/EventHandlers.java#L49-L53

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/resources/data/harderfarming/loot_tables/blocks/grass.json

Edited by Draco18s

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.

Link to comment
Share on other sites

I'm quite new to java, how does one make sure the event is fired? I created a class called EventHandler inside of my handlers package and it contains literally just this.


@EventBusSubscriber
public class EventHandler {

}

so anything I put in here will be fired?

Link to comment
Share on other sites

1 minute ago, TheCrudNation said:

So I don't need to reference my EventHandler class anywhere else?

As long as it's got the EventBusSubscriber annotation and the event handler methods are static, and have the SubscribeEvent annotation, you should be good to go.

Link to comment
Share on other sites

6 hours ago, diesieben07 said:

Can you stop recommending this crappy way to people?

Sure can.

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello...I got a crash, "The game crashed whilst rendering entity in world Error: java.lang.IllegalArgumentException: Duplicate delegates" In game I was walking upstairs in a house, and it suddenly crashed on me. Now it keeps crashing when I try to enter that world. I tried to give more RAM by changing it to 4...I'm not really wanting to get rid of any of the mods I have if possible. I'm absolutely clueless about crashes and whatnot...can anyone tell me what's gone wrong? This is the pastebin crash report Here Let me know if I need to include anything else
    • Hello!! Waiting around 45 seconds to reply can be a drag, especially when you're in the middle of a conversation. It might be worth looking into whether the forum software can tweak things a bit. Like maybe active members could have a shorter delay or none at all, while newbies or less active folks still have to wait. I don't have the power to change this myself, but I'll mention it to the forum mods.  Hang in there!
    • HELLO!! With your setup, you should be getting better performance. Try using Minecraft version 1.12.2 or 1.16.5 for better mod compatibility. I personally advice you to have the latest Optifine installed and tweak settings like lowering render distance and graphics. Also, consider using performance mods like Sodium and updating your GPU drivers. Allocating 4-8 GB RAM in the launcher might help too. Good luck!
    • Getting back into modding, the last time I seriously modded was almost 6 years ago.  I'm pretty rusty and a lot has changed.  What I'm trying to do right now is right a method that can remove an item's recipe using only said item's ResourceLocation as an input. From what I've gathered from older examples online it seems like the preferred method to do this involves using a DummyRecipe as that breaks the least amount of stuff (such as achievements related to a given item). The problem I'm having is that most of these examples are quite dated, usually being for 1.12. It seems that enough of the methods have changed for 1.18.2 forge that the implementation will be quite different, and that is what I'm struggling with so right now.  The basic concepts are still the same, but some of the classes I need to reference and what methods are where on said classes has been swapped around, and its giving me trouble.   I'm sure I could figure it out after a few days, but I figured it would make sense to ask for help as that may expedite the process.   Thanks in advance.
    • i getting same issue with my modpack so how can find the which mod not incompatible with i like wood, i removed variant vanilla mod because was most sense but still red loading screen and closing with world generating screen appering without crash. anyone can help me?
  • Topics

×
×
  • Create New...

Important Information

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