use of simplepets.brainsynder.api.event.pet.PetMoveEvent in project SimplePets by brainsynder-Dev.
the class EntityPet method move.
@Override
public void move(EnumMoveType enummovetype, double d0, double d1, double d2) {
if (pet == null)
return;
if (pet.getOwner() == null)
return;
PetMoveEvent event = new PetMoveEvent(this, PetMoveEvent.Cause.RIDE);
Bukkit.getServer().getPluginManager().callEvent(event);
super.move(enummovetype, d0, d1, d2);
}
use of simplepets.brainsynder.api.event.pet.PetMoveEvent 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) {
}
}
}
use of simplepets.brainsynder.api.event.pet.PetMoveEvent in project SimplePets by brainsynder-Dev.
the class EntityPet method move.
@Override
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
super.move(enummovetype, vec3d);
try {
PetMoveEvent event = new PetMoveEvent(this, PetMoveEvent.Cause.WALK);
Bukkit.getServer().getPluginManager().callEvent(event);
} catch (Throwable ignored) {
}
}
use of simplepets.brainsynder.api.event.pet.PetMoveEvent in project SimplePets by brainsynder-Dev.
the class EntityControllerPet method move.
public void move(Vec3D vec3D, FieldAccessor<Boolean> fieldAccessor) {
float strafe = (float) vec3D.x;
float vertical = (float) vec3D.y;
float forward = (float) vec3D.z;
reloadLocation();
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;
}
strafe *= 0.75;
this.o((float) getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue());
if (!world.isClientSide) {
super.e(new Vec3D(strafe, vertical, forward));
}
if (pet == null) {
if (displayEntity != null) {
displayEntity.remove();
this.remove();
}
return;
}
if (pet.getOwner() == null) {
if (displayEntity != null) {
displayEntity.remove();
this.remove();
}
return;
}
try {
PetMoveEvent event = new PetMoveEvent(this, PetMoveEvent.Cause.RIDE);
Bukkit.getServer().getPluginManager().callEvent(event);
} catch (Throwable ignored) {
}
}
use of simplepets.brainsynder.api.event.pet.PetMoveEvent in project SimplePets by brainsynder-Dev.
the class PathFinderGoalWalkToPlayer method c.
@Override
public void c() {
if (owner.hasPet()) {
if (owner.getPet().getEntity() != null) {
if (pet == null) {
if (pet.getEntity() != null)
pet.getEntity().remove();
return;
}
if (pet.getOwner() == null) {
if (pet.getEntity() != null)
pet.getEntity().remove();
return;
}
try {
PetMoveEvent event = new PetMoveEvent(pet, PetMoveEvent.Cause.WALK);
Bukkit.getServer().getPluginManager().callEvent(event);
} catch (Throwable ignored) {
}
}
Location location = pet.getWalkToLocation();
((EntityPet) pet).getNavigation().a(location.getX(), location.getY(), location.getZ(), speed);
}
}
Aggregations