Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12371ef
commit fd01a3a
Showing
10 changed files
with
83 additions
and
156 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityFunctions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.MobCategory; | ||
import net.minecraft.world.entity.MobType; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class EntityFunctions { | ||
|
||
public static final Predicate<Entity> IS_LIVING = (entity) -> entity instanceof LivingEntity; | ||
public static final Predicate<Entity> IS_PLAYER = (entity) -> entity instanceof Player; | ||
public static final Predicate<Entity> IS_LOCAL_PLAYER = (entity) -> entity instanceof net.minecraft.client.player.LocalPlayer; | ||
public static final Predicate<Entity> IS_SERVER_PLAYER = (entity) -> entity instanceof ServerPlayer; | ||
public static final Predicate<Entity> IS_FAKE_PLAYER = (entity) -> entity instanceof net.minecraftforge.common.util.FakePlayer; | ||
public static final Predicate<Entity> IS_PROJECTILE = (entity) -> entity instanceof net.minecraft.world.entity.projectile.Projectile; | ||
|
||
public static final Predicate<Entity> IS_FRIENDLY = (entity) -> getCategory(entity).isFriendly(); | ||
public static final Predicate<Entity> IS_PERSISTENT = (entity) -> getCategory(entity).isPersistent(); | ||
public static final Predicate<Entity> IS_MISC = (entity) -> getCategory(entity) == MobCategory.MISC; | ||
public static final Predicate<Entity> IS_MONSTER = (entity) -> getCategory(entity) == MobCategory.MONSTER; | ||
public static final Predicate<Entity> IS_CREATURE = (entity) -> getCategory(entity) == MobCategory.CREATURE; | ||
public static final Predicate<Entity> IS_AMBIENT = (entity) -> getCategory(entity) == MobCategory.AMBIENT; | ||
public static final Predicate<Entity> IS_AXOLOTLS = (entity) -> getCategory(entity) == MobCategory.AXOLOTLS; | ||
public static final Predicate<Entity> IS_UNDERGROUND_WATER_CREATURE = (entity) -> getCategory(entity) == MobCategory.UNDERGROUND_WATER_CREATURE; | ||
public static final Predicate<Entity> IS_WATER_CREATURE = (entity) -> getCategory(entity) == MobCategory.WATER_CREATURE; | ||
public static final Predicate<Entity> IS_WATER_AMBIENT = (entity) -> getCategory(entity) == MobCategory.WATER_AMBIENT; | ||
|
||
public static final Predicate<LivingEntity> IS_UNDEFINED = (living) -> living.getMobType() == MobType.UNDEFINED; | ||
public static final Predicate<LivingEntity> IS_DEFINED = (living) -> living.getMobType() != MobType.UNDEFINED; | ||
public static final Predicate<LivingEntity> IS_UNDEAD = (living) -> living.getMobType() == MobType.UNDEAD; | ||
public static final Predicate<LivingEntity> IS_ARTHROPOD = (living) -> living.getMobType() == MobType.ARTHROPOD; | ||
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(); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/auioc/mcmod/arnicalib/game/entity/EntityUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.auioc.mcmod.arnicalib.game.entity; | ||
|
||
import org.auioc.mcmod.arnicalib.game.world.LevelUtils; | ||
import net.minecraft.core.Vec3i; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.Vec3; | ||
|
||
public class EntityUtils { | ||
|
||
public static void teleportTo(Entity entity, Vec3i pos) { | ||
entity.teleportTo(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D); | ||
} | ||
|
||
public static void teleportTo(Entity entity, Vec3 pos) { | ||
entity.teleportTo(pos.x, pos.y, pos.z); | ||
} | ||
|
||
public static void teleportTo(Entity entity, ResourceKey<Level> dim, Vec3 pos) { | ||
entity.changeDimension(LevelUtils.getLevel(dim), LevelUtils.createSimpleTeleporter(pos)); | ||
} | ||
|
||
public static void teleportTo(Entity entity, ResourceKey<Level> dim, Vec3i pos) { | ||
entity.changeDimension(LevelUtils.getLevel(dim), LevelUtils.createSimpleTeleporter(pos)); | ||
} | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
...mod/arnicalib/utils/game/PlayerUtils.java → ...od/arnicalib/game/entity/PlayerUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...d/arnicalib/game/entity/IHProjectile.java → .../game/entity/projectile/IHProjectile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...d/arnicalib/game/entity/ITippedArrow.java → .../game/entity/projectile/ITippedArrow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/org/auioc/mcmod/arnicalib/mixin/common/api/IMixinArrow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/org/auioc/mcmod/arnicalib/mixin/common/api/IMixinProjectile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 0 additions & 148 deletions
148
src/main/java/org/auioc/mcmod/arnicalib/utils/game/EntityUtils.java
This file was deleted.
Oops, something went wrong.