Skip to content

Commit

Permalink
add tag player.fake_block_locations and fake_block[loc]
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 23, 2019
1 parent 9b02152 commit a48be85
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
Expand Up @@ -5,6 +5,7 @@
import com.denizenscript.denizen.scripts.commands.player.SidebarCommand;
import com.denizenscript.denizen.utilities.DenizenAPI;
import com.denizenscript.denizen.utilities.Utilities;
import com.denizenscript.denizen.utilities.blocks.FakeBlock;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizen.utilities.depends.Depends;
import com.denizenscript.denizen.utilities.entity.BossBarHelper;
Expand Down Expand Up @@ -2653,6 +2654,52 @@ public ObjectTag run(Attribute attribute, PlayerTag object) {
return new ElementTag(suffix);
}
});

// <--[tag]
// @attribute <PlayerTag.fake_block_locations>
// @returns ListTag(LocationTag)
// @description
// Returns a list of locations that the player will see a fake block at, as set by <@link command showfake> or connected commands.
// -->
registerTag("fake_block_locations", new TagRunnable.ObjectForm<PlayerTag>() {
@Override
public ObjectTag run(Attribute attribute, PlayerTag object) {
ListTag list = new ListTag();
FakeBlock.FakeBlockMap map = FakeBlock.blocks.get(object.getOfflinePlayer().getUniqueId());
if (map != null) {
for (LocationTag loc : map.byLocation.keySet()) {
list.addObject(loc.clone());
}
}
return list;
}
});

// <--[tag]
// @attribute <PlayerTag.fake_block[<location>]>
// @returns MaterialTag
// @description
// Returns the fake material that the player will see at the input location, as set by <@link command showfake> or connected commands.
// Works best alongside <@link tag PlayerTag.fake_block_locations>.
// Returns null if the player doesn't have a fake block at the location.
// -->
registerTag("fake_block", new TagRunnable.ObjectForm<PlayerTag>() {
@Override
public ObjectTag run(Attribute attribute, PlayerTag object) {
if (!attribute.hasContext(1)) {
return null;
}
LocationTag input = LocationTag.valueOf(attribute.getContext(1));
FakeBlock.FakeBlockMap map = FakeBlock.blocks.get(object.getOfflinePlayer().getUniqueId());
if (map != null) {
FakeBlock block = map.byLocation.get(input);
if (block != null) {
return block.material;
}
}
return null;
}
});
}

public static ObjectTagProcessor<PlayerTag> tagProcessor = new ObjectTagProcessor<>();
Expand Down
Expand Up @@ -48,7 +48,8 @@ public class ShowFakeCommand extends AbstractCommand {
// Note as well that some clientside block effects may occur (eg fake fire may appear momentarily to actually ignite things, but won't actually damage them).
//
// @Tags
// None
// <PlayerTag.fake_block_locations>
// <PlayerTag.fake_block[<location>]>
//
// @Usage
// Use to place a fake gold block at where the player is looking
Expand Down

0 comments on commit a48be85

Please sign in to comment.