New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing information to instances of LootContext #4443
Add missing information to instances of LootContext #4443
Conversation
This has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@mezz Any issues with this PR? |
I overlooked this before. |
Ah I see, the changes in the vanilla conditions is a problem. |
@mezz The issue goes in the other direction. Vanilla loot tables will work fine with Forge. It's Forge loot tables that will not work in vanilla, but only if they use the mentioned conditions in the mentioned scenarios. |
Ok, I see. That is less of an issue, but it does seem like it would be confusing for modders that run across those situations though. |
Loot conditions have no awareness of what table they're in. |
I don't think minecart/fish hook should have "looted entity", you have to remember that that method name is only assigned by MCP and is our guess at which it actually is. But in vanilla, "looted entity" is only used in tables for drops when the "looted entity" is dying and spawning its own drops, iirc. It's kind of weird to think of fish as the drops of the fish hook, imo. |
{ | ||
"loot": ["minecraft:chests/simple_dungeon"] | ||
}, | ||
"requirements": [["no"]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"requirements" can be omitted if all of the criteria are needed, as it is in this case.
@williewillus Vanilla passes the player as the looted entity for advancement loot rewards. |
huh, okay. looks good then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be very useful in the mod I'm working on. Nice work!
I could use this to get the position of the loot in every case except when a container generates loot without a player... I can live with that though.
@Tmtravlr I don't think adding new information to the LootContext is in scope for this PR. You could make your own PR for that though. |
This has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I have looked into this more and think it makes sense. |
Changes in this PR
This PR adds any missing info to LootContext instances if that info is available. For example, the minecart loot context does not provide the player, though the player may be available. A list of the changes made to each LootContext follows:
Usecases
The additional information allows LootFunctions and LootConditions to provide functionality that they could not provide before, or expands the range of scenarios they can work in. For example, biome dependent fishing loot is made possible by this PR and is demonstrated in the test mod. Additional use cases include depth dependent loot in loot containers and minecarts, and items that change loot from loot containers, minecarts and fishing when in the inventory.
Testing
This PR includes a test mod(disabled by default) which:
A test world is attached to this post. It contains command blocks that help test that this PR works correctly, as well as a pond in the savannah biome. All the command blocks are labeled with their function using signs. Note that the in biome condition checks that biome that the looted entity is in, with fishing the looted entity is the fish hook.
Vanilla Compatibility
As loot tables are solely server-side, this PR does not compromise compatibility between Forge and Vanilla Minecraft. However due to the additional information provided, it does cause certain vanilla loot conditions to work in scenarios that they would not work in in Vanilla MC. By "work" I mean that they will not return early, or they will have a visible effect. A list of these conditions and the scenarios in which their behaviour will change follows:
entity_scores
andentity_properties
conditions with "killer_player" as the target will work for advancement loot rewards, minecart loot, chest loot and fishing loot.entity_scores
andentity_properties
conditions with "this" as the target will work for advancement loot rewards, minecart loot and fishing loot.killed_by_player
will work for advancement loot rewards, minecart loot, chest loot and fishing loot.Are these changes in behaviour an issue?
Improved Loot Contexts Test World.zip