From bf48c41f2f340f7ffbf7c518dd84463079421310 Mon Sep 17 00:00:00 2001 From: WakelessSloth56 Date: Wed, 5 Oct 2022 22:03:10 +0800 Subject: [PATCH] feat(game.entity): entity casters --- .../mcmod/arnicalib/game/entity/EntityCasters.java | 14 ++++++++++++++ ...{EntityFunctions.java => EntityPredicates.java} | 6 +----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityCasters.java rename src/main/java/org/auioc/mcmod/arnicalib/game/entity/{EntityFunctions.java => EntityPredicates.java} (91%) diff --git a/src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityCasters.java b/src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityCasters.java new file mode 100644 index 00000000..6a4eafed --- /dev/null +++ b/src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityCasters.java @@ -0,0 +1,14 @@ +package org.auioc.mcmod.arnicalib.game.entity; + +import java.util.function.Function; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; + +public class EntityCasters { + + public static final Function TO_LIVING = (entity) -> (LivingEntity) entity; + public static final Function TO_SERVER_PLAYER = (player) -> (ServerPlayer) player; + +} diff --git a/src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityFunctions.java b/src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityPredicates.java similarity index 91% rename from src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityFunctions.java rename to src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityPredicates.java index d08d548e..eda899db 100644 --- a/src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityFunctions.java +++ b/src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityPredicates.java @@ -1,6 +1,5 @@ package org.auioc.mcmod.arnicalib.game.entity; -import java.util.function.Function; import java.util.function.Predicate; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; @@ -9,7 +8,7 @@ import net.minecraft.world.entity.MobType; import net.minecraft.world.entity.player.Player; -public class EntityFunctions { +public class EntityPredicates { public static final Predicate IS_LIVING = (entity) -> entity instanceof LivingEntity; public static final Predicate IS_PLAYER = (entity) -> entity instanceof Player; @@ -36,9 +35,6 @@ public class EntityFunctions { public static final Predicate IS_ILLAGER = (living) -> living.getMobType() == MobType.ILLAGER; public static final Predicate IS_WATER = (living) -> living.getMobType() == MobType.WATER; - public static final Function CAST_TO_LIVING = (entity) -> (LivingEntity) entity; - public static final Function CAST_TO_SERVER_PLAYER = (player) -> (ServerPlayer) player; - private static MobCategory getCategory(Entity entity) { return entity.getType().getCategory(); }