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) {
}
}
}
use of simplepets.brainsynder.api.entity.passive.IEntityHorsePet in project SimplePets by brainsynder-Dev.
the class HorseColor method onRightClick.
@Override
public void onRightClick() {
if (entityPet instanceof IEntityHorsePet) {
IEntityHorsePet var = (IEntityHorsePet) entityPet;
int typeID = 0;
if (var.getColor() != null) {
typeID = var.getColor().getId();
}
if (typeID == 0) {
typeID = 6;
} else {
typeID--;
}
var.setColor(HorseColorType.getByID(typeID));
}
}
use of simplepets.brainsynder.api.entity.passive.IEntityHorsePet in project SimplePets by brainsynder-Dev.
the class HorseColor method onLeftClick.
@Override
public void onLeftClick() {
if (entityPet instanceof IEntityHorsePet) {
IEntityHorsePet var = (IEntityHorsePet) entityPet;
int typeID = 0;
if (var.getColor() != null) {
typeID = var.getColor().getId();
}
if (typeID == 6) {
typeID = 0;
} else {
typeID++;
}
var.setColor(HorseColorType.getByID(typeID));
}
}
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.P = (float) 0.5;
this.aR = (float) 0.02;
super.a(strafe, vertical, forward);
} else {
if (this.pet == null) {
this.P = (float) 0.5;
this.aR = (float) 0.02;
super.a(strafe, vertical, forward);
return;
}
if (!isOwnerRiding()) {
this.P = (float) 0.5;
this.aR = (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.aP = this.aN = this.yaw;
this.P = 1.0F;
strafe = (float) (owner.be * 0.5);
forward = owner.bg;
if (forward <= 0.0) {
forward *= (rideSpeed * 0.25);
} else {
forward *= rideSpeed;
}
if (!(this instanceof IEntityHorsePet))
strafe *= 0.75;
this.k((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.aF = this.aG;
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.aG += (f5 - this.aG) * 0.4;
// this.limbSwing += this.limbSwingAmount;
this.aH += this.aG;
}
}
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) {
}
}
}
use of simplepets.brainsynder.api.entity.passive.IEntityHorsePet in project SimplePets by brainsynder-Dev.
the class EntityPet method g.
public void g(float sideMot, float forwMot) {
if (pet == null)
return;
if (pet.getOwner() == null)
return;
if (this.bx().isEmpty()) {
this.P = 0.5F;
this.aR = 0.02F;
super.g(sideMot, forwMot);
} else {
if (this.pet == null) {
this.P = 0.5F;
this.aR = 0.02F;
super.g(sideMot, forwMot);
return;
}
if (!isOwnerRiding()) {
this.P = 0.5F;
this.aR = 0.02F;
super.g(sideMot, forwMot);
return;
}
EntityPlayer owner = ((CraftPlayer) getOwner()).getHandle();
if (fieldAccessor != null) {
if (fieldAccessor.hasField(owner)) {
if (fieldAccessor.get(owner)) {
if (isOnGround(this)) {
this.motY = 0.5D;
} else {
if (pet.getPetType().canFly(pet.getOwner())) {
this.motY = 0.5D;
}
}
}
}
}
this.yaw = owner.yaw;
this.lastYaw = this.yaw;
this.pitch = owner.pitch * 0.5F;
this.setYawPitch(this.yaw, this.pitch);
this.aO = this.aM = this.yaw;
this.P = 1.0F;
sideMot = owner.be * 0.5F;
forwMot = owner.bf;
if (forwMot <= 0.0F) {
forwMot *= (0.25 * rideSpeed);
} else {
forwMot *= rideSpeed;
}
if (!(this instanceof IEntityHorsePet))
sideMot *= 0.75F;
this.l((float) getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue());
if (!world.isClientSide) {
PetMoveEvent event = new PetMoveEvent(this, PetMoveEvent.Cause.RIDE);
Bukkit.getServer().getPluginManager().callEvent(event);
super.g(sideMot, forwMot);
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 (forwMot > 0.0F) {
float f3 = MathHelper.sin(this.yaw * 0.017453292F);
float f4 = MathHelper.cos(this.yaw * 0.017453292F);
this.motX += (double) (-0.4F * f3 * 0.0F);
this.motZ += (double) (0.4F * f4 * 0.0F);
}
}
this.aF = this.aG;
double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ;
float f5 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
if (f5 > 1.0F) {
f5 = 1.0F;
}
this.aG += (f5 - this.aG) * 0.4F;
this.aH += this.aG;
}
}
}
Aggregations