use of net.minecraft.block.properties.IProperty in project Immersive-Tech by FerroO2000.
the class BlockMetalDevice method createBlockState.
@Override
protected BlockStateContainer createBlockState() {
BlockStateContainer base = super.createBlockState();
IUnlistedProperty[] unlisted = (base instanceof ExtendedBlockState) ? ((ExtendedBlockState) base).getUnlistedProperties().toArray(new IUnlistedProperty[0]) : new IUnlistedProperty[0];
unlisted = Arrays.copyOf(unlisted, unlisted.length + 1);
unlisted[unlisted.length - 1] = IEProperties.CONNECTIONS;
return new ExtendedBlockState(this, base.getProperties().toArray(new IProperty[0]), unlisted);
}
use of net.minecraft.block.properties.IProperty in project BloodMagic by WayofTime.
the class BloodMagicCorePlugin method parseState.
private static IBlockState parseState(String blockInfo) {
String[] split = blockInfo.split("\\[");
// Make sure brackets are removed from state
split[1] = split[1].substring(0, split[1].lastIndexOf("]"));
// Find the block
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(split[0]));
if (block == Blocks.AIR)
// The block is air, so we're looking at invalid data
return Blocks.AIR.getDefaultState();
BlockStateContainer blockState = block.getBlockState();
IBlockState returnState = blockState.getBaseState();
// Force our values into the state
// Splits up each value
String[] stateValues = split[1].split(",");
for (String value : stateValues) {
// Separates property and value
String[] valueSplit = value.split("=");
IProperty property = blockState.getProperty(valueSplit[0]);
if (property != null)
// Force the property into the state
returnState = returnState.withProperty(property, (Comparable) property.parseValue(valueSplit[1]).get());
}
return returnState;
}
use of net.minecraft.block.properties.IProperty in project MC-Prefab by Brian-Wuest.
the class BuildBlock method SetBlockState.
public static BuildBlock SetBlockState(StructureConfiguration configuration, World world, BlockPos originalPos, EnumFacing assumedNorth, BuildBlock block, Block foundBlock, IBlockState blockState, Structure structure) {
try {
if (!block.blockStateData.equals("")) {
return BuildBlock.SetBlockStateFromTagData(configuration, world, originalPos, assumedNorth, block, foundBlock, blockState, structure);
}
EnumFacing vineFacing = BuildBlock.getVineFacing(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
EnumAxis logFacing = BuildBlock.getLogFacing(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
Axis boneFacing = BuildBlock.getBoneFacing(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
BlockQuartz.EnumType quartzFacing = BuildBlock.getQuartsFacing(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
EnumOrientation leverOrientation = BuildBlock.getLeverOrientation(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
// If this block has custom processing for block state just continue onto the next block. The sub-class is expected to place the block.
if (block.getProperties().size() > 0) {
Collection<IProperty<?>> properties = blockState.getPropertyKeys();
// applied.
for (IProperty<?> property : properties) {
BuildProperty buildProperty = block.getProperty(property.getName());
// Make sure that this property exists in our file. The only way it wouldn't be there would be if a mod adds properties to vanilla blocks.
if (buildProperty != null) {
try {
Optional<?> propertyValue = property.parseValue(buildProperty.getValue());
if (!propertyValue.isPresent() || propertyValue.getClass().getName().equals("com.google.common.base.Absent")) {
FMLLog.log.warn("Property value for property name [" + property.getName() + "] for block [" + block.getBlockName() + "] is considered Absent, figure out why.");
continue;
}
Comparable<?> comparable = property.getValueClass().cast(propertyValue.get());
if (comparable == null) {
continue;
}
comparable = BuildBlock.setComparable(comparable, foundBlock, property, configuration, block, assumedNorth, propertyValue, vineFacing, logFacing, boneFacing, quartzFacing, leverOrientation, structure);
if (comparable == null) {
continue;
}
try {
if (blockState.getValue(property) != comparable) {
blockState = BuildBlock.setProperty(blockState, property, comparable);
}
} catch (Exception ex) {
System.out.println("Error setting properly value for property name [" + property.getName() + "] property value [" + buildProperty.getValue() + "] for block [" + block.getBlockName() + "] The default value will be used.");
}
} catch (Exception ex) {
if (property != null && buildProperty != null) {
System.out.println("Error getting properly value for property name [" + property.getName() + "] property value [" + buildProperty.getValue() + "] for block [" + block.getBlockName() + "]");
throw ex;
}
}
} else {
// System.out.println("Property: [" + property.getName() + "] does not exist for Block: [" + block.getBlockName() + "] this is usually due to mods adding properties to vanilla blocks.");
}
}
}
block.setBlockState(blockState);
return block;
} catch (Exception ex) {
System.out.println("Error setting block state for block [" + block.getBlockName() + "] for structure configuration class [" + configuration.getClass().getName() + "]");
throw ex;
}
}
use of net.minecraft.block.properties.IProperty in project Ceramics by KnightMiner.
the class PropertyStateMapper method getModelResourceLocation.
@Nonnull
@Override
protected ModelResourceLocation getModelResourceLocation(@Nonnull IBlockState state) {
ResourceLocation res = new ResourceLocation(state.getBlock().getRegistryName().getResourceDomain(), name + state.getValue(prop).getName());
// if we ignore all properites, just use normal
if (ignoreAll) {
return new ModelResourceLocation(res, "normal");
}
LinkedHashMap<IProperty<?>, Comparable<?>> map = Maps.newLinkedHashMap(state.getProperties());
map.remove(prop);
for (IProperty<?> ignored : ignore) {
map.remove(ignored);
}
return new ModelResourceLocation(res, this.getPropertyString(map));
}
use of net.minecraft.block.properties.IProperty in project ImmersiveEngineering by BluSunrize.
the class BlockConnector method createBlockState.
@Override
protected BlockStateContainer createBlockState() {
BlockStateContainer base = super.createBlockState();
IUnlistedProperty[] unlisted = (base instanceof ExtendedBlockState) ? ((ExtendedBlockState) base).getUnlistedProperties().toArray(new IUnlistedProperty[0]) : new IUnlistedProperty[0];
unlisted = Arrays.copyOf(unlisted, unlisted.length + 1);
unlisted[unlisted.length - 1] = IEProperties.CONNECTIONS;
return new ExtendedBlockState(this, base.getProperties().toArray(new IProperty[0]), unlisted);
}
Aggregations