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

Spawners Incoming #7477

Closed
wants to merge 51 commits into from
Closed

Conversation

Burbulinis
Copy link
Contributor

@Burbulinis Burbulinis commented Jan 19, 2025

Description

This PR aims to add advanced support for interacting with base spawners, spawners, trial spawner configurations and trial spawners.

PR #7009 was abandoned, thus this PR was made.

Everything here is only supported for versions newer than 1.21+, making this PR a breaking change because of ExprSpawnerType

TODO: tests, remove the enum class info for equipment slots after the merge of #7194


Target Minecraft Versions: 1.21+
Requirements: 1.21+
Related Issues: #6856, #5846

This was referenced Jan 19, 2025
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.

This is just the first batch.
I would also like to note, imo, for all occurrences when inside of the get method of expressions. If the condition was unmet, instead of returning new Object[0] with Object being what the type needs to be, it should return null.

TESTS

import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

public class ExprWeight extends SimplePropertyExpression<Object, Integer> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Docs

continue;

if (!weighted.supportsWeightChange()) {
error("The weight of this object cannot be changed.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Only problem I have with this, is that it doesn't say what object that was provided cannot be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It provides the line and file, but sure that is fair


@Override
protected String getPropertyName() {
return "the weight";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return "the weight";
return "weight";


@Override
protected String getPropertyName() {
return "spawner" + (isNegated() ? " is not " : " is ") + "activated";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return "spawner" + (isNegated() ? " is not " : " is ") + "activated";
return "an activated spawner";

The isNegated part is handled within PropertyCondition.

Comment on lines +72 to +78
if (light > 15) {
warning("The sky light spawn level cannot be greater than 15, thus setting it to a value larger than 15 will do nothing.");
return;
} else if (light < 0) {
warning("The sky light spawn level cannot be less than 0, thus setting it to a value less than 0 will do nothing.");
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Smae here


@Override
protected String getPropertyName() {
return type.name().toLowerCase() + " trial spawner config";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return type.name().toLowerCase() + " trial spawner config";
return type.name().toLowerCase(Locale.ENGLISH) + " trial spawner config";


@Override
protected String getPropertyName() {
return (additional ? "additional " : "base ") + "spawns";
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to match property registered

Comment on lines +127 to +131
if (additional) {
builder.append("additional");
} else {
builder.append("base");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Match patterns

Comment on lines +69 to +72
if (players)
values.addAll(spawner.getTrackedPlayers());
else
values.addAll(spawner.getTrackedEntities());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (players)
values.addAll(spawner.getTrackedPlayers());
else
values.addAll(spawner.getTrackedEntities());
if (players) {
values.addAll(spawner.getTrackedPlayers());
} else {
values.addAll(spawner.getTrackedEntities());
}

@@ -2555,6 +2555,16 @@ input keys:
sneak: sneak key, sneaking key
sprint: sprint key, sprinting key

//todo: remove after merge of equippable pr
Copy link
Contributor

Choose a reason for hiding this comment

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

Using a java comment💀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh god i was brainwashed

@Efnilite Efnilite added feature Pull request adding a new feature. breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) labels Jan 19, 2025
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.

epic start

Copy link
Contributor

@ShaneBeee ShaneBeee left a comment

Choose a reason for hiding this comment

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

Just a few things.
Pardon me if something of these have been mention already.
I was half way thru this when Effy submitted his!

return;

Classes.registerClass(new ClassInfo<>(TrialSpawnerConfig.class, "trialspawnerconfig")
.user("(trial ?)?spawner ?config(urations?)?")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is "trial" optional? To prevent possible conflicts in the future and/or with other addons, this should be required.

);

Classes.registerClass(new ClassInfo<>(SpawnerEntry.class, "spawnerentry")
.user("spawner ?entry")
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably be entr(y|ies) maybe?

@Examples("set the spawned item of target block to diamond")
@Since("INSERT VERSION")
@RequiredPlugins("MC 1.21+")
public class EffSpawnedItem extends Effect {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason this is an effect and not an expression?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is no way to get the spawned item, only setting it is possible afaik

Copy link
Contributor

Choose a reason for hiding this comment

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

2 additional things

  1. This is Paper exclusive
  2. The setSpawnedItem just makes it the entity type be a dropped item, with the item being what was provided in setSpaawnedItem

.supplier(EffTrialSpawnerTrack::new)
.priority(SyntaxInfo.COMBINED)
.addPatterns(
"make [the] %blocks/trialspawnerconfigs% (1:start|stop) tracking %entities%",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm cofused, why two patterns? a Player is an entity, in the execute you could check if the entity is an instance of a player

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if i am correct, tracking the player with the start tracking entity method works differently than player. I am not exactly sure how it works but I'll clean up the docs

"",
"Base spawners are trial spawner configurations, spawner minecarts and creature spawners."
})
@Examples({
Copy link
Contributor

Choose a reason for hiding this comment

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

Should include some examples of your changers


@Override
public String toString(@Nullable Event event, boolean debug) {
return "possible trial spawner rewards of" + getExpr().toString(event, debug);
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesnt seem to be remotely related to the pattern?!?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alot of things were changed during the making of this and I completely forgot about the toString methods.

.supplier(ExprTrackedEntities::new)
.priority(PropertyExpression.DEFAULT_PRIORITY)
.addPatterns(
"[the] tracked (1:player[s]|entit(y|ies)) (from|of) %blocks/trialspawnerconfigs%",
Copy link
Contributor

Choose a reason for hiding this comment

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

should include spawner here, or something to destinguish this.
Spigot/Paper have tracked player/entity stuff, so we shouldnt create possible conflicts

} else {
builder.append("normal ");
}
builder.append("trial spawner configuration of trial spawner at ")
Copy link
Contributor

Choose a reason for hiding this comment

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

this worries me how insanely long this is going to be.

@ShaneBeee
Copy link
Contributor

After all my comments I wanted to add one final comment.

This is my opinion (.... again... opinion).
I personally dont think this should be in Skript.
This is so insanely convoluted for basically one block (a spawner [yes I get it, the variants])
The docs are going to be all over the place, and so hard to figure out how to do anything.

I personally (again, my opinion) feel that this is better suited for its own addon.

@Burbulinis
Copy link
Contributor Author

Burbulinis commented Jan 20, 2025

After all my comments I wanted to add one final comment.

This is my opinion (.... again... opinion). I personally dont think this should be in Skript. This is so insanely convoluted for basically one block (a spawner [yes I get it, the variants]) The docs are going to be all over the place, and so hard to figure out how to do anything.

I personally (again, my opinion) feel that this is better suited for its own addon.

I guess I agree with this... Any other opinions?

@Burbulinis Burbulinis marked this pull request as draft January 22, 2025 18:47
@Burbulinis Burbulinis closed this Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants