Search in sources :

Example 11 with TileEntity

use of com.loohp.interactionvisualizer.objectholders.TileEntity 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 12 with TileEntity

use of com.loohp.interactionvisualizer.objectholders.TileEntity 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 13 with TileEntity

use of com.loohp.interactionvisualizer.objectholders.TileEntity 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

TileEntity (com.loohp.interactionvisualizer.objectholders.TileEntity)13 TileEntityType (com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType)13 NMSTileEntitySet (com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet)12 Material (org.bukkit.Material)12 World (org.bukkit.World)12 TileEntityRemovedEvent (com.loohp.interactionvisualizer.api.events.TileEntityRemovedEvent)1 BlockPosition (com.loohp.interactionvisualizer.objectholders.BlockPosition)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 LinkedHashMap (java.util.LinkedHashMap)1 Block (org.bukkit.block.Block)1 CraftChunk (org.bukkit.craftbukkit.v1_11_R1.CraftChunk)1 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)1 CraftChunk (org.bukkit.craftbukkit.v1_12_R1.CraftChunk)1 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)1 CraftChunk (org.bukkit.craftbukkit.v1_13_R1.CraftChunk)1 CraftWorld (org.bukkit.craftbukkit.v1_13_R1.CraftWorld)1 CraftChunk (org.bukkit.craftbukkit.v1_13_R2.CraftChunk)1 CraftWorld (org.bukkit.craftbukkit.v1_13_R2.CraftWorld)1 CraftChunk (org.bukkit.craftbukkit.v1_14_R1.CraftChunk)1 CraftWorld (org.bukkit.craftbukkit.v1_14_R1.CraftWorld)1