Search in sources :

Example 11 with Property

use of com.sk89q.worldedit.registry.state.Property in project FastAsyncWorldEdit by IntellectualSites.

the class PaperweightAdapter method getInternalBlockStateId.

@Override
public OptionalInt getInternalBlockStateId(BlockState state) {
    Block mcBlock = getBlockFromType(state.getBlockType());
    net.minecraft.world.level.block.state.BlockState newState = mcBlock.defaultBlockState();
    Map<Property<?>, Object> states = state.getStates();
    newState = applyProperties(mcBlock.getStateDefinition(), newState, states);
    final int combinedId = Block.getId(newState);
    return combinedId == 0 && state.getBlockType() != BlockTypes.AIR ? OptionalInt.empty() : OptionalInt.of(combinedId);
}
Also used : BaseBlock(com.sk89q.worldedit.world.block.BaseBlock) Block(net.minecraft.world.level.block.Block) Property(com.sk89q.worldedit.registry.state.Property) DirectionalProperty(com.sk89q.worldedit.registry.state.DirectionalProperty) BooleanProperty(com.sk89q.worldedit.registry.state.BooleanProperty) EnumProperty(com.sk89q.worldedit.registry.state.EnumProperty) IntegerProperty(com.sk89q.worldedit.registry.state.IntegerProperty) DirectionProperty(net.minecraft.world.level.block.state.properties.DirectionProperty)

Example 12 with Property

use of com.sk89q.worldedit.registry.state.Property in project FastAsyncWorldEdit by IntellectualSites.

the class FabricAdapter method adapt.

public static net.minecraft.block.BlockState adapt(BlockState blockState) {
    Block mcBlock = adapt(blockState.getBlockType());
    net.minecraft.block.BlockState newState = mcBlock.getDefaultState();
    Map<Property<?>, Object> states = blockState.getStates();
    return applyProperties(mcBlock.getStateFactory(), newState, states);
}
Also used : Block(net.minecraft.block.Block) Property(com.sk89q.worldedit.registry.state.Property) DirectionalProperty(com.sk89q.worldedit.registry.state.DirectionalProperty) BooleanProperty(com.sk89q.worldedit.registry.state.BooleanProperty) DirectionProperty(net.minecraft.state.property.DirectionProperty) EnumProperty(com.sk89q.worldedit.registry.state.EnumProperty) IntegerProperty(com.sk89q.worldedit.registry.state.IntegerProperty)

Example 13 with Property

use of com.sk89q.worldedit.registry.state.Property in project FastAsyncWorldEdit by IntellectualSites.

the class ForgeAdapter method adapt.

public static net.minecraft.block.BlockState adapt(BlockState blockState) {
    Block mcBlock = adapt(blockState.getBlockType());
    net.minecraft.block.BlockState newState = mcBlock.getDefaultState();
    Map<Property<?>, Object> states = blockState.getStates();
    return applyProperties(mcBlock.getStateContainer(), newState, states);
}
Also used : Block(net.minecraft.block.Block) Property(com.sk89q.worldedit.registry.state.Property) DirectionalProperty(com.sk89q.worldedit.registry.state.DirectionalProperty) BooleanProperty(com.sk89q.worldedit.registry.state.BooleanProperty) IProperty(net.minecraft.state.IProperty) EnumProperty(com.sk89q.worldedit.registry.state.EnumProperty) IntegerProperty(com.sk89q.worldedit.registry.state.IntegerProperty) DirectionProperty(net.minecraft.state.DirectionProperty)

Example 14 with Property

use of com.sk89q.worldedit.registry.state.Property in project FastAsyncWorldEdit by IntellectualSites.

the class ForgeBlockRegistry method getProperties.

@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
    Block block = ForgeAdapter.adapt(blockType);
    Map<String, Property<?>> map = new TreeMap<>();
    Collection<IProperty<?>> propertyKeys = block.getDefaultState().getProperties();
    for (IProperty<?> key : propertyKeys) {
        map.put(key.getName(), ForgeAdapter.adaptProperty(key));
    }
    return map;
}
Also used : IProperty(net.minecraft.state.IProperty) Block(net.minecraft.block.Block) TreeMap(java.util.TreeMap) Property(com.sk89q.worldedit.registry.state.Property) IProperty(net.minecraft.state.IProperty)

Example 15 with Property

use of com.sk89q.worldedit.registry.state.Property in project FastAsyncWorldEdit by IntellectualSites.

the class FabricBlockRegistry method getProperties.

@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
    Block block = FabricAdapter.adapt(blockType);
    Map<String, Property<?>> map = new TreeMap<>();
    Collection<net.minecraft.state.property.Property<?>> propertyKeys = block.getDefaultState().getProperties();
    for (net.minecraft.state.property.Property<?> key : propertyKeys) {
        map.put(key.getName(), FabricAdapter.adaptProperty(key));
    }
    return map;
}
Also used : Block(net.minecraft.block.Block) TreeMap(java.util.TreeMap) Property(com.sk89q.worldedit.registry.state.Property)

Aggregations

Property (com.sk89q.worldedit.registry.state.Property)18 Map (java.util.Map)10 BooleanProperty (com.sk89q.worldedit.registry.state.BooleanProperty)8 EnumProperty (com.sk89q.worldedit.registry.state.EnumProperty)8 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)7 DirectionalProperty (com.sk89q.worldedit.registry.state.DirectionalProperty)7 IntegerProperty (com.sk89q.worldedit.registry.state.IntegerProperty)7 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)6 BlockType (com.sk89q.worldedit.world.block.BlockType)5 Collectors (java.util.stream.Collectors)5 Maps (com.google.common.collect.Maps)4 WorldEditException (com.sk89q.worldedit.WorldEditException)4 Direction (com.sk89q.worldedit.util.Direction)4 BlockState (com.sk89q.worldedit.world.block.BlockState)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Locale (java.util.Locale)4 Set (java.util.Set)4 Stream (java.util.stream.Stream)4 Block (net.minecraft.block.Block)4