Search in sources :

Example 6 with ArmorStandDefault

use of simplepets.brainsynder.pet.types.ArmorStandDefault 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);
                stand.setPassenger(shulker);
                ((IEntityControllerPet) customEntity).setDisplayEntity(stand);
            }
        }
        return customEntity;
    } catch (Exception e) {
        throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
    }
}
Also used : IEntityPet(simplepets.brainsynder.api.entity.IEntityPet) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) EntityControllerPet(simplepets.brainsynder.nms.v1_11_R1.entities.list.EntityControllerPet) ArmorStand(org.bukkit.entity.ArmorStand) ArmorStandDefault(simplepets.brainsynder.pet.types.ArmorStandDefault) ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) World(net.minecraft.server.v1_11_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld) EulerAngle(org.bukkit.util.EulerAngle) Shulker(org.bukkit.entity.Shulker) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld) SimplePetsException(simplepets.brainsynder.errors.SimplePetsException) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet)

Aggregations

ArmorStand (org.bukkit.entity.ArmorStand)6 Shulker (org.bukkit.entity.Shulker)6 EulerAngle (org.bukkit.util.EulerAngle)6 IEntityControllerPet (simplepets.brainsynder.api.entity.IEntityControllerPet)6 IEntityPet (simplepets.brainsynder.api.entity.IEntityPet)6 SimplePetsException (simplepets.brainsynder.errors.SimplePetsException)6 ArmorStandDefault (simplepets.brainsynder.pet.types.ArmorStandDefault)6 ShulkerDefault (simplepets.brainsynder.pet.types.ShulkerDefault)6 World (net.minecraft.server.v1_11_R1.World)1 World (net.minecraft.server.v1_12_R1.World)1 World (net.minecraft.server.v1_13_R1.World)1 World (net.minecraft.server.v1_13_R2.World)1 World (net.minecraft.server.v1_14_R1.World)1 World (net.minecraft.server.v1_15_R1.World)1 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)1 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)1 CraftWorld (org.bukkit.craftbukkit.v1_13_R1.CraftWorld)1 CraftEntity (org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity)1 CraftWorld (org.bukkit.craftbukkit.v1_13_R2.CraftWorld)1