Skip to content

Java Intergration

KilaBash edited this page Sep 27, 2024 · 9 revisions

Development Environment

repositories {
    maven { url = "https://maven.firstdarkdev.xyz/snapshots" } // LDLib, Photon
}

Fabric

dependencies {
    modImplementation("com.lowdragmc.photon:photon-fabric-1.20.1:{latest_version}") { transitive = false }
    modImplementation("com.lowdragmc.ldlib:ldlib-fabric-1.20.1:{latest_version}") { transitive = false }
}

Forge

dependencies {
    implementation fg.deobf("com.lowdragmc.photon:photon-forge-1.20.1:{latest_version}") { transitive = false }
    implementation fg.deobf("com.lowdragmc.ldlib:ldlib-forge-1.20.1:{latest_version}") { transitive = false }
}

Architectury (Common)

dependencies {
    implementation fg.deobf("com.lowdragmc.photon:photon-common-1.20.1:{latest_version}") { transitive = false }
    implementation fg.deobf("com.lowdragmc.ldlib:ldlib-common-1.20.1:{latest_version}") { transitive = false }
}

How to load and use the effect files?

FX fx = FXHelper.getFX(new ResourceLocation("photon:fire"));
// bind it to a block
new BlockEffect(fx, level, pos).start();
// bind it to an entity
new EntityEffect(fx, level, entity).start();

Implement your ownIFXEffect to manage the lifecycle of your photon effects.

Sometimes, you wanna control the effect you have with additional logic. You can implement the IFXEffect and do what you want.

To undertand it clearly, you can check the code of BlockEffect and EntityEffect. They are good examples and easy to understand.

public interface IFXEffect {
    /**
     * get all emitters included in this effect.
     */
    FX getFx();
    /**
     * set effect offset
     */
    void setOffset(double x, double y, double z);

    /**
     * set effect delay
     */
    void setDelay(int delay);

    /**
     * Whether to remove particles directly when the bound object invalid.
     * <br>
     * default - wait for particles death.
     */
    void setForcedDeath(boolean forcedDeath);

    /**
     * Allows multiple identical effects to be bound to a same object。
     */
    void setAllowMulti(boolean allowMulti);

    /**
     * get all emitters included in this effect.
     */
    List<IParticleEmitter> getEmitters();

    /**
     * update each emitter during their duration,
     * @param emitter emitter
     * @return true - block emitter origin tick logic.
     */
    boolean updateEmitter(IParticleEmitter emitter);

    /**
     * start effect。
     */
    void start();

}