Search in sources :

Example 1 with EnumTrait

use of org.spongepowered.api.block.trait.EnumTrait in project SpongeCommon by SpongePowered.

the class BlockTypeRegistryModule method registerBlockTrait.

private void registerBlockTrait(String id, BlockType block) {
    Block nmsBlock = (Block) block;
    for (IBlockState state : nmsBlock.getBlockState().getValidStates()) {
        ((IMixinBlockState) state).generateId(nmsBlock);
        BlockStateRegistryModule.getInstance().registerBlockState((BlockState) state);
    }
    for (Map.Entry<BlockTrait<?>, ?> mapEntry : block.getDefaultState().getTraitMap().entrySet()) {
        BlockTrait<?> property = mapEntry.getKey();
        final String propertyId = BlockPropertyIdProvider.getIdAndTryRegistration((IProperty<?>) property, (Block) block, id);
        if (property instanceof IMixinPropertyHolder) {
            ((IMixinPropertyHolder) property).setId(propertyId);
        }
        if (property instanceof EnumTrait) {
            EnumTraitRegistryModule.getInstance().registerBlock(propertyId, block, (EnumTrait<?>) property);
        } else if (property instanceof IntegerTrait) {
            IntegerTraitRegistryModule.getInstance().registerBlock(propertyId, block, (IntegerTrait) property);
        } else if (property instanceof BooleanTrait) {
            BooleanTraitRegistryModule.getInstance().registerBlock(propertyId, block, (BooleanTrait) property);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockTrait(org.spongepowered.api.block.trait.BlockTrait) IMixinPropertyHolder(org.spongepowered.common.interfaces.block.IMixinPropertyHolder) Block(net.minecraft.block.Block) EnumTrait(org.spongepowered.api.block.trait.EnumTrait) BooleanTrait(org.spongepowered.api.block.trait.BooleanTrait) HashMap(java.util.HashMap) Map(java.util.Map) BiMap(com.google.common.collect.BiMap) HashBiMap(com.google.common.collect.HashBiMap) IMixinBlockState(org.spongepowered.common.interfaces.block.IMixinBlockState) IntegerTrait(org.spongepowered.api.block.trait.IntegerTrait)

Aggregations

BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockTrait (org.spongepowered.api.block.trait.BlockTrait)1 BooleanTrait (org.spongepowered.api.block.trait.BooleanTrait)1 EnumTrait (org.spongepowered.api.block.trait.EnumTrait)1 IntegerTrait (org.spongepowered.api.block.trait.IntegerTrait)1 IMixinBlockState (org.spongepowered.common.interfaces.block.IMixinBlockState)1 IMixinPropertyHolder (org.spongepowered.common.interfaces.block.IMixinPropertyHolder)1