Search in sources :

Example 36 with World

use of net.minecraft.server.v1_16_R2.World in project UltraCosmetics by iSach.

the class MorphElderGuardian method onEquip.

@Override
protected void onEquip() {
    super.onEquip();
    World world = ((CraftWorld) getPlayer().getWorld()).getHandle();
    customGuardian = new CustomGuardian(world);
    customEntities.add(customGuardian);
    customGuardian.check();
    Location location = getPlayer().getLocation();
    double x = location.getX();
    double y = location.getY();
    double z = location.getZ();
    customGuardian.setLocation(x, y, z, 0, 0);
    EntitySpawningManager.setBypass(true);
    world.addEntity(customGuardian);
    EntitySpawningManager.setBypass(false);
    getPlayer().setPassenger(customGuardian.getBukkitEntity());
    customGuardian.setInvisible(true);
}
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) CustomGuardian(be.isach.ultracosmetics.v1_12_R1.customentities.CustomGuardian) Location(org.bukkit.Location)

Example 37 with World

use of net.minecraft.server.v1_16_R2.World in project SimplePets by brainsynder-Dev.

the class SpawnUtil method spawn.

public IEntityPet spawn(Location l, IPet pet, String className) {
    try {
        World mcWorld = ((CraftWorld) l.getWorld()).getHandle();
        EntityTypes<?> types = EntityUtils.getType((className.equals("EntityControllerPet")) ? EntityWrapper.ZOMBIE : pet.getEntityType());
        EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(EntityTypes.class, World.class, IPet.class).newInstance(types, mcWorld, pet);
        customEntity.setInvisible(false);
        customEntity.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
        mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
        if (customEntity instanceof IEntityControllerPet) {
            if (pet.getPetType() instanceof ArmorStandDefault) {
                ArmorStand stand = EntityArmorStandPet.spawn(l, ((EntityControllerPet) customEntity));
                stand.setGravity(false);
                stand.setArms(true);
                stand.setCollidable(false);
                stand.setLeftLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setLeftArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            } else if (pet.getPetType() instanceof ShulkerDefault) {
                ArmorStand stand = EntityGhostStandPet.spawn(l, pet);
                stand.setGravity(false);
                stand.setCollidable(false);
                stand.setSmall(true);
                Shulker shulker = EntityShulkerPet.spawn(l, (EntityControllerPet) customEntity);
                shulker.setAI(false);
                shulker.setCollidable(false);
                ((CraftEntity) stand).getHandle().passengers.add(0, ((CraftEntity) shulker).getHandle());
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            }
        }
        return customEntity;
    } catch (Exception e) {
        e.printStackTrace();
        throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
    }
}
Also used : ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) CraftEntity(org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity) CraftWorld(org.bukkit.craftbukkit.v1_13_R2.CraftWorld) World(net.minecraft.server.v1_13_R2.World) Shulker(org.bukkit.entity.Shulker) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) EntityControllerPet(simplepets.brainsynder.nms.v1_13_R2.entities.list.EntityControllerPet) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) ArmorStand(org.bukkit.entity.ArmorStand) ArmorStandDefault(simplepets.brainsynder.pet.types.ArmorStandDefault) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) EulerAngle(org.bukkit.util.EulerAngle) CraftWorld(org.bukkit.craftbukkit.v1_13_R2.CraftWorld)

Example 38 with World

use of net.minecraft.server.v1_16_R2.World in project SimplePets by brainsynder-Dev.

the class SpawnUtil method spawn.

