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

Feature/pathfinding to be double #4915

Merged
merged 20 commits into from
Jul 18, 2022
Merged
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/main/java/ch/njol/skript/effects/EffPathfind.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

@Name("Pathfind")
@Description({"Make an entity pathfind towards a location or another entity. Not all entities can pathfind. " +
"If the pathfinding target is another entity, the entities may or may not continuously follow the target."})
"If the pathfinding target is another entity, the entities may or may not continuously follow the target. This is a Paper Spigot exclusive."})
@Examples({
"make all creepers pathfind towards player",
"make all cows stop pathfinding",
"make event-entity pathfind towards player"
"make event-entity pathfind towards player at speed 1"
})
@Since("INSERT VERSION")
public class EffPathfind extends Effect {
Copy link
Member

Choose a reason for hiding this comment

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

Since you're editing, the check at L49 is no longer needed since it's 1.13+

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a Paper Spigot exclusive effect.

Copy link
Member

Choose a reason for hiding this comment

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

Then that class needs @RequiredPlugins annotation instead of the description note

Expand Down Expand Up @@ -72,7 +72,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
@Override
protected void execute(Event event) {
Object target = this.target != null ? this.target.getSingle(event) : null;
int speed = this.speed != null ? this.speed.getSingle(event).intValue() : 1;
double speed = this.speed != null ? this.speed.getOptionalSingle(event).orElse(1).doubleValue() : 1;
for (LivingEntity entity : entities.getArray(event)) {
if (!(entity instanceof Mob))
continue;
Expand All @@ -87,13 +87,12 @@ protected void execute(Event event) {
}

@Override
public String toString(@Nullable Event e, boolean debug) {
public String toString(@Nullable Event event, boolean debug) {
if (target == null)
return "make " + entities.toString(e, debug) + " stop pathfinding";

String repr = "make " + entities.toString(e, debug) + " pathfind towards " + target.toString(e, debug);
return "make " + entities.toString(event, debug) + " stop pathfinding";
String repr = "make " + entities.toString(event, debug) + " pathfind towards " + target.toString(event, debug);
if (speed != null)
repr += " at speed " + speed.toString(e, debug);
repr += " at speed " + speed.toString(event, debug);
return repr;
}

Expand Down