use of net.minecraft.block.properties.IProperty in project BiomesOPlenty by Glitchfiend.
the class BlockStateUtils method addStatesToList.
// recursively add state values to a list
private static void addStatesToList(IBlockState state, List<IBlockState> list, Stack<IProperty> stack) {
if (stack.empty()) {
list.add(state);
return;
} else {
IProperty prop = stack.pop();
for (Object value : prop.getAllowedValues()) {
addStatesToList(state.withProperty(prop, (Comparable) value), list, stack);
}
stack.push(prop);
}
}
use of net.minecraft.block.properties.IProperty in project BiomesOPlenty by Glitchfiend.
the class BlockStateUtils method getStatesSet.
// returns a set of states, one for every possible combination of values from the provided properties
public static ImmutableSet<IBlockState> getStatesSet(IBlockState baseState, IProperty... properties) {
Stack<IProperty> propStack = new Stack<IProperty>();
List<IBlockState> states = new ArrayList<IBlockState>();
for (IProperty prop : properties) {
propStack.push(prop);
}
if (!propStack.isEmpty()) {
addStatesToList(baseState, states, propStack);
}
ImmutableSet<IBlockState> ret = ImmutableSet.copyOf(states);
return ret;
}
use of net.minecraft.block.properties.IProperty in project BiomesOPlenty by Glitchfiend.
the class ClientProxy method registerBlockSided.
@Override
public void registerBlockSided(Block block) {
if (block instanceof IBOPBlock) {
IBOPBlock bopBlock = (IBOPBlock) block;
// Register non-rendering properties
IProperty[] nonRenderingProperties = bopBlock.getNonRenderingProperties();
if (nonRenderingProperties != null) {
// use a custom state mapper which will ignore the properties specified in the block as being non-rendering
IStateMapper custom_mapper = (new StateMap.Builder()).ignore(nonRenderingProperties).build();
ModelLoader.setCustomStateMapper(block, custom_mapper);
}
// Register colour handlers
if (bopBlock.getBlockColor() != null || bopBlock.getItemColor() != null) {
blocksToColour.add(block);
}
}
}
use of net.minecraft.block.properties.IProperty in project ImmersiveEngineering by BluSunrize.
the class BlockIETileProvider method getActualState.
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
state = super.getActualState(state, world, pos);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof IAttachedIntegerProperies) {
for (String s : ((IAttachedIntegerProperies) tile).getIntPropertyNames()) state = applyProperty(state, ((IAttachedIntegerProperies) tile).getIntProperty(s), ((IAttachedIntegerProperies) tile).getIntPropertyValue(s));
}
if (tile instanceof IDirectionalTile && (state.getPropertyKeys().contains(IEProperties.FACING_ALL) || state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL))) {
PropertyDirection prop = state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL) ? IEProperties.FACING_HORIZONTAL : IEProperties.FACING_ALL;
state = applyProperty(state, prop, ((IDirectionalTile) tile).getFacing());
}
if (tile instanceof IActiveState) {
IProperty boolProp = ((IActiveState) tile).getBoolProperty(IActiveState.class);
if (state.getPropertyKeys().contains(boolProp))
state = applyProperty(state, boolProp, ((IActiveState) tile).getIsActive());
}
if (tile instanceof IDualState) {
IProperty boolProp = ((IDualState) tile).getBoolProperty(IDualState.class);
if (state.getPropertyKeys().contains(boolProp))
state = applyProperty(state, boolProp, ((IDualState) tile).getIsSecondState());
}
if (tile instanceof TileEntityMultiblockPart)
state = applyProperty(state, IEProperties.MULTIBLOCKSLAVE, ((TileEntityMultiblockPart) tile).isDummy());
else if (tile instanceof IHasDummyBlocks)
state = applyProperty(state, IEProperties.MULTIBLOCKSLAVE, ((IHasDummyBlocks) tile).isDummy());
if (tile instanceof IMirrorAble)
state = applyProperty(state, ((IMirrorAble) tile).getBoolProperty(IMirrorAble.class), ((IMirrorAble) tile).getIsMirrored());
return state;
}
use of net.minecraft.block.properties.IProperty in project ImmersiveEngineering by BluSunrize.
the class BlockIETileProvider method createTileEntity.
@Nullable
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
TileEntity basic = createBasicTE(world, state.getValue(property));
Collection<IProperty<?>> keys = state.getPropertyKeys();
if (basic instanceof IDirectionalTile) {
EnumFacing newFacing = null;
if (keys.contains(IEProperties.FACING_HORIZONTAL))
newFacing = state.getValue(IEProperties.FACING_HORIZONTAL);
else if (keys.contains(IEProperties.FACING_ALL))
newFacing = state.getValue(IEProperties.FACING_ALL);
int type = ((IDirectionalTile) basic).getFacingLimitation();
if (newFacing != null) {
switch(type) {
case 2:
case 4:
case 5:
case 6:
if (newFacing.getAxis() == Axis.Y)
newFacing = null;
break;
case 3:
if (newFacing.getAxis() != Axis.Y)
newFacing = null;
break;
}
if (newFacing != null)
((IDirectionalTile) basic).setFacing(newFacing);
}
}
if (basic instanceof IAttachedIntegerProperies) {
IAttachedIntegerProperies tileIntProps = (IAttachedIntegerProperies) basic;
String[] names = ((IAttachedIntegerProperies) basic).getIntPropertyNames();
for (String propertyName : names) {
PropertyInteger property = tileIntProps.getIntProperty(propertyName);
if (keys.contains(property))
tileIntProps.setValue(propertyName, state.getValue(property));
}
}
return basic;
}
Aggregations