Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ public class ParticlesEffect extends SpellEffect {

protected ConfigData<Particle> particle;

protected ConfigData<Color> rgbColor;
protected ConfigData<Color> argbColor;

protected ConfigData<Material> material;
protected ConfigData<BlockData> blockData;
protected ConfigData<DustOptions> dustOptions;
protected ConfigData<Particle.Spell> spellOptions;
protected ConfigData<DustTransition> dustTransition;

protected ConfigData<Vector> vibrationOffset;
Expand All @@ -59,6 +62,7 @@ public class ParticlesEffect extends SpellEffect {
protected ConfigData<Float> xSpread;
protected ConfigData<Float> ySpread;
protected ConfigData<Float> zSpread;
protected ConfigData<Float> dragonBreathPower;
protected ConfigData<Float> sculkChargeRotation;

protected ConfigData<Boolean> force;
Expand All @@ -68,11 +72,14 @@ public class ParticlesEffect extends SpellEffect {
public void loadFromConfig(ConfigurationSection config) {
particle = ConfigDataUtil.getParticle(config, "particle-name", Particle.POOF);

argbColor = ConfigDataUtil.getARGBColor(config, "argb-color", null);
rgbColor = ConfigDataUtil.getColor(config, "color", null);
argbColor = ConfigDataUtil.getARGBColor(config, "argb-color", null).orDefault(rgbColor);

material = ConfigDataUtil.getMaterial(config, "material", null);
blockData = ConfigDataUtil.getBlockData(config, "material", null);
dustOptions = ConfigDataUtil.getDustOptions(config, "color", "size", new DustOptions(Color.RED, 1));
dustTransition = ConfigDataUtil.getDustTransition(config, "color", "to-color", "size", new DustTransition(Color.RED, Color.BLACK, 1));
spellOptions = ConfigDataUtil.getSpellOptions(config, "spell.color", "spell.power", new Particle.Spell(Color.WHITE, 1));

vibrationOffset = ConfigDataUtil.getVector(config, "vibration-offset", new Vector());
vibrationOrigin = ConfigDataUtil.getEnum(config, "vibration-origin", ParticlePosition.class, ParticlePosition.POSITION);
Expand All @@ -91,12 +98,14 @@ public void loadFromConfig(ConfigurationSection config) {
arrivalTime = ConfigDataUtil.getInteger(config, "arrival-time", -1);
shriekDelay = ConfigDataUtil.getInteger(config, "shriek-delay", 0);

dragonBreathPower = ConfigDataUtil.getFloat(config, "dragon-breath-power", 1);
sculkChargeRotation = ConfigDataUtil.getFloat(config, "sculk-charge-rotation", 0);

speed = ConfigDataUtil.getFloat(config, "speed", 0.2f);

ConfigData<Float> horizSpread = ConfigDataUtil.getFloat(config, "horiz-spread", 0.2f);
xSpread = ConfigDataUtil.getFloat(config, "x-spread", horizSpread);
zSpread = ConfigDataUtil.getFloat(config, "z-spread", horizSpread);
sculkChargeRotation = ConfigDataUtil.getFloat(config, "sculk-charge-rotation", 0);

ConfigData<Float> vertSpread = ConfigDataUtil.getFloat(config, "vert-spread", 0.2f);
ySpread = ConfigDataUtil.getFloat(config, "y-spread", vertSpread);
Expand Down Expand Up @@ -149,6 +158,12 @@ public Runnable playEffectLocation(Location location, SpellData data) {
protected Object getParticleData(@NotNull Particle particle, @Nullable Entity entity, @NotNull Location location, @NotNull SpellData data) {
Class<?> type = particle.getDataType();

if (type == Color.class) {
return particle == Particle.ENTITY_EFFECT ?
argbColor.get(data) :
rgbColor.get(data);
}

if (type == ItemStack.class) {
Material material = this.material.get(data);
return material == null ? null : new ItemStack(material);
Expand Down Expand Up @@ -209,12 +224,15 @@ protected Object getParticleData(@NotNull Particle particle, @Nullable Entity en

if (type == BlockData.class) return blockData.get(data);
if (type == DustOptions.class) return dustOptions.get(data);
if (type == Particle.Spell.class) return spellOptions.get(data);
if (type == DustTransition.class) return dustTransition.get(data);
if (type == Float.class) return sculkChargeRotation.get(data);
if (type == Integer.class) return shriekDelay.get(data);
if (type == Color.class) return argbColor.get(data);

return null;
return switch (particle) {
case SHRIEK -> shriekDelay.get(data);
case DRAGON_BREATH -> dragonBreathPower.get(data);
case SCULK_CHARGE -> sculkChargeRotation.get(data);
default -> null;
};
}

protected Location getSpawnLocation(@NotNull Particle particle, @NotNull Location position, @NotNull SpellData data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,28 @@ public class ParticleCloudSpell extends TargetedSpell implements TargetedLocatio

private final ConfigData<Component> customName;

private final ConfigData<Color> color;
private final ConfigData<Color> rgbColor;
private final ConfigData<Color> argbColor;

private final ConfigData<ItemStack> item;
private final ConfigData<BlockData> blockData;
private final ConfigData<DustOptions> dustOptions;
private final ConfigData<Particle.Spell> spellOptions;
private final ConfigData<DustTransition> dustTransition;

private final ConfigData<Particle> particle;

private final ConfigData<Integer> waitTime;
private final ConfigData<Integer> shriekDelay;
private final ConfigData<Integer> ticksDuration;
private final ConfigData<Integer> durationOnUse;
private final ConfigData<Integer> reapplicationDelay;

private final ConfigData<Float> radius;
private final ConfigData<Float> radiusOnUse;
private final ConfigData<Float> radiusPerTick;
private final ConfigData<Float> dragonBreathPower;
private final ConfigData<Float> sculkChargeRotation;

private final ConfigData<Boolean> useGravity;
private final ConfigData<Boolean> canTargetEntities;
Expand All @@ -74,6 +80,12 @@ public ParticleCloudSpell(MagicConfig config, String spellName) {
internalKey + "dust-transition.size",
new DustTransition(Color.RED, Color.BLACK, 1)
);
spellOptions = ConfigDataUtil.getSpellOptions(
config.getMainConfig(),
internalKey + "spell.color",
internalKey + "spell.power",
new Particle.Spell(Color.WHITE, 1)
);

ConfigData<Material> material = getConfigDataMaterial("material", null);
if (material.isConstant()) {
Expand All @@ -88,9 +100,14 @@ public ParticleCloudSpell(MagicConfig config, String spellName) {
};
}

shriekDelay = getConfigDataInt("shriek-delay", 0);

dragonBreathPower = getConfigDataFloat("dragon-breath-power", 1);
sculkChargeRotation = getConfigDataFloat("sculk-charge-rotation", 0);

ConfigData<Integer> colorInt = getConfigDataInt("color", 0xFF0000);
color = ConfigDataUtil.getARGBColor(config.getMainConfig(), internalKey + "argb-color", null)
.orDefault(data -> Color.fromRGB(colorInt.get(data)));
rgbColor = getConfigDataColor("color", null).orDefault(data -> Color.fromRGB(colorInt.get(data)));
argbColor = ConfigDataUtil.getARGBColor(config.getMainConfig(), internalKey + "argb-color", null).orDefault(rgbColor);

waitTime = getConfigDataInt("wait-time-ticks", 10);
ticksDuration = getConfigDataInt("duration-ticks", 3 * TimeUtil.TICKS_PER_SECOND);
Expand Down Expand Up @@ -184,13 +201,24 @@ private CastResult spawnCloud(SpellData data) {
private Object getParticleData(@NotNull Particle particle, @NotNull SpellData data) {
Class<?> type = particle.getDataType();

if (type == Color.class) return color.get(data);
if (type == ItemStack.class) return item.get(data);
if (type == BlockData.class) return blockData.get(data);
if (type == DustOptions.class) return dustOptions.get(data);
if (type == Particle.Spell.class) return spellOptions.get(data);
if (type == DustTransition.class) return dustTransition.get(data);

return null;
if (type == Color.class) {
return particle == Particle.ENTITY_EFFECT ?
argbColor.get(data) :
rgbColor.get(data);
}

return switch (particle) {
case SHRIEK -> shriekDelay.get(data);
case DRAGON_BREATH -> dragonBreathPower.get(data);
case SCULK_CHARGE -> sculkChargeRotation.get(data);
default -> null;
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,35 @@ public boolean isConstant() {
return data -> def;
}

@NotNull
public static ConfigData<Particle.Spell> getSpellOptions(@NotNull ConfigurationSection config,
@NotNull String colorPath,
@NotNull String powerPath,
@Nullable Particle.Spell def) {
ConfigData<Color> color = getColor(config, colorPath, def == null ? null : def.getColor());
ConfigData<Float> power = def == null ? getFloat(config, powerPath) : getFloat(config, powerPath, def.getPower());

if (color.isConstant() && power.isConstant()) {
Color c = color.get();
if (c == null) return data -> def;

Float p = power.get();
if (p == null) return data -> def;

return data -> new Particle.Spell(c, p);
}

return (VariableConfigData<Particle.Spell>) data -> {
Color c = color.get(data);
if (c == null) return def;

Float p = power.get(data);
if (p == null) return def;

return new Particle.Spell(c, p);
};
}

@NotNull
public static ConfigData<DustOptions> getDustOptions(@NotNull ConfigurationSection config,
@NotNull String colorPath,
Expand Down