Skip to content

Commit

Permalink
implement new core VectorObject in LocationTag
Browse files Browse the repository at this point in the history
also minor meta/format fixes
  • Loading branch information
mcmonkey4eva committed May 8, 2023
1 parent e772001 commit 6c58100
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Expand Up @@ -70,7 +70,6 @@ public EntityDeathScriptEvent() {
registerSwitches("by", "cause");
}


public EntityTag entity;
public EntityTag damager;
public EntityTag projectile;
Expand Down
Expand Up @@ -55,13 +55,13 @@
import java.util.function.Function;
import java.util.stream.Collectors;

public class LocationTag extends org.bukkit.Location implements ObjectTag, Notable, Adjustable, FlaggableObject {
public class LocationTag extends org.bukkit.Location implements VectorObject, ObjectTag, Notable, Adjustable, FlaggableObject {

// <--[ObjectType]
// @name LocationTag
// @prefix l
// @base ElementTag
// @implements FlaggableObject
// @implements FlaggableObject, VectorObject
// @ExampleTagBase player.location
// @ExampleValues <player.location>,<npc.location>
// @ExampleForReturns
Expand Down Expand Up @@ -3465,7 +3465,7 @@ else if (attribute.startsWith("unexplored_structure", 2) && attribute.hasContext
// Returns a 1-length vector in the same direction as this vector location.
// -->
tagProcessor.registerTag(LocationTag.class, "normalize", (attribute, object) -> {
double len = Math.sqrt(Math.pow(object.getX(), 2) + Math.pow(object.getY(), 2) + Math.pow(object.getZ(), 2));
double len = object.length();
if (len == 0) {
len = 1;
}
Expand All @@ -3481,7 +3481,7 @@ else if (attribute.startsWith("unexplored_structure", 2) && attribute.hasContext
// Returns the 3D length of the vector/location.
// -->
tagProcessor.registerTag(ElementTag.class, "vector_length", (attribute, object) -> {
return new ElementTag(Math.sqrt(Math.pow(object.getX(), 2) + Math.pow(object.getY(), 2) + Math.pow(object.getZ(), 2)));
return new ElementTag(object.length());
});

// <--[tag]
Expand Down
Expand Up @@ -21,7 +21,7 @@ public class TradeTag implements ObjectTag, Adjustable {
// @prefix trade
// @base ElementTag
// @implements PropertyHolderObject
// @ExampleTagBase trade[trade[result=diamond;max_use=10;inputs=stick]]
// @ExampleTagBase trade[trade[result=diamond;max_uses=10;inputs=stick]]
// @ExampleValues trade[result=diamond;max_uses=10;inputs=stick]
// @format
// The identity format for trades is just the text 'trade'. All other data is specified through properties.
Expand Down

0 comments on commit 6c58100

Please sign in to comment.