Jump to content

Recommended Posts

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

Posted

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

  • Thanks 1
Posted

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

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