Search in sources :

Example 51 with CraftWorld

use of org.bukkit.craftbukkit.v1_9_R2.CraftWorld in project MyPet by xXKeyleXx.

the class EntityRegistry method createMinecraftEntity.

@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
    EntityMyPet petEntity = null;
    Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
    World world = ((CraftWorld) bukkitWorld).getHandle();
    try {
        Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
        Object obj = ctor.newInstance(world, pet);
        if (obj instanceof EntityMyPet) {
            petEntity = (EntityMyPet) obj;
        }
    } catch (Exception e) {
        MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!");
        e.printStackTrace();
    }
    return petEntity;
}
Also used : World(net.minecraft.server.v1_12_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 52 with CraftWorld

use of org.bukkit.craftbukkit.v1_9_R2.CraftWorld in project MyPet by xXKeyleXx.

the class EntityMySnowman method addAirBlocksInBB.

private void addAirBlocksInBB(org.bukkit.World bukkitWorld, AxisAlignedBB axisalignedbb) {
    int minX = MathHelper.floor(axisalignedbb.a - 0.1);
    int maxX = MathHelper.floor(axisalignedbb.d + 1.1D);
    int minY = MathHelper.floor(axisalignedbb.b - 0.1);
    int maxY = MathHelper.floor(axisalignedbb.e + 1.1D);
    int minZ = MathHelper.floor(axisalignedbb.c - 0.1);
    int maxZ = MathHelper.floor(axisalignedbb.f + 1.1D);
    WorldServer world = ((CraftWorld) bukkitWorld).getHandle();
    for (int x = minX; x < maxX; x++) {
        for (int z = minZ; z < maxZ; z++) {
            if (bukkitWorld.isChunkLoaded(x, z)) {
                for (int y = minY - 1; y < maxY; y++) {
                    Block block = world.getType(new BlockPosition(x, y, z)).getBlock();
                    if (block == Blocks.AIR) {
                        snowMap.put(new Location(bukkitWorld, x, y, z), 10);
                    }
                }
            }
        }
    }
}
Also used : CraftWorld(org.bukkit.craftbukkit.v1_8_R2.CraftWorld) Location(org.bukkit.Location)

Example 53 with CraftWorld

use of org.bukkit.craftbukkit.v1_9_R2.CraftWorld in project MyPet by xXKeyleXx.

the class CustomInventory method dropContentAt.

public void dropContentAt(Location loc) {
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    for (int i = 0; i < this.getSize(); i++) {
        ItemStack is = this.splitWithoutUpdate(i);
        if (is != null) {
            is = is.cloneItemStack();
            EntityItem itemEntity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), is);
            itemEntity.pickupDelay = 20;
            world.addEntity(itemEntity);
        }
    }
}
Also used : CraftWorld(org.bukkit.craftbukkit.v1_8_R2.CraftWorld) CraftItemStack(org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_8_R2.CraftWorld)

Example 54 with CraftWorld

use of org.bukkit.craftbukkit.v1_9_R2.CraftWorld in project MyPet by xXKeyleXx.

the class EntityRegistry method createMinecraftEntity.

@Override
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
    EntityMyPet petEntity = null;
    Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType());
    World world = ((CraftWorld) bukkitWorld).getHandle();
    try {
        Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class);
        Object obj = ctor.newInstance(world, pet);
        if (obj instanceof EntityMyPet) {
            petEntity = (EntityMyPet) obj;
        }
    } catch (Exception e) {
        MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!");
        e.printStackTrace();
    }
    return petEntity;
}
Also used : World(net.minecraft.server.v1_8_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 55 with CraftWorld

use of org.bukkit.craftbukkit.v1_9_R2.CraftWorld in project MyPet by xXKeyleXx.

the class CustomInventory method dropContentAt.

public void dropContentAt(Location loc) {
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    for (int i = 0; i < this.getSize(); i++) {
        ItemStack is = this.splitWithoutUpdate(i);
        if (is != null) {
            is = is.cloneItemStack();
            EntityItem itemEntity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), is);
            itemEntity.pickupDelay = 20;
            world.addEntity(itemEntity);
        }
    }
}
Also used : CraftWorld(org.bukkit.craftbukkit.v1_9_R1.CraftWorld) CraftItemStack(org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_9_R1.CraftWorld)

Aggregations

Location (org.bukkit.Location)13 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)10 CraftWorld (org.bukkit.craftbukkit.v1_10_R1.CraftWorld)9 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)9 CraftWorld (org.bukkit.craftbukkit.v1_9_R2.CraftWorld)9 CraftWorld (org.bukkit.craftbukkit.v1_7_R4.CraftWorld)5 CraftWorld (org.bukkit.craftbukkit.v1_8_R1.CraftWorld)5 CraftWorld (org.bukkit.craftbukkit.v1_8_R2.CraftWorld)5 GameProfile (com.mojang.authlib.GameProfile)4 Property (com.mojang.authlib.properties.Property)4 BigInteger (java.math.BigInteger)4 MessageDigest (java.security.MessageDigest)4 UUID (java.util.UUID)4 PlayerProfile (net.aufdemrand.denizen.nms.util.PlayerProfile)4 CraftWorld (org.bukkit.craftbukkit.v1_9_R1.CraftWorld)4 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)3 Scoreboard (org.bukkit.scoreboard.Scoreboard)3 Team (org.bukkit.scoreboard.Team)3 Field (java.lang.reflect.Field)2 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)2