Add Looting to Item-Dropping Procedures for Entities Tutorial

Started by Wyrm on

Topic category: User side tutorials

Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Add Looting to Item-Dropping Procedures for Entities Tutorial
Fri, 01/19/2024 - 22:54 (edited)

I'm not sure who needs to see this, but I know I definitely would have liked to have known this when I started, as I had a lot of trouble trying to get Looting to affect loot tables. So if you want to use an item-dropping procedure instead of a loot table, this is what you have to do. 

Keep in mind that this is for if you want the mob to drop only one of your item with a higher chance when you use Looting. If you want it to have a chance drop multiple items with Looting, add another "Spawn item/gem" block underneath. I also used 2023.1 for this, but I don't see why this wouldn't work for other versions.

https://imgur.com/a/F7hCtMa

The very top part without the "Get level of enchantment" blocks is just an ordinary random chance item drop procedure, everything else after that is the chance with looting.

Replace "Stray" at the top with any mob you want. I mainly used this with vanilla mobs as trying to edit their loot table was very confusing for me.

Replace the number after "Random [0,1) <" with the chance you want and the number after "Item in main hand of Source Entity" with the level of Looting. In my example, the diamond normally has a 5% chance to drop, a 25% chance with Looting 1, a 45% chance with Looting 2, a 65% chance with Looting 3, and a 100% chance with Looting 255. I used 255 as a test, so if you don't want that then you can just delete that whole if/do block.

It is important that you specify that the Event/Target Entity is the entity you kill and the Source Entity is the Player who kills it.

Anyways, as a first time modder, I felt very triumphant that I figured this out on my own, so I felt the need to share it with anyone else who needs help. Happy Modding!

Edited by Wyrm on Fri, 01/19/2024 - 22:54
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This was really helpful. now…
Sun, 01/28/2024 - 15:58

This was really helpful. now i have a reference for any enchantment procedures for any future projects

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have made a procedure that…
Fri, 12/27/2024 - 21:21

I have made a procedure that I think is better, as it actually uses the looting level to calculate how many times the item has a chance to drop from the kill. This means that if you have looting past level 3 (which you can for example get if you play with Quark installed), you will get the benefits of your tool's high looting level.
The first condition is to make the loot drop only if XP is also going to drop, which should usually be whenever a player is credited for the kill. That is for example the case with blaze rods dropping from blazes.

If your mob doesn't drop XP when killed, use this. It should achieve roughly the same thing, though I don't think it will trigger on kill assists.

I am also working on a procedure that will factor in enchantments from other mods, though that one is more difficult and I couldn't get it to have no upper limit so far, so it will only go between levels 1 and 3. I want that one to make compatibility with the Hunter enchantment from Majrusz's Enchantments. I'll post if here if it ends up working once I test it.

MCreator plugin used: Snails' Plugin - only for the simpler diceroll calculation - you can obviously use other methods of getting a random outcome

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
IMPORTANT EDIT:I forgot to…
Fri, 12/27/2024 - 21:39

IMPORTANT EDIT:
I forgot to add this:

Without this main condition, I suspect that the mob dying to damage not caused by an entity (such as fall damage, void damage, etc.) would probably crash the game.

Also, the condition for the drop to happen only if a player is involved in killing the mob, that is a very niche check that you might not want. It would prevent the drop only if the mob is killed by an entity holding a Looting weapon which is not a player or a pet. This will probably almost never happen in your game. It only prevents the extra drops in scenarios such as the source entity being a zombie with an enchanted sword.
So you may very well not want to add that condition. I'll keep it though, cause I like attention to detail.

 

Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I HAVE DONE IT! The…
Sat, 12/28/2024 - 01:25

I HAVE DONE IT! The procedure now works with Looting without an upper limit to the enchantment level and it works with Hunter from Majrusz's Enchantments at levels 1 to 9. I have made it a template procedure, which can get called by a mob dying with specified dependencies, so I can reuse the procedure for other bonus Looting drops. With custom logic that keeps track of the UUID of whatever player last attacked it or had a pet attack it, I have also managed to make it so it drops the extra loot whenever the kill is credited to a player, because it now relies on the looting level of the item in the main hand of the player that is kept track of by the costom logic, rather than Source Entity. So kill assists will also yield extra drops.

I think I will make a video tutorial on how it works, but it is almost 2:30 AM now so I really need to go to bed XD