use of net.minecraft.block.properties.IProperty in project Almura by AlmuraDev.
the class StatefulLazyBlockState method resolveProperties.
private <T extends Comparable<T>> Map<IProperty<? extends Comparable<?>>, StateValue<? extends Comparable<?>>> resolveProperties(final Map<String, StateValue<? extends Comparable<?>>> source) {
final Block block = (Block) this.block.require();
final Map<IProperty<? extends Comparable<?>>, StateValue<? extends Comparable<?>>> target = new HashMap<>();
final BlockStateContainer definition = block.getBlockState();
for (final Map.Entry<String, StateValue<? extends Comparable<?>>> entry : source.entrySet()) {
@Nullable final IProperty<T> property = (IProperty<T>) definition.getProperty(entry.getKey());
if (property != null) {
target.put(property, entry.getValue());
}
}
return target;
}
use of net.minecraft.block.properties.IProperty in project Almura by AlmuraDev.
the class LookingDebugPanel method renderItemStackFromBlock.
private void renderItemStackFromBlock(final IBlockState state, final ItemStack pickStack) {
this.clipContent = false;
// Draw what we know of
if (!pickStack.isEmpty()) {
this.drawItem(pickStack, 4, this.autoHeight + 4);
if (pickStack.getItem() instanceof ItemBlock) {
this.drawText(Text.of(TextColors.WHITE, Block.REGISTRY.getNameForObject(state.getBlock())), 24, this.autoHeight - 14, false, true);
} else {
this.drawText(Text.of(TextColors.WHITE, Block.REGISTRY.getNameForObject(state.getBlock())), 24, this.autoHeight - 14, false, true);
}
} else {
this.drawText(Text.of(TextColors.WHITE, Block.REGISTRY.getNameForObject(state.getBlock())), 24, this.autoHeight + 3, false, true);
}
final Map<IProperty<?>, Comparable<?>> properties = state.getProperties();
final boolean hasProperties = !properties.isEmpty();
if (hasProperties) {
this.autoHeight -= 2;
}
for (final Map.Entry<IProperty<?>, Comparable<?>> entry : properties.entrySet()) {
final IProperty<?> property = entry.getKey();
final String name = property.getName();
final Comparable<?> value = entry.getValue();
final String describedValue = getName(property, value);
if (value instanceof Boolean) {
this.drawText(Text.of(TextColors.WHITE, name, ": ", ((Boolean) value) ? TextColors.GREEN : TextColors.RED, describedValue), 24, this.autoHeight);
} else {
this.drawProperty(name, describedValue, 24, pickStack.isEmpty() ? this.autoHeight + 13 : this.autoHeight);
}
}
if (hasProperties) {
this.autoHeight -= 4;
}
}
use of net.minecraft.block.properties.IProperty in project Minestuck by mraof.
the class StructureBlockRegistry method getStairs.
public IBlockState getStairs(String name, EnumFacing facing, boolean upsideDown) {
Rotation rotation;
switch(facing) {
case EAST:
rotation = Rotation.CLOCKWISE_90;
break;
case SOUTH:
rotation = Rotation.CLOCKWISE_180;
break;
case WEST:
rotation = Rotation.COUNTERCLOCKWISE_90;
break;
default:
rotation = Rotation.NONE;
}
IBlockState state = getBlockState(name);
state = state.withRotation(rotation);
if (upsideDown)
for (IProperty<?> property : state.getPropertyKeys()) if (property.getValueClass().equals(BlockStairs.EnumHalf.class)) {
state = state.withProperty((IProperty<BlockStairs.EnumHalf>) property, BlockStairs.EnumHalf.TOP);
break;
}
return state;
}
use of net.minecraft.block.properties.IProperty in project Binnie by ForestryMC.
the class StateMapperFlower method getModelResourceLocation.
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
Map<IProperty<?>, Comparable<?>> properties = Maps.newLinkedHashMap(state.getProperties());
IFlowerType flowerType = (IFlowerType) state.getValue(BlockFlower.FLOWER);
if (flowerType.getSections() < 2) {
properties.remove(BlockFlower.SECTION);
} else if (flowerType.getSections() <= state.getValue(BlockFlower.SECTION)) {
properties.put(BlockFlower.SECTION, flowerType.getSections() - 1);
}
if (state.getValue(BlockFlower.SEED)) {
properties.remove(BlockFlower.SECTION);
properties.remove(BlockFlower.FLOWER);
properties.remove(BlockFlower.FLOWERED);
} else {
properties.remove(BlockFlower.SEED);
}
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flower", getPropertyString(properties));
}
use of net.minecraft.block.properties.IProperty in project BiomesOPlenty by Glitchfiend.
the class BlockStateUtils method getStateInfoAsString.
// utility function for dumping block state info to a string
public static String getStateInfoAsString(IBlockState state) {
String desc = state.getBlock().getClass().getName() + "[";
Iterator it = state.getProperties().entrySet().iterator();
boolean first = true;
while (it.hasNext()) {
if (!first) {
desc = desc + ",";
}
Entry entry = (Entry) it.next();
IProperty iproperty = (IProperty) entry.getKey();
Comparable comparable = (Comparable) entry.getValue();
desc = desc + iproperty.getName() + "=" + iproperty.getName(comparable);
first = false;
}
desc = desc + "]";
return desc;
}
Aggregations