Search in sources :

Example 21 with CraftWorld

use of org.bukkit.craftbukkit.v1_18_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_9_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_9_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_9_R1.CraftWorld)

Example 22 with CraftWorld

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

Example 23 with CraftWorld

use of org.bukkit.craftbukkit.v1_18_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_11_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld)

Example 24 with CraftWorld

use of org.bukkit.craftbukkit.v1_18_R2.CraftWorld in project acidisland by tastybento.

the class NMSHandler method setFlowerPotBlock.

/* (non-Javadoc)
     * @see com.wasteofplastic.askyblock.nms.NMSAbstraction#setBlock(org.bukkit.block.Block, org.bukkit.inventory.ItemStack)
     */
@Override
public void setFlowerPotBlock(final Block block, final ItemStack itemStack) {
    if (block.getType().equals(Material.FLOWER_POT)) {
        Location loc = block.getLocation();
        CraftWorld cw = (CraftWorld) block.getWorld();
        BlockPosition bp = new BlockPosition(loc.getX(), loc.getY(), loc.getZ());
        TileEntityFlowerPot te = (TileEntityFlowerPot) cw.getHandle().getTileEntity(bp);
        // Bukkit.getLogger().info("Debug: flowerpot materialdata = " + (new ItemStack(potItem, 1,(short) potItemData).toString()));
        net.minecraft.server.v1_11_R1.ItemStack cis = CraftItemStack.asNMSCopy(itemStack);
        te.setContents(cis);
        te.update();
    }
}
Also used : BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) TileEntityFlowerPot(net.minecraft.server.v1_11_R1.TileEntityFlowerPot) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld) Location(org.bukkit.Location)

Example 25 with CraftWorld

use of org.bukkit.craftbukkit.v1_18_R2.CraftWorld in project acidisland by tastybento.

the class NMSHandler method setFlowerPotBlock.

/* (non-Javadoc)
     * @see com.wasteofplastic.askyblock.nms.NMSAbstraction#setBlock(org.bukkit.block.Block, org.bukkit.inventory.ItemStack)
     * Credis: Mister_Frans (THANK YOU VERY MUCH !)
     */
@Override
public void setFlowerPotBlock(Block block, ItemStack itemStack) {
    Location loc = block.getLocation();
    CraftWorld cw = (CraftWorld) block.getWorld();
    BlockPosition bp = new BlockPosition(loc.getX(), loc.getY(), loc.getZ());
    TileEntityFlowerPot te = (TileEntityFlowerPot) cw.getHandle().getTileEntity(bp);
    // Bukkit.getLogger().info("Debug: flowerpot materialdata = " + (new ItemStack(potItem, 1,(short) potItemData).toString()));
    net.minecraft.server.v1_8_R1.ItemStack cis = CraftItemStack.asNMSCopy(itemStack);
    te.a(cis.getItem(), cis.getData());
    te.update();
}
Also used : BlockPosition(net.minecraft.server.v1_8_R1.BlockPosition) TileEntityFlowerPot(net.minecraft.server.v1_8_R1.TileEntityFlowerPot) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld) Location(org.bukkit.Location)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)63 Location (org.bukkit.Location)56 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)42 ItemStack (org.bukkit.inventory.ItemStack)42 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)40 BlockPos (net.minecraft.core.BlockPos)36 Zombie (org.bukkit.entity.Zombie)32 LivingEntity (org.bukkit.entity.LivingEntity)29 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)28 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)28 ItemEntity (net.minecraft.world.entity.item.ItemEntity)27 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)26 HangingEntity (net.minecraft.world.entity.decoration.HangingEntity)25 FallingBlockEntity (net.minecraft.world.entity.item.FallingBlockEntity)25 FireworkRocketEntity (net.minecraft.world.entity.projectile.FireworkRocketEntity)25 SignBlockEntity (net.minecraft.world.level.block.entity.SignBlockEntity)25 Entity (org.bukkit.entity.Entity)25 HumanEntity (org.bukkit.entity.HumanEntity)25 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)23 CraftWorld (org.bukkit.craftbukkit.v1_9_R1.CraftWorld)17