Search in sources :

Example 1 with IEntityHorsePet

use of simplepets.brainsynder.api.entity.passive.IEntityHorsePet in project SimplePets by brainsynder-Dev.

the class EntityPet method e.

/**
 * This method handles the Pet riding
 *
 * NMS Translations (Thanks Forge):
 *   a(float,float,float) = travel(float,float,float)
 *   aF = prevLimbSwingAmount
 *   aG = limbSwingAmount
 *   aR = jumpMovementFactor
 *
 * Search for: !this.isInWater() || this instanceof EntityHuman && ((EntityHuman)this).abilities.isFlying
 * Class: {@link net.minecraft.server.v1_15_R1.EntityLiving}
 */
@Override
public // public void a(float strafe, float vertical, float forward) {
void e(Vec3D vec3D) {
    double strafe = vec3D.x;
    double vertical = vec3D.y;
    double forward = vec3D.z;
    if (passengers == null) {
        this.H = (float) 0.5;
        this.aM = (float) 0.02;
        super.a(vec3D);
    } else {
        if (this.pet == null) {
            this.H = (float) 0.5;
            this.aM = (float) 0.02;
            super.e(vec3D);
            return;
        }
        if (!isOwnerRiding()) {
            this.H = (float) 0.5;
            this.aM = (float) 0.02;
            super.e(vec3D);
            return;
        }
        EntityPlayer owner = ((CraftPlayer) getOwner()).getHandle();
        if (fieldAccessor != null) {
            if (fieldAccessor.hasField(owner)) {
                if (fieldAccessor.get(owner)) {
                    if (isOnGround(this)) {
                        setMot(getMot().x, 0.5, getMot().z);
                    } else {
                        if (pet.getPetType().canFly(pet.getOwner())) {
                            setMot(getMot().x, 0.3, getMot().z);
                        }
                    }
                }
            }
        }
        this.yaw = owner.yaw;
        this.lastYaw = this.yaw;
        this.pitch = (float) (owner.pitch * 0.5);
        this.setYawPitch(this.yaw, this.pitch);
        this.aL = this.aD = this.yaw;
        this.H = 1.0F;
        strafe = (float) (owner.aZ * 0.5);
        forward = owner.bb;
        if (forward <= 0.0) {
            forward *= 0.25;
        }
        Vec3D vec = new Vec3D(strafe, vertical, forward);
        // if (!(this instanceof IEntityHorsePet)) vec3D.vec3D.x *= 0.75;
        this.o((float) getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue());
        super.e(vec);
        if (!world.isClientSide) {
            if (this instanceof IEntityHorsePet) {
                Location location = getBukkitEntity().getLocation();
                setPosition(location.getX(), location.getY(), location.getZ());
                PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(this);
                owner.playerConnection.sendPacket(packet);
                if (forward > 0.0F) {
                    float f = MathHelper.sin((float) (this.yaw * 0.017453292));
                    float f1 = MathHelper.cos((float) (this.yaw * 0.017453292));
                    // This would be 0 anyways?
                    setMot(getMot().add((-0.4 * f * 0.0), 0, (0.4 * f1 * 0.0)));
                }
                // this.prevLimbSwingAmount = this.limbSwingAmount;
                this.aC = this.aD;
                double d0 = this.locX() - this.lastX;
                double d1 = this.locZ() - this.lastZ;
                float f5 = (float) (MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0);
                if (f5 > 1.0) {
                    f5 = (float) 1.0;
                }
                // this.limbSwingAmount += (f5 - this.limbSwingAmount) * 0.4F;
                this.aD += (f5 - this.aD) * 0.4;
                // this.limbSwing += this.limbSwingAmount;
                this.aE += this.aD;
            }
        }
        CraftEntity bukkitEntity = getBukkitEntity();
        if (pet == null) {
            if (bukkitEntity != null)
                bukkitEntity.remove();
            return;
        }
        if (getOwner() == null) {
            if (bukkitEntity != null)
                bukkitEntity.remove();
            return;
        }
        try {
            PetMoveEvent event = new PetMoveEvent(this, PetMoveEvent.Cause.RIDE);
            Bukkit.getServer().getPluginManager().callEvent(event);
        } catch (Throwable ignored) {
        }
    }
}
Also used : PetMoveEvent(simplepets.brainsynder.api.event.pet.PetMoveEvent) CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet) Location(org.bukkit.Location)

