Package org.cyclops.cyclopscore.helper
Class EntityHelpers
java.lang.Object
org.cyclops.cyclopscore.helper.EntityHelpers
Helpers for entities.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.Vec3igetEntitySize(net.minecraft.world.entity.Entity entity) Get the size of an entity.static net.minecraft.nbt.CompoundTaggetPersistedPlayerNbt(net.minecraft.world.entity.player.Player player) Get the persisted NBT tag from a player.static voidonEntityCollided(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 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 booleanspawnEntity(net.minecraft.world.level.ServerLevelAccessor world, net.minecraft.world.entity.Mob entityLiving, net.minecraft.world.entity.MobSpawnType spawnReason) Spawn the entity in the world.static voidspawnXpAtPlayer(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, int xp) Spawn xp orbs at the given player.
-
Field Details
-
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 inBlock.stepOn(Level, BlockPos, BlockState, Entity).- Parameters:
world- The worldblockPos- 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.world.level.ServerLevelAccessor 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.
-