Search in sources :

Example 16 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R1.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_7_R4.CraftWorld) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_7_R4.CraftWorld)

Example 17 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R1.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_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld)

Example 18 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R1.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_R1.CraftWorld) CraftItemStack(org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld)

Example 19 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R1.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 : CraftWorld(org.bukkit.craftbukkit.v1_8_R2.CraftWorld) World(net.minecraft.server.v1_8_R2.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R2.CraftWorld)

Example 20 with CraftWorld

use of org.bukkit.craftbukkit.v1_16_R1.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 != ItemStack.a) {
            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_11_R1.CraftWorld) CraftItemStack(org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)133 Location (org.bukkit.Location)118 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)100 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)77 BlockPos (net.minecraft.core.BlockPos)69 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)69 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)57 ItemStack (org.bukkit.inventory.ItemStack)56 LivingEntity (org.bukkit.entity.LivingEntity)51 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)50 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)48 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)43 Entity (org.bukkit.entity.Entity)39 ArrayList (java.util.ArrayList)38 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)38 World (org.bukkit.World)32 Zombie (org.bukkit.entity.Zombie)32 ItemEntity (net.minecraft.world.entity.item.ItemEntity)29 List (java.util.List)28 UUID (java.util.UUID)28