-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
Adds Loot Tables #7242
base: dev/feature
Are you sure you want to change the base?
Adds Loot Tables #7242
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.
Good start :)
src/main/java/ch/njol/skript/expressions/ExprLootTableFromString.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/classes/data/DefaultConverters.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootTableSeed.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.
tests tests tests!!!
src/main/java/ch/njol/skript/expressions/ExprLootTableSeed.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootTableSeed.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootTableSeed.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootTableSeed.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.
Just to cause more mayham, wanna make this a module?
Change toString for LootTable class info, Change syntax
…killer/entity of context
src/main/java/ch/njol/skript/expressions/ExprLootContextWithEntity.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextWithKiller.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextWithLuck.java
Outdated
Show resolved
Hide resolved
src/test/skript/tests/syntaxes/expressions/ExprLootTableSeed.sk
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextWithLuck.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextWithKiller.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextWithEntity.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextEntity.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextKiller.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextLuck.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextWithEntity.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootContextWithKiller.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootTableSeed.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLootTableSeed.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.
After talking a bit with someone else and getting their feedback on a suggestion I wanna post it here for you as well.
What's the thought about making a wrapper class for the loot context similar to how recipes were done?
Currently every time you wanna change the syntax you end up doing new builder -> copy old stats -> add new stat
for each of the stats in other words
ExprLootContextWithEntity -> new -> edit entity -> return
ExprLootContextWithKiller -> new -> edit killer -> return
ExprLootContextWithLuck -> new -> edit luck -> return
Due to this you ended up with two expressions for the same things
ExprLootContextWithX
and ExprLootContextX
these could be merged into 1 expression allowing changers and using a wrapper around LootContext with methods for setting the values you can do something like
LootContextWrapper#setKiller
LootContextWrapper#setLuck
LootContextWrapper#setEntity
Hell you could probably even change the loot context location. This addition will also allow the usage of a Secpression meaning we could instead see syntax like
set {_plank} to a new loot context:
set loot context entity to {_player}
set loot context luck to 10
set loot context killer to {_players twin brother}
set loot context location to location({_x},-5,10, "World")
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.
A lot of the syntaxes are worryingly generic. As a specific example, I can see people getting very confused with killer of {_thing}
. I would prefer a lot of these to have required keywords that make sure they don't conflict/get confused with other syntaxes.
…rom the Recipe pull request, and changes
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.
Looking good, your test files need to end with new lines though :)
src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableUtils.java
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/elements/conditions/CondHasLootTable.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.
I didn't look at changers and I removed things that mentioned to use Loottabletypes until they're added back for for a first look it's good. I really wish github didn't force line breaks on long lines
src/main/java/ch/njol/skript/classes/data/DefaultConverters.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextCreateEvent.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java
Outdated
Show resolved
Hide resolved
src/test/skript/tests/syntaxes/expressions/ExprLootContextWithLuck.sk
Outdated
Show resolved
Hide resolved
src/test/skript/tests/syntaxes/expressions/ExprLootContextWithEntity.sk
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.
Slight look over.
...java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextEntity.java
Outdated
Show resolved
Hide resolved
...java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextKiller.java
Outdated
Show resolved
Hide resolved
...n/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLuck.java
Outdated
Show resolved
Hide resolved
...java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextEntity.java
Outdated
Show resolved
Hide resolved
...java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextKiller.java
Outdated
Show resolved
Hide resolved
...n/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLuck.java
Outdated
Show resolved
Hide resolved
...a/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprSecCreateLootContext.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/classes/data/DefaultConverters.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextCreateEvent.java
Outdated
Show resolved
Hide resolved
src/test/skript/tests/syntaxes/expressions/ExprLootTableSeed.sk
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableUtils.java
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableUtils.java
Show resolved
Hide resolved
...a/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprSecCreateLootContext.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableModule.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/elements/conditions/CondIsLootable.java
Outdated
Show resolved
Hide resolved
...java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextKiller.java
Outdated
Show resolved
Hide resolved
...va/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLocation.java
Outdated
Show resolved
Hide resolved
...n/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLuck.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootItems.java
Outdated
Show resolved
Hide resolved
"set block at event-location to wool block", | ||
"if block at event-location is lootable:", | ||
"\t# uh oh, nothing will happen because a wool is not a lootable block." | ||
|
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.
|
||
static { | ||
Skript.registerEffect(EffGenerateLoot.class, | ||
"generate loot (of|using) [[the] loot[ ]table] %loottable% (with|using) [[the] [loot] context] %lootcontext% in [[the] inventor(y|ies)] %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.
It might be nice to have an option to generate without specifying a context, and have skript just auto-fill a context at the origin of a world
src/main/java/org/skriptlang/skript/bukkit/loottables/elements/effects/EffGenerateLoot.java
Show resolved
Hide resolved
@Name("Generate Loot") | ||
@Description({ | ||
"Generates the loot in the specified inventories from a loot table using a loot context. " + | ||
"Some loot tables will require some of these values whereas others may not.", |
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 loot tables will require some of these values whereas others may not.", | |
"Some loot tables will require some of these values whereas others may not.", |
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.
Can you elaborate? give an example?
src/main/java/org/skriptlang/skript/bukkit/loottables/elements/effects/EffGenerateLoot.java
Show resolved
Hide resolved
public class ExprLootContextLocation extends SimplePropertyExpression<LootContext, Location> { | ||
|
||
static { | ||
registerDefault(ExprLootContextLocation.class, Location.class, "loot [context] location", "lootcontexts"); |
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.
registerDefault(ExprLootContextLocation.class, Location.class, "loot [context] location", "lootcontexts"); | |
registerDefault(ExprLootContextLocation.class, Location.class, "loot[ing] [context] location", "lootcontexts"); |
public class ExprLootContextLuck extends SimplePropertyExpression<LootContext, Float> { | ||
|
||
static { | ||
registerDefault(ExprLootContextLuck.class, Float.class, "loot [context] luck [value|factor]", "lootcontexts"); |
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.
registerDefault(ExprLootContextLuck.class, Float.class, "loot [context] luck [value|factor]", "lootcontexts"); | |
registerDefault(ExprLootContextLuck.class, Float.class, "loot[ing] [context] luck [value|factor]", "lootcontexts"); |
"[the] loot [item[s]] of [[the] loot[ ]table[s]] %loottables% (with|using) [[the] [loot] context] %lootcontext%", | ||
"[the] %loottables%'[s] loot [item[s]] (with|using) [[the] [loot] context] %lootcontext%" |
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.
"[the] loot [item[s]] of [[the] loot[ ]table[s]] %loottables% (with|using) [[the] [loot] context] %lootcontext%", | |
"[the] %loottables%'[s] loot [item[s]] (with|using) [[the] [loot] context] %lootcontext%" | |
"[the] (loot|item[s]) of [[the] loot[ ]table[s]] %loottables% (with|using) [[the] [loot] context] %lootcontext%", | |
"[the] %loottables%'[s] (loot|item[s]) (with|using) [[the] [loot] context] %lootcontext%" |
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 loot and items are better off not seeing each other anymore
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 feel like items is too generic
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.
Hmm
Maybe just loot then, since i don't think loot items makes much grammatical sense
src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTable.java
Show resolved
Hide resolved
Variables.setLocalVariables(contextEvent, Variables.copyLocalVariables(event)); | ||
TriggerItem.walk(trigger, contextEvent); | ||
Variables.setLocalVariables(event, Variables.copyLocalVariables(contextEvent)); | ||
Variables.removeLocals(contextEvent); |
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.
can use Variables.withLocalVariables now
Description
Adds loot tables and loot generation to Skript.
Target Minecraft Versions: any
Requirements: none
Related Issues: #5937