Search in sources :

Example 1 with Direction

use of arekkuusu.solar.api.state.Direction in project Solar by ArekkuusuJerii.

the class BlockQelaion method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    Optional<TileQelaion> optional = getTile(TileQelaion.class, world, pos);
    if (optional.isPresent()) {
        List<EnumFacing> closed = optional.get().getInputs();
        Direction direction = Direction.getDirectionFromFacings(closed.toArray(new EnumFacing[closed.size()]));
        return ((IExtendedBlockState) state).withProperty(Direction.DIR_UNLISTED, direction);
    }
    return super.getExtendedState(state, world, pos);
}
Also used : TileQelaion(arekkuusu.solar.common.block.tile.TileQelaion) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) EnumFacing(net.minecraft.util.EnumFacing) Direction(arekkuusu.solar.api.state.Direction)

Example 2 with Direction

use of arekkuusu.solar.api.state.Direction in project Solar by ArekkuusuJerii.

the class BakedQelaion method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, VertexFormat format) {
    return cache.compute(state, quads -> {
        boolean hasNode = state != null && state.getValue(BlockQelaion.HAS_NODE);
        quads.addAll(BlockBaker.QELAION.getQuads());
        quads.addAll(QuadBuilder.withFormat(format).setFrom(5, 5, 5).setTo(11, 11, 11).addAll(0, 9, 0, 9, hasNode ? on : off).setHasBrightness(true).bakeJava());
        if (state instanceof IExtendedBlockState) {
            Direction direction = ((IExtendedBlockState) state).getValue(Direction.DIR_UNLISTED);
            if (direction != null && direction != Direction.NON) {
                QuadBuilder builder = QuadBuilder.withFormat(format).setFrom(2, 2, 2).setTo(14, 14, 14);
                for (EnumFacing facing : direction.getFacings()) builder = builder.addFace(facing, 2, 14, 2, 14, base);
                quads.addAll(builder.bakeJava());
            }
        }
    });
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) EnumFacing(net.minecraft.util.EnumFacing) QuadBuilder(net.katsstuff.mirror.client.baked.QuadBuilder) Direction(arekkuusu.solar.api.state.Direction)

Aggregations

Direction (arekkuusu.solar.api.state.Direction)2 EnumFacing (net.minecraft.util.EnumFacing)2 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)2 TileQelaion (arekkuusu.solar.common.block.tile.TileQelaion)1 QuadBuilder (net.katsstuff.mirror.client.baked.QuadBuilder)1