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 ExtraUtilsHelper method registerXUPlant.
static void registerXUPlant(ItemStack seed, Block block, ItemStack soil, ItemStack[] output, final int maxAge, final float growthStep, final boolean useFertilizer) {
IProperty propGrowth = null;
final IBlockState state = block.getDefaultState();
for (IProperty prop : state.getPropertyKeys()) if ("growth".equals(prop.getName()))
propGrowth = prop;
if (propGrowth != null) {
IProperty finalPropGrowth = propGrowth;
DefaultPlantHandler handler = new DefaultPlantHandler() {
private HashSet<ComparableItemStack> validSeeds = new HashSet<>();
@Override
protected HashSet<ComparableItemStack> getSeedSet() {
return validSeeds;
}
@Override
public float getGrowthStep(ItemStack seed, ItemStack soil, float growth, TileEntity tile, float fertilizer, boolean render) {
return !useFertilizer ? growthStep : (growthStep * fertilizer);
}
@Override
@SideOnly(Side.CLIENT)
public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) {
return new IBlockState[] { state.withProperty(finalPropGrowth, Math.min(maxAge, Math.round(maxAge * growth))) };
}
};
handler.register(seed, output, soil, state);
BelljarHandler.registerHandler(handler);
}
}
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, 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));
}
List<T> sorted = Lists.newArrayList(name.getAllowedValues());
Collections.sort(sorted);
TableCellEnum<T> cell = new TableCellEnum<>(null, (T) state.getValue(name), sorted.stream().map(t1 -> new TableCellEnum.Option<>(t1, name.getName(currentProperty))).collect(Collectors.toList()));
cell.addListener(t -> {
setBlockStateAndNotify(state.withProperty(name, t));
delegate.reloadData();
});
cell.setEnabled(!extended);
return new TitledCell(name.getName(), cell);
}
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.blockRegistry.getNameForObject(block).getResourceDomain();
for (IBlockState state : block.getBlockState().getValidStates()) {
int meta = state.getBlock().getMetaFromState(state);
List<IProperty> propertyNames = new ArrayList<>(state.getPropertyNames());
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 SecurityCraft by Geforce132.
the class ItemBlockReinforcedSlabs method canPlaceBlockOnSide.
@Override
@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
BlockPos blockpos1 = pos;
IProperty iproperty = this.singleSlab.getVariantProperty();
Object object = this.singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab) {
boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;
if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && object == iblockstate.getValue(iproperty)) {
return true;
}
}
pos = pos.offset(side);
IBlockState iblockstate1 = worldIn.getBlockState(pos);
return iblockstate1.getBlock() == this.singleSlab && object == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos1, side, player, stack);
}
Aggregations