Java Code Examples for net.minecraft.world.chunk.Chunk#getTileEntityMap()

The following examples show how to use net.minecraft.world.chunk.Chunk#getTileEntityMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
    Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
    pos.setPos(x, y, z);
    TileEntity tile = tiles.get(pos);
    return tile != null ? getTag(tile) : null;
}
 
Example 2
Source File: SpongeQueue_1_11.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
    Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
    pos.setPos(x, y, z);
    TileEntity tile = tiles.get(pos);
    return tile != null ? getTag(tile) : null;
}
 
Example 3
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
    Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
    pos.set(x, y, z);
    TileEntity tile = tiles.get(pos);
    return tile != null ? getTag(tile) : null;
}
 
Example 4
Source File: SpongeQueue_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
    Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
    pos.setPos(x, y, z);
    TileEntity tile = tiles.get(pos);
    return tile != null ? getTag(tile) : null;
}
 
Example 5
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
    Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
    pos.setPos(x, y, z);
    TileEntity tile = tiles.get(pos);
    return tile != null ? getTag(tile) : null;
}
 
Example 6
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
    Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
    pos.setPos(x, y, z);
    TileEntity tile = tiles.get(pos);
    return tile != null ? getTag(tile) : null;
}
 
Example 7
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
    Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
    pos.setPos(x, y, z);
    TileEntity tile = tiles.get(pos);
    return tile != null ? getTag(tile) : null;
}
 
Example 8
Source File: PositionUtils.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets a list of all the TileEntities within the given range of the center position.
 * The list is sorted by distance to the center position (closest one first)
 * @param world
 * @param centerPos
 * @param rangeH
 * @param rangeVertPos the range upwards from the center position
 * @param rangeVertNeg the range downwards from the center position
 * @param filter a predicate to check if the found TileEntity is suitable
 * @return
 */
public static List<BlockPosDistance> getTileEntityPositions(World world, BlockPos centerPos, int rangeH,
        int rangeVertPos, int rangeVertNeg, Predicate <? super TileEntity> filter)
{
    List<BlockPosDistance> posDist = new ArrayList<BlockPosDistance>();

    for (int cx = (centerPos.getX() - rangeH) >> 4; cx <= ((centerPos.getX() + rangeH) >> 4); cx++)
    {
        for (int cz = (centerPos.getZ() - rangeH) >> 4; cz <= ((centerPos.getZ() + rangeH) >> 4); cz++)
        {
            if (world.isBlockLoaded(new BlockPos(cx << 4, centerPos.getY(), cz << 4), world.isRemote) == false)
            {
                continue;
            }

            Chunk chunk = world.getChunk(cx, cz);
            if (chunk != null)
            {
                Map<BlockPos, TileEntity> map = chunk.getTileEntityMap();

                for (BlockPos pos : map.keySet())
                {
                    if (PositionUtils.isWithinRange(centerPos, pos, rangeH, rangeVertPos, rangeVertNeg) &&
                        (filter == null || filter.apply(map.get(pos))))
                    {
                        posDist.add(new BlockPosDistance(pos, centerPos));
                    }
                }
            }
        }
    }

    Collections.sort(posDist);

    return posDist;
}