Search in sources :

Example 96 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project JeffLib by JEFF-Media-GbR.

the class NMSHandler method setHeadTexture.

@Override
public void setHeadTexture(final Block block, @NotNull final GameProfile gameProfile) {
    final World world = ((CraftWorld) block.getWorld()).getHandle();
    final BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
    final TileEntitySkull skull = (TileEntitySkull) world.getTileEntity(blockPosition);
    skull.setGameProfile(gameProfile);
}
Also used : CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 97 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project JeffLib by JEFF-Media-GbR.

the class NMSHandler method setHeadTexture.

@Override
public void setHeadTexture(final Block block, @NotNull final GameProfile gameProfile) {
    final World world = ((CraftWorld) block.getWorld()).getHandle();
    final BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
    final TileEntitySkull skull = (TileEntitySkull) world.getTileEntity(blockPosition);
    skull.setGameProfile(gameProfile);
}
Also used : CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 98 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project JeffLib by JEFF-Media-GbR.

the class NMSHandler method setHeadTexture.

@Override
public void setHeadTexture(@NotNull final Block block, @NotNull final GameProfile gameProfile) {
    final ServerLevel world = ((CraftWorld) block.getWorld()).getHandle();
    final BlockPos blockPosition = new BlockPos(block.getX(), block.getY(), block.getZ());
    final SkullBlockEntity skull = (SkullBlockEntity) world.getBlockEntity(blockPosition);
    assert skull != null;
    skull.setOwner(gameProfile);
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) SkullBlockEntity(net.minecraft.world.level.block.entity.SkullBlockEntity) BlockPos(net.minecraft.core.BlockPos) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 99 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project TheAPI by TheDevTec.

the class v1_10_R1 method getChunk.

@Override
public Object getChunk(World world, int x, int z) {
    WorldServer sworld = ((CraftWorld) world).getHandle();
    net.minecraft.server.v1_10_R1.Chunk loaded = ((ChunkProviderServer) sworld.getChunkProvider()).getChunkIfLoaded(x, z);
    if (loaded == null) {
        // load
        try {
            net.minecraft.server.v1_10_R1.Chunk chunk;
            chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader)).a(sworld, x, z);
            if (chunk != null) {
                chunk.setLastSaved(sworld.getTime());
                if (((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator != null) {
                    ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.recreateStructures(chunk, x, z);
                }
            }
            if (chunk != null) {
                ((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
                postToMainThread(() -> {
                    chunk.addEntities();
                });
                loaded = chunk;
            }
        } catch (Exception e) {
        }
    }
    if (loaded == null) {
        // generate new chunk
        ChunkRegionLoader loader = null;
        if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader) instanceof ChunkRegionLoader) {
            loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader);
        }
        if (loader != null && loader.chunkExists(sworld, x, z)) {
            loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.getChunkProvider(), x, z);
        } else {
            loaded = ((ChunkProviderServer) sworld.getChunkProvider()).originalGetChunkAt(x, z);
        }
        loaded = ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.getOrCreateChunk(x, z);
        ((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
    }
    return loaded;
}
Also used : ChunkProviderServer(net.minecraft.server.v1_10_R1.ChunkProviderServer) WorldServer(net.minecraft.server.v1_10_R1.WorldServer) ChunkRegionLoader(net.minecraft.server.v1_10_R1.ChunkRegionLoader) CraftWorld(org.bukkit.craftbukkit.v1_10_R1.CraftWorld)

Example 100 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project TheAPI by TheDevTec.

the class v1_11_R1 method getChunk.

@Override
public Object getChunk(World world, int x, int z) {
    WorldServer sworld = ((CraftWorld) world).getHandle();
    net.minecraft.server.v1_11_R1.Chunk loaded = ((ChunkProviderServer) sworld.getChunkProvider()).getChunkIfLoaded(x, z);
    if (loaded == null) {
        // load
        try {
            net.minecraft.server.v1_11_R1.Chunk chunk;
            chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader)).a(sworld, x, z);
            if (chunk != null) {
                chunk.setLastSaved(sworld.getTime());
                if (((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator != null) {
                    ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.recreateStructures(chunk, x, z);
                }
            }
            if (chunk != null) {
                ((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
                postToMainThread(() -> {
                    chunk.addEntities();
                });
                loaded = chunk;
            }
        } catch (Exception e) {
        }
    }
    if (loaded == null) {
        // generate new chunk
        ChunkRegionLoader loader = null;
        if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader) instanceof ChunkRegionLoader) {
            loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader);
        }
        if (loader != null && loader.chunkExists(sworld, x, z)) {
            loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.getChunkProvider(), x, z);
        } else {
            loaded = ((ChunkProviderServer) sworld.getChunkProvider()).originalGetChunkAt(x, z);
        }
        loaded = ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.getOrCreateChunk(x, z);
        ((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
    }
    return loaded;
}
Also used : ChunkProviderServer(net.minecraft.server.v1_11_R1.ChunkProviderServer) WorldServer(net.minecraft.server.v1_11_R1.WorldServer) ChunkRegionLoader(net.minecraft.server.v1_11_R1.ChunkRegionLoader) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)147 Location (org.bukkit.Location)131 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)111 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)103 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)95 BlockPos (net.minecraft.core.BlockPos)83 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)74 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)66 ItemStack (org.bukkit.inventory.ItemStack)61 Block (org.bukkit.block.Block)57 LivingEntity (org.bukkit.entity.LivingEntity)54 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)53 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)47 ArrayList (java.util.ArrayList)43 World (org.bukkit.World)41 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)39 Entity (org.bukkit.entity.Entity)39 Level (net.minecraft.world.level.Level)38 List (java.util.List)34 GameProfile (com.mojang.authlib.GameProfile)32