mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
AmbientEffects service: the effects due around a player, decided by the module; Reference.SPECIAL_ENTITY
This commit is contained in:
1 parent
6757cbdd0f
commit
284213e9b8
2 files changed
+98
No files matched your search
@@ -27,6 +27,8 @@ public enum Reference {
|
||||
POTION_EFFECT,
|
||||
/** An enchantment, such as {@code minecraft:sharpness}. */
|
||||
ENCHANTMENT,
|
||||
/** A mob of another plugin or content provider, such as {@code mythicmobs:skeleton_king}. */
|
||||
SPECIAL_ENTITY,
|
||||
/** A biome of the pack. */
|
||||
PACK_BIOME,
|
||||
/** A region of the pack. */
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.volmit.service;
|
||||
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The ambient effects of an area: sounds, particles, potion effects and commands that play around the players who stay
|
||||
* in it. The host asks, now and then, for the players it keeps; the module says which effects of the area are due, and
|
||||
* every random choice that goes with them (where the sound seems to come from, how the particles scatter, how long the
|
||||
* potion lasts), so that the host only has to carry them out. An effect is due only now and then, as its interval and
|
||||
* chance say, so most answers are empty. The host asks every provider and carries out all answers.
|
||||
*/
|
||||
@Service(Providers.ALL)
|
||||
public interface AmbientEffects {
|
||||
/**
|
||||
* The effects due for a player standing at {@code at}.
|
||||
*
|
||||
* @param at world X and Z, Y the height above the dimension's bottom
|
||||
*/
|
||||
List<Effect> due(PackWorld world, BlockPosition at);
|
||||
|
||||
/**
|
||||
* One effect that plays now. The host carries out the parts it has, in the order sound, particles, commands, potion.
|
||||
* A part the platform lacks, such as an unknown sound, is skipped.
|
||||
*
|
||||
* @param sound a sound to play, or null
|
||||
* @param particles particles to show, or null
|
||||
* @param commands console commands to run, none when the effect has no commands that may run now
|
||||
* @param potion a potion effect to give, or null
|
||||
*/
|
||||
record Effect(Sound sound, Particles particles, List<Command> commands, Potion potion) {
|
||||
public Effect {
|
||||
commands = List.copyOf(commands);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A sound played to the player.
|
||||
*
|
||||
* @param key the platform's sound key
|
||||
* @param offsetX blocks from the player where the sound seems to come from, as the other offsets
|
||||
* @param volume the sound's volume
|
||||
* @param pitch the sound's pitch
|
||||
*/
|
||||
record Sound(String key, int offsetX, int offsetY, int offsetZ, float volume, float pitch) {
|
||||
public Sound {
|
||||
Objects.requireNonNull(key, "key");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Particles shown to the player. They appear {@code forward} blocks ahead of the player, {@code sideways} blocks to
|
||||
* the right (negative for the left) and on the surface at that spot, one block up, moved by {@code jitterX} and
|
||||
* {@code jitterZ} and by {@code lift} blocks up.
|
||||
*
|
||||
* @param key the platform's particle key
|
||||
* @param count how many particles; none makes {@code altX}, {@code altY} and {@code altZ} their motion
|
||||
* @param altX the particles' offset or motion, as the other two
|
||||
* @param extra an extra value some particles take; 0 for none
|
||||
*/
|
||||
record Particles(String key, double forward, double sideways, double jitterX, double jitterZ, int lift, int count,
|
||||
double altX, double altY, double altZ, double extra) {
|
||||
public Particles {
|
||||
Objects.requireNonNull(key, "key");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A command to run where the effect plays.
|
||||
*
|
||||
* @param command the commands, their delay and repeats; {@code {x}}, {@code {y}} and {@code {z}} stand for the block
|
||||
* position
|
||||
* @param offsetX blocks from the player where the command runs, as the other two
|
||||
*/
|
||||
record Command(EntitySpec.Command command, double offsetX, double offsetY, double offsetZ) {
|
||||
public Command {
|
||||
Objects.requireNonNull(command, "command");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A potion effect for the player. A player who has the same potion effect with a stronger amplifier keeps it.
|
||||
*
|
||||
* @param key the platform's potion effect key
|
||||
* @param strength the amplifier
|
||||
* @param ticks how long it lasts, in server ticks
|
||||
*/
|
||||
record Potion(String key, int strength, int ticks) {
|
||||
public Potion {
|
||||
Objects.requireNonNull(key, "key");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user