Search in sources :

Example 6 with IEntityHorsePet

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

the class HorseStyle method getItem.

@Override
public ItemBuilder getItem() {
    ItemBuilder item = type.getDataItemByName("horsestyle", 0);
    if (entityPet instanceof IEntityHorsePet) {
        IEntityHorsePet var = (IEntityHorsePet) entityPet;
        HorseStyleType typeID = HorseStyleType.NONE;
        if (var.getStyle() != null) {
            typeID = var.getStyle();
        }
        switch(typeID) {
            case NONE:
                item = type.getDataItemByName("horsestyle", 0);
                break;
            case BLACK_DOTS:
                item = type.getDataItemByName("horsestyle", 1);
                break;
            case WHITE_DOTS:
                item = type.getDataItemByName("horsestyle", 2);
                break;
            case WHITEFIELD:
                item = type.getDataItemByName("horsestyle", 3);
                break;
            case WHITE:
                item = type.getDataItemByName("horsestyle", 4);
                break;
        }
    }
    return item;
}
Also used : HorseStyleType(simplepets.brainsynder.wrapper.HorseStyleType) ItemBuilder(simple.brainsynder.api.ItemBuilder) IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet)

Example 7 with IEntityHorsePet

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

the class HorseStyle method onRightClick.

@Override
public void onRightClick() {
    if (entityPet instanceof IEntityHorsePet) {
        IEntityHorsePet var = (IEntityHorsePet) entityPet;
        int typeID = 0;
        if (var.getStyle() != null) {
            typeID = var.getStyle().getId();
        }
        if (typeID == 0) {
            typeID = 4;
        } else {
            typeID--;
        }
        var.setStyle(HorseStyleType.getByID(typeID));
    }
}
Also used : IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet)

Example 8 with IEntityHorsePet

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

the class HorseStyle method onLeftClick.

@Override
public void onLeftClick() {
    if (entityPet instanceof IEntityHorsePet) {
        IEntityHorsePet var = (IEntityHorsePet) entityPet;
        int typeID = 0;
        if (var.getStyle() != null) {
            typeID = var.getStyle().getId();
        }
        if (typeID == 4) {
            typeID = 0;
        } else {
            typeID++;
        }
        var.setStyle(HorseStyleType.getByID(typeID));
    }
}
Also used : IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet)

Example 9 with IEntityHorsePet

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

the class EntityPet method a.

/**
 * 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: EntityLiving
 */
@Override
public void a(float strafe, float vertical, float forward) {
    if (passengers == null) {
        this.Q = (float) 0.5;
        this.aU = (float) 0.02;
        super.a(strafe, vertical, forward);
    } else {
        if (this.pet == null) {
            this.Q = (float) 0.5;
            this.aU = (float) 0.02;
            super.a(strafe, vertical, forward);
            return;
        }
        if (!isOwnerRiding()) {
            this.Q = (float) 0.5;
            this.aU = (float) 0.02;
            super.a(strafe, vertical, forward);
            return;
        }
        EntityPlayer owner = ((CraftPlayer) getOwner()).getHandle();
        if (fieldAccessor != null) {
            if (fieldAccessor.hasField(owner)) {
                if (fieldAccessor.get(owner)) {
                    if (isOnGround(this)) {
                        this.motY = 0.5;
                    } else {
                        if (pet.getPetType().canFly(pet.getOwner())) {
                            this.motY = 0.3;
                        }
                    }
                }
            }
        }
        this.yaw = owner.yaw;
        this.lastYaw = this.yaw;
        this.pitch = (float) (owner.pitch * 0.5);
        this.setYawPitch(this.yaw, this.pitch);
        this.aR = this.aP = this.yaw;
        this.Q = 1.0F;
        strafe = (float) (owner.bh * 0.5);
        forward = owner.bj;
        if (forward <= 0.0) {
            forward *= 0.25;
        }
        if (!(this instanceof IEntityHorsePet))
            strafe *= 0.75;
        this.o((float) getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue());
        if (!world.isClientSide) {
            super.a(strafe, vertical, forward);
            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.motX += -0.4 * f * 0.0;
                    this.motZ += 0.4 * f1 * 0.0;
                }
                // this.prevLimbSwingAmount = this.limbSwingAmount;
                this.aI = this.aJ;
                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.aJ += (f5 - this.aJ) * 0.4;
                // this.limbSwing += this.limbSwingAmount;
                this.aK += this.aJ;
            }
        }
        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) CraftPlayer(org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer) IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet) Location(org.bukkit.Location)

Example 10 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: 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.K = (float) 0.5;
        this.aO = (float) 0.02;
        super.a(vec3D);
    } else {
        if (this.pet == null) {
            this.K = (float) 0.5;
            this.aO = (float) 0.02;
            super.e(vec3D);
            return;
        }
        if (!isOwnerRiding()) {
            this.K = (float) 0.5;
            this.aO = (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.aF = this.yaw;
        this.K = 1.0F;
        strafe = (float) (owner.bb * 0.5);
        forward = owner.bd;
        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));
                    setMot(getMot().add((-0.4 * f * 0.0), 0, (0.4 * f1 * 0.0)));
                }
                // this.prevLimbSwingAmount = this.limbSwingAmount;
                this.aE = this.aF;
                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.aF += (f5 - this.aF) * 0.4;
                // this.limbSwing += this.limbSwingAmount;
                this.aG += this.aF;
            }
        }
        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_14_R1.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) IEntityHorsePet(simplepets.brainsynder.api.entity.passive.IEntityHorsePet) Location(org.bukkit.Location)

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