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<>(state.getPropertyKeys());
propertyNames.sort(Comparator.comparing(IProperty::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 RFToolsDimensions by McJty.
the class KnownDimletConfiguration method initMaterialDimlet.
private static void initMaterialDimlet(Block block) {
if (block instanceof BlockLiquid || block == Blocks.LIT_REDSTONE_ORE) {
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<>(state.getPropertyKeys());
propertyNames.sort(Comparator.comparing(IProperty::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 SecurityCraft by Geforce132.
the class ItemBlockReinforcedSlabs2 method canPlaceBlockOnSide.
@Override
@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
BlockPos blockpos1 = pos;
IProperty iproperty = singleSlab.getVariantProperty();
Object object = singleSlab.getVariant(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == 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() == singleSlab && object == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos1, side, player, stack);
}
use of net.minecraft.block.properties.IProperty in project Almura by AlmuraDev.
the class StatefulLazyBlockState method createState.
@Override
<T extends Comparable<T>> IBlockState createState() {
final Block block = (Block) this.block.require();
IBlockState state = block.getDefaultState();
for (final Map.Entry<IProperty<? extends Comparable<?>>, StateValue<? extends Comparable<?>>> entry : this.properties.get().entrySet()) {
@Nullable final IProperty<T> property = (IProperty<T>) entry.getKey();
if (property != null) {
@Nullable final T value = ((StateValue<T>) entry.getValue()).get(property);
if (value != null) {
state = state.withProperty(property, value);
}
}
}
return state;
}
use of net.minecraft.block.properties.IProperty in project malmo by Microsoft.
the class BlockDrawingHelper method endDrawing.
public void endDrawing(World w) {
// Post-drawing code.
for (StateCheck sc : this.checkList) {
IBlockState stateActual = w.getBlockState(sc.pos);
Block blockActual = stateActual.getBlock();
Block blockDesired = sc.desiredState.getBlock();
if (blockActual == blockDesired) {
// Now check the block states:
if (stateActual != sc.desiredState) {
if (sc.propertiesToCheck == null) {
// No specific properties to check - just do a blanket reset.
w.setBlockState(sc.pos, sc.desiredState);
} else {
// Reset only the properties we've been asked to check:
for (IProperty prop : sc.propertiesToCheck) {
stateActual = stateActual.withProperty(prop, sc.desiredState.getValue(prop));
}
w.setBlockState(sc.pos, stateActual);
}
}
}
}
}
Aggregations