Search in sources :

Example 1 with StateMapperBase

use of net.minecraft.client.renderer.block.statemap.StateMapperBase in project Railcraft by Railcraft.

the class ActuatorModel method getDependencies.

@Override
public Collection<ResourceLocation> getDependencies() {
    BlockMachineActuator block = (BlockMachineActuator) RailcraftBlocks.ACTUATOR.block();
    if (block == null)
        return Collections.emptyList();
    if (models.isEmpty()) {
        StateMapperBase baseStateMapper = new StateMap.Builder().withName(block.getVariantProperty()).ignore(BlockMachineActuator.RED_FLAG).ignore(BlockMachineActuator.WHITE_FLAG).build();
        baseModelLocations.putAll(baseStateMapper.putStateModelLocations(block));
        StateMapperBase redFlagStateMapper = new StateMap.Builder().withSuffix("_flag_red").ignore(block.getVariantProperty()).ignore(BlockMachineActuator.THROWN).ignore(BlockMachineActuator.FACING).ignore(BlockMachineActuator.WHITE_FLAG).build();
        redFlagModelLocations.putAll(redFlagStateMapper.putStateModelLocations(block));
        StateMapperBase whiteFlagStateMapper = new StateMap.Builder().withSuffix("_flag_white").ignore(block.getVariantProperty()).ignore(BlockMachineActuator.THROWN).ignore(BlockMachineActuator.FACING).ignore(BlockMachineActuator.RED_FLAG).build();
        whiteFlagModelLocations.putAll(whiteFlagStateMapper.putStateModelLocations(block));
        models.addAll(baseModelLocations.values());
        models.addAll(redFlagModelLocations.values());
        models.addAll(whiteFlagModelLocations.values());
    }
    return models;
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) BlockMachineActuator(mods.railcraft.common.blocks.machine.wayobjects.actuators.BlockMachineActuator)

Example 2 with StateMapperBase

use of net.minecraft.client.renderer.block.statemap.StateMapperBase in project Railcraft by Railcraft.

the class IRailcraftItemBlock method getModelLocation.

@SideOnly(Side.CLIENT)
default default ModelResourceLocation getModelLocation(IBlockState state) {
    StateMapperBase stateMapper = null;
    if (state.getBlock() instanceof IRailcraftBlock)
        stateMapper = ((IRailcraftBlock) state.getBlock()).getStateMapper();
    if (stateMapper == null)
        return new ModelResourceLocation(state.getBlock().getRegistryName(), new DefaultStateMapper().getPropertyString(state.getProperties()));
    Map<IBlockState, ModelResourceLocation> stateMap = stateMapper.putStateModelLocations(state.getBlock());
    return stateMap.get(state);
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) DefaultStateMapper(net.minecraft.client.renderer.block.statemap.DefaultStateMapper) IBlockState(net.minecraft.block.state.IBlockState) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with StateMapperBase

use of net.minecraft.client.renderer.block.statemap.StateMapperBase in project Witchworks by Um-Mitternacht.

the class BlockFluid method registerModels.

@Override
@SideOnly(Side.CLIENT)
public void registerModels() {
    final Item item = Item.getItemFromBlock(this);
    assert item != null;
    ModelBakery.registerItemVariants(item);
    final ModelResourceLocation modelResourceLocation = new ModelResourceLocation(LibMod.MOD_ID + ":fluid", getFluid().getName());
    ModelLoader.setCustomMeshDefinition(item, stack -> modelResourceLocation);
    ModelLoader.setCustomStateMapper(this, new StateMapperBase() {

        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState p_178132_1_) {
            return modelResourceLocation;
        }
    });
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with StateMapperBase

use of net.minecraft.client.renderer.block.statemap.StateMapperBase in project Overloaded by CJ-MC-Mods.

the class AbstractBlockHyperNode method registerModel.

@SideOnly(Side.CLIENT)
@Override
public void registerModel() {
    ModelResourceLocation location = new ModelResourceLocation(getRegistryName(), null);
    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, location);
    StateMapperBase ignoreState = new StateMapperBase() {

        @Override
        @Nonnull
        protected ModelResourceLocation getModelResourceLocation(@Nonnull IBlockState iBlockState) {
            return location;
        }
    };
    ModelLoader.setCustomStateMapper(this, ignoreState);
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) IBlockState(net.minecraft.block.state.IBlockState) Nonnull(javax.annotation.Nonnull) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with StateMapperBase

use of net.minecraft.client.renderer.block.statemap.StateMapperBase in project ImmersiveEngineering by BluSunrize.

the class IECustomStateMapper method getStateMapper.

public static StateMapperBase getStateMapper(IIEMetaBlock metaBlock) {
    String key = metaBlock.getIEBlockName();
    StateMapperBase mapper = stateMappers.get(key);
    if (mapper == null) {
        mapper = metaBlock.getCustomMapper();
        if (mapper == null)
            mapper = new IECustomStateMapper();
        stateMappers.put(key, mapper);
    }
    return mapper;
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase)

Aggregations

StateMapperBase (net.minecraft.client.renderer.block.statemap.StateMapperBase)7 IBlockState (net.minecraft.block.state.IBlockState)5 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 Item (net.minecraft.item.Item)3 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)2 Nonnull (javax.annotation.Nonnull)1 BlockMachineActuator (mods.railcraft.common.blocks.machine.wayobjects.actuators.BlockMachineActuator)1 Block (net.minecraft.block.Block)1 BlockFenceGate (net.minecraft.block.BlockFenceGate)1 BlockSlab (net.minecraft.block.BlockSlab)1 BlockWall (net.minecraft.block.BlockWall)1 ModelBakery (net.minecraft.client.renderer.block.model.ModelBakery)1 DefaultStateMapper (net.minecraft.client.renderer.block.statemap.DefaultStateMapper)1 StateMap (net.minecraft.client.renderer.block.statemap.StateMap)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 ModelRegistryEvent (net.minecraftforge.client.event.ModelRegistryEvent)1 ModelLoader (net.minecraftforge.client.model.ModelLoader)1