Search in sources :

Example 1 with MoonPhase

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

the class BlockCelestialResonator method updateTick.

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
    if (!world.isRemote) {
        MoonPhase currentPhase = state.getValue(MoonPhase.MOON_PHASE);
        MoonPhase newPhase = MoonPhase.getMoonPhase(world);
        if (currentPhase != newPhase) {
            world.setBlockState(pos, state.withProperty(MoonPhase.MOON_PHASE, newPhase).withProperty(State.ACTIVE, true));
        } else if (state.getValue(State.ACTIVE)) {
            world.setBlockState(pos, state.withProperty(State.ACTIVE, false));
        }
        world.scheduleUpdate(pos, this, tickRate(world));
    }
}
Also used : MoonPhase(arekkuusu.solar.api.state.MoonPhase)

Example 2 with MoonPhase

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

the class BakedCosmicResonator method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, VertexFormat format) {
    return cache.compute(state, quads -> {
        if (state == null) {
            quads.addAll(QuadBuilder.withFormat(format).setFrom(5, 5, 5).setTo(11, 11, 11).addAll(5F, 11F, 5F, 11F, full_moon).bakeJava());
        } else {
            MoonPhase phase = state.getValue(MOON_PHASE);
            QuadBuilder builder = QuadBuilder.withFormat(format).setFrom(5, 5, 5).setTo(11, 11, 11).setHasBrightness(true);
            switch(phase) {
                case NEW_MOON:
                    builder = builder.addAll(5F, 11F, 5F, 11F, new_moon);
                    break;
                case FULL_MOON:
                    builder = builder.addAll(5F, 11F, 5F, 11F, full_moon);
                    break;
                case ECLIPSE:
                    builder = builder.addAll(5F, 11F, 5F, 11F, eclipse);
                    break;
                default:
                    {
                        boolean inverse = phase.ordinal() > 4;
                        builder = builder.addFace(EAST, 5F, 11F, 5F, 11F, inverse ? new_moon : full_moon).addFace(WEST, 5F, 11F, 5F, 11F, inverse ? full_moon : new_moon).addFace(UP, 5F, 11F, 5F, 11F, phases.get(phase)).addFace(DOWN, 5F, 11F, 5F, 11F, phases.get(phase)).mirror().addFace(NORTH, 5F, 11F, 5F, 11F, phases.get(phase)).mirror().addFace(SOUTH, 5F, 11F, 5F, 11F, phases.get(phase));
                    }
            }
            quads.addAll(builder.bakeJava());
        }
    });
}
Also used : MoonPhase(arekkuusu.solar.api.state.MoonPhase) QuadBuilder(net.katsstuff.mirror.client.baked.QuadBuilder)

Aggregations

MoonPhase (arekkuusu.solar.api.state.MoonPhase)2 QuadBuilder (net.katsstuff.mirror.client.baked.QuadBuilder)1