Adding Drops to Vanilla Block?

Started by Adamskii6 on Mon, 01/09/2017 - 10:32

Topic category: Help with modding (Java Edition)

Last seen on 19:00, 11. Jan 2017
Joined Jan 2017
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Adding Drops to Vanilla Block?
Mon, 01/09/2017 - 10:32

So, I've started on a mod that makes sand in the beach biome drop some seashells. How do I do this? I've created the seashells but I don't know how to make a vanilla sandblock drop them, especially in the beach biome. This is all really difficult and I have very little experience with coding so please try to explain how I should do it. Thanks!

Last seen on 10:15, 29. Mar 2017
Joined Sep 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
i dont think its possible
Mon, 01/09/2017 - 13:45

i dont think its possible without coding

Last seen on 20:14, 7. Dec 2017
Joined Oct 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
You can't, it's actually
Mon, 01/09/2017 - 14:20

You can't, it's actually against Minecraft's TOS, but there might be a way using forge methods.

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
You need first make a event
Mon, 01/09/2017 - 14:47

You need first make a event handler. For this you can use GUI Overlay elements (because it is bascially event handler already). There you need subscribe for BlockEvent.HarvestDropsEvent add your item to dropList. So something like:

@SubscribeEvent
      public void onBlockBreak(BlockEvent.HarvestDropsEvent event)
   {

if(event.state.getBlock() == Blocks.sand && event.world.getBiomeGenForCoords(event.pos).biomeName == "Beach"){

event.drops.add(YOUR_ITEM);

}

   }

In case that you will get errors that some field is private , you will need use some getters like for example "getWorld()" instead of "world"

Last seen on 02:07, 12. Mar 2020
Joined Nov 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Naparu thanks to you i'm one…
Wed, 01/31/2018 - 03:33

Naparu thanks to you i'm one step closer to finally creating my first event handler. I've spent almost 2 weeks doing research and some trial and error. I however have still not managed to get it to work. I see there is a public static class GUIRenderEventClass { built inside the Gui overlay's code.

Are we supposed to replace that with our own? including the @subscribeEvent that comes right after it? I'm a bit confused, but I'm very close to making it. Please reply you are one of the most knowledgeable people I've seen giving explanations here on Mcreator.

Thanks