mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 22:27:32 +00:00
57 lines
1.4 KiB
Java
57 lines
1.4 KiB
Java
package noppes.npcs.controllers.data;
|
|
|
|
import kamkeel.npcs.network.packets.request.script.EffectScriptPacket;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import noppes.npcs.constants.ScriptContext;
|
|
|
|
/**
|
|
* Script handler for CustomEffect scripts.
|
|
* Manages a single script container for effect hooks (onEffectAdd, onEffectTick, onEffectRemove).
|
|
*/
|
|
public class EffectScript extends SingleScriptHandler implements IScriptHandlerPacket {
|
|
|
|
/**
|
|
* The effect ID for packet communication. -1 if not bound to an effect.
|
|
*/
|
|
private int effectId = -1;
|
|
|
|
/**
|
|
* Create an unbound EffectScript (for server-side use).
|
|
*/
|
|
public EffectScript() {
|
|
}
|
|
|
|
/**
|
|
* Create an EffectScript bound to a specific effect (for GUI use).
|
|
*
|
|
* @param effectId The ID of the CustomEffect
|
|
*/
|
|
public EffectScript(int effectId) {
|
|
this.effectId = effectId;
|
|
}
|
|
|
|
@Override
|
|
public ScriptContext getContext() {
|
|
return ScriptContext.EFFECT;
|
|
}
|
|
|
|
@Override
|
|
public String noticeString() {
|
|
return effectId >= 0 ? "CustomEffect[" + effectId + "]" : "CustomEffect";
|
|
}
|
|
|
|
|
|
@Override
|
|
public void requestData() {
|
|
if (effectId >= 0)
|
|
EffectScriptPacket.Get(effectId);
|
|
}
|
|
|
|
@Override
|
|
public void sendSavePacket(int index, int totalCount, NBTTagCompound nbt) {
|
|
if (effectId >= 0)
|
|
EffectScriptPacket.Save(effectId, index, totalCount, nbt);
|
|
}
|
|
|
|
}
|