Search in sources :

Example 46 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method getNearbyItems.

@Override
public Stream<Item> getNearbyItems(Location location, int range, boolean onlyChunk, KeySet blacklisted, KeySet whitelisted) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    List<Entity> entityList = new ArrayList<>();
    if (onlyChunk) {
        Chunk chunk = ((CraftChunk) location.getChunk()).getHandle();
        for (int i = 0; i < chunk.entitySlices.length; i++) entityList.addAll(chunk.entitySlices[i]);
        entityList = entityList.stream().filter(entity -> entity instanceof EntityItem).collect(Collectors.toList());
    } else {
        AxisAlignedBB boundingBox = new AxisAlignedBB(location.getX() + range, location.getY() + range, location.getZ() + range, location.getX() - range, location.getY() - range, location.getZ() - range);
        entityList = world.a((Entity) null, boundingBox, entity -> entity instanceof EntityItem);
    }
    return entityList.stream().map(entity -> (Item) entity.getBukkitEntity()).filter(item -> !blacklisted.contains(item.getItemStack()) && (whitelisted.isEmpty() || whitelisted.contains(item.getItemStack())));
}
Also used : AxisAlignedBB(net.minecraft.server.v1_8_R3.AxisAlignedBB) InventoryHolder(com.bgsoftware.wildchests.objects.inventory.InventoryHolder) DataInputStream(java.io.DataInputStream) NBTTagList(net.minecraft.server.v1_8_R3.NBTTagList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Item(org.bukkit.entity.Item) EntityHuman(net.minecraft.server.v1_8_R3.EntityHuman) EntityItem(net.minecraft.server.v1_8_R3.EntityItem) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) Inventory(org.bukkit.inventory.Inventory) ArrayList(java.util.ArrayList) Effect(org.bukkit.Effect) Location(org.bukkit.Location) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) NBTCompressedStreamTools(net.minecraft.server.v1_8_R3.NBTCompressedStreamTools) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) BigInteger(java.math.BigInteger) ChestType(com.bgsoftware.wildchests.api.objects.ChestType) KeySet(com.bgsoftware.wildchests.key.KeySet) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftHumanEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity) Material(org.bukkit.Material) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) HumanEntity(org.bukkit.entity.HumanEntity) DataOutput(java.io.DataOutput) TileEntityChest(net.minecraft.server.v1_8_R3.TileEntityChest) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) Collectors(java.util.stream.Collectors) World(net.minecraft.server.v1_8_R3.World) Base64(java.util.Base64) List(java.util.List) Stream(java.util.stream.Stream) Chunk(net.minecraft.server.v1_8_R3.Chunk) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) AxisAlignedBB(net.minecraft.server.v1_8_R3.AxisAlignedBB) Entity(net.minecraft.server.v1_8_R3.Entity) CraftHumanEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity) HumanEntity(org.bukkit.entity.HumanEntity) Entity(net.minecraft.server.v1_8_R3.Entity) Item(org.bukkit.entity.Item) EntityItem(net.minecraft.server.v1_8_R3.EntityItem) ArrayList(java.util.ArrayList) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) World(net.minecraft.server.v1_8_R3.World) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) Chunk(net.minecraft.server.v1_8_R3.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) EntityItem(net.minecraft.server.v1_8_R3.EntityItem)

Example 47 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project InteractionVisualizer by LOOHP.

the class V1_11 method getTileEntities.

@Override
public NMSTileEntitySet<?, ?> getTileEntities(ChunkPosition chunk, boolean load) {
    if (!chunk.isLoaded() && !load) {
        return null;
    }
    World world = chunk.getWorld();
    return new NMSTileEntitySet<net.minecraft.server.v1_11_R1.BlockPosition, net.minecraft.server.v1_11_R1.TileEntity>(((CraftChunk) chunk.getChunk()).getHandle().tileEntities, entry -> {
        net.minecraft.server.v1_11_R1.BlockPosition pos = entry.getKey();
        Material type = CraftMagicNumbers.getMaterial(entry.getValue().getBlock());
        TileEntityType tileEntityType = TileEntity.getTileEntityType(type);
        if (tileEntityType != null) {
            return new TileEntity(world, pos.getX(), pos.getY(), pos.getZ(), tileEntityType);
        } else {
            return null;
        }
    });
}
Also used : TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) Material(org.bukkit.Material) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) World(org.bukkit.World) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_11_R1.CraftChunk)

Example 48 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project InteractionVisualizer by LOOHP.

the class V1_12 method getTileEntities.

