use of net.minecraft.block.BlockLever.EnumOrientation 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;
}
}
Aggregations