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

Adds Loot Tables #7242

Open
wants to merge 31 commits into
base: dev/feature
Choose a base branch
from

Conversation

Burbulinis
Copy link

Description

Adds loot tables and loot generation to Skript.


Target Minecraft Versions: any
Requirements: none
Related Issues: #5937

Copy link
Member

@Moderocky Moderocky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start :)

Copy link
Contributor

@Asleeepp Asleeepp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests tests tests!!!

Copy link
Contributor

@Fusezion Fusezion left a 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?

@Burbulinis Burbulinis requested a review from Moderocky December 4, 2024 15:46
@Efnilite Efnilite added the feature Pull request adding a new feature. label Dec 4, 2024
Copy link
Contributor

@Fusezion Fusezion left a 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")

Copy link
Member

@sovdeeth sovdeeth left a 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.

Copy link
Member

@Efnilite Efnilite left a 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 :)

Copy link
Contributor

@Fusezion Fusezion left a 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

Copy link
Contributor

@TheAbsolutionism TheAbsolutionism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight look over.

@Burbulinis Burbulinis requested a review from sovdeeth December 9, 2024 17:19
"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."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


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%"
Copy link
Member

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

@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.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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.",

Copy link
Member

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?

public class ExprLootContextLocation extends SimplePropertyExpression<LootContext, Location> {

static {
registerDefault(ExprLootContextLocation.class, Location.class, "loot [context] location", "lootcontexts");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
registerDefault(ExprLootContextLuck.class, Float.class, "loot [context] luck [value|factor]", "lootcontexts");
registerDefault(ExprLootContextLuck.class, Float.class, "loot[ing] [context] luck [value|factor]", "lootcontexts");

Comment on lines +41 to +42
"[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%"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"[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%"

Copy link
Member

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

Copy link
Author

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

Copy link
Member

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

Comment on lines +83 to +86
Variables.setLocalVariables(contextEvent, Variables.copyLocalVariables(event));
TriggerItem.walk(trigger, contextEvent);
Variables.setLocalVariables(event, Variables.copyLocalVariables(contextEvent));
Variables.removeLocals(contextEvent);
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants