Skip to content
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

De-hardcode Shears #1287

Draft
wants to merge 2 commits into
base: 1.16
Choose a base branch
from
Draft

De-hardcode Shears #1287

wants to merge 2 commits into from

Conversation

deirn
Copy link
Member

@deirn deirn commented Jan 26, 2021

Redirects all item == Items.SHEARS from vanilla.
Used this to transform the loot tables (of course i'm not doing that manually)

grep -L '"item": "minecraft:shears"' * | xargs rm -f
grep -rli '"item": "minecraft:shears"' * | xargs -i@ sed -i 's/"item": "minecraft:shears"/"tag": "fabric:shears"/g' @

Closes #1226

@Prospector
Copy link
Contributor

For now, replacing the whole loot table jsons is fine in my opinion, however at some point I think we need a better way to do this, so that any mod can go in and replace stuff like this in a way that would allow for multiple mods to work on the same loot table.

@deirn
Copy link
Member Author

deirn commented Jan 27, 2021

That sounds like a nightmare to support :P

@OroArmor
Copy link

maybe it would make sense to mixin to where the condition is checked, then to see if its shears then to check if its in the tag rather than change the loottables

@deirn
Copy link
Member Author

deirn commented Jan 27, 2021

I believe I could mixin to MatchToolLootCondition#test. The upside is it'll transform any loot tables, but then there won't be a way to check only for vanilla shears. I looked around on forge and it just replaces the loot table like I did.

@OroArmor
Copy link

hm thats a good point. however, im not sure why someone would want something specific to the vanilla shears. There also might be a way to add another condition that forces the item in that case, but this feels hacky. The idea of transforming the loottables isn't bad, i was just hoping there would be a better way in code to do so.

@Prospector
Copy link
Contributor

I definitely think Fabric should only ever touch vanilla loot tables, not modded ones, what I was mainly talking about would be allowing multiple other mods to make similar modifications to vanilla loot tables. For example, one mod that changed a drop, and another that changed a condition. However, as I said, out of scope for this PR.

@Technici4n Technici4n added enhancement New feature or request reviews needed This PR needs more reviews small change priority:medium Medium priority PRs that should get reviews labels Jan 28, 2021
@Technici4n Technici4n requested a review from a team January 28, 2021 17:39
@maityyy
Copy link
Contributor

maityyy commented Jan 29, 2021

For leaves/cobweb loot tables, etc., you can use Fabric Loot Table API v1 or wait for new v2. Would be a good test for @Juuxel

@deirn
Copy link
Member Author

deirn commented Jan 29, 2021

As Prospector said, there's currently no easy way to modify entries via code. Adding a new pool with same result won't work since there will be duplicates. https://youtu.be/9zXBNFLADGg

@liach
Copy link
Contributor

liach commented Jan 29, 2021

Guess we will write a loot table visitor, like the tree visitors used by asm, javac api and all those cool stuff?

@RedstoneParadox
Copy link
Contributor

RedstoneParadox commented Feb 17, 2021

Guess we will write a loot table visitor, like the tree visitors used by asm, javac api and all those cool stuff?

Is anyone currently working on that?

Edit: I mean if no one is, I can work on that.

@kanpov
Copy link

kanpov commented Jan 31, 2022

rip stale fabric pr number 1996894

@Juuxel
Copy link
Member

Juuxel commented Jan 31, 2022

As Prospector said, there's currently no easy way to modify entries via code. Adding a new pool with same result won't work since there will be duplicates. https://youtu.be/9zXBNFLADGg

@deirn I think that can be done with #1241's LootTableEvents.REPLACE if you actually implement the entry modification yourself. (Just iterate through the pools and replace whatever's needed, then construct a new table and replace the old one)

@Technici4n
Copy link
Member

Wouldn't that require a way to not modify "manual" loot tables? We probably want users to be able to override our changes. Can't we use datagen to replace vanilla's tables?

@Juuxel
Copy link
Member

Juuxel commented Jan 31, 2022

Wouldn't that require a way to not modify "manual" loot tables?

Yeah, and that's an issue with the loot api in general; see Fabricord #api.

Can't we use datagen to replace vanilla's tables?

How do we ensure that FAPI's "augmented" vanilla loot tables are not loaded instead of loot tables in other mods? If a mod makes an actual replacement for the loot table, that should be preferred over that sort of compat replacement.

@Technici4n
Copy link
Member

No idea how we could prevent that tbh. Possibly with a resource condition that allows other mods to disable our tables?

@deirn deirn marked this pull request as draft February 2, 2022 07:44
@AnAwesomGuy
Copy link

would love this, as im currently trying to make a mod that adds stone shears

@Technici4n
Copy link
Member

Would be interesting to see how Forge addresses this.

@deirn
Copy link
Member Author

deirn commented Apr 18, 2023

Last time I looked at Forge it just replaced the loot tables.

@Technici4n
Copy link
Member

That seems fine by me, we could likely datagen them.

@DaFuqs
Copy link

DaFuqs commented May 5, 2023

Multi-Item-Lib does not handle loot tables, it seems like.
IMO, instead of using an in-code registry like done in Multi-Item-Lib, items should be put in a tag instead, like c:shears for easier backwards compatility and matching the vanilla way, like other tools like pickaxes are handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:medium Medium priority PRs that should get reviews reviews needed This PR needs more reviews small change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shears not completely de-hardcoded