use of net.minecraft.server.v1_16_R3.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method a.
@Override
public PathType a(IBlockAccess var1, int var2, int var3, int var4, EntityInsentient var5, int var6, int var7, int var8, boolean var9, boolean var10) {
EnumSet var11 = EnumSet.noneOf(PathType.class);
PathType var12 = PathType.BLOCKED;
double var13 = var5.width / 2.0D;
BlockPosition var15 = new BlockPosition(var5);
var12 = this.a(var1, var2, var3, var4, var6, var7, var8, var9, var10, var11, var12, var15);
if (var11.contains(PathType.FENCE)) {
return PathType.FENCE;
} else {
PathType var16 = PathType.BLOCKED;
Iterator var17 = var11.iterator();
while (var17.hasNext()) {
PathType var18 = (PathType) var17.next();
if (var5.a(var18) < 0.0F) {
return var18;
}
if (var5.a(var18) >= var5.a(var16)) {
var16 = var18;
}
}
if (var12 == PathType.OPEN && var5.a(var16) == 0.0F) {
return PathType.OPEN;
} else {
return var16;
}
}
}
use of net.minecraft.server.v1_16_R3.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method a.
@Override
public int a(PathPoint[] var1, PathPoint var2, PathPoint var3, float var4) {
int var5 = 0;
int var6 = 0;
PathType var7 = this.a(this.b, var2.a, var2.b + 1, var2.c);
if (this.b.a(var7) >= 0.0F) {
var6 = MathHelper.d(Math.max(1.0F, this.b.Q));
}
double var8 = a(this.a, new BlockPosition(var2.a, var2.b, var2.c));
PathPoint var10 = this.a(var2.a, var2.b, var2.c + 1, var6, var8, EnumDirection.SOUTH);
PathPoint var11 = this.a(var2.a - 1, var2.b, var2.c, var6, var8, EnumDirection.WEST);
PathPoint var12 = this.a(var2.a + 1, var2.b, var2.c, var6, var8, EnumDirection.EAST);
PathPoint var13 = this.a(var2.a, var2.b, var2.c - 1, var6, var8, EnumDirection.NORTH);
if (var10 != null && !var10.i && var10.a(var3) < var4) {
var1[var5++] = var10;
}
if (var11 != null && !var11.i && var11.a(var3) < var4) {
var1[var5++] = var11;
}
if (var12 != null && !var12.i && var12.a(var3) < var4) {
var1[var5++] = var12;
}
if (var13 != null && !var13.i && var13.a(var3) < var4) {
var1[var5++] = var13;
}
boolean var14 = var13 == null || var13.m == PathType.OPEN || var13.l != 0.0F;
boolean var15 = var10 == null || var10.m == PathType.OPEN || var10.l != 0.0F;
boolean var16 = var12 == null || var12.m == PathType.OPEN || var12.l != 0.0F;
boolean var17 = var11 == null || var11.m == PathType.OPEN || var11.l != 0.0F;
PathPoint var18;
if (var14 && var17) {
var18 = this.a(var2.a - 1, var2.b, var2.c - 1, var6, var8, EnumDirection.NORTH);
if (var18 != null && !var18.i && var18.a(var3) < var4) {
var1[var5++] = var18;
}
}
if (var14 && var16) {
var18 = this.a(var2.a + 1, var2.b, var2.c - 1, var6, var8, EnumDirection.NORTH);
if (var18 != null && !var18.i && var18.a(var3) < var4) {
var1[var5++] = var18;
}
}
if (var15 && var17) {
var18 = this.a(var2.a - 1, var2.b, var2.c + 1, var6, var8, EnumDirection.SOUTH);
if (var18 != null && !var18.i && var18.a(var3) < var4) {
var1[var5++] = var18;
}
}
if (var15 && var16) {
var18 = this.a(var2.a + 1, var2.b, var2.c + 1, var6, var8, EnumDirection.SOUTH);
if (var18 != null && !var18.i && var18.a(var3) < var4) {
var1[var5++] = var18;
}
}
return var5;
}
use of net.minecraft.server.v1_16_R3.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method a.
public PathType a(IBlockAccess var1, int var2, int var3, int var4, EntityHumanNPC var5, int var6, int var7, int var8, boolean var9, boolean var10) {
EnumSet var11 = EnumSet.noneOf(PathType.class);
PathType var12 = PathType.BLOCKED;
double var13 = var5.width / 2.0D;
BlockPosition var15 = new BlockPosition(var5);
var12 = this.a(var1, var2, var3, var4, var6, var7, var8, var9, var10, var11, var12, var15);
if (var11.contains(PathType.FENCE)) {
return PathType.FENCE;
} else {
PathType var16 = PathType.BLOCKED;
Iterator var17 = var11.iterator();
while (var17.hasNext()) {
PathType var18 = (PathType) var17.next();
if (var5.a(var18) < 0.0F) {
return var18;
}
if (var5.a(var18) >= var5.a(var16)) {
var16 = var18;
}
}
if (var12 == PathType.OPEN && var5.a(var16) == 0.0F) {
return PathType.OPEN;
} else {
return var16;
}
}
}
use of net.minecraft.server.v1_16_R3.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method a.
private PathPoint a(int var1, int var2, int var3, int var4, double var5, EnumDirection var7) {
PathPoint var8 = null;
BlockPosition var9 = new BlockPosition(var1, var2, var3);
double var10 = a(this.a, var9);
if (var10 - var5 > 1.125D) {
return null;
} else {
PathType var12 = this.a(this.b, var1, var2, var3);
float var13 = this.b.a(var12);
double var14 = this.b.width / 2.0D;
if (var13 >= 0.0F) {
var8 = this.a(var1, var2, var3);
var8.m = var12;
var8.l = Math.max(var8.l, var13);
}
if (var12 == PathType.WALKABLE) {
return var8;
} else {
if (var8 == null && var4 > 0 && var12 != PathType.FENCE && var12 != PathType.TRAPDOOR) {
var8 = this.a(var1, var2 + 1, var3, var4 - 1, var5, var7);
if (var8 != null && (var8.m == PathType.OPEN || var8.m == PathType.WALKABLE) && this.b.width < 1.0F) {
double var16 = var1 - var7.getAdjacentX() + 0.5D;
double var18 = var3 - var7.getAdjacentZ() + 0.5D;
AxisAlignedBB var20 = new AxisAlignedBB(var16 - var14, var2 + 0.001D, var18 - var14, var16 + var14, this.b.length + a(this.a, var9.up()) - 0.002D, var18 + var14);
if (!this.b.world.getCubes((Entity) null, var20)) {
var8 = null;
}
}
}
if (var12 == PathType.WATER && !this.e()) {
if (this.a(this.b, var1, var2 - 1, var3) != PathType.WATER) {
return var8;
}
while (var2 > 0) {
--var2;
var12 = this.a(this.b, var1, var2, var3);
if (var12 != PathType.WATER) {
return var8;
}
var8 = this.a(var1, var2, var3);
var8.m = var12;
var8.l = Math.max(var8.l, this.b.a(var12));
}
}
if (var12 == PathType.OPEN) {
AxisAlignedBB var21 = new AxisAlignedBB(var1 - var14 + 0.5D, var2 + 0.001D, var3 - var14 + 0.5D, var1 + var14 + 0.5D, var2 + this.b.length, var3 + var14 + 0.5D);
if (!this.b.world.getCubes((Entity) null, var21)) {
return null;
}
if (this.b.width >= 1.0F) {
PathType var17 = this.a(this.b, var1, var2 - 1, var3);
if (var17 == PathType.BLOCKED) {
var8 = this.a(var1, var2, var3);
var8.m = PathType.WALKABLE;
var8.l = Math.max(var8.l, var13);
return var8;
}
}
int var22 = 0;
while (var2 > 0 && var12 == PathType.OPEN) {
--var2;
if (var22++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
return null;
}
var12 = this.a(this.b, var1, var2, var3);
var13 = this.b.a(var12);
if (var12 != PathType.OPEN && var13 >= 0.0F) {
var8 = this.a(var1, var2, var3);
var8.m = var12;
var8.l = Math.max(var8.l, var13);
break;
}
if (var13 < 0.0F) {
return null;
}
}
}
return var8;
}
}
}
use of net.minecraft.server.v1_16_R3.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerAnimationImpl method play.
public static void play(PlayerAnimation animation, Player bplayer, int radius) {
// TODO: this is pretty gross
final EntityPlayer player = (EntityPlayer) NMSImpl.getHandle(bplayer);
if (DEFAULTS.containsKey(animation)) {
playDefaultAnimation(player, radius, DEFAULTS.get(animation));
return;
}
switch(animation) {
case SIT:
player.getBukkitEntity().setMetadata("citizens.sitting", new FixedMetadataValue(CitizensAPI.getPlugin(), true));
NPCRegistry registry = CitizensAPI.getNamedNPCRegistry("PlayerAnimationImpl");
if (registry == null) {
registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
}
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
holder.spawn(player.getBukkitEntity().getLocation());
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
trait.setGravity(false);
trait.setHasArms(false);
trait.setHasBaseplate(false);
trait.setSmall(true);
trait.setMarker(true);
trait.setVisible(false);
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
new BukkitRunnable() {
@Override
public void cancel() {
super.cancel();
holder.destroy();
}
@Override
public void run() {
if (player.dead || !player.valid || !player.getBukkitEntity().hasMetadata("citizens.sitting") || !player.getBukkitEntity().getMetadata("citizens.sitting").get(0).asBoolean()) {
cancel();
return;
}
if (player instanceof NPCHolder && !((NPCHolder) player).getNPC().isSpawned()) {
cancel();
return;
}
if (!NMS.getPassengers(holder.getEntity()).contains(player.getBukkitEntity())) {
NMS.mount(holder.getEntity(), player.getBukkitEntity());
}
}
}.runTaskTimer(CitizensAPI.getPlugin(), 0, 1);
break;
case SLEEP:
PacketPlayOutBed packet = new PacketPlayOutBed(player, new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
sendPacketNearby(packet, player, radius);
break;
case SNEAK:
player.getBukkitEntity().setSneaking(true);
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
break;
case START_ELYTRA:
player.J();
break;
case START_USE_MAINHAND_ITEM:
player.c(EnumHand.MAIN_HAND);
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
break;
case START_USE_OFFHAND_ITEM:
player.c(EnumHand.OFF_HAND);
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
break;
case STOP_SITTING:
player.getBukkitEntity().setMetadata("citizens.sitting", new FixedMetadataValue(CitizensAPI.getPlugin(), false));
NMS.mount(player.getBukkitEntity(), null);
break;
case STOP_SLEEPING:
playDefaultAnimation(player, radius, 2);
break;
case STOP_SNEAKING:
player.getBukkitEntity().setSneaking(false);
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
break;
case STOP_USE_ITEM:
player.clearActiveItem();
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
break;
default:
throw new UnsupportedOperationException();
}
}
Aggregations