Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Fix Color Tag
Browse files Browse the repository at this point in the history
Also added a null chek to leashed_entity
  • Loading branch information
Xenmai committed Oct 4, 2017
1 parent 93f8e39 commit 29858e7
Showing 1 changed file with 17 additions and 4 deletions.
Expand Up @@ -31,6 +31,7 @@
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.Carrier;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.util.Color;
import org.spongepowered.api.world.World;

import java.util.*;
Expand Down Expand Up @@ -572,12 +573,21 @@ else if (source instanceof Entity) {
});
// <--[tag]
// @Name EntityTag.leashed_entity
// @Updated 2017/10/02
// @Updated 2017/10/04
// @Group Current Information
// @ReturnType EntityTag
// @Returns the entity currently leashed by this hitch. Leash hitch entities only.
// -->
handlers.put("leashed_entity", (dat, obj) -> new EntityTag(((LeashHitch) ((EntityTag) obj).internal).getLeashedEntity()));
handlers.put("leashed_entity", (dat, obj) -> {
Entity ent = ((LeashHitch) ((EntityTag) obj).internal).getLeashedEntity();
if (ent == null) {
if (!dat.hasFallback()) {
dat.error.run("This hitch has no leashed entity!");
}
return new NullTag();
}
return new EntityTag(ent);
});
// <--[tag]
// @Name EntityTag.application_delay
// @Updated 2017/10/02
Expand All @@ -588,12 +598,15 @@ else if (source instanceof Entity) {
handlers.put("application_delay", (dat, obj) -> new IntegerTag(((AreaEffectCloud) ((EntityTag) obj).internal).applicationDelay().get()));
// <--[tag]
// @Name EntityTag.cloud_color
// @Updated 2017/10/02
// @Updated 2017/10/04
// @Group Current Information
// @ReturnType TextTag
// @Returns the color of this cloud. Area effect cloud entities only.
// -->
handlers.put("cloud_color", (dat, obj) -> new TextTag(((AreaEffectCloud) ((EntityTag) obj).internal).color().get().toString()));
handlers.put("cloud_color", (dat, obj) -> {
Color color = ((AreaEffectCloud) ((EntityTag) obj).internal).color().get();
return new LocationTag(color.getRed(), color.getGreen(), color.getBlue());
});
// <--[tag]
// @Name EntityTag.duration
// @Updated 2017/10/02
Expand Down

0 comments on commit 29858e7

Please sign in to comment.