use of org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity in project SimplePets by brainsynder-Dev.
the class EntityControllerPet method repeatTask.
@Override
public void repeatTask() {
super.repeatTask();
if (!this.isInvisible())
this.setInvisible(true);
if (getPet() != null)
if (isBaby())
setBaby((getPet().getPetType() instanceof ShulkerDefault));
Player p = getPet().getOwner();
if (hasCustomName()) {
setCustomNameVisible(false);
if (displayEntity.getPassenger() != null) {
this.displayEntity.getPassenger().setCustomName(getCustomName());
this.displayEntity.getPassenger().setCustomNameVisible(true);
} else {
this.displayEntity.setCustomName(getCustomName());
this.displayEntity.setCustomNameVisible(true);
}
}
if (this.displayEntity != null) {
if (this.displayEntity.isValid()) {
if (displayEntity.getPassenger() == null) {
reloadLocation();
net.minecraft.server.v1_11_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
if (((CraftPlayer) getOwner()).getHandle().isInvisible() != displayEntity.isInvisible()) {
displayEntity.setInvisible(!displayEntity.isInvisible());
}
return;
}
if (this.displayEntity.getPassenger() != null) {
net.minecraft.server.v1_11_R1.Entity displayEntity = ((CraftEntity) this.displayEntity.getPassenger()).getHandle();
if (((CraftPlayer) p).getHandle().isInvisible() != displayEntity.isInvisible()) {
displayEntity.setInvisible(!displayEntity.isInvisible());
}
}
}
}
}
use of org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity 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 org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity in project SimplePets by brainsynder-Dev.
the class EntityControllerPet method reloadLocation.
@Override
public void reloadLocation() {
if (displayEntity.getPassenger() != null) {
net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
Location loc;
if (this.displayRider != null) {
if (this.displayRider.getType().equals(EntityType.SHULKER)) {
loc = getBukkitEntity().getLocation().clone().subtract(0, 0.735, 0);
} else {
loc = getBukkitEntity().getLocation().clone();
}
} else {
loc = getBukkitEntity().getLocation().clone();
}
displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
if (entity instanceof Player) {
Player player = (Player) entity;
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
});
return;
}
net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
Location loc;
if (this.displayRider != null) {
if (this.displayRider.getType().equals(EntityType.SHULKER)) {
loc = getBukkitEntity().getLocation().clone().add(0, 0.75, 0);
} else {
loc = getBukkitEntity().getLocation().clone();
}
} else {
loc = getBukkitEntity().getLocation().clone();
}
displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
if (entity instanceof Player) {
Player player = (Player) entity;
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
});
}
use of org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity in project UltraCosmetics by iSach.
the class EntityUtil method sendDestroyPacket.
@Override
public void sendDestroyPacket(Player player, org.bukkit.entity.Entity entity) {
ClientboundRemoveEntitiesPacket packet = new ClientboundRemoveEntitiesPacket(((CraftEntity) entity).getHandle().getId());
((CraftPlayer) player).getHandle().connection.send(packet);
}
use of org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity in project UltraCosmetics by iSach.
the class EntityUtil method follow.
@Override
public void follow(org.bukkit.entity.Entity toFollow, org.bukkit.entity.Entity follower) {
Entity pett = ((CraftEntity) follower).getHandle();
((Mob) pett).getNavigation().setMaxVisitedNodesMultiplier(2);
Object petf = ((CraftEntity) follower).getHandle();
Location targetLocation = toFollow.getLocation();
Path path;
path = ((Mob) petf).getNavigation().createPath(targetLocation.getX() + 1, targetLocation.getY(), targetLocation.getZ() + 1, 1);
if (path != null) {
((Mob) petf).getNavigation().moveTo(path, 1.05D);
((Mob) petf).getNavigation().setSpeedModifier(1.05D);
}
}
Aggregations