Untitled

 avatar
unknown
plain_text
10 months ago
3.0 kB
18
Indexable
package usagi.my_world_java.block.effects;

import com.lowdragmc.photon.client.fx.FX;
import com.lowdragmc.photon.client.fx.FXHelper;
import com.lowdragmc.photon.client.fx.IFXEffect;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import usagi.my_world_java.block.VolcanoSmokeBlock;


public class VolcanoSmokeBlockEffect implements IFXEffect {

    private final FX smokeFx;
    private final Level level;
    private final BlockPos blockPos;

    // Configuration
    private Vector3f offset = new Vector3f(0.5f, 1.0f, 0.5f); // Above block center
    private Quaternionf rotation = new Quaternionf();
    private Vector3f scale = new Vector3f(1.0f);
    private int delay = 0;
    private boolean forcedDeath = true;
    private boolean allowMulti = false;
    private boolean isActive = false;

    public VolcanoSmokeBlockEffect(Level level, BlockPos pos) {
        this.level = level;
        this.blockPos = pos;

        // Get the smoke1 effect
        this.smokeFx = FXHelper.getFX(new ResourceLocation("photon:smoke1"));

    }

    @Override
    public FX getFx() {
        return smokeFx;
    }

    @Override
    public void setOffset(Vector3f offset) {
        this.offset = new Vector3f(offset);
    }

    @Override
    public void setRotation(Quaternionf quaternion) {
        this.rotation = new Quaternionf(quaternion);
    }

    @Override
    public void setScale(Vector3f scale) {
        this.scale = new Vector3f(scale);
    }

    @Override
    public void setDelay(int delay) {
        this.delay = delay;
    }

    @Override
    public void setForcedDeath(boolean forcedDeath) {
        this.forcedDeath = forcedDeath;
    }

    @Override
    public void setAllowMulti(boolean allowMulti) {
        this.allowMulti = allowMulti;
    }

    @Override
    public Level getLevel() {
        return level;
    }

    @Override
    public void start() {
        if (!level.isClientSide || smokeFx == null) return;

        if (delay > 0) {
            // Schedule delayed start
            level.scheduleTick(blockPos, level.getBlockState(blockPos).getBlock(), delay);
        } else {
            startImmediate();
        }
    }

    private void startImmediate() {
        isActive = true;



        System.out.println("Started volcano smoke effect at " + blockPos);
    }


    public boolean shouldContinue() {
        if (forcedDeath) {
            // Check if the volcano smoke block still exists
            BlockState currentState = level.getBlockState(blockPos);
            return currentState.getBlock() instanceof VolcanoSmokeBlock;
        }
        return isActive;
    }

    public void stop() {
        isActive = false;
    }
}
Editor is loading...
Leave a Comment