-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Added TooltipLines operator #1450
Added TooltipLines operator #1450
Conversation
.function(input -> { | ||
ValueObjectTypeItemStack.ValueItemStack itemStack = input.getValue(0, ValueTypes.OBJECT_ITEMSTACK); | ||
return ValueTypeList.ValueList.ofList(ValueTypes.STRING, | ||
itemStack.getRawValue().getTooltipLines(Minecraft.getInstance().player, TooltipFlag.Default.NORMAL).stream() |
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.
Minecraft
is a client-side-only class, so this will unfortunately crash when used on servers.
But I believe the first param of getTooltipLines
is Nullable
, so we can just pass null
here.
I had a feeling it would be that way, wasn't sure if the context would be
changing the output so kept it in (copied from the IntegratedTerminals
query code).
I suppose setting it to null will make the output consistent, but might
create scenarios where testing in a terminal query would produce different
results, though that might not be important.
I'll change it when I get home, running some errands right now
…On Mon, Dec 30, 2024, 15:58 Ruben Taelman ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/Operators.java
<#1450 (comment)>
:
> @@ -1965,6 +1967,19 @@ public IValue evaluate(OperatorBase.SafeVariablesGetter variables) throws Evalua
itemStack -> !itemStack.isEmpty() && itemStack.hasTag()
)).build());
+ /**
+ * Get the tooltip lines of an itemstack.
+ */
+ public static final IOperator OBJECT_ITEMSTACK_TOOLTIP_LINES = REGISTRY.register(OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG
+ .output(ValueTypes.LIST).symbol("tooltip_lines").operatorName("tooltiplines").interactName("tooltipLines")
+ .function(input -> {
+ ValueObjectTypeItemStack.ValueItemStack itemStack = input.getValue(0, ValueTypes.OBJECT_ITEMSTACK);
+ return ValueTypeList.ValueList.ofList(ValueTypes.STRING,
+ itemStack.getRawValue().getTooltipLines(Minecraft.getInstance().player, TooltipFlag.Default.NORMAL).stream()
Minecraft is a client-side-only class, so this will unfortunately crash
when used on servers.
But I believe the first param of getTooltipLines is Nullable, so we can
just pass null here.
—
Reply to this email directly, view it on GitHub
<#1450 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALUMCD46IEY25JFYV4EFFXD2IFNSDAVCNFSM6AAAAABUME6ILGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKMRVGY4DEMJSGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Indeed, there may be cases where it will be different. |
Good catch, I changed that description 7 times based on the other
operators, became blind for whether or not it was good enough
…On Mon, Dec 30, 2024, 17:02 Jack McKalling ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/main/resources/assets/integrateddynamics/lang/en_us.json
<#1450 (comment)>
:
> @@ -1232,6 +1232,8 @@
"operator.integrateddynamics.itemstack.nbt.info": "Get the NBT tag of the given item.",
"operator.integrateddynamics.itemstack.hasnbt": "Has NBT",
"operator.integrateddynamics.itemstack.hasnbt.info": "If the item stack has an NBT tag.",
+ "operator.integrateddynamics.itemstack.tooltiplines": "Tooltip Lines",
+ "operator.integrateddynamics.itemstack.tooltiplines.info": "Get the tooltip of the given item in a list of strings.",
Would it be better to say "*as* a list of strings"?
—
Reply to this email directly, view it on GitHub
<#1450 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALUMCD5SZ5XA3QSBKTSRKNL2IFU73AVCNFSM6AAAAABUME6ILGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKMRVG42DONZZGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
* Get the tooltip lines of an itemstack. | ||
*/ | ||
public static final IOperator OBJECT_ITEMSTACK_TOOLTIP_LINES = REGISTRY.register(OperatorBuilders.ITEMSTACK_1_SUFFIX_LONG | ||
.output(ValueTypes.LIST).symbol("tooltip_lines").operatorName("tooltiplines").interactName("tooltipLines") |
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 wonder if tooltip
instead of tooltip_lines
would not be sufficient. (no strong opinion) (same would apply to the other names)
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.
yea, I was basing it on the ItemStack method name, but makes sense for it to be short right now, since there's no version that returns it as a single object (maybe at some point after #1402 ?)
Currently having some discussion about this and my original intended use case on the discord, the option of adding an extra Entity.ItemTooltip(Item) operator has been coined for dealing with the player context, won't be finalizing this PR until all discussion is resolved but will continue testing things. |
Both the entity-based and entity-less variants could be valuable. |
I didn't add tests yet for the entity variant, I noticed that many of the more complex entity operators are missing tests and might have used that as a basis for not trying yet (it works in game, I promise) feel free to nitpick about naming, I'm working in jetbrains so it's just a refactor button away |
src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/Operators.java
Outdated
Show resolved
Hide resolved
src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/Operators.java
Outdated
Show resolved
Hide resolved
…rator/Operators.java
…rator/Operators.java
Thanks @pippinsmith! |
You're welcome, gonna throw the 1.20 build in the modpack I'm playing when I get the chance. |
Implements #1449