Files
SteamWar/LobbySystem/src/de/steamwar/lobby/particle/design/EntryParameters.java
T
YoyoNow f63390915b
Pull Request Build / Build (pull_request) Successful in 1m57s
Add glyph flight for enchant particles and blend team links
Entries with the enchant particle get a Glyph flight setting: float down as
usual, fly into the player or fly out of them, the latter two unlocked by the
WarGear Season placement and participation. Team link lines now start in the
drawing player's particle and blend into the partner's along the way.
2026-10-26 15:13:39 +01:00

228 lines
11 KiB
Java

/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle.design;
import de.steamwar.lobby.particle.ParticleRequirement;
import de.steamwar.lobby.particle.ParticleElement;
import de.steamwar.lobby.particle.elements.*;
import de.steamwar.lobby.particle.elements.custom.NonMoving;
import lombok.experimental.UtilityClass;
import org.bukkit.Material;
import java.util.List;
import java.util.function.UnaryOperator;
// Parameters every entry has, independent of its design
@UtilityClass
public class EntryParameters {
public enum TickMode {
MOVE,
ALWAYS,
}
// Body places offsets, heights, rings and wings around the player's body, even while gliding or swimming
public enum Placement {
WORLD,
BODY,
}
// Enchanting glyphs can fly between each point and the player instead of floating down
public enum GlyphFlight {
NORMAL,
INTO_PLAYER,
OUT_OF_PLAYER,
}
public enum Movement {
ANY(element -> element),
MOVING(element -> data -> {
if (data.isMoving()) element.tick(data);
}),
STANDING_STILL(NonMoving::new),
;
private final UnaryOperator<ParticleElement> wrapper;
Movement(UnaryOperator<ParticleElement> wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public enum Gliding {
ANY(element -> element),
GLIDING(Flying::new),
NOT_GLIDING(NonFlying::new),
;
private final UnaryOperator<ParticleElement> wrapper;
Gliding(UnaryOperator<ParticleElement> wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public enum Ground {
ANY(element -> element),
ON_GROUND(Floor::new),
IN_AIR(NonFloor::new),
;
private final UnaryOperator<ParticleElement> wrapper;
Ground(UnaryOperator<ParticleElement> wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public enum Sneak {
ANY(element -> element),
SNEAKING(Sneaking::new),
NOT_SNEAKING(element -> data -> {
if (!data.getPlayer().isSneaking()) element.tick(data);
}),
;
private final UnaryOperator<ParticleElement> wrapper;
Sneak(UnaryOperator<ParticleElement> wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public enum Visibility {
EVERYONE(element -> element),
ONLY_SELF(OnlySelf::new),
ONLY_OTHERS(OnlyOthers::new),
;
private final UnaryOperator<ParticleElement> wrapper;
Visibility(UnaryOperator<ParticleElement> wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public final ChoiceParameter<ParticleType> PARTICLE = ChoiceParameter.ofEnum("particle", "PARTICLE_PARAM_PARTICLE", ParticleType.FLAME, type -> !type.isBuildable(), ParticleType::getRequirement);
public final IntParameter COUNT = new IntParameter("count", "PARTICLE_PARAM_COUNT", 5, 1, 20);
// Minecraft scatters particles around their point by about this many blocks; beyond half a block a design dissolves
public final DoubleParameter SPREAD_X = new DoubleParameter("spreadX", "PARTICLE_PARAM_SPREAD_X", 0, 0, 0.5, 0.01);
public final DoubleParameter SPREAD_Y = new DoubleParameter("spreadY", "PARTICLE_PARAM_SPREAD_Y", 0, 0, 0.5, 0.01);
public final DoubleParameter SPREAD_Z = new DoubleParameter("spreadZ", "PARTICLE_PARAM_SPREAD_Z", 0, 0, 0.5, 0.01);
// For most particles the speed of their random spray; above 0.2 they shoot blocks away
public final DoubleParameter SPEED = new DoubleParameter("speed", "PARTICLE_PARAM_SPEED", 0.01, 0, 0.05, 0.005);
public final GradientParameter COLORS = new GradientParameter("colors", "PARTICLE_PARAM_COLORS", 8);
// Blocks that are also items, so they work for block and item particles alike
public final ChoiceParameter<Material> BLOCK = new ChoiceParameter<>("block", "PARTICLE_PARAM_BLOCK", Material.STONE, List.of(
new ChoiceParameter.Choice<>("stone", Material.STONE, false),
new ChoiceParameter.Choice<>("cobblestone", Material.COBBLESTONE, false),
new ChoiceParameter.Choice<>("dirt", Material.DIRT, false),
new ChoiceParameter.Choice<>("grass_block", Material.GRASS_BLOCK, false),
new ChoiceParameter.Choice<>("sand", Material.SAND, false),
new ChoiceParameter.Choice<>("red_sand", Material.RED_SAND, false),
new ChoiceParameter.Choice<>("gravel", Material.GRAVEL, false),
new ChoiceParameter.Choice<>("oak_planks", Material.OAK_PLANKS, false),
new ChoiceParameter.Choice<>("oak_leaves", Material.OAK_LEAVES, false),
new ChoiceParameter.Choice<>("cherry_leaves", Material.CHERRY_LEAVES, false),
new ChoiceParameter.Choice<>("snow_block", Material.SNOW_BLOCK, false),
new ChoiceParameter.Choice<>("ice", Material.ICE, false),
new ChoiceParameter.Choice<>("glass", Material.GLASS, false),
new ChoiceParameter.Choice<>("tnt", Material.TNT, false),
new ChoiceParameter.Choice<>("pumpkin", Material.PUMPKIN, false),
new ChoiceParameter.Choice<>("melon", Material.MELON, false),
new ChoiceParameter.Choice<>("honey_block", Material.HONEY_BLOCK, false),
new ChoiceParameter.Choice<>("slime_block", Material.SLIME_BLOCK, false),
new ChoiceParameter.Choice<>("netherrack", Material.NETHERRACK, false),
new ChoiceParameter.Choice<>("soul_sand", Material.SOUL_SAND, false),
new ChoiceParameter.Choice<>("magma_block", Material.MAGMA_BLOCK, false),
new ChoiceParameter.Choice<>("end_stone", Material.END_STONE, false),
new ChoiceParameter.Choice<>("obsidian", Material.OBSIDIAN, false),
new ChoiceParameter.Choice<>("prismarine", Material.PRISMARINE, false),
new ChoiceParameter.Choice<>("sculk", Material.SCULK, false),
new ChoiceParameter.Choice<>("amethyst_block", Material.AMETHYST_BLOCK, false),
new ChoiceParameter.Choice<>("coal_block", Material.COAL_BLOCK, false),
new ChoiceParameter.Choice<>("iron_block", Material.IRON_BLOCK, false),
new ChoiceParameter.Choice<>("gold_block", Material.GOLD_BLOCK, false),
new ChoiceParameter.Choice<>("redstone_block", Material.REDSTONE_BLOCK, false),
new ChoiceParameter.Choice<>("lapis_block", Material.LAPIS_BLOCK, false),
new ChoiceParameter.Choice<>("emerald_block", Material.EMERALD_BLOCK, false),
new ChoiceParameter.Choice<>("diamond_block", Material.DIAMOND_BLOCK, false),
new ChoiceParameter.Choice<>("white_wool", Material.WHITE_WOOL, false),
new ChoiceParameter.Choice<>("red_wool", Material.RED_WOOL, false),
new ChoiceParameter.Choice<>("orange_wool", Material.ORANGE_WOOL, false),
new ChoiceParameter.Choice<>("yellow_wool", Material.YELLOW_WOOL, false),
new ChoiceParameter.Choice<>("lime_wool", Material.LIME_WOOL, false),
new ChoiceParameter.Choice<>("light_blue_wool", Material.LIGHT_BLUE_WOOL, false),
new ChoiceParameter.Choice<>("blue_wool", Material.BLUE_WOOL, false),
new ChoiceParameter.Choice<>("purple_wool", Material.PURPLE_WOOL, false),
new ChoiceParameter.Choice<>("pink_wool", Material.PINK_WOOL, false),
new ChoiceParameter.Choice<>("black_wool", Material.BLACK_WOOL, false)
));
public final DoubleParameter OFFSET_X = new DoubleParameter("offsetX", "PARTICLE_PARAM_OFFSET_X", 0, -3, 3, 0.1);
public final DoubleParameter OFFSET_Y = new DoubleParameter("offsetY", "PARTICLE_PARAM_OFFSET_Y", 0, -3, 3, 0.1);
public final DoubleParameter OFFSET_Z = new DoubleParameter("offsetZ", "PARTICLE_PARAM_OFFSET_Z", 0, -3, 3, 0.1);
public final IntParameter INTERVAL = new IntParameter("interval", "PARTICLE_PARAM_INTERVAL", 1, 1, 100);
public final IntParameter TRAIL_DURATION = new IntParameter("trailDuration", "PARTICLE_PARAM_TRAIL_DURATION", 20, 1, 200);
// Where a trail particle flies to, relative to where it spawns
public final DoubleParameter TRAIL_TARGET_X = new DoubleParameter("trailTargetX", "PARTICLE_PARAM_TRAIL_TARGET_X", 0, -5, 5, 0.1);
public final DoubleParameter TRAIL_TARGET_Y = new DoubleParameter("trailTargetY", "PARTICLE_PARAM_TRAIL_TARGET_Y", 1, -5, 5, 0.1);
public final DoubleParameter TRAIL_TARGET_Z = new DoubleParameter("trailTargetZ", "PARTICLE_PARAM_TRAIL_TARGET_Z", 0, -5, 5, 0.1);
public final ChoiceParameter<GlyphFlight> GLYPH_FLIGHT = ChoiceParameter.ofEnum("glyphFlight", "PARTICLE_PARAM_GLYPH_FLIGHT", GlyphFlight.NORMAL, flight -> false,
flight -> switch (flight) {
case NORMAL -> ParticleRequirement.NO_REQUIRMENT;
case INTO_PLAYER -> Unlocks.WARGEAR_SEASON_PLACEMENT.get();
case OUT_OF_PLAYER -> Unlocks.WARGEAR_SEASON.get();
});
public final ChoiceParameter<Placement> PLACEMENT = ChoiceParameter.ofEnum("placement", "PARTICLE_PARAM_PLACEMENT", Placement.WORLD);
public final ChoiceParameter<TickMode> TICK_MODE = ChoiceParameter.ofEnum("tickMode", "PARTICLE_PARAM_TICK_MODE", TickMode.MOVE);
public final ChoiceParameter<Movement> MOVEMENT = ChoiceParameter.ofEnum("movement", "PARTICLE_PARAM_MOVEMENT", Movement.ANY);
public final ChoiceParameter<Gliding> GLIDING = ChoiceParameter.ofEnum("gliding", "PARTICLE_PARAM_GLIDING", Gliding.ANY);
public final ChoiceParameter<Ground> GROUND = ChoiceParameter.ofEnum("ground", "PARTICLE_PARAM_GROUND", Ground.ANY);
public final ChoiceParameter<Sneak> SNEAK = ChoiceParameter.ofEnum("sneak", "PARTICLE_PARAM_SNEAK", Sneak.ANY);
public final ChoiceParameter<Visibility> VISIBILITY = ChoiceParameter.ofEnum("visibility", "PARTICLE_PARAM_VISIBILITY", Visibility.EVERYONE);
public final List<Parameter<?>> ALL = List.of(
PARTICLE, GLYPH_FLIGHT, COUNT, SPREAD_X, SPREAD_Y, SPREAD_Z, SPEED, COLORS, BLOCK,
TRAIL_DURATION, TRAIL_TARGET_X, TRAIL_TARGET_Y, TRAIL_TARGET_Z,
OFFSET_X, OFFSET_Y, OFFSET_Z, PLACEMENT, INTERVAL, TICK_MODE,
MOVEMENT, GLIDING, GROUND, SNEAK, VISIBILITY
);
}