Skip to content

Commit

Permalink
feat(game.entity): entity casters
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Oct 5, 2022
1 parent 74cfebe commit bf48c41
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
@@ -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<Entity, LivingEntity> TO_LIVING = (entity) -> (LivingEntity) entity;
public static final Function<Player, ServerPlayer> TO_SERVER_PLAYER = (player) -> (ServerPlayer) player;

}
@@ -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;
Expand All @@ -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<Entity> IS_LIVING = (entity) -> entity instanceof LivingEntity;
public static final Predicate<Entity> IS_PLAYER = (entity) -> entity instanceof Player;
Expand All @@ -36,9 +35,6 @@ public class EntityFunctions {
public static final Predicate<LivingEntity> IS_ILLAGER = (living) -> living.getMobType() == MobType.ILLAGER;
public static final Predicate<LivingEntity> IS_WATER = (living) -> living.getMobType() == MobType.WATER;

public static final Function<Entity, LivingEntity> CAST_TO_LIVING = (entity) -> (LivingEntity) entity;
public static final Function<Player, ServerPlayer> CAST_TO_SERVER_PLAYER = (player) -> (ServerPlayer) player;

private static MobCategory getCategory(Entity entity) {
return entity.getType().getCategory();
}
Expand Down

0 comments on commit bf48c41

Please sign in to comment.