use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.
the class Eating method onLeftClick.
@Override
public void onLeftClick() {
if (entityPet instanceof IHorseAbstract) {
IHorseAbstract var = (IHorseAbstract) entityPet;
var.setEating(!var.isEating());
}
}
use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.
the class Eating method getItem.
@Override
public ItemBuilder getItem() {
ItemBuilder item = type.getDataItemByName(getTargetName(), 0);
if (item != null) {
if (entityPet instanceof IHorseAbstract) {
IHorseAbstract var = (IHorseAbstract) entityPet;
item.withName(item.getName().replace("%value%", String.valueOf(var.isEating())));
}
}
return item;
}
use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.
the class Saddle method getItem.
@Override
public ItemBuilder getItem() {
ItemBuilder item = type.getDataItemByName("saddle", 0);
try {
if (entityPet instanceof IEntityPigPet) {
IEntityPigPet pig = (IEntityPigPet) entityPet;
item.withName(item.getName().replace("%value%", String.valueOf(pig.hasSaddle())));
} else if (entityPet instanceof IHorseAbstract) {
IHorseAbstract var = (IHorseAbstract) entityPet;
item.withName(item.getName().replace("%value%", String.valueOf(var.isSaddled())));
}
} catch (Exception e) {
item.withName("&6Has Saddle: &cERROR");
}
return item;
}
use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.
the class Saddle method onLeftClick.
@Override
public void onLeftClick() {
if (entityPet instanceof IEntityPigPet) {
IEntityPigPet pig = (IEntityPigPet) entityPet;
pig.setSaddled(!pig.hasSaddle());
} else if (entityPet instanceof IHorseAbstract) {
IHorseAbstract var = (IHorseAbstract) entityPet;
var.setSaddled(!var.isSaddled());
}
}
use of simplepets.brainsynder.api.entity.misc.IHorseAbstract in project SimplePets by brainsynder-Dev.
the class Pet method setVehicle.
public void setVehicle(boolean value, boolean byEvent) {
if (!byEvent) {
if (type.canMount(owner)) {
if (ent instanceof IHorseAbstract) {
IHorseAbstract horse = (IHorseAbstract) ent;
if (!horse.isSaddled())
horse.setSaddled(true);
}
if (getPet().getPassenger() != null) {
PetVehicleEvent event = new PetVehicleEvent(this, PetVehicleEvent.Type.DISMOUNT);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
return;
if (ent instanceof IEntityControllerPet) {
((IEntityControllerPet) ent).getDisplayEntity().eject();
} else {
ent.getEntity().eject();
}
value = false;
} else if (isVehicle()) {
value = false;
}
if (value && (vehicle != value)) {
if (isHat) {
PetHatEvent event = new PetHatEvent(this, PetHatEvent.Type.REMOVE);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
return;
instance.getUtilities().removePassenger(owner, ent.getEntity());
setHat(false);
}
PetVehicleEvent event = new PetVehicleEvent(this, PetVehicleEvent.Type.MOUNT);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
return;
value = true;
if (owner.getLocation().getBlock() != null) {
List<Material> blocks = Utilities.getBlacklistedMaterials();
if (!blocks.contains(owner.getLocation().getBlock().getType()) && !blocks.contains(owner.getEyeLocation().getBlock().getType())) {
getPet().teleport(owner);
}
} else {
getPet().teleport(owner);
}
new BukkitRunnable() {
@Override
public void run() {
if (ent instanceof IEntityControllerPet) {
((IEntityControllerPet) ent).getDisplayEntity().setPassenger(owner);
} else {
ent.getEntity().setPassenger(owner);
}
}
}.runTaskLater(PetCore.get(), 2L);
}
}
}
vehicle = value;
}
Aggregations