Class EntityHelpers

java.lang.Object
org.cyclops.cyclopscore.helper.EntityHelpers

public class EntityHelpers extends Object
Helpers for entities.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The NBT tag name that is used for storing the unique name id for an entity.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<net.minecraft.world.entity.Entity>
    getEntitiesInArea(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockPos, int area)
    Get the list of entities within a certain area.
    static net.minecraft.core.Vec3i
    getEntitySize(net.minecraft.world.entity.Entity entity)
    Get the size of an entity.
    static net.minecraft.nbt.CompoundTag
    getPersistedPlayerNbt(net.minecraft.world.entity.player.Player player)
    Get the persisted NBT tag from a player.
    static void
    onEntityCollided(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState, net.minecraft.world.entity.Entity entity)
    This should by called when custom entities collide.
    static boolean
    spawnEntity(net.minecraft.server.level.ServerLevel world, net.minecraft.world.entity.Mob entityLiving, net.minecraft.world.entity.MobSpawnType spawnReason)
    Spawn the entity in the world.
    static Optional<net.minecraft.world.entity.Entity>
    spawnEntity(net.minecraft.world.level.Level world, net.minecraft.resources.ResourceLocation entityName, double x, double y, double z)
    Spawns the creature specified by the entity name in the location specified by the last three parameters.
    static void
    spawnXpAtPlayer(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, int xp)
    Spawn xp orbs at the given player.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NBTTAG_ID

      public static final String NBTTAG_ID
      The NBT tag name that is used for storing the unique name id for an entity.
      See Also:
  • Constructor Details

    • EntityHelpers

      public EntityHelpers()
  • Method Details

    • onEntityCollided

      public static void onEntityCollided(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState, net.minecraft.world.entity.Entity entity)
      This should by called when custom entities collide. It will call the correct method in Block.stepOn(Level, BlockPos, BlockState, Entity).
      Parameters:
      world - The world
      blockPos - The position.
      entity - The entity that collides.
    • getEntitiesInArea

      public static List<net.minecraft.world.entity.Entity> getEntitiesInArea(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockPos, int area)
      Get the list of entities within a certain area.
      Parameters:
      world - The world to look in.
      blockPos - The position.
      area - The radius of the area.
      Returns:
      The list of entities in that area.
    • spawnEntity

      public static Optional<net.minecraft.world.entity.Entity> spawnEntity(net.minecraft.world.level.Level world, @Nullable net.minecraft.resources.ResourceLocation entityName, double x, double y, double z)
      Spawns the creature specified by the entity name in the location specified by the last three parameters.
      Parameters:
      world - The world.
      entityName - The name of the entity.
      x - X coordinate.
      y - Y coordinate.
      z - Z coordinate.
      Returns:
      the entity that was spawned.
    • spawnEntity

      public static boolean spawnEntity(net.minecraft.server.level.ServerLevel world, net.minecraft.world.entity.Mob entityLiving, net.minecraft.world.entity.MobSpawnType spawnReason)
      Spawn the entity in the world.
      Parameters:
      world - The world.
      entityLiving - The entity to spawn.
      spawnReason - The spawn reason.
      Returns:
      If the entity was spawned.
    • getEntitySize

      public static net.minecraft.core.Vec3i getEntitySize(net.minecraft.world.entity.Entity entity)
      Get the size of an entity.
      Parameters:
      entity - The entity.
      Returns:
      The size.
    • spawnXpAtPlayer

      public static void spawnXpAtPlayer(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, int xp)
      Spawn xp orbs at the given player.
      Parameters:
      world - The world.
      player - The player.
      xp - The amount of experience to spawn.
    • getPersistedPlayerNbt

      public static net.minecraft.nbt.CompoundTag getPersistedPlayerNbt(net.minecraft.world.entity.player.Player player)
      Get the persisted NBT tag from a player.
      Parameters:
      player - The player.
      Returns:
      The player's persisted NBT tag.