Search in sources :

Example 11 with TileEntity

use of net.minecraft.server.v1_14_R1.TileEntity in project Movecraft by APDevTeam.

the class IWorldHandler method moveTileEntity.

private void moveTileEntity(@NotNull World nativeWorld, @NotNull BlockPosition newPosition, @NotNull TileEntity tile) {
    Chunk chunk = nativeWorld.getChunkAtWorldCoords(newPosition);
    tile.invalidateBlockCache();
    tile.setWorld(nativeWorld);
    tile.setPosition(newPosition);
    if (nativeWorld.captureBlockStates) {
        tile.setWorld(nativeWorld);
        tile.setPosition(newPosition);
        nativeWorld.capturedTileEntities.put(newPosition, tile);
        return;
    }
    chunk.tileEntities.put(newPosition, tile);
}
Also used : Chunk(net.minecraft.server.v1_14_R1.Chunk)

Example 12 with TileEntity

use of net.minecraft.server.v1_14_R1.TileEntity in project TheAPI by TheDevTec.

the class v1_10_R1 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_10_R1.Chunk c = (net.minecraft.server.v1_10_R1.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null) {
        c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
    }
    BlockPosition pos = new BlockPosition(x, y, z);
    // REMOVE TILE ENTITY
    c.tileEntities.remove(pos);
    sc.getBlocks().setBlock(x & 15, y & 15, z & 15, (IBlockData) IblockData);
    // ADD TILE ENTITY
    if (IblockData instanceof ITileEntity) {
        TileEntity ent = ((ITileEntity) IblockData).a(c.world, 0);
        c.tileEntities.put(pos, ent);
        Object packet = ent.getUpdatePacket();
        Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
    }
}
Also used : ITileEntity(net.minecraft.server.v1_10_R1.ITileEntity) TileEntity(net.minecraft.server.v1_10_R1.TileEntity) ITileEntity(net.minecraft.server.v1_10_R1.ITileEntity) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_10_R1.CraftChunk) ChunkSection(net.minecraft.server.v1_10_R1.ChunkSection)

Example 13 with TileEntity

use of net.minecraft.server.v1_14_R1.TileEntity in project TheAPI by TheDevTec.

the class v1_13_R1 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_13_R1.Chunk c = (net.minecraft.server.v1_13_R1.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null) {
        c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
    }
    BlockPosition pos = new BlockPosition(x, y, z);
    // REMOVE TILE ENTITY
    c.tileEntities.remove(pos);
    try {
        DataBits bits = (DataBits) dataBits.get(sc.getBlocks());
        @SuppressWarnings("unchecked") DataPalette<IBlockData> pallete = (DataPalette<IBlockData>) dataPallete.get(sc.getBlocks());
        bits.a(b(x & 15, y & 15, z & 15), pallete.a((IBlockData) IblockData));
    } catch (Exception er) {
    }
    // ADD TILE ENTITY
    if (IblockData instanceof ITileEntity) {
        TileEntity ent = ((ITileEntity) IblockData).a(c);
        c.tileEntities.put(pos, ent);
        Object packet = ent.getUpdatePacket();
        Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
    }
}
Also used : ITileEntity(net.minecraft.server.v1_13_R1.ITileEntity) DataBits(net.minecraft.server.v1_13_R1.DataBits) BlockPosition(net.minecraft.server.v1_13_R1.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_13_R1.CraftChunk) DataPalette(net.minecraft.server.v1_13_R1.DataPalette) TileEntity(net.minecraft.server.v1_13_R1.TileEntity) ITileEntity(net.minecraft.server.v1_13_R1.ITileEntity) IBlockData(net.minecraft.server.v1_13_R1.IBlockData) ChunkSection(net.minecraft.server.v1_13_R1.ChunkSection)

Example 14 with TileEntity

use of net.minecraft.server.v1_14_R1.TileEntity in project TheAPI by TheDevTec.

the class v1_13_R2 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_13_R2.Chunk c = (net.minecraft.server.v1_13_R2.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null) {
        c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
    }
    BlockPosition pos = new BlockPosition(x, y, z);
    // REMOVE TILE ENTITY
    c.tileEntities.remove(pos);
    try {
        DataBits bits = (DataBits) dataBits.get(sc.getBlocks());
        @SuppressWarnings("unchecked") DataPalette<IBlockData> pallete = (DataPalette<IBlockData>) dataPallete.get(sc.getBlocks());
        bits.a(b(x & 15, y & 15, z & 15), pallete.a((IBlockData) IblockData));
    } catch (Exception er) {
    }
    // ADD TILE ENTITY
    if (IblockData instanceof ITileEntity) {
        TileEntity ent = ((ITileEntity) IblockData).a(c);
        c.tileEntities.put(pos, ent);
        Object packet = ent.getUpdatePacket();
        Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
    }
}
Also used : ITileEntity(net.minecraft.server.v1_13_R2.ITileEntity) DataBits(net.minecraft.server.v1_13_R2.DataBits) BlockPosition(net.minecraft.server.v1_13_R2.BlockPosition) CraftChunk(org.bukkit.craftbukkit.v1_13_R2.CraftChunk) Chunk(org.bukkit.Chunk) DataPalette(net.minecraft.server.v1_13_R2.DataPalette) ITileEntity(net.minecraft.server.v1_13_R2.ITileEntity) TileEntity(net.minecraft.server.v1_13_R2.TileEntity) IBlockData(net.minecraft.server.v1_13_R2.IBlockData) ChunkSection(net.minecraft.server.v1_13_R2.ChunkSection)

Example 15 with TileEntity

use of net.minecraft.server.v1_14_R1.TileEntity in project TheAPI by TheDevTec.

the class v1_11_R1 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_11_R1.Chunk c = (net.minecraft.server.v1_11_R1.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null) {
        c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
    }
    BlockPosition pos = new BlockPosition(x, y, z);
    // REMOVE TILE ENTITY
    c.tileEntities.remove(pos);
    sc.getBlocks().setBlock(x & 15, y & 15, z & 15, (IBlockData) IblockData);
    // ADD TILE ENTITY
    if (IblockData instanceof ITileEntity) {
        TileEntity ent = ((ITileEntity) IblockData).a(c.world, 0);
        c.tileEntities.put(pos, ent);
        Object packet = ent.getUpdatePacket();
        Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
    }
}
Also used : TileEntity(net.minecraft.server.v1_11_R1.TileEntity) ITileEntity(net.minecraft.server.v1_11_R1.ITileEntity) ITileEntity(net.minecraft.server.v1_11_R1.ITileEntity) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_11_R1.CraftChunk) ChunkSection(net.minecraft.server.v1_11_R1.ChunkSection)

Aggregations

Chunk (org.bukkit.Chunk)15 Location (org.bukkit.Location)14 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 Map (java.util.Map)10 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 UUID (java.util.UUID)8 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)8 TileEntity (net.minecraft.server.v1_16_R3.TileEntity)8 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)7 List (java.util.List)6 TileEntity (net.minecraft.server.v1_8_R3.TileEntity)6 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)5