Teleport Item to Inventory when Mined

Started by Cheezy_Amuzus on Sun, 08/09/2020 - 22:45

Topic category: Help with modding (Java Edition)

Last seen on 21:02, 11. Aug 2020
Joined May 2018
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Teleport Item to Inventory when Mined
Sun, 08/09/2020 - 22:45

Hi, first post on the forum (i think) and I was able to do a lot of advanced modding in MCreator but I'm having an issue figuring out how to make it so when a block is mined, or mob is killed with an item that has an enchantment I made, it teleports the drops to the player's inventory. I've gotten everything else done except I'm stuck on the part where it finds out the normal drops for the mob or block so it can set it in the player's inventory.

Last seen on 21:02, 11. Aug 2020
Joined May 2018
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Btw I found out how to…
Sun, 08/09/2020 - 23:58

Btw I found out how to teleport blocks to inventory when mined but not drops. For example, when you mine stone it teleports the stone into your inventory not cobblestone which is what it should drop.

Last seen on 06:19, 28. Oct 2020
Joined Jun 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
you could then remove one…
Tue, 08/11/2020 - 09:54

you could then remove one stone from the inventory and give the player a cobblestone

Last seen on 06:19, 28. Oct 2020
Joined Jun 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
And how did you make sure…
Tue, 08/11/2020 - 09:54

And how did you make sure the actual drop doesn't get picked up by the player?

Last seen on 21:02, 11. Aug 2020
Joined May 2018
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
For your first question: So…
Tue, 08/11/2020 - 19:51

For your first question: So I have to code all the alternate drops for each block? Well, what if someone uses the enchantment on pickaxe with a block in other mods?

For your second question: I break the block in the event because based on what I've seen when triggered with "when a block is broken" it runs the event specifically before the block is officially broken. So I just get the drop of the block that was mined and import it into the player's inventory and then the last event destroys the block and turns it into an air block before it can officially be "broken" so it doesn't drop anything. On the player's screen it seems seamless and it looks normal. If you want me to send my code I can.

Last seen on 21:02, 11. Aug 2020
Joined May 2018
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
For your first question: So…
Tue, 08/11/2020 - 19:52

For your first question: So I have to code all the alternate drops for each block? Well, what if someone uses the enchantment on pickaxe with a block in other mods?

For your second question: I break the block in the event because based on what I've seen when triggered with "when a block is broken" it runs the event specifically before the block is officially broken. So I just get the drop of the block that was mined and import it into the player's inventory and then the last event destroys the block and turns it into an air block before it can officially be "broken" so it doesn't drop anything. On the player's screen it seems seamless and it looks normal. If you want me to send my code I can.

Last seen on 06:19, 28. Oct 2020
Joined Jun 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Ok, but I think people would…
Wed, 08/12/2020 - 07:38

Ok, but I think people would understand if different mods won't compile with each other, otherwise you might have to code to access the code? (Don't ask me how, I cannot code.)

Last seen on 06:19, 28. Oct 2020
Joined Jun 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I know this would be really…
Wed, 08/12/2020 - 07:55

I know this would be really painstaking process but it actually wouldn't take that long to code in every block in minecraft because 

1. Not all of them are mineable

2. You can just copy&paste the code and change the input and output. 

if you are looking at mobs it gets pretty complicated. You can quickly place fire where they stood to burn the loot and turn it to air again? it would only take a tick or two so it wouldn't be really recognisable.  it wouldn't work in water but that is the only suggestion I have. For the actual drop for the player you need to look at the minecraft wiki for the loot table and drop rate.

Last seen on 06:19, 28. Oct 2020
Joined Jun 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
After some thought, you don…
Mon, 08/17/2020 - 11:05

After some thought, you don't even have to code most of it. You already know how to get the blocks into the player's inventory. You just need to specify on the few blocks including leaves, coal, diamonds, stone, crops, sea lanterns, etc. There is a much shorter list of that, and won't take you long.