public IEntityPet spawn(Location l, IPet pet, String className) {
    try {
        World mcWorld = ((CraftWorld) l.getWorld()).getHandle();
        EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(World.class, IPet.class).newInstance(mcWorld, pet);
        customEntity.setInvisible(false);
        customEntity.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
        mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
        if (customEntity instanceof IEntityControllerPet) {
            if (pet.getPetType() instanceof ArmorStandDefault) {
                ArmorStand stand = EntityArmorStandPet.spawn(l, ((EntityControllerPet) customEntity));
                stand.setGravity(false);
                stand.setArms(true);
                stand.setCollidable(false);
                stand.setLeftLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setLeftArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                stand.setRightArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            } else if (pet.getPetType() instanceof ShulkerDefault) {
                ArmorStand stand = EntityGhostStandPet.spawn(l, pet);
                stand.setGravity(false);
                stand.setCollidable(false);
                stand.setSmall(true);
                Shulker shulker = EntityShulkerPet.spawn(l, (EntityControllerPet) customEntity);
                shulker.setAI(false);
                shulker.setCollidable(false);
                ((CraftEntity) stand).getHandle().passengers.add(0, ((CraftEntity) shulker).getHandle());
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            }
        }
        return customEntity;
    } catch (Exception e) {
        e.printStackTrace();
        throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
    }
}
Also used : ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) World(net.minecraft.server.v1_12_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) Shulker(org.bukkit.entity.Shulker) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) EntityControllerPet(simplepets.brainsynder.nms.v1_12_R1.entities.list.EntityControllerPet) ArmorStand(org.bukkit.entity.ArmorStand) ArmorStandDefault(simplepets.brainsynder.pet.types.ArmorStandDefault) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) EulerAngle(org.bukkit.util.EulerAngle) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 39 with World

use of net.minecraft.server.v1_16_R2.World in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final NBTTagCompound tag = new NBTTagCompound();
    tag.setString("id", entityID);
    final World world = ((CraftWorld) w).getHandle();
    final Entity entity = EntityTypes.a(tag, world);
    if (entity == null) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.setPositionRotation(x, y, z, yaw, 0);
    world.addEntity(entity, SpawnReason.SPAWNER_EGG);
    final PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(entity, (byte) yaw);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(rotation);
}
Also used : Entity(net.minecraft.server.v1_12_R1.Entity) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_12_R1.PacketPlayOutEntityHeadRotation) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) 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 40 with World

use of net.minecraft.server.v1_16_R2.World in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@SuppressWarnings("resource")
@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final NBTTagCompound tag = new NBTTagCompound();
    tag.setString("id", entityID);
    final World world = ((CraftWorld) w).getHandle();
    final Entity entity = EntityTypes.a(tag, world);
    if (entity == null) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.setPositionRotation(x, y, z, yaw, 0);
    world.addEntity(entity, SpawnReason.SPAWNER_EGG);
    final PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(entity, (byte) yaw);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(rotation);
}
Also used : Entity(net.minecraft.server.v1_13_R2.Entity) NBTTagCompound(net.minecraft.server.v1_13_R2.NBTTagCompound) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_13_R2.PacketPlayOutEntityHeadRotation) CraftPlayer(org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer) CraftWorld(org.bukkit.craftbukkit.v1_13_R2.CraftWorld) World(net.minecraft.server.v1_13_R2.World) CraftWorld(org.bukkit.craftbukkit.v1_13_R2.CraftWorld)

Aggregations

Location (org.bukkit.Location)27 World (net.minecraft.server.v1_16_R3.World)16 World (net.minecraft.server.v1_12_R1.World)15 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)15 World (net.minecraft.server.v1_8_R3.World)14 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)14 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)14 ArrayList (java.util.ArrayList)12 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)11 List (java.util.List)10 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)10 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)10 WildLoadersPlugin (com.bgsoftware.wildloaders.WildLoadersPlugin)8 Hologram (com.bgsoftware.wildloaders.api.holograms.Hologram)8 ChunkLoader (com.bgsoftware.wildloaders.api.loaders.ChunkLoader)8 ChunkLoaderNPC (com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC)8 ITileEntityChunkLoader (com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader)8 WChunkLoader (com.bgsoftware.wildloaders.loaders.WChunkLoader)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8