use of net.minecraft.server.v1_16_R1.Chunk in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_12_R1 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.getEntities(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 net.minecraft.server.v1_16_R1.Chunk 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 net.minecraft.server.v1_16_R1.Chunk in project MechanicsMain by WeaponMechanics.
the class Block_1_15_R1 method getMultiBlockMaskPacket.
@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable BlockState mask) {
if (blocks == null || blocks.isEmpty()) {
throw new IllegalArgumentException("No blocks are being changed!");
}
Map<org.bukkit.Chunk, List<Block>> sortedBlocks = new HashMap<>();
for (Block block : blocks) {
List<Block> list = sortedBlocks.computeIfAbsent(block.getChunk(), chunk -> new ArrayList<>());
list.add(block);
}
List<Object> packets = new ArrayList<>(sortedBlocks.size());
IBlockData theMask = mask == null ? null : ((CraftBlockState) mask).getHandle();
for (List<Block> entry : sortedBlocks.values()) {
packets.add(getMultiBlockMaskPacket(entry, theMask));
}
return packets;
}
use of net.minecraft.server.v1_16_R1.Chunk in project Movecraft by APDevTeam.
the class IWorldHandler method setBlockFast.
private void setBlockFast(@NotNull World world, @NotNull BlockPosition position, @NotNull IBlockData data) {
Chunk chunk = world.getChunkAtWorldCoords(position);
ChunkSection chunkSection = chunk.getSections()[position.getY() >> 4];
if (chunkSection == null) {
// Put a GLASS block to initialize the section. It will be replaced next with the real block.
chunk.setType(position, Blocks.GLASS.getBlockData(), false);
chunkSection = chunk.getSections()[position.getY() >> 4];
}
if (chunkSection.getType(position.getX() & 15, position.getY() & 15, position.getZ() & 15).equals(data)) {
// Block is already of correct type and data, don't overwrite
return;
}
chunkSection.setType(position.getX() & 15, position.getY() & 15, position.getZ() & 15, data);
world.notify(position, data, data, 3);
var engine = chunk.e();
if (engine != null)
engine.a(position);
chunk.markDirty();
}
use of net.minecraft.server.v1_16_R1.Chunk in project Movecraft by APDevTeam.
the class IWorldHandler method setBlockFast.
private void setBlockFast(@NotNull World world, @NotNull BlockPosition position, @NotNull IBlockData data) {
Chunk chunk = world.getChunkAtWorldCoords(position);
ChunkSection chunkSection = chunk.getSections()[position.getY() >> 4];
if (chunkSection == null) {
// Put a GLASS block to initialize the section. It will be replaced next with the real block.
chunk.setType(position, Blocks.GLASS.getBlockData(), false);
chunkSection = chunk.getSections()[position.getY() >> 4];
}
if (chunkSection.getType(position.getX() & 15, position.getY() & 15, position.getZ() & 15).equals(data)) {
// Block is already of correct type and data, don't overwrite
return;
}
chunkSection.setType(position.getX() & 15, position.getY() & 15, position.getZ() & 15, data);
world.notify(position, data, data, 3);
var engine = chunk.e();
if (engine != null)
engine.a(position);
chunk.markDirty();
}
Aggregations