@Override
public NMSTileEntitySet<?, ?> getTileEntities(ChunkPosition chunk, boolean load) {
    if (!chunk.isLoaded() && !load) {
        return null;
    }
    World world = chunk.getWorld();
    return new NMSTileEntitySet<net.minecraft.server.v1_12_R1.BlockPosition, net.minecraft.server.v1_12_R1.TileEntity>(((CraftChunk) chunk.getChunk()).getHandle().tileEntities, entry -> {
        net.minecraft.server.v1_12_R1.BlockPosition pos = entry.getKey();
        Material type = CraftMagicNumbers.getMaterial(entry.getValue().getBlock());
        TileEntityType tileEntityType = TileEntity.getTileEntityType(type);
        if (tileEntityType != null) {
            return new TileEntity(world, pos.getX(), pos.getY(), pos.getZ(), tileEntityType);
        } else {
            return null;
        }
    });
}
Also used : TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) Material(org.bukkit.Material) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) World(org.bukkit.World) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_12_R1.CraftChunk)

Example 49 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project InteractionVisualizer by LOOHP.

the class V1_13_1 method getTileEntities.

@Override
public NMSTileEntitySet<?, ?> getTileEntities(ChunkPosition chunk, boolean load) {
    if (!chunk.isLoaded() && !load) {
        return null;
    }
    World world = chunk.getWorld();
    return new NMSTileEntitySet<net.minecraft.server.v1_13_R2.BlockPosition, net.minecraft.server.v1_13_R2.TileEntity>(((CraftChunk) chunk.getChunk()).getHandle().tileEntities, entry -> {
        net.minecraft.server.v1_13_R2.BlockPosition pos = entry.getKey();
        Material type = CraftMagicNumbers.getMaterial(entry.getValue().getBlock().getBlock());
        TileEntityType tileEntityType = TileEntity.getTileEntityType(type);
        if (tileEntityType != null) {
            return new TileEntity(world, pos.getX(), pos.getY(), pos.getZ(), tileEntityType);
        } else {
            return null;
        }
    });
}
Also used : TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) Material(org.bukkit.Material) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) CraftWorld(org.bukkit.craftbukkit.v1_13_R2.CraftWorld) World(org.bukkit.World) CraftChunk(org.bukkit.craftbukkit.v1_13_R2.CraftChunk)

Example 50 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project InteractionVisualizer by LOOHP.

the class V1_16_4 method getTileEntities.

@Override
public NMSTileEntitySet<?, ?> getTileEntities(ChunkPosition chunk, boolean load) {
    if (!chunk.isLoaded() && !load) {
        return null;
    }
    World world = chunk.getWorld();
    return new NMSTileEntitySet<net.minecraft.server.v1_16_R3.BlockPosition, net.minecraft.server.v1_16_R3.TileEntity>(((CraftChunk) chunk.getChunk()).getHandle().tileEntities, entry -> {
        net.minecraft.server.v1_16_R3.BlockPosition pos = entry.getKey();
        Material type = CraftMagicNumbers.getMaterial(entry.getValue().getBlock().getBlock());
        TileEntityType tileEntityType = TileEntity.getTileEntityType(type);
        if (tileEntityType != null) {
            return new TileEntity(world, pos.getX(), pos.getY(), pos.getZ(), tileEntityType);
        } else {
            return null;
        }
    });
}
Also used : TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) Material(org.bukkit.Material) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) World(org.bukkit.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk)

Aggregations

LevelChunk (net.minecraft.world.level.chunk.LevelChunk)17 Material (org.bukkit.Material)14 World (org.bukkit.World)12 NMSTileEntitySet (com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet)11 TileEntity (com.loohp.interactionvisualizer.objectholders.TileEntity)11 TileEntityType (com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType)11 BlockPos (net.minecraft.core.BlockPos)11 Location (org.bukkit.Location)11 ArrayList (java.util.ArrayList)9 List (java.util.List)9 CraftChunk (org.bukkit.craftbukkit.v1_17_R1.CraftChunk)9 CraftChunk (org.bukkit.craftbukkit.v1_18_R2.CraftChunk)9 WildLoadersPlugin (com.bgsoftware.wildloaders.WildLoadersPlugin)8 Hologram (com.bgsoftware.wildloaders.api.holograms.Hologram)8 ChunkLoader (com.bgsoftware.wildloaders.api.loaders.ChunkLoader)8 ChunkLoaderNPC (com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC)8 ITileEntityChunkLoader (com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader)8 WChunkLoader (com.bgsoftware.wildloaders.loaders.WChunkLoader)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8