Class BlockHelper

java.lang.Object
com.pixelmonmod.pixelmon.api.util.helpers.BlockHelper

public class BlockHelper extends Object
Created by Jay113355 on 10/3/2016.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.world.phys.shapes.VoxelShape
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    countTileEntitiesOfType(net.minecraft.world.level.Level world, net.minecraft.world.level.ChunkPos pos, Class<? extends net.minecraft.world.level.block.entity.BlockEntity> clazz)
    Counts all TileEntities within a chunk.
    static <T extends net.minecraft.world.level.block.entity.BlockEntity>
    Map<net.minecraft.core.BlockPos,T>
    findAllTileEntityWithinRange(Class<T> tileEntity, net.minecraft.world.entity.Entity entity, double range, Predicate<T> predicate)
    Finds all TileEntities within range of the provided entity
    static <T extends net.minecraft.world.level.block.entity.BlockEntity>
    Map<net.minecraft.core.BlockPos,T>
    findAllTileEntityWithinRange(Class<T> tileEntity, net.minecraft.world.level.Level world, net.minecraft.world.phys.Vec3 pos, double range, Predicate<T> predicate)
    Finds all TileEntities within the given range
    static <T extends net.minecraft.world.level.block.entity.BlockEntity>
    T
    findClosestTileEntity(Class<T> tileEntity, net.minecraft.world.entity.Entity entity, double range, Predicate<T> predicate)
    Finds the closest TileEntity to the provided entity.
    static <T extends Comparable<T>>
    Optional<T>
    getPropertyValue(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.state.properties.Property<T> property)
     
    static <T extends net.minecraft.world.level.block.entity.BlockEntity>
    T
    getTileEntity(Class<T> clazz, net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos)
     
    static void
    placeBed(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos1, net.minecraft.core.Direction facing, net.minecraft.world.item.DyeColor color)
     
    static boolean
    validateReach(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos)
     

    Methods inherited from class java.lang.Object

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

    • EMPTY_SHAPE

      public static final net.minecraft.world.phys.shapes.VoxelShape EMPTY_SHAPE
  • Constructor Details

    • BlockHelper

      public BlockHelper()
  • Method Details

    • findClosestTileEntity

      public static <T extends net.minecraft.world.level.block.entity.BlockEntity> T findClosestTileEntity(Class<T> tileEntity, net.minecraft.world.entity.Entity entity, double range, Predicate<T> predicate)
      Finds the closest TileEntity to the provided entity.
      Type Parameters:
      T - A class that extends TileEntity.
      Parameters:
      tileEntity - The TileEntity class to find.
      entity - The entity to search around.
      range - The range around the entity to search.
      predicate - Used for extra checking. if you just want the closest tile entity, return true.
      Returns:
      The closest TileEntity matching the class and predicate. Null if none was found.
    • findAllTileEntityWithinRange

      public static <T extends net.minecraft.world.level.block.entity.BlockEntity> Map<net.minecraft.core.BlockPos,T> findAllTileEntityWithinRange(Class<T> tileEntity, net.minecraft.world.entity.Entity entity, double range, Predicate<T> predicate)
      Finds all TileEntities within range of the provided entity
      Type Parameters:
      T - A class that extends TileEntity.
      Parameters:
      tileEntity - The TileEntity class to find.
      entity - The entity we're searching around.
      range - The range around the entity to search.
      predicate - Optional TileEntity condition, can be null.
      Returns:
      A map of the positions and TileEntities.
    • findAllTileEntityWithinRange

      public static <T extends net.minecraft.world.level.block.entity.BlockEntity> Map<net.minecraft.core.BlockPos,T> findAllTileEntityWithinRange(Class<T> tileEntity, net.minecraft.world.level.Level world, net.minecraft.world.phys.Vec3 pos, double range, Predicate<T> predicate)
      Finds all TileEntities within the given range
      Type Parameters:
      T - A class that extends TileEntity.
      Parameters:
      tileEntity - The TileEntity class to find.
      world - The world to search in.
      pos - The pos to search around.
      range - The range to search.
      predicate - Optional TileEntity condition, can be null.
      Returns:
      A map of the positions and TileEntities.
    • countTileEntitiesOfType

      public static int countTileEntitiesOfType(net.minecraft.world.level.Level world, net.minecraft.world.level.ChunkPos pos, Class<? extends net.minecraft.world.level.block.entity.BlockEntity> clazz)
      Counts all TileEntities within a chunk.
      Parameters:
      world - the world that the chunk is in.
      pos - The chunk position.
      clazz - The TileEntity class to count.
      Returns:
      The number of TileEntities found.
    • getTileEntity

      public static <T extends net.minecraft.world.level.block.entity.BlockEntity> T getTileEntity(Class<T> clazz, net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos)
    • validateReach

      public static boolean validateReach(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos)
      Returns:
      true if the player can reach this block pos.
    • placeBed

      public static void placeBed(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos1, net.minecraft.core.Direction facing, net.minecraft.world.item.DyeColor color)
    • getPropertyValue

      public static <T extends Comparable<T>> Optional<T> getPropertyValue(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.state.properties.Property<T> property)