added block_list and block_tags to handle block tags.
This commit is contained in:
1 parent
6ee8d55f88
commit
b13c59eedf
4 files changed
+52
-1
No files matched your search
@@ -266,6 +266,16 @@ block_state(block('iron_trapdoor[half=top]'),'powered') => false
|
|||||||
bool(block_state(block('iron_trapdoor[half=top]'),'powered')) => 0
|
bool(block_state(block('iron_trapdoor[half=top]'),'powered')) => 0
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
### `block_list()`, `block_list(tag)`
|
||||||
|
|
||||||
|
Returns list of all blocks. If tag is provided, returns list of blocks that belong to this block tag.
|
||||||
|
|
||||||
|
### `block_tags()`, `block_tags(block)`, `block_tags(block, tag)`
|
||||||
|
|
||||||
|
Without arguments, returns list of available tags, with block supplied (either by coordinates, or via block name), returns lost
|
||||||
|
of tags the block belongs to, and if a tag is specified, returns `null` if tag is invalid, `false` if this block doesn't belong
|
||||||
|
to this tag, and `true` if the block belongs to the tag.
|
||||||
|
|
||||||
### `block_data(pos)`
|
### `block_data(pos)`
|
||||||
|
|
||||||
Return NBT string associated with specific location, or null if the block does not carry block data. Can be currently
|
Return NBT string associated with specific location, or null if the block does not carry block data. Can be currently
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ blast_resistance
|
|||||||
block
|
block
|
||||||
block_data
|
block_data
|
||||||
block_light
|
block_light
|
||||||
|
block_list
|
||||||
block_sound
|
block_sound
|
||||||
block_state
|
block_state
|
||||||
block_tick
|
block_tick
|
||||||
|
block_tags
|
||||||
blocks_daylight
|
blocks_daylight
|
||||||
blocks_movement
|
blocks_movement
|
||||||
brightness
|
brightness
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
transparent opacity blocks_daylight emitted_light light block_light sky_light see_sky brightness
|
transparent opacity blocks_daylight emitted_light light block_light sky_light see_sky brightness
|
||||||
hardness blast_resistance top loaded suffocates power ticks_randomly update block_tick random_tick in_slime_chunk
|
hardness blast_resistance top loaded suffocates power ticks_randomly update block_tick random_tick in_slime_chunk
|
||||||
set without_updates
|
set without_updates
|
||||||
blocks_movement block_sound material map_colour block_state block_data poi set_poi
|
blocks_movement block_sound material map_colour block_state block_list block_tags block_data poi set_poi
|
||||||
place_item set_biome biome loaded_status generation_status inhabited_time spawn_potential chunk_tickets
|
place_item set_biome biome loaded_status generation_status inhabited_time spawn_potential chunk_tickets
|
||||||
structure_eligibility structures structure_references set_structure reset_chunk reload_chunk custom_dimension
|
structure_eligibility structures structure_references set_structure reset_chunk reload_chunk custom_dimension
|
||||||
add_chunk_ticket
|
add_chunk_ticket
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ import net.minecraft.sound.SoundCategory;
|
|||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.Property;
|
import net.minecraft.state.property.Property;
|
||||||
import net.minecraft.structure.StructureStart;
|
import net.minecraft.structure.StructureStart;
|
||||||
|
import net.minecraft.tag.TagManager;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Clearable;
|
import net.minecraft.util.Clearable;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
@@ -1018,6 +1019,44 @@ public class WorldAccess {
|
|||||||
return (_c, _t) -> retval;
|
return (_c, _t) -> retval;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expression.addLazyFunction("block_list", -1, (c, t, lv) ->
|
||||||
|
{
|
||||||
|
if (lv.size() == 0)
|
||||||
|
{
|
||||||
|
Value ret = ListValue.wrap(Registry.BLOCK.getIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
||||||
|
return (_c, _t) -> ret;
|
||||||
|
}
|
||||||
|
CarpetContext cc = (CarpetContext)c;
|
||||||
|
TagManager tagManager = cc.s.getMinecraftServer().getTagManager();
|
||||||
|
String tag = lv.get(0).evalValue(c).getString();
|
||||||
|
net.minecraft.tag.Tag<Block> blockTag = tagManager.getBlocks().getTag(new Identifier(tag));
|
||||||
|
if (blockTag == null) return LazyValue.NULL;
|
||||||
|
Value ret = ListValue.wrap(blockTag.values().stream().map(b -> ValueConversions.of(Registry.BLOCK.getId(b))).collect(Collectors.toList()));
|
||||||
|
return (_c, _t) -> ret;
|
||||||
|
});
|
||||||
|
|
||||||
|
expression.addLazyFunction("block_tags", -1, (c, t, lv) ->
|
||||||
|
{
|
||||||
|
CarpetContext cc = (CarpetContext)c;
|
||||||
|
TagManager tagManager = cc.s.getMinecraftServer().getTagManager();
|
||||||
|
if (lv.size() == 0)
|
||||||
|
{
|
||||||
|
Value ret = ListValue.wrap(tagManager.getBlocks().getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
||||||
|
return (_c, _t) -> ret;
|
||||||
|
}
|
||||||
|
BlockArgument blockLocator = BlockArgument.findIn(cc, lv, 0, true);
|
||||||
|
if (blockLocator.offset == lv.size())
|
||||||
|
{
|
||||||
|
Value ret = ListValue.wrap(tagManager.getBlocks().getTagsFor(blockLocator.block.getBlockState().getBlock()).stream().map(ValueConversions::of).collect(Collectors.toList()));
|
||||||
|
return (_c, _t) -> ret;
|
||||||
|
}
|
||||||
|
String tag = lv.get(blockLocator.offset).evalValue(c).getString();
|
||||||
|
net.minecraft.tag.Tag<Block> blockTag = tagManager.getBlocks().getTag(new Identifier(tag));
|
||||||
|
if (blockTag == null) return LazyValue.NULL;
|
||||||
|
return blockLocator.block.getBlockState().isIn(blockTag)?LazyValue.TRUE:LazyValue.FALSE;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
expression.addLazyFunction("biome", -1, (c, t, lv) -> {
|
expression.addLazyFunction("biome", -1, (c, t, lv) -> {
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
BlockArgument locator = BlockArgument.findIn(cc, lv, 0);
|
BlockArgument locator = BlockArgument.findIn(cc, lv, 0);
|
||||||
|
|||||||
Reference in new issue
Block a user