Search in sources :

Example 6 with EntityControllerPet

use of simplepets.brainsynder.nms.v1_11_R1.entities.list.EntityControllerPet 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)

Example 7 with EntityControllerPet

use of simplepets.brainsynder.nms.v1_11_R1.entities.list.EntityControllerPet in project SimplePets by brainsynder-Dev.

the class EntityPet method repeatTask.

public void repeatTask() {
    if (pet == null)
        return;
    if (this instanceof IFlyablePet) {
        if (pet.isVehicle()) {
            if (floatDown) {
                if (!this.onGround && this.motY < 0.0D) {
                    this.motY *= 0.4;
                }
            }
        }
    }
    if (pet.getOwner() != null) {
        Player p = pet.getOwner();
        if (((CraftPlayer) p).getHandle().isInvisible() != this.isInvisible()) {
            this.setInvisible(!this.isInvisible());
            if (isInvisible()) {
                if (this instanceof IEntityControllerPet) {
                    ((EntityControllerPet) this).getVisibleEntity().getEntity().setGlowing(true);
                } else {
                    glowing = true;
                }
            } else {
                if (this instanceof IEntityControllerPet) {
                    ((EntityControllerPet) this).getVisibleEntity().getEntity().setGlowing(false);
                } else {
                    glowing = false;
                }
            }
        }
        if (pet.isHat()) {
            this.lastYaw = this.yaw = p.getLocation().getYaw();
        }
        double current = getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
        if (isOwnerRiding()) {
            if (current != rideSpeed)
                getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(rideSpeed);
        } else {
            if (current != walkSpeed)
                getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(walkSpeed);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet) EntityControllerPet(simplepets.brainsynder.nms.v1_11_R1.entities.list.EntityControllerPet) IFlyablePet(simplepets.brainsynder.api.entity.misc.IFlyablePet) CraftPlayer(org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer) IEntityControllerPet(simplepets.brainsynder.api.entity.IEntityControllerPet)

Aggregations

IEntityControllerPet (simplepets.brainsynder.api.entity.IEntityControllerPet)7 ArmorStand (org.bukkit.entity.ArmorStand)6 Shulker (org.bukkit.entity.Shulker)6 EulerAngle (org.bukkit.util.EulerAngle)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 EntityControllerPet (simplepets.brainsynder.nms.v1_11_R1.entities.list.EntityControllerPet)2 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 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)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