Example 2 with IEntityHorsePet

use of simplepets.brainsynder.api.entity.passive.IEntityHorsePet in project SimplePets by brainsynder-Dev.

the class HorseColor method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder item = null;
    if (entityPet instanceof IEntityHorsePet) {
        IEntityHorsePet var = (IEntityHorsePet) entityPet;
        HorseColorType typeID = HorseColorType.WHITE;
        if (var.getColor() != null) {
            typeID = var.getColor();
        }
        switch(typeID) {
            case BLACK:
                item = type.getDataItemByName("horsecolor", 0);
                break;
            case CHESTNUT:
                item = type.getDataItemByName("horsecolor", 1);
                break;
            case CREAMY:
                item = type.getDataItemByName("horsecolor", 2);
                break;
            case BROWN:
                item = type.getDataItemByName("horsecolor", 3);
                break;
            case DARKBROWN:
                item = type.getDataItemByName("horsecolor", 4);
                break;
            case GRAY:
                item = type.getDataItemByName("horsecolor", 5);
                break;
            case WHITE:
                item = type.getDataItemByName("horsecolor", 6);
                break;
        }
    }
    return item;
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) HorseColorType(simplepets.brainsynder.wrapper.HorseColorType) IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet)

Example 3 with IEntityHorsePet

use of simplepets.brainsynder.api.entity.passive.IEntityHorsePet in project SimplePets by brainsynder-Dev.

the class HorseArmor method onLeftClick.

@Override
public void onLeftClick() {
    if (entityPet instanceof IEntityHorsePet) {
        IEntityHorsePet var = (IEntityHorsePet) entityPet;
        int typeID = 0;
        if (var.getArmor() != null) {
            typeID = var.getArmor().getId();
        }
        if (typeID == 3) {
            typeID = 0;
        } else {
            typeID++;
        }
        var.setArmor(HorseArmorType.fromId(typeID));
    }
}
Also used : IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet)

Example 4 with IEntityHorsePet

use of simplepets.brainsynder.api.entity.passive.IEntityHorsePet in project SimplePets by brainsynder-Dev.

the class HorseArmor method onRightClick.

@Override
public void onRightClick() {
    if (entityPet instanceof IEntityHorsePet) {
        IEntityHorsePet var = (IEntityHorsePet) entityPet;
        int typeID = 0;
        if (var.getArmor() != null) {
            typeID = var.getArmor().getId();
        }
        if (typeID == 0) {
            typeID = 3;
        } else {
            typeID--;
        }
        var.setArmor(HorseArmorType.fromId(typeID));
    }
}
Also used : IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet)

Example 5 with IEntityHorsePet

use of simplepets.brainsynder.api.entity.passive.IEntityHorsePet in project SimplePets by brainsynder-Dev.

the class HorseArmor method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder item = null;
    if (entityPet instanceof IEntityHorsePet) {
        IEntityHorsePet var = (IEntityHorsePet) entityPet;
        int typeID = 0;
        if (var.getArmor() != null) {
            typeID = var.getArmor().getId();
        }
        switch(typeID) {
            case 0:
                item = type.getDataItemByName("horsearmor", 0);
                break;
            case 1:
                item = type.getDataItemByName("horsearmor", 1);
                break;
            case 2:
                item = type.getDataItemByName("horsearmor", 2);
                break;
            case 3:
                item = type.getDataItemByName("horsearmor", 3);
                break;
        }
    }
    return item;
}
Also used : ItemBuilder(simple.brainsynder.api.ItemBuilder) IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet)

Aggregations

IEntityHorsePet (simplepets.brainsynder.api.entity.passive.IEntityHorsePet)15 Location (org.bukkit.Location)6 PetMoveEvent (simplepets.brainsynder.api.event.pet.PetMoveEvent)6 ItemBuilder (simple.brainsynder.api.ItemBuilder)3 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer)1 CraftEntity (org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity)1 CraftPlayer (org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer)1 CraftEntity (org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity)1 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)1 HorseColorType (simplepets.brainsynder.wrapper.HorseColorType)1 HorseStyleType (simplepets.brainsynder.wrapper.HorseStyleType)1