Search in sources :

Example 86 with CraftWorld

use of org.bukkit.craftbukkit.v1_18_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 && CraftMagicNumbers.getMaterial(is.getItem()) != org.bukkit.Material.AIR) {
            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_R3.CraftWorld) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 87 with CraftWorld

use of org.bukkit.craftbukkit.v1_18_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 + Util.getClassName(entityClass) + "(" + pet.getPetType() + ") is no valid MyPet(Entity)!");
        e.printStackTrace();
    }
    return petEntity;
}
Also used : CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld) World(net.minecraft.server.v1_9_R2.World) CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld)

Example 88 with CraftWorld

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

the class PlatformHelper method strikeLightning.

@Override
public void strikeLightning(Location loc, float distance) {
    ServerLevel world = ((CraftWorld) loc.getWorld()).getHandle();
    LightningBolt lightning = new LightningBolt(EntityType.LIGHTNING_BOLT, world);
    lightning.setVisualOnly(true);
    lightning.moveTo(loc.getX(), loc.getY(), loc.getZ(), 0.0F, 0.0F);
    /*world.getCraftServer()
                .getServer()
                .getPlayerList()
                .broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(),
                        new ClientboundAddEntityPacket(lightning));
        world.getCraftServer()
                .getServer()
                .getPlayerList()
                .broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(),
                        new ClientboundSoundPacket(SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, loc.getX(), loc.getY(), loc.getZ(), distance, 1F));
        */
    // Thank you wrong mappings for this workaround
    DedicatedServer server = world.getCraftServer().getServer();
    Method getPlayerListReflect = ReflectionUtil.getMethod(DedicatedServer.class, "getPlayerList");
    try {
        DedicatedPlayerList playerList = (DedicatedPlayerList) getPlayerListReflect.invoke(server, null);
        playerList.broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(), new ClientboundAddEntityPacket(lightning));
        playerList.broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(), new ClientboundSoundPacket(SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, loc.getX(), loc.getY(), loc.getZ(), distance, 1F));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) LightningBolt(net.minecraft.world.entity.LightningBolt) ClientboundAddEntityPacket(net.minecraft.network.protocol.game.ClientboundAddEntityPacket) DedicatedPlayerList(net.minecraft.server.dedicated.DedicatedPlayerList) DedicatedServer(net.minecraft.server.dedicated.DedicatedServer) Method(java.lang.reflect.Method) ClientboundSoundPacket(net.minecraft.network.protocol.game.ClientboundSoundPacket) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) InvocationTargetException(java.lang.reflect.InvocationTargetException) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException)

Example 89 with CraftWorld

use of org.bukkit.craftbukkit.v1_18_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());
    Level world = ((CraftWorld) bukkitWorld).getHandle();
    try {
        Constructor<?> ctor = entityClass.getConstructor(Level.class, MyPet.class);
        Object obj = ctor.newInstance(world, pet);
        if (obj instanceof EntityMyPet) {
            petEntity = (EntityMyPet) obj;
        }
    } catch (Exception e) {
        MyPetApi.getLogger().info(ChatColor.RED + Util.getClassName(entityClass) + "(" + pet.getPetType() + ") is no valid MyPet(Entity)!");
        e.printStackTrace();
    }
    return petEntity;
}
Also used : Level(net.minecraft.world.level.Level) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 90 with CraftWorld

use of org.bukkit.craftbukkit.v1_18_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());
    Level world = ((CraftWorld) bukkitWorld).getHandle();
    try {
        Constructor<?> ctor = entityClass.getConstructor(Level.class, MyPet.class);
        Object obj = ctor.newInstance(world, pet);
        if (obj instanceof EntityMyPet) {
            petEntity = (EntityMyPet) obj;
        }
    } catch (Exception e) {
        MyPetApi.getLogger().info(ChatColor.RED + Util.getClassName(entityClass) + "(" + pet.getPetType() + ") is no valid MyPet(Entity)!");
        e.printStackTrace();
    }
    return petEntity;
}
Also used : Level(net.minecraft.world.level.Level) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

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)22 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)20 ServerLevel (net.minecraft.server.level.ServerLevel)18 CraftWorld (org.bukkit.craftbukkit.v1_9_R1.CraftWorld)17 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