mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-23 19:05:12 +01:00
Small refactoring
This commit is contained in:
parent
aacc7fdeb4
commit
de3f967a21
@ -9,6 +9,10 @@ import me.filoghost.fcommons.Strings;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
public static double distanceSquared(double locX1, double locX2, double locZ1, double locZ2) {
|
||||||
|
return square(locX1 - locX2) + square(locZ1 - locZ2);
|
||||||
|
}
|
||||||
|
|
||||||
public static double square(double num) {
|
public static double square(double num) {
|
||||||
return num * num;
|
return num * num;
|
||||||
}
|
}
|
||||||
|
@ -215,12 +215,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
|
|||||||
// Send a packet near to "remind" players that the item is riding the armor stand (Spigot bug or client bug)
|
// Send a packet near to "remind" players that the item is riding the armor stand (Spigot bug or client bug)
|
||||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import net.minecraft.server.v1_10_R1.AxisAlignedBB;
|
|||||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||||
import net.minecraft.server.v1_10_R1.Entity;
|
import net.minecraft.server.v1_10_R1.Entity;
|
||||||
import net.minecraft.server.v1_10_R1.EntityDamageSource;
|
import net.minecraft.server.v1_10_R1.EntityDamageSource;
|
||||||
|
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_10_R1.EntitySlime;
|
import net.minecraft.server.v1_10_R1.EntitySlime;
|
||||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||||
@ -55,12 +56,12 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
|||||||
// Send a packet near to "remind" players that the slime is riding the armor stand (Spigot bug or client bug)
|
// Send a packet near to "remind" players that the slime is riding the armor stand (Spigot bug or client bug)
|
||||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,12 +215,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,12 +215,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,12 +217,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,12 +217,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.getPlayers()) {
|
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.getPlayers()) {
|
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX() - super.locX()) + Utils.square(nmsPlayer.locZ() - super.locZ());
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX(), super.locX(), nmsPlayer.locZ(), super.locZ());
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.getPlayers()) {
|
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX() - super.locX()) + Utils.square(nmsPlayer.locZ() - super.locZ());
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX(), super.locX(), nmsPlayer.locZ(), super.locZ());
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.getPlayers()) {
|
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX() - super.locX()) + Utils.square(nmsPlayer.locZ() - super.locZ());
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX(), super.locX(), nmsPlayer.locZ(), super.locZ());
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.getPlayers()) {
|
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX() - super.locX()) + Utils.square(nmsPlayer.locZ() - super.locZ());
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX(), super.locX(), nmsPlayer.locZ(), super.locZ());
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,12 +204,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,12 +204,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,12 +216,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
|
|||||||
// Send a packet near to "remind" players that the item is riding the armor stand (Spigot bug or client bug)
|
// Send a packet near to "remind" players that the item is riding the armor stand (Spigot bug or client bug)
|
||||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import net.minecraft.server.v1_9_R1.AxisAlignedBB;
|
|||||||
import net.minecraft.server.v1_9_R1.DamageSource;
|
import net.minecraft.server.v1_9_R1.DamageSource;
|
||||||
import net.minecraft.server.v1_9_R1.Entity;
|
import net.minecraft.server.v1_9_R1.Entity;
|
||||||
import net.minecraft.server.v1_9_R1.EntityDamageSource;
|
import net.minecraft.server.v1_9_R1.EntityDamageSource;
|
||||||
|
import net.minecraft.server.v1_9_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_9_R1.EntityPlayer;
|
import net.minecraft.server.v1_9_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_9_R1.EntitySlime;
|
import net.minecraft.server.v1_9_R1.EntitySlime;
|
||||||
import net.minecraft.server.v1_9_R1.NBTTagCompound;
|
import net.minecraft.server.v1_9_R1.NBTTagCompound;
|
||||||
@ -55,12 +56,12 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
|||||||
// Send a packet near to "remind" players that the slime is riding the armor stand (Spigot bug or client bug)
|
// Send a packet near to "remind" players that the slime is riding the armor stand (Spigot bug or client bug)
|
||||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,12 +216,12 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
|||||||
private void broadcastLocationPacketNMS() {
|
private void broadcastLocationPacketNMS() {
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,12 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
|
|||||||
// Send a packet near to "remind" players that the item is riding the armor stand (Spigot bug or client bug)
|
// Send a packet near to "remind" players that the item is riding the armor stand (Spigot bug or client bug)
|
||||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import net.minecraft.server.v1_9_R2.AxisAlignedBB;
|
|||||||
import net.minecraft.server.v1_9_R2.DamageSource;
|
import net.minecraft.server.v1_9_R2.DamageSource;
|
||||||
import net.minecraft.server.v1_9_R2.Entity;
|
import net.minecraft.server.v1_9_R2.Entity;
|
||||||
import net.minecraft.server.v1_9_R2.EntityDamageSource;
|
import net.minecraft.server.v1_9_R2.EntityDamageSource;
|
||||||
|
import net.minecraft.server.v1_9_R2.EntityHuman;
|
||||||
import net.minecraft.server.v1_9_R2.EntityPlayer;
|
import net.minecraft.server.v1_9_R2.EntityPlayer;
|
||||||
import net.minecraft.server.v1_9_R2.EntitySlime;
|
import net.minecraft.server.v1_9_R2.EntitySlime;
|
||||||
import net.minecraft.server.v1_9_R2.NBTTagCompound;
|
import net.minecraft.server.v1_9_R2.NBTTagCompound;
|
||||||
@ -55,12 +56,12 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
|||||||
// Send a packet near to "remind" players that the slime is riding the armor stand (Spigot bug or client bug)
|
// Send a packet near to "remind" players that the slime is riding the armor stand (Spigot bug or client bug)
|
||||||
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
PacketPlayOutMount mountPacket = new PacketPlayOutMount(vehicle);
|
||||||
|
|
||||||
for (Object humanEntity : super.world.players) {
|
for (EntityHuman humanEntity : super.world.players) {
|
||||||
if (humanEntity instanceof EntityPlayer) {
|
if (humanEntity instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||||
|
|
||||||
double distanceSquared = Utils.square(nmsPlayer.locX - super.locX) + Utils.square(nmsPlayer.locZ - super.locZ);
|
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||||
if (distanceSquared < 1024 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user