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())));
}
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;
}
});
}
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;
}
});
}
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;
}
});
}
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;
}
});
}
Aggregations