mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 20:52:12 -07:00
#923: Back Particle by a minecraft registry
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -6,151 +6,173 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public enum Particle {
|
public enum Particle implements Keyed {
|
||||||
EXPLOSION_NORMAL,
|
EXPLOSION_NORMAL("poof"),
|
||||||
EXPLOSION_LARGE,
|
EXPLOSION_LARGE("explosion"),
|
||||||
EXPLOSION_HUGE,
|
EXPLOSION_HUGE("explosion_emitter"),
|
||||||
FIREWORKS_SPARK,
|
FIREWORKS_SPARK("firework"),
|
||||||
WATER_BUBBLE,
|
WATER_BUBBLE("bubble"),
|
||||||
WATER_SPLASH,
|
WATER_SPLASH("splash"),
|
||||||
WATER_WAKE,
|
WATER_WAKE("fishing"),
|
||||||
SUSPENDED,
|
SUSPENDED("underwater"),
|
||||||
SUSPENDED_DEPTH,
|
SUSPENDED_DEPTH("underwater", false),
|
||||||
CRIT,
|
CRIT("crit"),
|
||||||
CRIT_MAGIC,
|
CRIT_MAGIC("enchanted_hit"),
|
||||||
SMOKE_NORMAL,
|
SMOKE_NORMAL("smoke"),
|
||||||
SMOKE_LARGE,
|
SMOKE_LARGE("large_smoke"),
|
||||||
SPELL,
|
SPELL("effect"),
|
||||||
SPELL_INSTANT,
|
SPELL_INSTANT("instant_effect"),
|
||||||
SPELL_MOB,
|
SPELL_MOB("entity_effect"),
|
||||||
SPELL_MOB_AMBIENT,
|
SPELL_MOB_AMBIENT("ambient_entity_effect"),
|
||||||
SPELL_WITCH,
|
SPELL_WITCH("witch"),
|
||||||
DRIP_WATER,
|
DRIP_WATER("dripping_water"),
|
||||||
DRIP_LAVA,
|
DRIP_LAVA("dripping_lava"),
|
||||||
VILLAGER_ANGRY,
|
VILLAGER_ANGRY("angry_villager"),
|
||||||
VILLAGER_HAPPY,
|
VILLAGER_HAPPY("happy_villager"),
|
||||||
TOWN_AURA,
|
TOWN_AURA("mycelium"),
|
||||||
NOTE,
|
NOTE("note"),
|
||||||
PORTAL,
|
PORTAL("portal"),
|
||||||
ENCHANTMENT_TABLE,
|
ENCHANTMENT_TABLE("enchant"),
|
||||||
FLAME,
|
FLAME("flame"),
|
||||||
LAVA,
|
LAVA("lava"),
|
||||||
CLOUD,
|
CLOUD("cloud"),
|
||||||
/**
|
/**
|
||||||
* Uses {@link Particle.DustOptions} as DataType
|
* Uses {@link Particle.DustOptions} as DataType
|
||||||
*/
|
*/
|
||||||
REDSTONE(DustOptions.class),
|
REDSTONE("dust", DustOptions.class),
|
||||||
SNOWBALL,
|
SNOWBALL("item_snowball"),
|
||||||
SNOW_SHOVEL,
|
SNOW_SHOVEL("item_snowball", false),
|
||||||
SLIME,
|
SLIME("item_slime"),
|
||||||
HEART,
|
HEART("heart"),
|
||||||
/**
|
/**
|
||||||
* Uses {@link ItemStack} as DataType
|
* Uses {@link ItemStack} as DataType
|
||||||
*/
|
*/
|
||||||
ITEM_CRACK(ItemStack.class),
|
ITEM_CRACK("item", ItemStack.class),
|
||||||
/**
|
/**
|
||||||
* Uses {@link BlockData} as DataType
|
* Uses {@link BlockData} as DataType
|
||||||
*/
|
*/
|
||||||
BLOCK_CRACK(BlockData.class),
|
BLOCK_CRACK("block", BlockData.class),
|
||||||
/**
|
/**
|
||||||
* Uses {@link BlockData} as DataType
|
* Uses {@link BlockData} as DataType
|
||||||
*/
|
*/
|
||||||
BLOCK_DUST(BlockData.class),
|
BLOCK_DUST("block", BlockData.class, false),
|
||||||
WATER_DROP,
|
WATER_DROP("rain"),
|
||||||
MOB_APPEARANCE,
|
MOB_APPEARANCE("elder_guardian"),
|
||||||
DRAGON_BREATH,
|
DRAGON_BREATH("dragon_breath"),
|
||||||
END_ROD,
|
END_ROD("end_rod"),
|
||||||
DAMAGE_INDICATOR,
|
DAMAGE_INDICATOR("damage_indicator"),
|
||||||
SWEEP_ATTACK,
|
SWEEP_ATTACK("sweep_attack"),
|
||||||
/**
|
/**
|
||||||
* Uses {@link BlockData} as DataType
|
* Uses {@link BlockData} as DataType
|
||||||
*/
|
*/
|
||||||
FALLING_DUST(BlockData.class),
|
FALLING_DUST("falling_dust", BlockData.class),
|
||||||
TOTEM,
|
TOTEM("totem_of_undying"),
|
||||||
SPIT,
|
SPIT("spit"),
|
||||||
SQUID_INK,
|
SQUID_INK("squid_ink"),
|
||||||
BUBBLE_POP,
|
BUBBLE_POP("bubble_pop"),
|
||||||
CURRENT_DOWN,
|
CURRENT_DOWN("current_down"),
|
||||||
BUBBLE_COLUMN_UP,
|
BUBBLE_COLUMN_UP("bubble_column_up"),
|
||||||
NAUTILUS,
|
NAUTILUS("nautilus"),
|
||||||
DOLPHIN,
|
DOLPHIN("dolphin"),
|
||||||
SNEEZE,
|
SNEEZE("sneeze"),
|
||||||
CAMPFIRE_COSY_SMOKE,
|
CAMPFIRE_COSY_SMOKE("campfire_cosy_smoke"),
|
||||||
CAMPFIRE_SIGNAL_SMOKE,
|
CAMPFIRE_SIGNAL_SMOKE("campfire_signal_smoke"),
|
||||||
COMPOSTER,
|
COMPOSTER("composter"),
|
||||||
FLASH,
|
FLASH("flash"),
|
||||||
FALLING_LAVA,
|
FALLING_LAVA("falling_lava"),
|
||||||
LANDING_LAVA,
|
LANDING_LAVA("landing_lava"),
|
||||||
FALLING_WATER,
|
FALLING_WATER("falling_water"),
|
||||||
DRIPPING_HONEY,
|
DRIPPING_HONEY("dripping_honey"),
|
||||||
FALLING_HONEY,
|
FALLING_HONEY("falling_honey"),
|
||||||
LANDING_HONEY,
|
LANDING_HONEY("landing_honey"),
|
||||||
FALLING_NECTAR,
|
FALLING_NECTAR("falling_nectar"),
|
||||||
SOUL_FIRE_FLAME,
|
SOUL_FIRE_FLAME("soul_fire_flame"),
|
||||||
ASH,
|
ASH("ash"),
|
||||||
CRIMSON_SPORE,
|
CRIMSON_SPORE("crimson_spore"),
|
||||||
WARPED_SPORE,
|
WARPED_SPORE("warped_spore"),
|
||||||
SOUL,
|
SOUL("soul"),
|
||||||
DRIPPING_OBSIDIAN_TEAR,
|
DRIPPING_OBSIDIAN_TEAR("dripping_obsidian_tear"),
|
||||||
FALLING_OBSIDIAN_TEAR,
|
FALLING_OBSIDIAN_TEAR("falling_obsidian_tear"),
|
||||||
LANDING_OBSIDIAN_TEAR,
|
LANDING_OBSIDIAN_TEAR("landing_obsidian_tear"),
|
||||||
REVERSE_PORTAL,
|
REVERSE_PORTAL("reverse_portal"),
|
||||||
WHITE_ASH,
|
WHITE_ASH("white_ash"),
|
||||||
/**
|
/**
|
||||||
* Uses {@link DustTransition} as DataType
|
* Uses {@link DustTransition} as DataType
|
||||||
*/
|
*/
|
||||||
DUST_COLOR_TRANSITION(DustTransition.class),
|
DUST_COLOR_TRANSITION("dust_color_transition", DustTransition.class),
|
||||||
/**
|
/**
|
||||||
* Uses {@link Vibration} as DataType
|
* Uses {@link Vibration} as DataType
|
||||||
*/
|
*/
|
||||||
VIBRATION(Vibration.class),
|
VIBRATION("vibration", Vibration.class),
|
||||||
FALLING_SPORE_BLOSSOM,
|
FALLING_SPORE_BLOSSOM("falling_spore_blossom"),
|
||||||
SPORE_BLOSSOM_AIR,
|
SPORE_BLOSSOM_AIR("spore_blossom_air"),
|
||||||
SMALL_FLAME,
|
SMALL_FLAME("small_flame"),
|
||||||
SNOWFLAKE,
|
SNOWFLAKE("snowflake"),
|
||||||
DRIPPING_DRIPSTONE_LAVA,
|
DRIPPING_DRIPSTONE_LAVA("dripping_dripstone_lava"),
|
||||||
FALLING_DRIPSTONE_LAVA,
|
FALLING_DRIPSTONE_LAVA("falling_dripstone_lava"),
|
||||||
DRIPPING_DRIPSTONE_WATER,
|
DRIPPING_DRIPSTONE_WATER("dripping_dripstone_water"),
|
||||||
FALLING_DRIPSTONE_WATER,
|
FALLING_DRIPSTONE_WATER("falling_dripstone_water"),
|
||||||
GLOW_SQUID_INK,
|
GLOW_SQUID_INK("glow_squid_ink"),
|
||||||
GLOW,
|
GLOW("glow"),
|
||||||
WAX_ON,
|
WAX_ON("wax_on"),
|
||||||
WAX_OFF,
|
WAX_OFF("wax_off"),
|
||||||
ELECTRIC_SPARK,
|
ELECTRIC_SPARK("electric_spark"),
|
||||||
SCRAPE,
|
SCRAPE("scrape"),
|
||||||
SONIC_BOOM,
|
SONIC_BOOM("sonic_boom"),
|
||||||
SCULK_SOUL,
|
SCULK_SOUL("sculk_soul"),
|
||||||
SCULK_CHARGE(Float.class),
|
/**
|
||||||
SCULK_CHARGE_POP,
|
* Use {@link Float} as DataType
|
||||||
SHRIEK(Integer.class),
|
*/
|
||||||
CHERRY_LEAVES,
|
SCULK_CHARGE("sculk_charge", Float.class),
|
||||||
EGG_CRACK,
|
SCULK_CHARGE_POP("sculk_charge_pop"),
|
||||||
|
/**
|
||||||
|
* Use {@link Integer} as DataType
|
||||||
|
*/
|
||||||
|
SHRIEK("shriek", Integer.class),
|
||||||
|
CHERRY_LEAVES("cherry_leaves"),
|
||||||
|
EGG_CRACK("egg_crack"),
|
||||||
/**
|
/**
|
||||||
* Uses {@link BlockData} as DataType
|
* Uses {@link BlockData} as DataType
|
||||||
*/
|
*/
|
||||||
BLOCK_MARKER(BlockData.class),
|
BLOCK_MARKER("block_marker", BlockData.class),
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
/**
|
/**
|
||||||
* Uses {@link MaterialData} as DataType
|
* Uses {@link MaterialData} as DataType
|
||||||
*/
|
*/
|
||||||
LEGACY_BLOCK_CRACK(MaterialData.class),
|
LEGACY_BLOCK_CRACK(null, MaterialData.class, false),
|
||||||
/**
|
/**
|
||||||
* Uses {@link MaterialData} as DataType
|
* Uses {@link MaterialData} as DataType
|
||||||
*/
|
*/
|
||||||
LEGACY_BLOCK_DUST(MaterialData.class),
|
LEGACY_BLOCK_DUST(null, MaterialData.class, false),
|
||||||
/**
|
/**
|
||||||
* Uses {@link MaterialData} as DataType
|
* Uses {@link MaterialData} as DataType
|
||||||
*/
|
*/
|
||||||
LEGACY_FALLING_DUST(MaterialData.class);
|
LEGACY_FALLING_DUST(null, MaterialData.class, false);
|
||||||
|
|
||||||
|
private final NamespacedKey key;
|
||||||
private final Class<?> dataType;
|
private final Class<?> dataType;
|
||||||
|
final boolean register;
|
||||||
|
|
||||||
Particle() {
|
Particle(String key) {
|
||||||
dataType = Void.class;
|
this(key, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
Particle(/*@NotNull*/ Class<?> data) {
|
Particle(String key, boolean register) {
|
||||||
|
this(key, Void.class, register);
|
||||||
|
}
|
||||||
|
|
||||||
|
Particle(String key, /*@NotNull*/ Class<?> data) {
|
||||||
|
this(key, data, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Particle(String key, /*@NotNull*/ Class<?> data, boolean register) {
|
||||||
|
if (key != null) {
|
||||||
|
this.key = NamespacedKey.minecraft(key);
|
||||||
|
} else {
|
||||||
|
this.key = null;
|
||||||
|
}
|
||||||
dataType = data;
|
dataType = data;
|
||||||
|
this.register = register;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,6 +184,16 @@ public enum Particle {
|
|||||||
return dataType;
|
return dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public NamespacedKey getKey() {
|
||||||
|
if (key == null) {
|
||||||
|
throw new UnsupportedOperationException("Cannot get key from legacy particle");
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options which can be applied to redstone dust particles - a particle
|
* Options which can be applied to redstone dust particles - a particle
|
||||||
* color and size.
|
* color and size.
|
||||||
|
@@ -156,6 +156,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||||||
* @see Material
|
* @see Material
|
||||||
*/
|
*/
|
||||||
Registry<Material> MATERIAL = new SimpleRegistry<>(Material.class, (mat) -> !mat.isLegacy());
|
Registry<Material> MATERIAL = new SimpleRegistry<>(Material.class, (mat) -> !mat.isLegacy());
|
||||||
|
/**
|
||||||
|
* Server particles.
|
||||||
|
*
|
||||||
|
* @see Particle
|
||||||
|
*/
|
||||||
|
Registry<Particle> PARTICLE_TYPE = new SimpleRegistry<>(Particle.class, (par) -> par.register);
|
||||||
/**
|
/**
|
||||||
* Server potions.
|
* Server potions.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user