From 3cd95e5c228a53bedf6f15b4469fee89af385bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ossi=20Erkkil=C3=A4?= Date: Tue, 25 Jul 2023 23:06:15 +0300 Subject: [PATCH] Add Keys.FROZEN_TIME & Keys.MAX_FROZEN_TIME --- .../java/org/spongepowered/api/data/Keys.java | 12 ++++++++++++ .../org/spongepowered/api/entity/Entity.java | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 66eecaf53d..ce25b19daf 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -1092,6 +1092,11 @@ public final class Keys { */ public static final Key> FOX_TYPE = Keys.key(ResourceKey.sponge("fox_type"), FoxType.class); + /** + * The time (in ticks) an {@link Entity} is frozen. + */ + public static final Key> FROZEN_TIME = Keys.key(ResourceKey.sponge("frozen_time"), Ticks.class); + /** * Represents the {@link Key} for the amount of fuel left in a {@link BrewingStand} or {@link FurnaceBlockEntity} or {@link FurnaceMinecart} * @@ -2242,6 +2247,13 @@ public final class Keys { */ public static final Key> MAX_FOOD_LEVEL = Keys.key(ResourceKey.sponge("max_food_level"), Integer.class); + /** + * The frozen time after which an {@link Entity} is completely frozen. Readonly. + * + * @see Keys#FROZEN_TIME + */ + public static final Key> MAX_FROZEN_TIME = Keys.key(ResourceKey.sponge("max_frozen_time"), Ticks.class); + /** * The maximum health of a {@link Living}. * diff --git a/src/main/java/org/spongepowered/api/entity/Entity.java b/src/main/java/org/spongepowered/api/entity/Entity.java index d7602f0b6f..35a03c9c23 100644 --- a/src/main/java/org/spongepowered/api/entity/Entity.java +++ b/src/main/java/org/spongepowered/api/entity/Entity.java @@ -355,6 +355,15 @@ default Value.Mutable fallDistance() { return this.requireValue(Keys.FALL_DISTANCE).asMutable(); } + /** + * {@link Keys#FROZEN_TIME} + * + * @return The frozen time + */ + default Value.Mutable frozenTime() { + return this.requireValue(Keys.FROZEN_TIME).asMutable(); + } + /** * {@link Keys#PASSENGERS} * @@ -589,6 +598,15 @@ default Value.Mutable maxAir() { return this.requireValue(Keys.MAX_AIR).asMutable(); } + /** + * {@link Keys#MAX_FROZEN_TIME} + * + * @return The max frozen time + */ + default Value.Mutable maxFrozenTime() { + return this.requireValue(Keys.MAX_FROZEN_TIME).asMutable(); + } + /** * {@link Keys#REMAINING_AIR} *