use of com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType in project InteractionVisualizer by LOOHP.
the class TileEntityManager method addTileEntities.
private static synchronized void addTileEntities(ChunkPosition chunk) {
NMSTileEntitySet<?, ?> list = NMS.getInstance().getTileEntities(chunk, false);
Set<Block> blocks = byChunk.get(chunk);
if (blocks == null) {
blocks = new LinkedHashSet<>();
byChunk.put(chunk, blocks);
}
Map<Block, TileEntityType> newBlocks = new LinkedHashMap<>();
if (list != null) {
for (TileEntity tile : list) {
if (tile != null) {
Block block = tile.getBlock();
TileEntityType type = tile.getType();
active.get(type).add(block);
newBlocks.put(block, type);
blocks.add(block);
}
}
}
Iterator<Block> itr = blocks.iterator();
while (itr.hasNext()) {
Block block = itr.next();
TileEntityType type = newBlocks.get(block);
if (type == null) {
itr.remove();
for (TileEntityType t : tileEntityTypes) {
if (active.get(t).remove(block)) {
Bukkit.getPluginManager().callEvent(new TileEntityRemovedEvent(block, t));
}
}
} else {
for (TileEntityType t : tileEntityTypes) {
if (!t.equals(type)) {
if (active.get(t).remove(block)) {
Bukkit.getPluginManager().callEvent(new TileEntityRemovedEvent(block, t));
}
}
}
}
}
}
use of com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType 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 com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType 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 com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType 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 com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType 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