Search in sources :

Example 1 with RotationIndicatorParticleData

use of com.simibubi.create.content.contraptions.particle.RotationIndicatorParticleData in project Create by Creators-of-Create.

the class KineticEffectHandler method spawnRotationIndicators.

public void spawnRotationIndicators() {
    float speed = kte.getSpeed();
    if (speed == 0)
        return;
    BlockState state = kte.getBlockState();
    Block block = state.getBlock();
    if (!(block instanceof KineticBlock))
        return;
    KineticBlock kb = (KineticBlock) block;
    float radius1 = kb.getParticleInitialRadius();
    float radius2 = kb.getParticleTargetRadius();
    Axis axis = kb.getRotationAxis(state);
    BlockPos pos = kte.getBlockPos();
    Level world = kte.getLevel();
    if (axis == null)
        return;
    if (world == null)
        return;
    char axisChar = axis.name().charAt(0);
    Vec3 vec = VecHelper.getCenterOf(pos);
    SpeedLevel speedLevel = SpeedLevel.of(speed);
    int color = speedLevel.getColor();
    int particleSpeed = speedLevel.getParticleSpeed();
    particleSpeed *= Math.signum(speed);
    if (world instanceof ServerLevel) {
        AllTriggers.triggerForNearbyPlayers(AllTriggers.ROTATION, world, pos, 5);
        RotationIndicatorParticleData particleData = new RotationIndicatorParticleData(color, particleSpeed, radius1, radius2, 10, axisChar);
        ((ServerLevel) world).sendParticles(particleData, vec.x, vec.y, vec.z, 20, 0, 0, 0, 1);
    }
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) SpeedLevel(com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel) BlockState(net.minecraft.world.level.block.state.BlockState) Vec3(net.minecraft.world.phys.Vec3) Block(net.minecraft.world.level.block.Block) BlockPos(net.minecraft.core.BlockPos) ServerLevel(net.minecraft.server.level.ServerLevel) SpeedLevel(com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel) Level(net.minecraft.world.level.Level) Axis(net.minecraft.core.Direction.Axis) RotationIndicatorParticleData(com.simibubi.create.content.contraptions.particle.RotationIndicatorParticleData)

Example 2 with RotationIndicatorParticleData

use of com.simibubi.create.content.contraptions.particle.RotationIndicatorParticleData in project Create by Creators-of-Create.

the class DebugScenes method particleScene.

public static void particleScene(SceneBuilder scene, SceneBuildingUtil util) {
    scene.title("debug_particles", "Emitting particles");
    scene.showBasePlate();
    scene.idle(10);
    scene.world.showSection(util.select.layersFrom(1), Direction.DOWN);
    scene.idle(10);
    Vec3 emitterPos = util.vector.of(2.5, 2.25, 2.5);
    Emitter emitter = Emitter.simple(ParticleTypes.LAVA, util.vector.of(0, .1, 0));
    Emitter rotation = Emitter.simple(new RotationIndicatorParticleData(SpeedLevel.MEDIUM.getColor(), 12, 1, 1, 20, 'Y'), util.vector.of(0, .1, 0));
    scene.overlay.showText(20).text("Incoming...").pointAt(emitterPos);
    scene.idle(30);
    scene.effects.emitParticles(emitterPos, emitter, 1, 60);
    scene.effects.emitParticles(emitterPos, rotation, 20, 1);
    scene.idle(30);
    scene.rotateCameraY(180);
}
Also used : Emitter(com.simibubi.create.foundation.ponder.instruction.EmitParticlesInstruction.Emitter) Vec3(net.minecraft.world.phys.Vec3) RotationIndicatorParticleData(com.simibubi.create.content.contraptions.particle.RotationIndicatorParticleData)

Aggregations

RotationIndicatorParticleData (com.simibubi.create.content.contraptions.particle.RotationIndicatorParticleData)2 Vec3 (net.minecraft.world.phys.Vec3)2 SpeedLevel (com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel)1 Emitter (com.simibubi.create.foundation.ponder.instruction.EmitParticlesInstruction.Emitter)1 BlockPos (net.minecraft.core.BlockPos)1 Axis (net.minecraft.core.Direction.Axis)1 ServerLevel (net.minecraft.server.level.ServerLevel)1 Level (net.minecraft.world.level.Level)1 Block (net.minecraft.world.level.block.Block)1 BlockState (net.minecraft.world.level.block.state.BlockState)1