use of net.minecraft.server.v1_13_R2.EntityInsentient in project solinia3-core by mixxit.
the class CommandPet method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
// TODO Auto-generated method stub
if (sender instanceof Player) {
try {
Player player = (Player) sender;
LivingEntity pet = StateManager.getInstance().getEntityManager().getPet(player.getUniqueId());
if (pet == null) {
player.sendMessage("You don't have a pet");
return true;
}
if (pet instanceof Sittable) {
Sittable sittable = (Sittable) pet;
if (sittable.isSitting()) {
player.sendMessage("You cannot control a pet which is sitting");
return true;
}
}
ISoliniaLivingEntity petLivingEntity = SoliniaLivingEntityAdapter.Adapt(pet);
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(player);
if (petLivingEntity == null || solPlayer == null)
return false;
if (args.length > 0) {
String petcommand = args[0];
if (petcommand.equals("leave")) {
if (petLivingEntity != null) {
petLivingEntity.clearHateList();
if (petLivingEntity.IsCorePet()) {
solPlayer.killAllPets();
} else {
StateManager.getInstance().getEntityManager().removePet(player.getUniqueId(), !petLivingEntity.isCharmed());
petLivingEntity.clearHateList();
}
player.setLastDamageCause(null);
}
}
if (petcommand.equals("back")) {
if (petLivingEntity != null) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(petLivingEntity.getNpcid());
if (npc != null)
if (npc.isPetControllable() == false) {
player.sendMessage("This pet is not controllable");
return true;
}
player.setLastDamageCause(null);
petLivingEntity.clearHateList();
ChatUtils.SendHint(player, HINT.PET_BACKINGOFFTGT, "", false);
EntityUtils.teleportSafely(pet, player.getLocation());
}
}
if (petcommand.equals("attack")) {
if (solPlayer.getEntityTarget() == null) {
ChatUtils.SendHint(player, HINT.NEED_TARGET, "", false);
}
LivingEntity targetentity = solPlayer.getEntityTarget();
if (targetentity != null && !targetentity.getUniqueId().equals(player.getUniqueId())) {
if (petLivingEntity != null) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(petLivingEntity.getNpcid());
if (npc != null)
if (npc.isPetControllable() == false) {
player.sendMessage("This pet is not controllable");
return true;
}
}
EntityUtils.teleportSafely(pet, player.getLocation());
petLivingEntity.setAttackTarget(null);
// Mez cancel target
Timestamp mezExpiry = StateManager.getInstance().getEntityManager().getMezzed(targetentity);
if (mezExpiry != null) {
petLivingEntity.setAttackTarget(null);
player.sendMessage("You cannot send your pet to attack a mezzed target");
return false;
}
if (pet.getUniqueId().equals(targetentity.getUniqueId())) {
petLivingEntity.setAttackTarget(null);
player.sendMessage("You cannot send your pet to attack itself");
return false;
}
if (petLivingEntity.getOwnerEntity().getUniqueId().equals(targetentity.getUniqueId())) {
petLivingEntity.setAttackTarget(null);
player.sendMessage("You cannot send your pet to attack you!");
return false;
}
ISoliniaPlayer tmpPlayer = SoliniaPlayerAdapter.Adapt(player);
if (tmpPlayer != null && tmpPlayer.isInGroup(targetentity)) {
petLivingEntity.setAttackTarget(null);
player.sendMessage("You cannot send your pet to attack your group!");
return false;
}
if (!pet.getUniqueId().equals(targetentity.getUniqueId())) {
petLivingEntity.setAttackTarget(targetentity);
player.sendMessage("You send your pet to attack!");
return true;
}
ChatUtils.SendHint(player, HINT.PET_ATTACKINGTGT, targetentity.getCustomName(), false);
}
return true;
}
if (petcommand.equals("equip")) {
if (petLivingEntity != null) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(petLivingEntity.getNpcid());
if (npc != null)
if (npc.isPetControllable() == false) {
player.sendMessage("This pet is not controllable/equippable");
return true;
}
}
PetEquip(player, pet);
}
if (petcommand.equals("hatelist")) {
player.sendMessage("Hate List: ");
if (petLivingEntity != null) {
petLivingEntity.sendHateList(player);
}
}
}
player.sendMessage("Pet Name: " + pet.getName() + " Pet Level: " + petLivingEntity.getMentorLevel());
player.sendMessage("Pet HP: " + pet.getHealth() + "/" + pet.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
EntityInsentient entityhandle = (EntityInsentient) ((org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity) pet).getHandle();
double dmg = entityhandle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).getValue();
player.sendMessage("Pet DMG: " + dmg + " (Hand to Hand)");
Entity target = ((Creature) pet).getTarget();
if (target == null) {
player.sendMessage("Pet Target: None");
} else {
player.sendMessage("Pet Target: " + target.getCustomName() + "/" + target.getName());
}
player.sendMessage("STR: " + petLivingEntity.getStrength() + " STA: " + petLivingEntity.getStamina() + " AGI: " + petLivingEntity.getAgility() + " DEX: " + petLivingEntity.getDexterity() + " INT: " + petLivingEntity.getIntelligence() + " WIS: " + petLivingEntity.getWisdom() + " CHA: " + petLivingEntity.getCharisma());
player.sendMessage("Pet Armour Class Mitigation (AC): " + petLivingEntity.getMitigationAC());
player.sendMessage("Pet Attack Value: " + petLivingEntity.getTotalAtk());
player.sendMessage("Pet Attack Speed: " + ChatColor.GOLD + petLivingEntity.getHaste() + "%" + ChatColor.RESET);
player.sendMessage("Pet MainWeapon Attack Rate (Seconds): " + ChatColor.GOLD + petLivingEntity.getAutoAttackTimerFrequencySeconds() + ChatColor.RESET);
player.sendMessage("Pet Total Rune of: " + petLivingEntity.getRune());
player.sendMessage("Skills:");
if (petLivingEntity.getClassObj() != null) {
if (petLivingEntity.getClassObj().getDodgelevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getDodgelevel())
player.sendMessage(ChatColor.GRAY + "Dodge Skill: " + petLivingEntity.getSkill(SkillType.Dodge));
if (petLivingEntity.getClassObj().getRipostelevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getRipostelevel())
player.sendMessage(ChatColor.GRAY + "Riposte Skill: " + petLivingEntity.getSkill(SkillType.Riposte));
if (petLivingEntity.getClassObj().getDoubleattacklevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getDoubleattacklevel())
player.sendMessage(ChatColor.GRAY + "Double Attack Skill: " + petLivingEntity.getSkill(SkillType.DoubleAttack));
if (petLivingEntity.getClassObj().getSafefalllevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getSafefalllevel())
player.sendMessage(ChatColor.GRAY + "Safefall Skill: " + petLivingEntity.getSkill(SkillType.SafeFall));
if (petLivingEntity.getClassObj().getDualwieldlevel() > 0)
if (petLivingEntity.getMentorLevel() >= petLivingEntity.getClassObj().getDualwieldlevel())
player.sendMessage(ChatColor.GRAY + "Dual Wield: " + petLivingEntity.getSkill(SkillType.DualWield));
}
player.sendMessage("Active Effects:");
SoliniaEntitySpells spells = StateManager.getInstance().getEntityManager().getActiveEntitySpells(pet);
for (SoliniaActiveSpell activeSpell : spells.getActiveSpells()) {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
String removetext = "";
ChatColor spellcolor = ChatColor.GREEN;
if (spell.isBeneficial()) {
removetext = "Removable spell";
} else {
removetext = "Unremovable spell";
spellcolor = ChatColor.RED;
}
TextComponent tc = new TextComponent();
tc.setText("- " + spellcolor + spell.getName() + ChatColor.RESET + " " + activeSpell.getTicksLeft() + " ticks left - ");
TextComponent tc2 = new TextComponent();
tc2.setText(removetext);
tc.addExtra(tc2);
sender.spigot().sendMessage(tc);
}
player.sendMessage("Pet subcommands: /pet back | /pet equip | /pet attack | /pet leave");
return true;
} catch (CoreStateInitException e) {
}
}
return true;
}
use of net.minecraft.server.v1_13_R2.EntityInsentient in project Citizens2 by CitizensDev.
the class NMSImpl method updatePathfindingRange.
@Override
public void updatePathfindingRange(NPC npc, float pathfindingRange) {
if (!npc.isSpawned() || !npc.getEntity().getType().isAlive())
return;
EntityLiving en = NMSImpl.getHandle((LivingEntity) npc.getEntity());
if (!(en instanceof EntityInsentient)) {
if (en instanceof EntityHumanNPC) {
((EntityHumanNPC) en).updatePathfindingRange(pathfindingRange);
}
return;
}
if (PATHFINDING_RANGE == null)
return;
EntityInsentient handle = (EntityInsentient) en;
NavigationAbstract navigation = handle.getNavigation();
try {
AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
inst.setValue(pathfindingRange);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_13_R2.EntityInsentient in project Citizens2 by CitizensDev.
the class NMSImpl method getTargetNavigator.
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, final Function<NavigationAbstract, Boolean> function) {
net.minecraft.server.v1_13_R2.Entity raw = getHandle(entity);
raw.onGround = true;
// not sure of a better way around this - if onGround is false, then
// navigation won't execute, and calling entity.move doesn't
// entirely fix the problem.
final NavigationAbstract navigation = NMSImpl.getNavigation(entity);
final float oldWater = raw instanceof EntityPlayer ? ((EntityHumanNPC) raw).a(PathType.WATER) : ((EntityInsentient) raw).a(PathType.WATER);
if (params.avoidWater() && oldWater >= 0) {
if (raw instanceof EntityPlayer) {
((EntityHumanNPC) raw).a(PathType.WATER, oldWater + 1F);
} else {
((EntityInsentient) raw).a(PathType.WATER, oldWater + 1F);
}
}
return new MCNavigator() {
float lastSpeed;
CancelReason reason;
@Override
public CancelReason getCancelReason() {
return reason;
}
@Override
public Iterable<Vector> getPath() {
return new NavigationIterable(navigation);
}
@Override
public void stop() {
if (params.debug() && navigation.m() != null) {
for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.m().d(); i++) {
PathPoint pp = navigation.m().a(i);
org.bukkit.block.Block block = new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()).getBlock();
player.sendBlockChange(block.getLocation(), block.getBlockData());
}
}
}
if (oldWater >= 0) {
if (raw instanceof EntityPlayer) {
((EntityHumanNPC) raw).a(PathType.WATER, oldWater);
} else {
((EntityInsentient) raw).a(PathType.WATER, oldWater);
}
}
stopNavigation(navigation);
}
@Override
public boolean update() {
if (params.speed() != lastSpeed) {
if (Messaging.isDebugging() && lastSpeed > 0) {
Messaging.debug("Repathfinding " + ((NPCHolder) entity).getNPC().getId() + " due to speed change");
}
Entity handle = getHandle(entity);
float oldWidth = handle.width;
if (handle instanceof EntityHorse) {
handle.width = Math.min(0.99f, oldWidth);
}
if (!function.apply(navigation)) {
reason = CancelReason.STUCK;
}
// minecraft requires that an entity fit onto both blocks if width >= 1f,
handle.width = oldWidth;
// but we'd prefer to make it just fit on 1 so hack around it a bit.
lastSpeed = params.speed();
}
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
BlockData data = Material.DANDELION.createBlockData();
for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.m().d(); i++) {
PathPoint pp = navigation.m().a(i);
player.sendBlockChange(new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()), data);
}
}
}
navigation.a(params.speed());
return NMSImpl.isNavigationFinished(navigation);
}
};
}
use of net.minecraft.server.v1_13_R2.EntityInsentient in project Citizens2 by CitizensDev.
the class PlayerControllerMove method a.
@Override
public void a() {
this.a.bj = 0F;
if (this.f) {
this.f = false;
BoundingBox bb = NMSBoundingBox.wrap(this.a.getBoundingBox());
int i = MathHelper.floor(bb.minY + 0.5D);
double d0 = this.b - this.a.locX;
double d1 = this.d - this.a.locZ;
double d2 = this.c - i;
double d3 = d0 * d0 + d2 * d2 + d1 * d1;
if (d3 < 2.500000277905201E-007D) {
// bi
this.a.bj = (0.0F);
return;
}
float f = (float) Math.toDegrees(Math.atan2(d1, d0)) - 90.0F;
this.a.yaw = a(this.a.yaw, f, 90.0F);
NMS.setHeadYaw(a.getBukkitEntity(), this.a.yaw);
AttributeInstance speed = this.a.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
if (!(this.a instanceof EntitySlime)) {
speed.setValue(0.1D * this.e);
}
float movement = (float) (this.e * speed.getValue()) * 10;
this.a.o(movement);
this.a.bj = movement;
if (shouldSlimeJump() || ((d2 >= NMS.getStepHeight(a.getBukkitEntity())) && (d0 * d0 + d1 * d1 < 1.0D))) {
this.h = cg();
this.h /= 3;
if (this.a instanceof EntityHumanNPC) {
((EntityHumanNPC) this.a).getControllerJump().a();
} else {
((EntityInsentient) this.a).getControllerJump().a();
}
}
}
}
use of net.minecraft.server.v1_13_R2.EntityInsentient in project Citizens2 by CitizensDev.
the class NMSImpl method getDestination.
@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
ControllerMove controller = handle instanceof EntityInsentient ? ((EntityInsentient) handle).getControllerMove() : handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getControllerMove() : null;
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
}
Aggregations