-
Notifications
You must be signed in to change notification settings - Fork 421
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
Stack aware getFoodComponent
#3295
Conversation
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.
Make sure Checkstyle passes before sending a PR...
Also, there are a couple copypastes you might want to fix.
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.
Please add a test to the testmod.
Added. The test works fine. |
fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/gametest/FoodGameTest.java
Show resolved
Hide resolved
fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/gametest/FoodGameTest.java
Show resolved
Hide resolved
fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/CustomDamageTest.java
Outdated
Show resolved
Hide resolved
...sfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/fluid/CombinedProvidersImpl.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/FoxEntityMixin.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/FoxEntityMixin.java
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/BlockItemMixin.java
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemStack.java
Outdated
Show resolved
Hide resolved
wait, the game test doesn't act as I thought. |
fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/gametest/FoodGameTest.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/gametest/FoodGameTest.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/CustomDamageTest.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/WolfEntityMixin.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/WolfEntityMixin.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/WolfEntityMixin.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItem.java
Outdated
Show resolved
Hide resolved
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.
Some notes about the javadoc
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemStack.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItem.java
Outdated
Show resolved
Hide resolved
…v1/FabricItemStack.java Co-authored-by: Juuz <[email protected]>
…v1/FabricItem.java Co-authored-by: Juuz <[email protected]>
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 PR looks good, my main worry is the amount of Mixins and @reDIrect's. I guess there isnt any other way around it. Might be nice to explore using Mixin Extras now that we have it.
|
||
@Mixin(BlockItem.class) | ||
class BlockItemMixin { | ||
@Redirect(method = "useOnBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/BlockItem;isFood()Z")) |
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.
Could a lot of these mixins be improved by using WrapOperation?
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.
At that moment IJ Idea and Minecraft Dev plugin doesn't support mixin extra well, so I use redirect instead to avoid potential a mass of errors.
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.
MCDev has had full mixinextras support for a long time now.
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.
Ah? I had a try just now, and found that it still suggests incorrect return type wrapping putting field.
For example, for the following wrap:
@WrapOperation(method = "<clinit>", at = @At(value = "FIELD", target = "Lnet/fabricmc/fabric/api/transfer/v1/fluid/FluidStorage;ITEM:Lnet/fabricmc/fabric/api/lookup/v1/item/ItemApiLookup;", opcode = Opcodes.PUTSTATIC))
the correct handler method signature should be
private static void customField(ItemApiLookup<Storage<FluidVariant>, ContainerItemContext> value, Operation<ItemApiLookup<Storage<FluidVariant>, ContainerItemContext>> original)
but minecraft dev plugin suggests that it should be
private static ItemApiLookup<Storage<FluidVariant>, ContainerItemContext> customField(ItemApiLookup<Storage<FluidVariant>, ContainerItemContext> value, Operation<ItemApiLookup<Storage<FluidVariant>, ContainerItemContext>> original)
The latter causes an error on game launching.
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.
Ok you might be right about that one… will fix
Don’t know of any other such cases
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.
I just found that fabric api project still remains loader 0.14.21... And fabric item api still depends on fabricloader >=0.4.0 in fabric.mod.json... Shall we update them?
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.
We had the same problem in #3403 (comment) and decided on using the @reDIrect's in 1.20.1/.2 and then for .4 using ME. Quite happy to leave this as-is and when cherry-picking to 1.20.4 I can change this to use ME.
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItem.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/WolfEntityMixin.java
Outdated
Show resolved
Hide resolved
fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/gametest/FoodGameTest.java
Outdated
Show resolved
Hide resolved
…v1/FabricItem.java Co-authored-by: Juuz <[email protected]>
small fix
I plan to do another release very shortly, I will re-target this PR to 1.20.4 and use ME. |
I have created a 1.20.4 + ME version of this PR here: #3520 |
Merged into 1.20.4 via #3520 Many thanks for this 👍 |
Similar to
getRecipeRemainder
.