-
-
Notifications
You must be signed in to change notification settings - Fork 370
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 crafting inventory slots expression (result/matrix) #4410
🚀 Add crafting inventory slots expression (result/matrix) #4410
Conversation
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
I believe we should be using ItemStack for everything. ItemType is used as a literal. This way we can allow for named, lore, enchanted items etc. This will also remove the need for the Utils |
This is an important note, I remember I saw a PR about replacing ItemStacks with ItemTypes but didn't follow up with why |
It really needs to be explained; So basically ItemTypes are supposed to be used as a Literal. Syntaxes such as Another example can be in SkQuery recipes, it only accepted ItemTypes, which restricted the user to not allow for named, enchanted or lored items. Where as Tuske later added the ability to use ItemStacks, so you could check if the item was named. This is good for like quests or missions where the item must be named. SkQuery recipes have since been removed. TPGamesNL also mentioned that we should be doing this for primitive number types. Returning an Integer, or a Double rather than just returning Number. But when it comes to accepting a change, you can be using Number, and just number.intValue() or whatever on it, so the output is certain, and the input can be anything avoiding the cannot understand effect error. Same goes with EntityData and Entity. EntityData is a literal, like |
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.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.
Nothing super major :D (mainly style suggestions)
I think this will be a useful feature
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCraftingSlots.java
Outdated
Show resolved
Hide resolved
public class ExprCraftingSlots extends SimpleExpression<ItemStack> { | ||
|
||
static { | ||
Skript.registerExpression(ExprCraftingSlots.class, ItemStack.class, ExpressionType.COMBINED, |
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 think this expression should probably return InventorySlots instead of ItemStacks.
Skript.registerExpression(ExprCraftingSlots.class, ItemStack.class, ExpressionType.COMBINED, | ||
"[the] crafting [inventory] result (slot|item) [of %inventories%]", | ||
"%inventories%'[s] crafting [inventory] result (slot|item)", | ||
"[the] crafting [inventory] (matrix|grid) [(slots|items|shape)] [of %inventories%]", |
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.
Do you think it would be better to allow the user to access the individual crafting grid slots?
Maybe something like.
crafting slot %*number% [of %inventories%]
This may also work better with returning InventorySlots
Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
bd134d0
to
3f08853
Compare
Do you still intend to work on this? |
closing due to inactivity |
Description
🚀 This PR aims to add a new expression for crafting inventory slots such as the
result item
andmatrix
Some utility methods have been added, if anyone have better way to achieve their results let me know.
NOTE: While testing I have found a potential bug when you try to change the
matrix
inpreparing craft
event that will trigger the event again and get into infinite loop, I will try to report that to spigot later when I can but for now I have disabled that behavior in Skript and sent a warning when someone try to use it.NOTE: This PR should be merged after #4409 to be able to use event-inventory
Target Minecraft Versions: Any
Requirements: None
Related Issues: #4908