Particle class
Пакет: com.hypixel.hytale.server.core.asset.type.particle.config
Файл: com/hypixel/hytale/server/core/asset/type/particle/config/Particle.java
implements: NetworkSerializable<com.hypixel.hytale.protocol.Particle>
Поля (4)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<Particle> |
CODEC |
|
com.hypixel.hytale.protocol.Particle |
var1 |
|
ObjectIterator |
var2 |
|
Entry |
var3 |
Методы (14)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
Int2ObjectMap<ParticleAnimationFrame> |
getAnimationInt2ObjectMap<ParticleAnimationFrame> getAnimation() |
public |
float |
getCameraFarFadeEndDistancefloat getCameraFarFadeEndDistance() |
public |
float |
getCameraFarFadeStartDistancefloat getCameraFarFadeStartDistance() |
public |
float |
getCameraNearFadeEndDistancefloat getCameraNearFadeEndDistance() |
public |
float |
getCameraNearFadeStartDistancefloat getCameraNearFadeStartDistance() |
public |
ParticleAnimationFrame |
getCollisionAnimationFrameParticleAnimationFrame getCollisionAnimationFrame() |
public |
Size |
getFrameSizeSize getFrameSize() |
public |
ParticleAnimationFrame |
getInitialAnimationFrameParticleAnimationFrame getInitialAnimationFrame() |
public |
float |
getSoftParticlesFadeFactorfloat getSoftParticlesFadeFactor() |
public |
String |
getTextureString getTexture() |
|
|
if if(this.initialAnimationFrame != null) |
|
|
if if(this.collisionAnimationFrame != null) |
|
|
if if(this.animation != null) |
public |
boolean |
isUseSpriteBlendingboolean isUseSpriteBlending() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.particle.config;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.codecs.EnumCodec;
class="kw">import com.hypixel.hytale.codec.codecs.map.Int2ObjectMapCodec;
class="kw">import com.hypixel.hytale.codec.schema.metadata.ui.UIDefaultCollapsedState;
class="kw">import com.hypixel.hytale.codec.schema.metadata.ui.UIEditorSectionStart;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.codec.validation.validator.MapKeyValidator;
class="kw">import com.hypixel.hytale.protocol.ParticleScaleRatioConstraint;
class="kw">import com.hypixel.hytale.protocol.ParticleUVOption;
class="kw">import com.hypixel.hytale.protocol.Size;
class="kw">import com.hypixel.hytale.protocol.SoftParticle;
class="kw">import com.hypixel.hytale.server.core.asset.common.CommonAssetValidator;
class="kw">import com.hypixel.hytale.server.core.codec.ProtocolCodecs;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry;
class="kw">import it.unimi.dsi.fastutil.objects.ObjectIterator;
class="kw">import javax.annotation.Nonnull;
class="kw">public class Particle class="kw">implements NetworkSerializable<com.hypixel.hytale.protocol.Particle> {
class="kw">public class="kw">static class="kw">final BuilderCodec<Particle> CODEC = BuilderCodec.builder(Particle.class, Particle::new)
.append(new KeyedCodec<>("Texture", Codec.STRING), (var0, var1) -> var0.texture = var1, var0 -> var0.texture)
.addValidator(Validators.nonNull())
.addValidator(CommonAssetValidator.TEXTURE_PARTICLES)
.metadata(new UIEditorSectionStart("Material"))
.documentation("The texture used for the particle.\nMUST ALWAYS BE DEFINED!")
.add()
.<Size>append(new KeyedCodec<>("FrameSize", ProtocolCodecs.SIZE), (var0, var1) -> var0.frameSize = var1, var0 -> var0.frameSize)
.documentation(
"Sometimes the texture has multiple variants of the same texture. If this field isn't defined the whole texture is used for the particle. By defining the dimension of these frames you can cut the texture into smaller parts. To use other frames than the first (most top left) frame you need to change the values in `FrameIndex`.\nInvalid sizes (0 or larger than the texture) are ignored and the whole texture is used."
)
.add()
.<SoftParticle>append(
new KeyedCodec<>(
"SoftParticles",
new EnumCodec<>(SoftParticle.class)
.documentKey(
SoftParticle.Enable,
"The region of the particle near solid geometry gets gradually more transparent. The strength is defined in `SoftParticlesFadeFactor`. On low-end GPUs this option is treated as `Disable`."
)
.documentKey(SoftParticle.Disable, "The particle doesn't gain transparency near solid geometry.")
.documentKey(SoftParticle.Require, "Same fade as `Enable`, but also applies on low-end GPUs.")
),
(var0, var1) -> var0.softParticle = var1,
var0 -> var0.softParticle
)
.addValidator(Validators.nonNull())
.documentation("Soft particles describe how the transparency of the particle changes near solid geometry.")
.add()
.<Float>append(
new KeyedCodec<>("SoftParticlesFadeFactor", Codec.FLOAT), (var0, var1) -> var0.softParticlesFadeFactor = var1, var0 -> var0.softParticlesFadeFactor
)
.addValidator(Validators.range(0.1F, 2.0F))
.documentation("Controls how quickly the particle fades near solid geometry. Higher values make the fade region thinner.")
.add()
.<Float>append(
new KeyedCodec<>("CameraNearFadeStartDistance", Codec.FLOAT),
(var0, var1) -> var0.cameraNearFadeStartDistance = var1,
var0 -> var0.cameraNearFadeStartDistance
)
.addValidator(Validators.greaterThanOrEqual(0.0F))
.documentation("Distance from the camera where particle opacity starts to increase.")
.add()
.<Float>append(
new KeyedCodec<>("CameraNearFadeEndDistance", Codec.FLOAT),
(var0, var1) -> var0.cameraNearFadeEndDistance = var1,
var0 -> var0.cameraNearFadeEndDistance
)
.addValidator(Validators.greaterThanOrEqual(0.0F))
.documentation("Distance from the camera where particle opacity reaches its configured value. Set both near fade distances to zero to disable the fade.")
.add()
.<Float>append(
new KeyedCodec<>("CameraFarFadeStartDistance", Codec.FLOAT),
(var0, var1) -> var0.cameraFarFadeStartDistance = var1,
var0 -> var0.cameraFarFadeStartDistance
)
.addValidator(Validators.greaterThanOrEqual(0.0F))
.documentation("Distance from the camera where particle opacity starts to decrease.")
.add()
.<Float>append(
new KeyedCodec<>("CameraFarFadeEndDistance", Codec.FLOAT), (var0, var1) -> var0.cameraFarFadeEndDistance = var1, var0 -> var0.cameraFarFadeEndDistance
)
.addValidator(Validators.greaterThanOrEqual(0.0F))
.documentation("Distance from the camera where particle opacity reaches zero. Set both far fade distances to zero to disable the fade.")
.add()
.<Boolean>appendInherited(
new KeyedCodec<>("UseSpriteBlending", Codec.BOOLEAN),
(var0, var1) -> var0.useSpriteBlending = var1,
var0 -> var0.useSpriteBlending,
(var0, var1) -> var0.useSpriteBlending = var1.useSpriteBlending
)
.documentation("If enabled, the texture between frames gets interpolated if the `FrameIndex` changes.")
.add()
.<Int2ObjectMap<ParticleAnimationFrame>>append(
new KeyedCodec<>("Animation", new Int2ObjectMapCodec<>(ParticleAnimationFrame.CODEC, Int2ObjectOpenHashMap::new)),
(var0, var1) -> var0.animation = var1,
var0 -> var0.animation
)
.addValidator(Validators.nonNull())
.addValidator(Validators.nonEmptyMap())
.addValidator(new MapKeyValidator<>(Validators.range(0, 100)))
.metadata(new UIEditorSectionStart("Animation"))
.metadata(UIDefaultCollapsedState.UNCOLLAPSED)
.documentation(
"Controls the animation of the particles by listing all the frames. Values range from 0 to 100 since they refer to the percentage of its lifetime.\n\nE.g. if the lifetime is 2s and the added frame is 50, the frame is shown after 1s/50% of its lifetime.\n\nNEEDS AT LEAST ONE FRAME!"
)
.add()
.<ParticleAnimationFrame>append(
new KeyedCodec<>("CollisionAnimationFrame", ParticleAnimationFrame.CODEC),
(var0, var1) -> var0.collisionAnimationFrame = var1,
var0 -> var0.collisionAnimationFrame
)
.documentation("Contains the frame that is used if `ParticleCollision` is enabled and `Action` is set to `LastFrame`.")
.add()
.<ParticleUVOption>append(
new KeyedCodec<>(
"UVOption",
new EnumCodec<>(ParticleUVOption.class)
.documentKey(ParticleUVOption.None, "The texture does not get flipped.")
.documentKey(ParticleUVOption.RandomFlipU, "Randomly flips the texture horizontally or not.")
.documentKey(ParticleUVOption.RandomFlipV, "Randomly flips the texture vertically or not.")
.documentKey(
ParticleUVOption.RandomFlipUV, "Randomly flips the texture on both axes together: either both horizontally and vertically, or not at all."
)
.documentKey(ParticleUVOption.FlipU, "Flips the texture horizontally.")
.documentKey(ParticleUVOption.FlipV, "Flips the texture vertically.")
.documentKey(ParticleUVOption.FlipUV, "Flips the texture both horizontally and vertically.")
),
(var0, var1) -> var0.uvOption = var1,
var0 -> var0.uvOption
)
.addValidator(Validators.nonNull())
.metadata(new UIEditorSectionStart("Initial Frame"))
.documentation("Flips the texture horizontally, vertically, both or none.")
.add()
.<ParticleScaleRatioConstraint>append(
new KeyedCodec<>(
"ScaleRatioConstraint",
new EnumCodec<>(ParticleScaleRatioConstraint.class)
.documentKey(ParticleScaleRatioConstraint.OneToOne, "The texture always keeps its original ratio.")
.documentKey(
ParticleScaleRatioConstraint.Preserved,
"The texture keeps the side ratio of the first scale keyframe (frame 0 of `Animation` combined with `InitialAnimationFrame`)."
)
.documentKey(ParticleScaleRatioConstraint.None, "The sides can be scaled independently during the `Animation`.")
),
(var0, var1) -> var0.scaleRatioConstraint = var1,
var0 -> var0.scaleRatioConstraint
)
.addValidator(Validators.nonNull())
.documentation("Controls side ratio of the texture.")
.add()
.<ParticleAnimationFrame>append(
new KeyedCodec<>("InitialAnimationFrame", ParticleAnimationFrame.CODEC),
(var0, var1) -> var0.initialAnimationFrame = var1,
var0 -> var0.initialAnimationFrame
)
.metadata(UIDefaultCollapsedState.UNCOLLAPSED)
.documentation("Defines the base frame values for the particle animation.")
.add()
.validator(
(var0, var1) -> {
if ((var0.cameraNearFadeStartDistance > 0.0F || var0.cameraNearFadeEndDistance > 0.0F)
&& var0.cameraNearFadeEndDistance <= var0.cameraNearFadeStartDistance) {
var1.fail("CameraNearFadeEndDistance must be greater than CameraNearFadeStartDistance.");
}
if ((var0.cameraFarFadeStartDistance > 0.0F || var0.cameraFarFadeEndDistance > 0.0F)
&& var0.cameraFarFadeEndDistance <= var0.cameraFarFadeStartDistance) {
var1.fail("CameraFarFadeEndDistance must be greater than CameraFarFadeStartDistance.");
}
}
)
.build();
class="kw">protected String texture;
class="kw">protected Size frameSize;
@Nonnull
class="kw">protected ParticleUVOption uvOption = ParticleUVOption.None;
@Nonnull
class="kw">protected ParticleScaleRatioConstraint scaleRatioConstraint = ParticleScaleRatioConstraint.OneToOne;
@Nonnull
class="kw">protected SoftParticle softParticle = SoftParticle.Enable;
class="kw">protected float softParticlesFadeFactor = 1.0F;
class="kw">protected float cameraNearFadeStartDistance;
class="kw">protected float cameraNearFadeEndDistance;
class="kw">protected float cameraFarFadeStartDistance;
class="kw">protected float cameraFarFadeEndDistance;
class="kw">protected boolean useSpriteBlending;
class="kw">protected ParticleAnimationFrame initialAnimationFrame;
class="kw">protected ParticleAnimationFrame collisionAnimationFrame;
class="kw">protected Int2ObjectMap<ParticleAnimationFrame> animation;
class="kw">public Particle(
String var1,
Size var2,
@Nonnull ParticleUVOption var3,
@Nonnull ParticleScaleRatioConstraint var4,
@Nonnull SoftParticle var5,
float var6,
float var7,
float var8,
float var9,
float var10,
boolean var11,
ParticleAnimationFrame var12,
ParticleAnimationFrame var13,
Int2ObjectMap<ParticleAnimationFrame> var14
) {
this.texture = var1;
this.frameSize = var2;
this.uvOption = var3;
this.scaleRatioConstraint = var4;
this.softParticle = var5;
this.softParticlesFadeFactor = var6;
this.cameraNearFadeStartDistance = var7;
this.cameraNearFadeEndDistance = var8;
this.cameraFarFadeStartDistance = var9;
this.cameraFarFadeEndDistance = var10;
this.useSpriteBlending = var11;
this.initialAnimationFrame = var12;
this.collisionAnimationFrame = var13;
this.animation = var14;
}
class="kw">protected Particle() {
}
class="kw">public String getTexture() {
class="kw">return this.texture;
}
class="kw">public Size getFrameSize() {
class="kw">return this.frameSize;
}
@Nonnull
class="kw">public ParticleUVOption getUvOption() {
class="kw">return this.uvOption;
}
@Nonnull
class="kw">public ParticleScaleRatioConstraint getScaleRatioConstraint() {
class="kw">return this.scaleRatioConstraint;
}
@Nonnull
class="kw">public SoftParticle getSoftParticle() {
class="kw">return this.softParticle;
}
class="kw">public float getSoftParticlesFadeFactor() {
class="kw">return this.softParticlesFadeFactor;
}
class="kw">public float getCameraNearFadeStartDistance() {
class="kw">return this.cameraNearFadeStartDistance;
}
class="kw">public float getCameraNearFadeEndDistance() {
class="kw">return this.cameraNearFadeEndDistance;
}
class="kw">public float getCameraFarFadeStartDistance() {
class="kw">return this.cameraFarFadeStartDistance;
}
class="kw">public float getCameraFarFadeEndDistance() {
class="kw">return this.cameraFarFadeEndDistance;
}
class="kw">public boolean isUseSpriteBlending() {
class="kw">return this.useSpriteBlending;
}
class="kw">public ParticleAnimationFrame getInitialAnimationFrame() {
class="kw">return this.initialAnimationFrame;
}
class="kw">public ParticleAnimationFrame getCollisionAnimationFrame() {
class="kw">return this.collisionAnimationFrame;
}
class="kw">public Int2ObjectMap<ParticleAnimationFrame> getAnimation() {
class="kw">return this.animation;
}
@Nonnull
class="kw">public com.hypixel.hytale.protocol.Particle toPacket() {
com.hypixel.hytale.protocol.Particle var1 = new com.hypixel.hytale.protocol.Particle();
var1.texturePath = this.texture;
var1.frameSize = this.frameSize;
var1.uvOption = this.uvOption;
var1.scaleRatioConstraint = this.scaleRatioConstraint;
var1.softParticles = this.softParticle;
var1.softParticlesFadeFactor = this.softParticlesFadeFactor;
var1.cameraNearFadeStartDistance = this.cameraNearFadeStartDistance;
var1.cameraNearFadeEndDistance = this.cameraNearFadeEndDistance;
var1.cameraFarFadeStartDistance = this.cameraFarFadeStartDistance;
var1.cameraFarFadeEndDistance = this.cameraFarFadeEndDistance;
var1.useSpriteBlending = this.useSpriteBlending;
if (this.initialAnimationFrame != null) {
var1.initialAnimationFrame = this.initialAnimationFrame.toPacket();
}
if (this.collisionAnimationFrame != null) {
var1.collisionAnimationFrame = this.collisionAnimationFrame.toPacket();
}
if (this.animation != null) {
var1.animationFrames = new Int2ObjectOpenHashMap();
ObjectIterator var2 = this.animation.int2ObjectEntrySet().iterator();
while (var2.hasNext()) {
Entry var3 = (Entry<ParticleAnimationFrame>)var2.next();
var1.animationFrames.put(var3.getIntKey(), ((ParticleAnimationFrame)var3.getValue()).toPacket());
}
}
class="kw">return var1;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "Particle{texture='"
+ this.texture
+ "', frameSize="
+ this.frameSize
+ ", uvOption="
+ this.uvOption
+ ", scaleRatioConstraint="
+ this.scaleRatioConstraint
+ ", softParticle="
+ this.softParticle
+ ", softParticlesFadeFactor="
+ this.softParticlesFadeFactor
+ ", cameraNearFadeStartDistance="
+ this.cameraNearFadeStartDistance
+ ", cameraNearFadeEndDistance="
+ this.cameraNearFadeEndDistance
+ ", cameraFarFadeStartDistance="
+ this.cameraFarFadeStartDistance
+ ", cameraFarFadeEndDistance="
+ this.cameraFarFadeEndDistance
+ ", useSpriteBlending="
+ this.useSpriteBlending
+ ", initialAnimationFrame="
+ this.initialAnimationFrame
+ ", collisionAnimationFrame="
+ this.collisionAnimationFrame
+ ", animation="
+ this.animation
+ "}";
}
}