use of net.minecraft.client.renderer.block.statemap.DefaultStateMapper 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);
}
use of net.minecraft.client.renderer.block.statemap.DefaultStateMapper in project artisan-worktables by codetaylor.
the class BlockModelRegistrationStrategy method register.
@Override
public void register() {
BlockBase.VARIANT.getAllowedValues().forEach(type -> {
IBlockState state = this.block.getDefaultState().withProperty(BlockBase.VARIANT, type);
Block block = state.getBlock();
Item item = Item.getItemFromBlock(block);
ModelLoader.setCustomModelResourceLocation(item, type.getMeta(), new ModelResourceLocation(Preconditions.checkNotNull(item.getRegistryName(), "Item %s has null registry name", item), BlockBase.VARIANT.getName() + "=" + type.getName()));
});
IBlockState state = this.block.getDefaultState().withProperty(BlockBase.VARIANT, EnumType.MAGE);
Block block = state.getBlock();
Item item = Item.getItemFromBlock(block);
ModelLoader.setCustomModelResourceLocation(item, Short.MAX_VALUE / 2 + EnumType.MAGE.getMeta(), new ModelResourceLocation(Preconditions.checkNotNull(item.getRegistryName(), "Item %s has null registry name", item), BlockBase.VARIANT.getName() + "=" + EnumType.MAGE.getName() + "_active"));
ModelLoader.setCustomStateMapper(this.block, new DefaultStateMapper() {
@Nonnull
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
EnumType type = state.getValue(BlockBase.VARIANT);
if (type == EnumType.MAGE) {
Block block = state.getBlock();
boolean active = state.getValue(BlockBase.ACTIVE);
return new ModelResourceLocation(Preconditions.checkNotNull(Block.REGISTRY.getNameForObject(block), "Block %s has null registry name", block), BlockBase.VARIANT.getName() + "=" + type.getName() + (active ? "_active" : ""));
} else {
Block block = state.getBlock();
return new ModelResourceLocation(Preconditions.checkNotNull(Block.REGISTRY.getNameForObject(block), "Block %s has null registry name", block), BlockBase.VARIANT.getName() + "=" + type.getName());
}
}
});
}
use of net.minecraft.client.renderer.block.statemap.DefaultStateMapper in project EnderIO by SleepyTrousers.
the class BlockDecoration method registerRenderers.
@Override
@SideOnly(Side.CLIENT)
public void registerRenderers(@Nonnull IModObject modObject) {
Item item = Item.getItemFromBlock(this);
Map<IBlockState, ModelResourceLocation> locations = new DefaultStateMapper().putStateModelLocations(this);
NNIterator<EnumDecoBlock> iterator = NNList.of(EnumDecoBlock.class).iterator();
while (iterator.hasNext()) {
EnumDecoBlock type = iterator.next();
IBlockState state = getDefaultState().withProperty(EnumDecoBlock.TYPE, type);
ModelResourceLocation mrl = locations.get(state);
if (mrl != null) {
ModelLoader.setCustomModelResourceLocation(item, EnumDecoBlock.getMetaFromType(type), mrl);
}
}
}
use of net.minecraft.client.renderer.block.statemap.DefaultStateMapper in project EnderIO by SleepyTrousers.
the class BlockDecorationFacing method registerRenderers.
@Override
@SideOnly(Side.CLIENT)
public void registerRenderers(@Nonnull IModObject modObject) {
Item item = Item.getItemFromBlock(this);
Map<IBlockState, ModelResourceLocation> locations = new DefaultStateMapper().putStateModelLocations(this);
NNIterator<EnumDecoBlock> iterator = NNList.of(EnumDecoBlock.class).iterator();
while (iterator.hasNext()) {
EnumDecoBlock type = iterator.next();
IBlockState state = getDefaultState().withProperty(EnumDecoBlock.TYPE, type).withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, false);
ModelResourceLocation mrl = locations.get(state);
if (mrl != null) {
ModelLoader.setCustomModelResourceLocation(item, EnumDecoBlock.getMetaFromType(type), mrl);
}
}
}
use of net.minecraft.client.renderer.block.statemap.DefaultStateMapper in project RebornCore by TechReborn.
the class ModelMethods method setBlockStateMapper.
public static void setBlockStateMapper(Block block, String fileName, String path, IProperty... ignoredProperties) {
final String slash = !path.isEmpty() ? "/" : "";
ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
Map<IProperty<?>, Comparable<?>> map = Maps.<IProperty<?>, Comparable<?>>newLinkedHashMap(state.getProperties());
for (IProperty<?> iproperty : ignoredProperties) {
map.remove(iproperty);
}
return new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), path + slash + fileName), this.getPropertyString(map));
}
});
}
Aggregations