public void schedule() { if (myPet.getStatus() == PetState.Here) { if (heal.getValue().doubleValue() > 0) { if (timeCounter-- <= 0) { if (myPet.getHealth() < myPet.getMaxHealth()) { if (!particles) { particles = true; myPet.getEntity().get().getHandle().showPotionParticles(Color.LIME); } myPet.getEntity().get().setHealth(myPet.getHealth() + heal.getValue().doubleValue()); } timeCounter = timer.getValue(); } else { particles = false; } } if (particles) { particles = false; myPet.getEntity().get().getHandle().hidePotionParticles(); } } else if (particles) { particles = false; } }
public void apply(EntityDamageEvent event) { double redirectedDamage = calculateRedirectedDamage(event.getFinalDamage()); if (myPet.getStatus() == PetState.Here && myPet.getHealth() - redirectedDamage > 0) { myPet.getEntity().get().damage(redirectedDamage); event.setDamage(event.getDamage() - redirectedDamage); myPet.getEntity().get().getHandle().makeSound(SoundCompat.ENDERMAN_TELEPORT.get(), 0.2F, 1.0F); MyPetApi.getPlatformHelper().playParticleEffect(myPet.getOwner().getPlayer().getLocation().add(0, 1, 0), ParticleCompat.CRIT_MAGIC.get(), 0.5F, 0.5F, 0.5F, 0.1F, 20, 20); MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, 1, 0), ParticleCompat.CRIT.get(), 0.5F, 0.5F, 0.5F, 0.1F, 10, 20); } }
public EntityMyPet(World world, MyPet myPet) { super(world); try { setSize(); this.myPet = myPet; this.petPathfinderSelector = new AIGoalSelector(); this.petTargetSelector = new AIGoalSelector(); this.walkSpeed = MyPetApi.getMyPetInfo().getSpeed(myPet.getPetType()); this.getAttributeInstance(GenericAttributes.d).setValue(walkSpeed); this.getAttributeInstance(GenericAttributes.b).setValue(32.0f); this.petNavigation = new VanillaNavigation(this); this.sitPathfinder = new Sit(this); this.getAttributeInstance(GenericAttributes.maxHealth).setValue(myPet.getMaxHealth()); this.setHealth((float) myPet.getHealth()); this.updateNameTag(); this.setPathfinder(); this.updateVisuals(); this.isMyPet = true; } catch (Exception e) { e.printStackTrace(); } }