use of net.minecraft.server.v1_16_R3.EntityPlayer in project NoCheatPlus by NoCheatPlus.
the class MCAccessCB2882 method isIllegalBounds.
@Override
public AlmostBoolean isIllegalBounds(final Player player) {
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
if (entityPlayer.dead)
return AlmostBoolean.NO;
// TODO: Does this need a method call for the "real" box? Might be no problem during moving events, though.
final AxisAlignedBB box = entityPlayer.boundingBox;
if (!entityPlayer.isSleeping()) {
// This can not really test stance but height of bounding box.
final double dY = Math.abs(box.e - box.b);
// dY > 1.65D ||
if (dY > 1.8)
return AlmostBoolean.YES;
if (dY < 0.1D && entityPlayer.length >= 0.1)
return AlmostBoolean.YES;
}
return AlmostBoolean.MAYBE;
}
use of net.minecraft.server.v1_16_R3.EntityPlayer in project NoCheatPlus by NoCheatPlus.
the class MCAccessSpigotCB1_9_R1 method isIllegalBounds.
@Override
public AlmostBoolean isIllegalBounds(final Player player) {
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
if (entityPlayer.dead) {
return AlmostBoolean.NO;
}
// TODO: Does this need a method call for the "real" box? Might be no problem during moving events, though.
final AxisAlignedBB box = entityPlayer.getBoundingBox();
if (LocUtil.isBadCoordinate(box.a, box.b, box.c, box.d, box.e, box.f)) {
return AlmostBoolean.YES;
}
if (!entityPlayer.isSleeping()) {
// This can not really test stance but height of bounding box.
final double dY = Math.abs(box.e - box.b);
if (dY > 1.8) {
// dY > 1.65D ||
return AlmostBoolean.YES;
}
if (dY < 0.1D && entityPlayer.length >= 0.1) {
return AlmostBoolean.YES;
}
}
return AlmostBoolean.MAYBE;
}
use of net.minecraft.server.v1_16_R3.EntityPlayer in project Denizen-For-Bukkit by DenizenScript.
the class PlayerHelperImpl method sendEntitySpawn.
@Override
public FakeEntity sendEntitySpawn(List<PlayerTag> players, DenizenEntityType entityType, LocationTag location, ArrayList<Mechanism> mechanisms, int customId, UUID customUUID, boolean autoTrack) {
CraftWorld world = ((CraftWorld) location.getWorld());
net.minecraft.server.v1_16_R3.Entity nmsEntity;
if (entityType.isCustom()) {
if (entityType.customEntityType == CustomEntityType.ITEM_PROJECTILE) {
org.bukkit.inventory.ItemStack itemStack = new ItemStack(Material.STONE);
for (Mechanism mechanism : mechanisms) {
if (mechanism.matches("item") && mechanism.requireObject(ItemTag.class)) {
itemStack = mechanism.valueAsType(ItemTag.class).getItemStack();
}
}
nmsEntity = new EntityItemProjectileImpl(world.getHandle(), location, CraftItemStack.asNMSCopy(itemStack));
} else if (entityType.customEntityType == CustomEntityType.FAKE_PLAYER) {
String name = null;
String skin = null;
for (Mechanism mechanism : new ArrayList<>(mechanisms)) {
if (mechanism.matches("name")) {
name = mechanism.getValue().asString();
mechanisms.remove(mechanism);
} else if (mechanism.matches("skin")) {
skin = mechanism.getValue().asString();
mechanisms.remove(mechanism);
}
if (name != null && skin != null) {
break;
}
}
nmsEntity = ((CraftFakePlayerImpl) CustomEntityHelperImpl.spawnFakePlayer(location, name, skin, false)).getHandle();
} else {
throw new IllegalArgumentException("entityType");
}
} else {
nmsEntity = world.createEntity(location, entityType.getBukkitEntityType().getEntityClass());
}
if (customUUID != null) {
nmsEntity.e(customId);
nmsEntity.a_(customUUID);
}
EntityTag entity = new EntityTag(nmsEntity.getBukkitEntity());
for (Mechanism mechanism : mechanisms) {
entity.safeAdjustDuplicate(mechanism);
}
nmsEntity.dead = false;
FakeEntity fake = new FakeEntity(players, location, entity.getBukkitEntity().getEntityId());
fake.entity = new EntityTag(entity.getBukkitEntity());
fake.entity.isFake = true;
fake.entity.isFakeValid = true;
List<TrackerData> trackers = new ArrayList<>();
fake.triggerSpawnPacket = (player) -> {
EntityPlayer nmsPlayer = ((CraftPlayer) player.getPlayerEntity()).getHandle();
PlayerConnection conn = nmsPlayer.playerConnection;
final EntityTrackerEntry tracker = new EntityTrackerEntry(world.getHandle(), nmsEntity, 1, true, conn::sendPacket, Collections.singleton(nmsPlayer));
tracker.b(nmsPlayer);
final TrackerData data = new TrackerData();
data.player = player;
data.tracker = tracker;
trackers.add(data);
if (autoTrack) {
new BukkitRunnable() {
boolean wasOnline = true;
@Override
public void run() {
if (!fake.entity.isFakeValid) {
cancel();
return;
}
if (player.isOnline()) {
if (!wasOnline) {
tracker.b(((CraftPlayer) player.getPlayerEntity()).getHandle());
wasOnline = true;
}
tracker.a();
} else if (wasOnline) {
wasOnline = false;
}
}
}.runTaskTimer(Denizen.getInstance(), 1, 1);
}
};
for (PlayerTag player : players) {
fake.triggerSpawnPacket.accept(player);
}
fake.triggerUpdatePacket = () -> {
for (TrackerData tracker : trackers) {
if (tracker.player.isOnline()) {
tracker.tracker.a();
}
}
};
fake.triggerDestroyPacket = () -> {
for (TrackerData tracker : trackers) {
if (tracker.player.isOnline()) {
tracker.tracker.a(((CraftPlayer) tracker.player.getPlayerEntity()).getHandle());
}
}
trackers.clear();
};
return fake;
}
use of net.minecraft.server.v1_16_R3.EntityPlayer in project MyPet by xXKeyleXx.
the class ControlTarget method shouldStart.
@Override
public boolean shouldStart() {
if (controlPathfinderGoal == null) {
if (petEntity.getPathfinder().hasGoal("Control")) {
controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
}
}
if (controlPathfinderGoal == null) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
}
for (EntityLiving entityLiving : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) {
if (entityLiving instanceof EntityPlayer) {
Player targetPlayer = (Player) entityLiving.getBukkitEntity();
if (myPet.getOwner().equals(targetPlayer)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
continue;
}
} else if (entityLiving instanceof EntityTameableAnimal) {
EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
if (tameable.isTamed() && tameable.getOwner() != null) {
Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
if (myPet.getOwner().equals(tameableOwner)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
continue;
}
}
} else if (entityLiving instanceof EntityMyPet) {
MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
continue;
}
}
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
continue;
}
if (behaviorSkill != null) {
if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
if (entityLiving instanceof EntityTameableAnimal) {
continue;
} else if (entityLiving instanceof EntityMyPet) {
continue;
} else if (entityLiving instanceof EntityPlayer) {
continue;
}
}
}
controlPathfinderGoal.stopControl();
this.target = entityLiving;
return true;
}
}
}
return false;
}
use of net.minecraft.server.v1_16_R3.EntityPlayer in project MyPet by xXKeyleXx.
the class ControlTarget method shouldStart.
@Override
public boolean shouldStart() {
if (controlPathfinderGoal == null) {
if (petEntity.getPathfinder().hasGoal("Control")) {
controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
}
}
if (controlPathfinderGoal == null) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
}
for (EntityLiving entityLiving : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow(this.range, 4.0D, this.range))) {
if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) {
if (entityLiving instanceof EntityPlayer) {
Player targetPlayer = (Player) entityLiving.getBukkitEntity();
if (myPet.getOwner().equals(targetPlayer)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
continue;
}
} else if (entityLiving instanceof EntityTameableAnimal) {
EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
if (tameable.isTamed() && tameable.getOwner() != null) {
Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
if (myPet.getOwner().equals(tameableOwner)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
continue;
}
}
} else if (entityLiving instanceof EntityMyPet) {
MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
continue;
}
}
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
continue;
}
if (behaviorSkill != null) {
if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
if (entityLiving instanceof EntityTameableAnimal) {
continue;
} else if (entityLiving instanceof EntityMyPet) {
continue;
} else if (entityLiving instanceof EntityPlayer) {
continue;
}
}
}
controlPathfinderGoal.stopControl();
this.target = entityLiving;
return true;
}
}
}
return false;
}
Aggregations