Jump to content

[1.15.2] Help with loot modifiers and global loot modifiers


BadBichShaquonda

Recommended Posts

Hi guys, I'm making a new shark entity and I wanted to make it so that if my shark breaks any kind of boat, modded or not, the respective wood drops with some sticks.

 

For example, if a shark breaks an obsidian wood boat from some random obsidian boat mod, it should drop obsidian wood planks and two sticks (complete fictional mod).

 

Before I ask my questions, I want to point out a couple things: when a player breaks a boat, the boat item is dropped from the Minecraft code itself (no loot tables involved), and it is then destroyed using its .remove() method.

 

Minecraft determines what kind of boat to drop using a switch block. I'm unsure how is it done in other mods, probably using a loot table, but anyway, just wanted to point this out.

 

Additionally, what I'm doing in my shark entity, specifically in my SharkAttackGoal, is the following:


0. ... lots of code: here's my GitHub: https://github.com/BadBichShaquonda/shark-mod/tree/dr_shtroumphi ...
1. Check if the shark is close enough to attack
2. If it is, check if the entity that is being attacked is in a boat
3. If it is, call the boat method to drop an Item and then the boat method to remove the boat, exactly like vanilla Minecraft
4. This essentially means that my shark has no actual link to the boat, which had to do with one of the questions I will ask

 

My questions are..

 

1. Is this even possible? My java programming skills are a lot better than my JSON loot table skills

 

Assuming it is possible, then:

 

2. Are there any good guides for making loot modifiers? I know there is a guide for global loot modifiers which does not look too complicated.
3. I know what tags are, so would I use tags in this case to get modded wood from modded boats, or is this completely wrong? What should I use?
4. Because my shark has no link to the boat, what condition would I have to add in the JSON for this? I know there is 'killer', but is my shark actually considered the killer? If not, how can I make it so?
5. Would I have to make a new condition, or function? How would I go about doing either of those things?

 

Assuming it isn't possible, then what would be better? Making my own loot modifiers for simple Minecraft boats, or just doing it in java as the normal Minecraft code does..?

 

Any help here would be appreciated, as I don't quite know the limitations of loot tables. 

 

Have a great day, and thank you for your reply!

Link to comment
Share on other sites

If the boat does its own drops via Java code, it does not hook into the loot_table system and therefor does not invoke the global loot modifiers system.

Beyond that I do not understand how that relates to your shark.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

So then there would be no way of using loot modifiers to get this to work, I assume?

4 minutes ago, Draco18s said:

Beyond that I do not understand how that relates to your shark.

Not sure what you mean by this, but essentially what I want is the boat to drop its wooden materials when my shark "breaks" it.

Would there be any other way, java-wise, that I could get the type of the boat and then make it drop its planks, whether the boat is from some other mod or not?

 

Thank you

Edited by BadBichShaquonda
Link to comment
Share on other sites

13 minutes ago, BadBichShaquonda said:

So then there would be no way of using loot modifiers to get this to work, I assume?

I haven't looked at boats, but like I said, if the boat is generating the stacks without going through the standard systems, then correct: loot modifiers won't work.

14 minutes ago, BadBichShaquonda said:

I could get the type of the boat and then make it drop its planks, whether the boat is from some other mod or not?

All you should have to do is "get boat, tell boat is is broken" and let the boat handle itself.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Also BoatEntity#getBoatType().asPlank()

Edited by Draco18s
  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

5 minutes ago, Ugdhar said:

I don't think BoatEntity#getBoatType() will work for modded boats, as the BoatEntity.Type enum is coded with the vanilla boat materials, and doesnot appear extensible.

Possible. I don't have a modded boat to look at. I was just looking at what BoatEntity#updateFallState() does (the only place it generates its non BoatItem drops).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

This mod has a bamboo boat:

https://github.com/bageldotjpg/Bamboo-Blocks/tree/master/src/main/java/com/pugz/bambooblocks/core

 

In https://github.com/bageldotjpg/Bamboo-Blocks/blob/master/src/main/java/com/pugz/bambooblocks/core/BambooBlocksRegistry.java :

public static final RegistryObject<Item> BAMBOO_BOAT = HELPER.createBoatItem("bamboo", BAMBOO_PLANKS);

 

I'm guessing then that any boat that would extend the boat item class would work in my favor? The HELPER variable is of type RegistryHeper.

Edited by BadBichShaquonda
Link to comment
Share on other sites

That helper class is someone a library mod (source here) where he uses a custom boat item, a custom "boat registry," a custom boat entity, which has a custom way of handling the drops.

 

You are not guaranteed that every modder will do things using that same library. In fact, I would suspect the opposite: that every modder will run their own custom solution.

 

Good (friggin') luck

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

The other solution is to just make the boat drop as normal, or not make it drop at all. I may just make it drop as normal since that will just solve everything.

Actually no it won't. Because the shark will only be able to break vanilla boats. The check I'm using is

if(enemy.isPassenger() && enemy.getRidingEntity().getClass() == BoatEntity.class) {
	BoatEntity boat = (BoatEntity) enemy.getRidingEntity();
	boat.entityDropItem(boat.getItemBoat());
	boat.remove();
}

 

Honestly I guess I'll just make it vanilla compatible, and the shark wont be able to break other mods' boats. and if someone wants it to be compatible, i'll make it compatible with some specific mods XD

 

15 minutes ago, Draco18s said:

Good (friggin') luck

Thanks XD

Link to comment
Share on other sites

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.