Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

In the mod that I'm working on I need to make it so that BlockMonsterSpawner (vanilla) drops a MobCage (my mod) when it is destroyed. I've looked for a @SubscribeEvent to use but cannot find one for block destruction, and as such have come to believe that there is not a way to do so without editing BlockMonsterSpawner.class.

 

My question, therefore, is twofold:

[*]Is there a way to modify or add to vanilla block drops in Forge? (The version I have in my environment is the current Recommended (10.12.1.1060).)

[*]If not, as I suspect and have seen several times from repeated googling, how should I go about changing the getItemDropped(int, Random, int) and quantityDropped(Random) methods to make BlockMonsterSpawner drop a MobCage? As is in Eclipse I cannot just edit the Minecraft files as they are read-only (as they should be).

 

Thank you in advance for your help for a beginning modder. If you're interested, my workspace is Eclipse as set up by Wuppy in his tutorial on setting up Forge development enviroment (http://www.wuppy29.com/minecraft/modding-tutorials/wuppys-minecraft-forge-modding-tutorials-for-1-7-set-up-part-2b-advanced-forge-setup/).

Subscribe to Blockevent.Blockbreak event. Check that is the block is a spawner and add your item to the drops list

  • Author

As seems always the case, the OP has solved their own problem moments after posting it due to finding something they originally overlooked.

 

When looking one more time in net.minecraftforge.event I found that net.minecraftforge.event.BlockEvent held a class HarvestDropsEvent that does exactly what I wanted to.

 

By pushing a(n?) @SubscribeEvent on(HarvestDropsEvent) to MinecraftForge.EVENT_BUS I was able to hook an event that if the block that checks for dropping happens to be an instanceof BlockMonsterSpawner to add an ItemStack(mobCage, 1) to the drop queue.

 

I hope that in the future people searching for how to do Custom Vanilla Block Drops in Forge can find this thread or do what I have done and find it themself so they can continue on and make great (or at least working) mods.

 

My Listening class for those interested to accomplish this task:

https://gist.github.com/CAD97/0f67b8f95804a0bd2d90

  • Author

Oh, and thanks for answering Degubi, but you were a little too slow xD

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.