ProtocolCodecs class
Пакет: com.hypixel.hytale.server.core.codec
Файл: com/hypixel/hytale/server/core/codec/ProtocolCodecs.java
Поля (2)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<Direction> |
DIRECTION |
|
Vector3f |
var1 |
Методы (2)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(var0.firstPerson != null) |
|
|
if if(var0.firstPersonOverride != null) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.codec;
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.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.schema.metadata.HytaleType;
class="kw">import com.hypixel.hytale.codec.schema.metadata.ui.UIDisplayMode;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.math.vector.Vector3fUtil;
class="kw">import com.hypixel.hytale.protocol.AccumulationMode;
class="kw">import com.hypixel.hytale.protocol.ChangeStatBehaviour;
class="kw">import com.hypixel.hytale.protocol.ChangeVelocityType;
class="kw">import com.hypixel.hytale.protocol.Color;
class="kw">import com.hypixel.hytale.protocol.ColorLight;
class="kw">import com.hypixel.hytale.protocol.Direction;
class="kw">import com.hypixel.hytale.protocol.EasingType;
class="kw">import com.hypixel.hytale.protocol.GameMode;
class="kw">import com.hypixel.hytale.protocol.InitialVelocity;
class="kw">import com.hypixel.hytale.protocol.IntersectionHighlight;
class="kw">import com.hypixel.hytale.protocol.ItemAnimation;
class="kw">import com.hypixel.hytale.protocol.RailConfig;
class="kw">import com.hypixel.hytale.protocol.RailPoint;
class="kw">import com.hypixel.hytale.protocol.Range;
class="kw">import com.hypixel.hytale.protocol.RangeVector2f;
class="kw">import com.hypixel.hytale.protocol.RangeVector3f;
class="kw">import com.hypixel.hytale.protocol.Rangeb;
class="kw">import com.hypixel.hytale.protocol.Rangef;
class="kw">import com.hypixel.hytale.protocol.SavedMovementStates;
class="kw">import com.hypixel.hytale.protocol.Size;
class="kw">import com.hypixel.hytale.protocol.UVMotion;
class="kw">import com.hypixel.hytale.protocol.UVMotionCurveType;
class="kw">import com.hypixel.hytale.server.core.asset.common.BlockyAnimationCache;
class="kw">import com.hypixel.hytale.server.core.asset.common.CommonAssetValidator;
class="kw">import com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
class="kw">import com.hypixel.hytale.server.core.codec.protocol.ColorAlphaCodec;
class="kw">import com.hypixel.hytale.server.core.codec.protocol.ColorCodec;
class="kw">import org.joml.Vector3f;
class="kw">public class="kw">final class ProtocolCodecs {
class="kw">public class="kw">static class="kw">final BuilderCodec<Direction> DIRECTION = BuilderCodec.<Direction>builder(Direction.class, Direction::new)
.metadata(UIDisplayMode.COMPACT)
.appendInherited(new KeyedCodec<>("Yaw", Codec.FLOAT), (var0, var1) -> var0.yaw = var1, var0 -> var0.yaw, (var0, var1) -> var0.yaw = var1.yaw)
.add()
.appendInherited(new KeyedCodec<>("Pitch", Codec.FLOAT), (var0, var1) -> var0.pitch = var1, var0 -> var0.pitch, (var0, var1) -> var0.pitch = var1.pitch)
.add()
.appendInherited(new KeyedCodec<>("Roll", Codec.FLOAT), (var0, var1) -> var0.roll = var1, var0 -> var0.roll, (var0, var1) -> var0.roll = var1.roll)
.add()
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<ColorLight> COLOR_LIGHT = BuilderCodec.builder(ColorLight.class, ColorLight::new)
.appendInherited(
new KeyedCodec<>("Color", Codec.STRING), ColorParseUtil::hexStringToColorLightDirect, ColorParseUtil::colorLightToHexString, (var0, var1) -> {
var0.red = var1.red;
var0.green = var1.green;
var0.blue = var1.blue;
}
)
.metadata(new HytaleType("ColorShort"))
.add()
.appendInherited(
new KeyedCodec<>("Radius", Codec.BYTE), (var0, var1) -> var0.radius = var1, var0 -> var0.radius, (var0, var1) -> var0.radius = var1.radius
)
.add()
.build();
class="kw">public class="kw">static class="kw">final ColorCodec COLOR = new ColorCodec();
class="kw">public class="kw">static class="kw">final ArrayCodec<Color> COLOR_ARRAY = new ArrayCodec<>(COLOR, Color[]::new);
class="kw">public class="kw">static class="kw">final ColorAlphaCodec COLOR_ALPHA = new ColorAlphaCodec();
class="kw">public class="kw">static class="kw">final EnumCodec<GameMode> GAMEMODE = new EnumCodec<>(GameMode.class)
.documentKey(GameMode.Creative, "Makes the player invulnerable and grants them the ability to fly.")
.documentKey(GameMode.Adventure, "The normal gamemode for players playing the game.");
class="kw">public class="kw">static class="kw">final EnumCodec<GameMode> GAMEMODE_LEGACY = new EnumCodec<>(GameMode.class, EnumCodec.EnumStyle.LEGACY);
class="kw">public class="kw">static class="kw">final BuilderCodec<Size> SIZE = BuilderCodec.<Size>builder(Size.class, Size::new)
.metadata(UIDisplayMode.COMPACT)
.addField(new KeyedCodec<>("Width", Codec.INTEGER), (var0, var1) -> var0.width = var1, var0 -> var0.width)
.addField(new KeyedCodec<>("Height", Codec.INTEGER), (var0, var1) -> var0.height = var1, var0 -> var0.height)
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<Range> RANGE = BuilderCodec.<Range>builder(Range.class, Range::new)
.metadata(UIDisplayMode.COMPACT)
.addField(new KeyedCodec<>("Min", Codec.INTEGER), (var0, var1) -> var0.min = var1, var0 -> var0.min)
.addField(new KeyedCodec<>("Max", Codec.INTEGER), (var0, var1) -> var0.max = var1, var0 -> var0.max)
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<Rangeb> RANGEB = BuilderCodec.<Rangeb>builder(Rangeb.class, Rangeb::new)
.metadata(UIDisplayMode.COMPACT)
.addField(new KeyedCodec<>("Min", Codec.BYTE), (var0, var1) -> var0.min = var1, var0 -> var0.min)
.addField(new KeyedCodec<>("Max", Codec.BYTE), (var0, var1) -> var0.max = var1, var0 -> var0.max)
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<Rangef> RANGEF = BuilderCodec.<Rangef>builder(Rangef.class, Rangef::new)
.metadata(UIDisplayMode.COMPACT)
.addField(new KeyedCodec<>("Min", Codec.DOUBLE), (var0, var1) -> var0.min = var1.floatValue(), var0 -> (double)var0.min)
.addField(new KeyedCodec<>("Max", Codec.DOUBLE), (var0, var1) -> var0.max = var1.floatValue(), var0 -> (double)var0.max)
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<RangeVector2f> RANGE_VECTOR2F = BuilderCodec.<RangeVector2f>builder(RangeVector2f.class, RangeVector2f::new)
.addField(new KeyedCodec<>("X", RANGEF), (var0, var1) -> var0.x = var1, var0 -> var0.x)
.addField(new KeyedCodec<>("Y", RANGEF), (var0, var1) -> var0.y = var1, var0 -> var0.y)
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<RangeVector3f> RANGE_VECTOR3F = BuilderCodec.<RangeVector3f>builder(RangeVector3f.class, RangeVector3f::new)
.addField(new KeyedCodec<>("X", RANGEF), (var0, var1) -> var0.x = var1, var0 -> var0.x)
.addField(new KeyedCodec<>("Y", RANGEF), (var0, var1) -> var0.y = var1, var0 -> var0.y)
.addField(new KeyedCodec<>("Z", RANGEF), (var0, var1) -> var0.z = var1, var0 -> var0.z)
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<InitialVelocity> INITIAL_VELOCITY = BuilderCodec.builder(InitialVelocity.class, InitialVelocity::new)
.append(new KeyedCodec<>("Yaw", RANGEF), (var0, var1) -> var0.yaw = var1, var0 -> var0.yaw)
.documentation("Defines the rotation around the y-Axis.")
.add()
.<Rangef>append(new KeyedCodec<>("Pitch", RANGEF), (var0, var1) -> var0.pitch = var1, var0 -> var0.pitch)
.documentation("Defines the rotation around the x-Axis.\n\n0, 180: at the same height as its origin\n90: up\n-90: down")
.add()
.<Rangef>append(new KeyedCodec<>("Speed", RANGEF), (var0, var1) -> var0.speed = var1, var0 -> var0.speed)
.documentation("Defines the starting speed in the direction set by `Yaw` and `Pitch`.")
.add()
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<UVMotion> UV_MOTION = BuilderCodec.builder(UVMotion.class, UVMotion::new)
.append(new KeyedCodec<>("Texture", Codec.STRING), (var0, var1) -> var0.texture = var1, var0 -> var0.texture)
.addValidator(CommonAssetValidator.TEXTURE_PARTICLES)
.documentation("Defines the texture used for the distortion. The texture gets tiled to avoid scale conflicts with `Scale`.")
.add()
.<Double>append(new KeyedCodec<>("Scale", Codec.DOUBLE), (var0, var1) -> var0.scale = var1.floatValue(), var0 -> (double)var0.scale)
.addValidator(Validators.range(0.0, 10.0))
.documentation("Defines the scale of the used texture.")
.add()
.<Boolean>append(new KeyedCodec<>("AddRandomUVOffset", Codec.BOOLEAN), (var0, var1) -> var0.addRandomUVOffset = var1, var0 -> var0.addRandomUVOffset)
.documentation("If checked, randomly offsets the centre of the distortion texture per particle.")
.add()
.<Double>append(new KeyedCodec<>("SpeedX", Codec.DOUBLE), (var0, var1) -> var0.speedX = var1.floatValue(), var0 -> (double)var0.speedX)
.addValidator(Validators.range(-10.0, 10.0))
.documentation("How fast the texture should get shifted along the x-Axis over time.")
.add()
.<Double>append(new KeyedCodec<>("SpeedY", Codec.DOUBLE), (var0, var1) -> var0.speedY = var1.floatValue(), var0 -> (double)var0.speedY)
.addValidator(Validators.range(-10.0, 10.0))
.documentation("How fast the texture should get shifted along the y-Axis over time.")
.add()
.<Double>append(new KeyedCodec<>("Strength", Codec.DOUBLE), (var0, var1) -> var0.strength = var1.floatValue(), var0 -> (double)var0.strength)
.addValidator(Validators.range(0.0, 50.0))
.documentation("Defines how strong the distortion is.")
.add()
.<UVMotionCurveType>append(
new KeyedCodec<>(
"StrengthCurveType",
new EnumCodec<>(UVMotionCurveType.class)
.documentKey(UVMotionCurveType.Constant, "The strength stays the same for the whole lifetime.")
.documentKey(
UVMotionCurveType.IncreaseLinear,
"The strength increases linear from 0 at the start to the defined strength at the end of the particles lifetime."
)
.documentKey(
UVMotionCurveType.IncreaseQuartIn,
"The strength increases quartic (power 4) from 0 at the start to the defined strength at the end of the particles lifetime.\nThe start is more smooth this way."
)
.documentKey(
UVMotionCurveType.IncreaseQuartInOut,
"The strength increases quartic (power 4) from 0 at the start to the defined strength at the end of the particles lifetime.\nIt slows down quartic at the end so both the end and the start are smooth."
)
.documentKey(
UVMotionCurveType.IncreaseQuartOut,
"The strength increases with quartic (power 4) slowdown from 0 at the start to the defined strength at the end of the particles lifetime.\nThe end is more smooth this way."
)
.documentKey(
UVMotionCurveType.DecreaseLinear,
"The strength decreases linear from the defined strength at the start to 0 at the end of the particles lifetime."
)
.documentKey(
UVMotionCurveType.DecreaseQuartIn,
"The strength decreases quartic (power 4) from the defined strength at the start to 0 at the end of the particles lifetime.\nThe start is more smooth this way."
)
.documentKey(
UVMotionCurveType.DecreaseQuartInOut,
"The strength decreases quartic (power 4) from the defined strength at the start to 0 at the end of the particles lifetime.\nIt slows down quartic at the end so both the end and the start are smooth."
)
.documentKey(
UVMotionCurveType.DecreaseQuartOut,
"The strength decreases with quartic (power 4) slowdown from the defined strength at the start to 0 at the end of the particles lifetime.\nThe end is more smooth this way."
)
),
(var0, var1) -> var0.strengthCurveType = var1,
var0 -> var0.strengthCurveType
)
.documentation("Defines how the strength of the distortion evolves over time.")
.add()
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<IntersectionHighlight> INTERSECTION_HIGHLIGHT = BuilderCodec.builder(
IntersectionHighlight.class, IntersectionHighlight::new
)
.append(new KeyedCodec<>("HighlightThreshold", Codec.FLOAT), (var0, var1) -> var0.highlightThreshold = var1, var0 -> var0.highlightThreshold)
.addValidator(Validators.range(0.0F, 1.0F))
.documentation("Defines how far away from the intersection the highlight still gets applied. 0 disables the highlight.")
.add()
.<Color>append(new KeyedCodec<>("HighlightColor", COLOR), (var0, var1) -> var0.highlightColor = var1, var0 -> var0.highlightColor)
.documentation("Defines the colour that gets applied to the region for the highlight.")
.add()
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<SavedMovementStates> SAVED_MOVEMENT_STATES = BuilderCodec.<SavedMovementStates>builder(
SavedMovementStates.class, SavedMovementStates::new
)
.addField(new KeyedCodec<>("Flying", Codec.BOOLEAN), (var0, var1) -> var0.flying = var1, var0 -> var0.flying)
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<ItemAnimation> ITEM_ANIMATION_CODEC = BuilderCodec.builder(ItemAnimation.class, ItemAnimation::new)
.append(new KeyedCodec<>("ThirdPerson", Codec.STRING), (var0, var1) -> var0.thirdPerson = var1, var0 -> var0.thirdPerson)
.addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER)
.add()
.<String>append(new KeyedCodec<>("ThirdPersonMoving", Codec.STRING), (var0, var1) -> var0.thirdPersonMoving = var1, var0 -> var0.thirdPersonMoving)
.addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER)
.add()
.<String>append(new KeyedCodec<>("ThirdPersonFace", Codec.STRING), (var0, var1) -> var0.thirdPersonFace = var1, var0 -> var0.thirdPersonFace)
.addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER)
.add()
.<String>append(new KeyedCodec<>("FirstPerson", Codec.STRING), (var0, var1) -> var0.firstPerson = var1, var0 -> var0.firstPerson)
.addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER)
.add()
.<String>append(new KeyedCodec<>("FirstPersonOverride", Codec.STRING), (var0, var1) -> var0.firstPersonOverride = var1, var0 -> var0.firstPersonOverride)
.addValidator(CommonAssetValidator.ANIMATION_ITEM_CHARACTER)
.add()
.addField(
new KeyedCodec<>("KeepPreviousFirstPersonAnimation", Codec.BOOLEAN),
(var0, var1) -> var0.keepPreviousFirstPersonAnimation = var1,
var0 -> var0.keepPreviousFirstPersonAnimation
)
.addField(new KeyedCodec<>("Speed", Codec.DOUBLE), (var0, var1) -> var0.speed = var1.floatValue(), var0 -> (double)var0.speed)
.addField(
new KeyedCodec<>("BlendingDuration", Codec.DOUBLE), (var0, var1) -> var0.blendingDuration = var1.floatValue(), var0 -> (double)var0.blendingDuration
)
.addField(new KeyedCodec<>("Looping", Codec.BOOLEAN), (var0, var1) -> var0.looping = var1, var0 -> var0.looping)
.addField(new KeyedCodec<>("ClipsGeometry", Codec.BOOLEAN), (var0, var1) -> var0.clipsGeometry = var1, var0 -> var0.clipsGeometry)
.afterDecode(var0 -> {
if (var0.firstPerson != null) {
BlockyAnimationCache.get(var0.firstPerson);
}
if (var0.firstPersonOverride != null) {
BlockyAnimationCache.get(var0.firstPersonOverride);
}
})
.build();
class="kw">public class="kw">static class="kw">final EnumCodec<ChangeStatBehaviour> CHANGE_STAT_BEHAVIOUR_CODEC = new EnumCodec<>(ChangeStatBehaviour.class)
.documentKey(ChangeStatBehaviour.Add, "Adds the value to the stat")
.documentKey(ChangeStatBehaviour.Set, "Changes the stat to the given value")
.documentKey(ChangeStatBehaviour.Min, "Lowers the stat to the given value, leaving it unchanged if already at or below it")
.documentKey(ChangeStatBehaviour.Max, "Raises the stat to the given value, leaving it unchanged if already at or above it");
class="kw">public class="kw">static class="kw">final EnumCodec<AccumulationMode> ACCUMULATION_MODE_CODEC = new EnumCodec<>(AccumulationMode.class)
.documentKey(AccumulationMode.Set, "Set the current value to the new one")
.documentKey(AccumulationMode.Sum, "Add the new value to the current one")
.documentKey(AccumulationMode.Average, "Average the new value with current one");
class="kw">public class="kw">static class="kw">final EnumCodec<EasingType> EASING_TYPE_CODEC = new EnumCodec<>(EasingType.class);
class="kw">public class="kw">static class="kw">final EnumCodec<ChangeVelocityType> CHANGE_VELOCITY_TYPE_CODEC = new EnumCodec<>(ChangeVelocityType.class)
.documentKey(ChangeVelocityType.Add, "Adds the velocity to any existing velocity")
.documentKey(ChangeVelocityType.Set, "Changes the velocity to the given value. Overriding existing values.");
class="kw">public class="kw">static class="kw">final BuilderCodec<RailPoint> RAIL_POINT_CODEC = BuilderCodec.builder(RailPoint.class, RailPoint::new)
.appendInherited(
new KeyedCodec<>("Point", Vector3fUtil.CODEC),
(var0, var1) -> var0.point = var1,
var0 -> new Vector3f(var0.point.x(), var0.point.y(), var0.point.z()),
(var0, var1) -> var0.point = var1.point
)
.addValidator(Validators.nonNull())
.add()
.<Vector3f>appendInherited(
new KeyedCodec<>("Normal", Vector3fUtil.CODEC),
(var0, var1) -> var0.normal = var1,
var0 -> new Vector3f(var0.normal.x(), var0.normal.y(), var0.normal.z()),
(var0, var1) -> var0.normal = var1.normal
)
.addValidator(Validators.nonNull())
.add()
.afterDecode(var0 -> {
Vector3f var1 = var0.normal.normalize(new Vector3f());
if (var1.isFinite()) {
var0.normal = var1;
}
})
.build();
class="kw">public class="kw">static class="kw">final BuilderCodec<RailConfig> RAIL_CONFIG_CODEC = BuilderCodec.builder(RailConfig.class, RailConfig::new)
.appendInherited(
new KeyedCodec<>("Points", new ArrayCodec<>(RAIL_POINT_CODEC, RailPoint[]::new)),
(var0, var1) -> var0.points = var1,
var0 -> var0.points,
(var0, var1) -> var0.points = var1.points
)
.addValidator(Validators.nonNull())
.addValidator(Validators.arraySizeRange(2, 16))
.add()
.build();
class="kw">public ProtocolCodecs() {
}
}