Search in sources :

Example 81 with CraftWorld

use of org.bukkit.craftbukkit.v1_8_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method doRandomTick.

@Override
public void doRandomTick(Location location) {
    BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    Chunk nmsChunk = ((CraftChunk) location.getChunk()).getHandle();
    IBlockData nmsBlock = nmsChunk.getType(pos);
    WorldServer nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (nmsBlock.isTicking()) {
        nmsBlock.b(nmsWorld, pos, nmsWorld.random);
    }
    Fluid fluid = nmsBlock.getFluid();
    if (fluid.f()) {
        fluid.b(nmsWorld, pos, nmsWorld.random);
    }
}
Also used : CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk)

Example 82 with CraftWorld

use of org.bukkit.craftbukkit.v1_8_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class CustomEntityHelperImpl method spawnItemProjectile.

@Override
public ItemProjectile spawnItemProjectile(Location location, ItemStack itemStack) {
    CraftWorld world = (CraftWorld) location.getWorld();
    EntityItemProjectileImpl entity = new EntityItemProjectileImpl(world.getHandle(), location, CraftItemStack.asNMSCopy(itemStack));
    world.getHandle().addEntity(entity);
    return entity.getBukkitEntity();
}
Also used : EntityItemProjectileImpl(com.denizenscript.denizen.nms.v1_16.impl.entities.EntityItemProjectileImpl) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 83 with CraftWorld

use of org.bukkit.craftbukkit.v1_8_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class ChunkHelperImpl method changeChunkServerThread.

@Override
public void changeChunkServerThread(World world) {
    if (DenizenCoreImplementation.tagThread == null) {
        return;
    }
    if (resetServerThread != null) {
        return;
    }
    ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
    ServerChunkCache provider = nmsWorld.getChunkProvider();
    try {
        resetServerThread = (Thread) chunkProviderServerThreadField.get(provider);
        chunkProviderServerThreadFieldSetter.invoke(provider, Thread.currentThread());
        worldThreadFieldSetter.invoke(nmsWorld, Thread.currentThread());
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) ServerChunkCache(net.minecraft.server.level.ServerChunkCache) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 84 with CraftWorld

use of org.bukkit.craftbukkit.v1_8_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class FishingHelperImpl method getResult.

@Override
public org.bukkit.inventory.ItemStack getResult(FishHook fishHook, CatchType catchType) {
    ItemStack result = null;
    FishingHook nmsHook = ((CraftFishHook) fishHook).getHandle();
    if (catchType == CatchType.DEFAULT) {
        float f = ((CraftWorld) fishHook.getWorld()).getHandle().random.nextFloat();
        int i = EnchantmentHelper.getMobLooting(nmsHook.getPlayerOwner());
        int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.FISHING_LUCK, nmsHook.getPlayerOwner());
        float f1 = 0.1F - (float) i * 0.025F - (float) j * 0.01F;
        float f2 = 0.05F + (float) i * 0.01F - (float) j * 0.01F;
        f1 = Mth.clamp(f1, 0.0F, 1.0F);
        f2 = Mth.clamp(f2, 0.0F, 1.0F);
        if (f < f1) {
            result = catchRandomJunk(nmsHook);
        } else {
            f -= f1;
            if (f < f2) {
                result = catchRandomTreasure(nmsHook);
            } else {
                result = catchRandomFish(nmsHook);
            }
        }
    } else if (catchType == CatchType.JUNK) {
        result = catchRandomJunk(nmsHook);
    } else if (catchType == CatchType.TREASURE) {
        result = catchRandomTreasure(nmsHook);
    } else if (catchType == CatchType.FISH) {
        result = catchRandomFish(nmsHook);
    }
    if (result != null) {
        return CraftItemStack.asBukkitCopy(result);
    } else {
        return null;
    }
}
Also used : CraftFishHook(org.bukkit.craftbukkit.v1_17_R1.entity.CraftFishHook) ItemStack(net.minecraft.world.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack) FishingHook(net.minecraft.world.entity.projectile.FishingHook) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 85 with CraftWorld

use of org.bukkit.craftbukkit.v1_8_R1.CraftWorld in project Denizen-For-Bukkit by DenizenScript.

the class Handler method getBiomes.

@Override
public List<BiomeNMS> getBiomes(World world) {
    ServerLevel level = ((CraftWorld) world).getHandle();
    ArrayList<BiomeNMS> output = new ArrayList<>();
    for (Map.Entry<ResourceKey<Biome>, Biome> pair : level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).entrySet()) {
        output.add(new BiomeNMSImpl(level, pair.getKey().location().toString()));
    }
    return output;
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) Biome(net.minecraft.world.level.biome.Biome) ArrayList(java.util.ArrayList) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) Map(java.util.Map) ResourceKey(net.minecraft.resources.ResourceKey) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl)

Aggregations

Location (org.bukkit.Location)55 Zombie (org.bukkit.entity.Zombie)32 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)28 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)28 ItemStack (org.bukkit.inventory.ItemStack)27 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)23 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)19 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)17 CraftWorld (org.bukkit.craftbukkit.v1_9_R1.CraftWorld)17 ServerLevel (net.minecraft.server.level.ServerLevel)16 CraftWorld (org.bukkit.craftbukkit.v1_10_R1.CraftWorld)16 GameProfile (com.mojang.authlib.GameProfile)11 UUID (java.util.UUID)11 Scoreboard (org.bukkit.scoreboard.Scoreboard)11 Team (org.bukkit.scoreboard.Team)11 CraftWorld (org.bukkit.craftbukkit.v1_9_R2.CraftWorld)8 BabyZombie (pl.plajer.villagedefense3.creatures.v1_9_R1.BabyZombie)8 FastZombie (pl.plajer.villagedefense3.creatures.v1_9_R1.FastZombie)8 HardZombie (pl.plajer.villagedefense3.creatures.v1_9_R1.HardZombie)8 TankerZombie (pl.plajer.villagedefense3.creatures.v1_9_R1.TankerZombie)8