use of simplepets.brainsynder.nms.v1_14_R1.entities.list.EntityControllerPet in project SimplePets by brainsynder-Dev.
the class SpawnUtil method spawn.
public IEntityPet spawn(Location l, IPet pet, String className) {
try {
World mcWorld = ((CraftWorld) l.getWorld()).getHandle();
EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(World.class, IPet.class).newInstance(mcWorld, pet);
customEntity.setInvisible(false);
customEntity.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
if (customEntity instanceof IEntityControllerPet) {
if (pet.getPetType() instanceof ArmorStandDefault) {
ArmorStand stand = EntityArmorStandPet.spawn(l, ((EntityControllerPet) customEntity));
stand.setGravity(false);
stand.setArms(true);
stand.setCollidable(false);
stand.setLeftLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
stand.setRightLegPose(new EulerAngle(0.0D, 0.0D, 0.0D));
stand.setLeftArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
stand.setRightArmPose(new EulerAngle(0.0D, 0.0D, 0.0D));
((IEntityControllerPet) customEntity).setDisplayEntity(stand);
} else if (pet.getPetType() instanceof ShulkerDefault) {
ArmorStand stand = EntityGhostStandPet.spawn(l, pet);
stand.setGravity(false);
stand.setCollidable(false);
stand.setSmall(true);
Shulker shulker = EntityShulkerPet.spawn(l, (EntityControllerPet) customEntity);
shulker.setAI(false);
shulker.setCollidable(false);
stand.setPassenger(shulker);
((IEntityControllerPet) customEntity).setDisplayEntity(stand);
}
}
return customEntity;
} catch (Exception e) {
throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
}
}
use of simplepets.brainsynder.nms.v1_14_R1.entities.list.EntityControllerPet in project SimplePets by brainsynder-Dev.
the class EntityPet method repeatTask.
public void repeatTask() {
if (pet == null)
return;
if (this instanceof IFlyablePet) {
if (pet.isVehicle()) {
if (floatDown) {
if (!this.onGround && this.motY < 0.0D) {
this.motY *= 0.4;
}
}
}
}
if (pet.getOwner() != null) {
Player p = pet.getOwner();
if (((CraftPlayer) p).getHandle().isInvisible() != this.isInvisible()) {
this.setInvisible(!this.isInvisible());
if (isInvisible()) {
if (this instanceof IEntityControllerPet) {
((EntityControllerPet) this).getVisibleEntity().getEntity().setGlowing(true);
} else {
glowing = true;
}
} else {
if (this instanceof IEntityControllerPet) {
((EntityControllerPet) this).getVisibleEntity().getEntity().setGlowing(false);
} else {
glowing = false;
}
}
}
if (pet.isHat()) {
this.lastYaw = this.yaw = p.getLocation().getYaw();
}
double current = getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
if (isOwnerRiding()) {
if (current != rideSpeed)
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(rideSpeed);
} else {
if (current != walkSpeed)
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(walkSpeed);
}
}
}
Aggregations