use of simplepets.brainsynder.errors.SimplePetsException in project SimplePets by brainsynder-Dev.
the class PetSpawner method spawnPet.
public static IEntityPet spawnPet(Pet pet, Class<? extends IEntityPet> clazz) {
ISpawner spawner = PetCore.get().getSpawner();
String entity = clazz.getSimpleName().replaceFirst("I", "");
if (spawner == null) {
throw new SimplePetsException("An error occurred when trying to retrieve the PetSpawner Class");
}
return spawner.spawnEntityPet(pet, entity);
}
use of simplepets.brainsynder.errors.SimplePetsException in project SimplePets by brainsynder-Dev.
the class PetSpawner method spawnPet.
public static IEntityPet spawnPet(Location location, Pet pet, Class<? extends IEntityPet> clazz) {
ISpawner spawner = PetCore.get().getSpawner();
String entity = clazz.getSimpleName().replaceFirst("I", "");
if (spawner == null) {
throw new SimplePetsException("An error occurred when trying to retrieve the PetSpawner Class");
}
return spawner.spawnEntityPet(location, pet, entity);
}
use of simplepets.brainsynder.errors.SimplePetsException 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();
EntityTypes<?> types = EntityUtils.getType((className.equals("EntityControllerPet")) ? EntityWrapper.ZOMBIE : pet.getEntityType());
EntityPet customEntity = (EntityPet) petMap.get(className).getDeclaredConstructor(EntityTypes.class, World.class, IPet.class).newInstance(types, 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);
((CraftEntity) stand).getHandle().passengers.add(0, ((CraftEntity) shulker).getHandle());
((IEntityControllerPet) customEntity).setDisplayEntity(stand);
}
}
return customEntity;
} catch (Exception e) {
e.printStackTrace();
throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
}
}
use of simplepets.brainsynder.errors.SimplePetsException 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);
((CraftEntity) stand).getHandle().passengers.add(0, ((CraftEntity) shulker).getHandle());
((IEntityControllerPet) customEntity).setDisplayEntity(stand);
}
}
return customEntity;
} catch (Exception e) {
e.printStackTrace();
throw new SimplePetsException("Could not summon the " + pet.getPetType().getConfigName() + " Pet", e);
}
}
use of simplepets.brainsynder.errors.SimplePetsException in project SimplePets by brainsynder-Dev.
the class Utilities method handlePathfinders.
public void handlePathfinders(Player player, Entity entity, double speed) {
try {
Class<?> clazz = Class.forName("simplepets.brainsynder.nms." + ReflectionUtil.getVersion() + ".pathfinders.HandlePathfinders");
if (clazz == null)
throw new SimplePetsException("HandlePathfinders not found");
Constructor<?> con = clazz.getDeclaredConstructor(Player.class, Entity.class, double.class);
con.newInstance(player, entity, speed);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations