use of net.minecraft.block.properties.IProperty in project ImmersiveEngineering by BluSunrize.
the class BlockMetalDevice1 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 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);
}
use of net.minecraft.block.properties.IProperty in project RFToolsDimensions by McJty.
the class KnownDimletConfiguration method initMaterialDimlet.
private static void initMaterialDimlet(Block block) {
if (block instanceof BlockLiquid) {
return;
}
Set<Filter.Feature> features = getBlockFeatures(block);
ResourceLocation nameForObject = Block.REGISTRY.getNameForObject(block);
String mod = nameForObject.getResourceDomain();
for (IBlockState state : block.getBlockState().getValidStates()) {
int meta = state.getBlock().getMetaFromState(state);
ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
if (stack.getItem() != null) {
// Protection
List<IProperty<?>> propertyNames = new ArrayList<>(CompatBlock.getPropertyKeys(state));
propertyNames.sort((o1, o2) -> o1.getName().compareTo(o2.getName()));
ImmutableMap<IProperty<?>, Comparable<?>> properties = state.getProperties();
Map<String, String> props = new HashMap<>();
for (Map.Entry<IProperty<?>, Comparable<?>> entry : properties.entrySet()) {
props.put(entry.getKey().getName(), entry.getValue().toString());
}
DimletKey key = new DimletKey(DimletType.DIMLET_MATERIAL, block.getRegistryName() + "@" + meta);
Settings settings = DimletRules.getSettings(key, mod, features, props);
if (!settings.isBlacklisted()) {
knownDimlets.put(key, settings);
}
}
}
}
use of net.minecraft.block.properties.IProperty in project RFToolsDimensions by McJty.
the class DimletDebug method dumpBlock.
private static void dumpBlock(Block block) {
if (block instanceof BlockLiquid) {
return;
}
Set<Filter.Feature> features = KnownDimletConfiguration.getBlockFeatures(block);
String mod = Block.REGISTRY.getNameForObject(block).getResourceDomain();
for (IBlockState state : block.getBlockState().getValidStates()) {
int meta = state.getBlock().getMetaFromState(state);
List<IProperty> propertyNames = new ArrayList<>(CompatBlock.getPropertyKeys(state));
propertyNames.sort((o1, o2) -> o1.getName().compareTo(o2.getName()));
ImmutableMap<IProperty<?>, Comparable<?>> properties = state.getProperties();
Map<String, String> props = new HashMap<>();
for (Map.Entry<IProperty<?>, Comparable<?>> entry : properties.entrySet()) {
props.put(entry.getKey().getName(), entry.getValue().toString());
}
DimletKey key = new DimletKey(DimletType.DIMLET_MATERIAL, block.getRegistryName() + "@" + meta);
Settings settings = DimletRules.getSettings(key, mod, features, props);
Logging.log(key + " (" + state.toString() + "): " + settings.toString());
}
}
use of net.minecraft.block.properties.IProperty in project RecurrentComplex by Ivorforce.
the class TableDataSourceBlockState method getPropertyElement.
@Nonnull
protected <T extends Comparable<T>> TitledCell getPropertyElement(int index, boolean extended) {
IBlockState state = computeBlockState();
@SuppressWarnings("unchecked") IProperty<T> name = (IProperty<T>) getSortedPropertyNames(state, extended).get(index);
List<T> properties = getSortedProperties(name);
T currentProperty = state.getValue(name);
if (properties.size() <= 4) {
List<TableCellButton> buttons = properties.stream().map(property -> {
TableCellButton button = new TableCellButton(null, null, (property == currentProperty ? TextFormatting.GREEN : "") + name.getName(property));
button.setEnabled(!extended);
button.addAction(() -> {
setBlockStateAndNotify(state.withProperty(name, property));
delegate.reloadData();
});
if (property == currentProperty)
button.setEnabled(false);
return button;
}).collect(Collectors.toList());
return new TitledCell(name.getName(), new TableCellMulti(buttons));
}
TableCellButton button = new TableCellButton(null, null, TextFormatting.GREEN + name.getName(currentProperty));
button.setEnabled(!extended);
button.addAction(() -> {
setBlockStateAndNotify(state.cycleProperty(name));
delegate.reloadData();
});
return new TitledCell(name.getName(), button);
}
Aggregations