mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-23 19:05:12 +01:00
Use internal entity tracker to send packets from NMS entities
This commit is contained in:
parent
4f25e6550b
commit
415f1c51bc
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.core.nms.entity;
|
||||
|
||||
public abstract class NMSEntityHelper<T> {
|
||||
|
||||
private T tracker;
|
||||
|
||||
protected final T getTracker() {
|
||||
if (tracker == null) {
|
||||
// Cache it the first time it's available
|
||||
tracker = getTracker0();
|
||||
}
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
protected abstract T getTracker0();
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_10_R1.EnumHand;
|
||||
import net.minecraft.server.v1_10_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_10_R1.EnumItemSlot;
|
||||
@ -39,12 +37,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -208,22 +208,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardItemLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.NMSCommons;
|
||||
@ -28,12 +27,14 @@ import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private final StandardItemLine parentHologramLine;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSItem(World world, StandardItemLine parentHologramLine) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
}
|
||||
@ -51,18 +52,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
Entity vehicle = bB();
|
||||
if (vehicle != null) {
|
||||
// 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);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutMount(vehicle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,12 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime;
|
||||
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
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.EntitySlime;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
@ -26,12 +24,14 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
@ -54,18 +54,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
Entity vehicle = bB();
|
||||
if (vehicle != null) {
|
||||
// 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);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutMount(vehicle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_10_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.EntityTrackerEntry;
|
||||
import net.minecraft.server.v1_10_R1.Packet;
|
||||
import net.minecraft.server.v1_10_R1.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTrackerEntry getTracker0() {
|
||||
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTrackerEntry tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_11_R1.DamageSource;
|
||||
import net.minecraft.server.v1_11_R1.Entity;
|
||||
import net.minecraft.server.v1_11_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_11_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_11_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_11_R1.EnumHand;
|
||||
import net.minecraft.server.v1_11_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_11_R1.EnumItemSlot;
|
||||
@ -39,12 +37,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -208,22 +208,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_11_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_11_R1.Entity;
|
||||
import net.minecraft.server.v1_11_R1.EntityTrackerEntry;
|
||||
import net.minecraft.server.v1_11_R1.Packet;
|
||||
import net.minecraft.server.v1_11_R1.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTrackerEntry getTracker0() {
|
||||
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTrackerEntry tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_12_R1.DamageSource;
|
||||
import net.minecraft.server.v1_12_R1.Entity;
|
||||
import net.minecraft.server.v1_12_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_12_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_12_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_12_R1.EnumHand;
|
||||
import net.minecraft.server.v1_12_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_12_R1.EnumItemSlot;
|
||||
@ -39,12 +37,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -208,22 +208,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_12_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_12_R1.Entity;
|
||||
import net.minecraft.server.v1_12_R1.EntityTrackerEntry;
|
||||
import net.minecraft.server.v1_12_R1.Packet;
|
||||
import net.minecraft.server.v1_12_R1.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTrackerEntry getTracker0() {
|
||||
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTrackerEntry tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_13_R1.DamageSource;
|
||||
import net.minecraft.server.v1_13_R1.Entity;
|
||||
import net.minecraft.server.v1_13_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_13_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_13_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_13_R1.EnumHand;
|
||||
import net.minecraft.server.v1_13_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_13_R1.EnumItemSlot;
|
||||
@ -41,12 +39,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -210,22 +210,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_13_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_13_R1.Entity;
|
||||
import net.minecraft.server.v1_13_R1.EntityTrackerEntry;
|
||||
import net.minecraft.server.v1_13_R1.Packet;
|
||||
import net.minecraft.server.v1_13_R1.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTrackerEntry getTracker0() {
|
||||
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTrackerEntry tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_13_R2.DamageSource;
|
||||
import net.minecraft.server.v1_13_R2.Entity;
|
||||
import net.minecraft.server.v1_13_R2.EntityArmorStand;
|
||||
import net.minecraft.server.v1_13_R2.EntityHuman;
|
||||
import net.minecraft.server.v1_13_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_13_R2.EnumHand;
|
||||
import net.minecraft.server.v1_13_R2.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_13_R2.EnumItemSlot;
|
||||
@ -41,12 +39,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -210,22 +210,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_13_R2;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_13_R2.Entity;
|
||||
import net.minecraft.server.v1_13_R2.EntityTrackerEntry;
|
||||
import net.minecraft.server.v1_13_R2.Packet;
|
||||
import net.minecraft.server.v1_13_R2.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTrackerEntry getTracker0() {
|
||||
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTrackerEntry tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_14_R1.DamageSource;
|
||||
import net.minecraft.server.v1_14_R1.Entity;
|
||||
import net.minecraft.server.v1_14_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_14_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_14_R1.EnumHand;
|
||||
import net.minecraft.server.v1_14_R1.EnumInteractionResult;
|
||||
@ -42,6 +40,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private CraftEntity customBukkitEntity;
|
||||
private String customName;
|
||||
|
||||
@ -49,6 +48,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
super(EntityTypes.ARMOR_STAND, world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -212,22 +212,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_14_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_14_R1.Entity;
|
||||
import net.minecraft.server.v1_14_R1.Packet;
|
||||
import net.minecraft.server.v1_14_R1.PlayerChunkMap.EntityTracker;
|
||||
import net.minecraft.server.v1_14_R1.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTracker> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTracker getTracker0() {
|
||||
return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTracker tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_15_R1.DamageSource;
|
||||
import net.minecraft.server.v1_15_R1.Entity;
|
||||
import net.minecraft.server.v1_15_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_15_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_15_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_15_R1.EnumHand;
|
||||
import net.minecraft.server.v1_15_R1.EnumInteractionResult;
|
||||
@ -42,6 +40,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private CraftEntity customBukkitEntity;
|
||||
private String customName;
|
||||
|
||||
@ -49,6 +48,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
super(EntityTypes.ARMOR_STAND, world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -212,22 +212,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX(), super.locX(), nmsPlayer.locZ(), super.locZ());
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_15_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_15_R1.Entity;
|
||||
import net.minecraft.server.v1_15_R1.Packet;
|
||||
import net.minecraft.server.v1_15_R1.PlayerChunkMap.EntityTracker;
|
||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTracker> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTracker getTracker0() {
|
||||
return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTracker tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_16_R1.DamageSource;
|
||||
import net.minecraft.server.v1_16_R1.Entity;
|
||||
import net.minecraft.server.v1_16_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_16_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_16_R1.EnumHand;
|
||||
import net.minecraft.server.v1_16_R1.EnumInteractionResult;
|
||||
@ -42,6 +40,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private CraftEntity customBukkitEntity;
|
||||
private String customName;
|
||||
|
||||
@ -49,6 +48,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
super(EntityTypes.ARMOR_STAND, world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -212,22 +212,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX(), super.locX(), nmsPlayer.locZ(), super.locZ());
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_16_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_16_R1.Entity;
|
||||
import net.minecraft.server.v1_16_R1.Packet;
|
||||
import net.minecraft.server.v1_16_R1.PlayerChunkMap.EntityTracker;
|
||||
import net.minecraft.server.v1_16_R1.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTracker> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTracker getTracker0() {
|
||||
return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTracker tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_16_R2.DamageSource;
|
||||
import net.minecraft.server.v1_16_R2.Entity;
|
||||
import net.minecraft.server.v1_16_R2.EntityArmorStand;
|
||||
import net.minecraft.server.v1_16_R2.EntityHuman;
|
||||
import net.minecraft.server.v1_16_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R2.EntityTypes;
|
||||
import net.minecraft.server.v1_16_R2.EnumHand;
|
||||
import net.minecraft.server.v1_16_R2.EnumInteractionResult;
|
||||
@ -42,6 +40,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private CraftEntity customBukkitEntity;
|
||||
private String customName;
|
||||
|
||||
@ -49,6 +48,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
super(EntityTypes.ARMOR_STAND, world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -212,22 +212,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX(), super.locX(), nmsPlayer.locZ(), super.locZ());
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_16_R2;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_16_R2.Entity;
|
||||
import net.minecraft.server.v1_16_R2.Packet;
|
||||
import net.minecraft.server.v1_16_R2.PlayerChunkMap.EntityTracker;
|
||||
import net.minecraft.server.v1_16_R2.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTracker> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTracker getTracker0() {
|
||||
return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTracker tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_16_R3.DamageSource;
|
||||
import net.minecraft.server.v1_16_R3.Entity;
|
||||
import net.minecraft.server.v1_16_R3.EntityArmorStand;
|
||||
import net.minecraft.server.v1_16_R3.EntityHuman;
|
||||
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R3.EntityTypes;
|
||||
import net.minecraft.server.v1_16_R3.EnumHand;
|
||||
import net.minecraft.server.v1_16_R3.EnumInteractionResult;
|
||||
@ -42,6 +40,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private CraftEntity customBukkitEntity;
|
||||
private String customName;
|
||||
|
||||
@ -49,6 +48,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
super(EntityTypes.ARMOR_STAND, world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -212,22 +212,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.getPlayers()) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX(), super.locX(), nmsPlayer.locZ(), super.locZ());
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_16_R3;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_16_R3.Entity;
|
||||
import net.minecraft.server.v1_16_R3.Packet;
|
||||
import net.minecraft.server.v1_16_R3.PlayerChunkMap.EntityTracker;
|
||||
import net.minecraft.server.v1_16_R3.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTracker> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTracker getTracker0() {
|
||||
return ((WorldServer) entity.world).getChunkProvider().playerChunkMap.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTracker tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,7 +10,6 @@ import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.fcommons.reflection.ReflectMethod;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -20,7 +19,6 @@ import net.minecraft.server.v1_8_R2.DamageSource;
|
||||
import net.minecraft.server.v1_8_R2.Entity;
|
||||
import net.minecraft.server.v1_8_R2.EntityArmorStand;
|
||||
import net.minecraft.server.v1_8_R2.EntityHuman;
|
||||
import net.minecraft.server.v1_8_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R2.ItemStack;
|
||||
import net.minecraft.server.v1_8_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_8_R2.PacketPlayOutEntityTeleport;
|
||||
@ -38,12 +36,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private String customName;
|
||||
|
||||
|
||||
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -197,22 +197,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_8_R2;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_8_R2.Entity;
|
||||
import net.minecraft.server.v1_8_R2.EntityTrackerEntry;
|
||||
import net.minecraft.server.v1_8_R2.Packet;
|
||||
import net.minecraft.server.v1_8_R2.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTrackerEntry getTracker0() {
|
||||
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTrackerEntry tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,7 +10,6 @@ import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.fcommons.reflection.ReflectMethod;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -20,7 +19,6 @@ import net.minecraft.server.v1_8_R3.DamageSource;
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
import net.minecraft.server.v1_8_R3.EntityArmorStand;
|
||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||
import net.minecraft.server.v1_8_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
|
||||
@ -38,12 +36,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -197,22 +197,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_8_R3;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTrackerEntry getTracker0() {
|
||||
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTrackerEntry tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_9_R1.DamageSource;
|
||||
import net.minecraft.server.v1_9_R1.Entity;
|
||||
import net.minecraft.server.v1_9_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_9_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_9_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_9_R1.EnumHand;
|
||||
import net.minecraft.server.v1_9_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_9_R1.EnumItemSlot;
|
||||
@ -39,6 +37,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
|
||||
private String customName;
|
||||
|
||||
@ -46,6 +45,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -209,22 +209,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_9_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardItemLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.NMSCommons;
|
||||
@ -28,12 +27,14 @@ import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack;
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private final StandardItemLine parentHologramLine;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSItem(World world, StandardItemLine parentHologramLine) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
}
|
||||
@ -51,18 +52,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
Entity vehicle = by();
|
||||
if (vehicle != null) {
|
||||
// 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);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutMount(vehicle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,12 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_9_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime;
|
||||
import net.minecraft.server.v1_9_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_9_R1.DamageSource;
|
||||
import net.minecraft.server.v1_9_R1.Entity;
|
||||
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.EntitySlime;
|
||||
import net.minecraft.server.v1_9_R1.NBTTagCompound;
|
||||
@ -26,12 +24,14 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
@ -54,18 +54,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
Entity vehicle = by();
|
||||
if (vehicle != null) {
|
||||
// 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);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutMount(vehicle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_9_R1;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_9_R1.Entity;
|
||||
import net.minecraft.server.v1_9_R1.EntityTrackerEntry;
|
||||
import net.minecraft.server.v1_9_R1.Packet;
|
||||
import net.minecraft.server.v1_9_R1.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTrackerEntry getTracker0() {
|
||||
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTrackerEntry tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.reflection.ReflectField;
|
||||
import me.filoghost.holographicdisplays.core.DebugLogger;
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.ProtocolPacketSettings;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
|
||||
@ -19,7 +18,6 @@ import net.minecraft.server.v1_9_R2.DamageSource;
|
||||
import net.minecraft.server.v1_9_R2.Entity;
|
||||
import net.minecraft.server.v1_9_R2.EntityArmorStand;
|
||||
import net.minecraft.server.v1_9_R2.EntityHuman;
|
||||
import net.minecraft.server.v1_9_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_9_R2.EnumHand;
|
||||
import net.minecraft.server.v1_9_R2.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_9_R2.EnumItemSlot;
|
||||
@ -39,12 +37,14 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final ProtocolPacketSettings protocolPacketSettings;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
private String customName;
|
||||
|
||||
public EntityNMSArmorStand(World world, StandardHologramLine parentHologramLine, ProtocolPacketSettings protocolPacketSettings) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.protocolPacketSettings = protocolPacketSettings;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.setInvisible(true);
|
||||
super.setSmall(true);
|
||||
@ -209,22 +209,7 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
|
||||
public void setLocationNMS(double x, double y, double z) {
|
||||
super.setPosition(x, y, z);
|
||||
if (protocolPacketSettings.sendAccurateLocationPackets()) {
|
||||
broadcastLocationPacketNMS();
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastLocationPacketNMS() {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 64 * 64 * 2 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutEntityTeleport(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_9_R2;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardItemLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.NMSCommons;
|
||||
@ -28,12 +27,14 @@ import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
|
||||
public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
|
||||
private final StandardItemLine parentHologramLine;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSItem(World world, StandardItemLine parentHologramLine) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.pickupDelay = Integer.MAX_VALUE;
|
||||
}
|
||||
@ -51,18 +52,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
|
||||
Entity vehicle = bz();
|
||||
if (vehicle != null) {
|
||||
// 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);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutMount(vehicle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,12 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_9_R2;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.Utils;
|
||||
import me.filoghost.holographicdisplays.core.hologram.StandardHologramLine;
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime;
|
||||
import net.minecraft.server.v1_9_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_9_R2.DamageSource;
|
||||
import net.minecraft.server.v1_9_R2.Entity;
|
||||
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.EntitySlime;
|
||||
import net.minecraft.server.v1_9_R2.NBTTagCompound;
|
||||
@ -26,12 +24,14 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
|
||||
private final StandardHologramLine parentHologramLine;
|
||||
private final VersionNMSEntityHelper helper;
|
||||
|
||||
private int resendMountPacketTicks;
|
||||
|
||||
public EntityNMSSlime(World world, StandardHologramLine parentHologramLine) {
|
||||
super(world);
|
||||
this.parentHologramLine = parentHologramLine;
|
||||
this.helper = new VersionNMSEntityHelper(this);
|
||||
|
||||
super.persistent = true;
|
||||
super.collides = false;
|
||||
@ -54,18 +54,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
|
||||
Entity vehicle = bz();
|
||||
if (vehicle != null) {
|
||||
// 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);
|
||||
|
||||
for (EntityHuman humanEntity : super.world.players) {
|
||||
if (humanEntity instanceof EntityPlayer) {
|
||||
EntityPlayer nmsPlayer = (EntityPlayer) humanEntity;
|
||||
|
||||
double distanceSquared = Utils.distanceSquared(nmsPlayer.locX, super.locX, nmsPlayer.locZ, super.locZ);
|
||||
if (distanceSquared < 32 * 32 && nmsPlayer.playerConnection != null) {
|
||||
nmsPlayer.playerConnection.sendPacket(mountPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
helper.broadcastPacket(new PacketPlayOutMount(vehicle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.nms.v1_9_R2;
|
||||
|
||||
import me.filoghost.holographicdisplays.core.nms.entity.NMSEntityHelper;
|
||||
import net.minecraft.server.v1_9_R2.Entity;
|
||||
import net.minecraft.server.v1_9_R2.EntityTrackerEntry;
|
||||
import net.minecraft.server.v1_9_R2.Packet;
|
||||
import net.minecraft.server.v1_9_R2.WorldServer;
|
||||
|
||||
public class VersionNMSEntityHelper extends NMSEntityHelper<EntityTrackerEntry> {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public VersionNMSEntityHelper(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityTrackerEntry getTracker0() {
|
||||
return ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
|
||||
}
|
||||
|
||||
public void broadcastPacket(Packet<?> packet) {
|
||||
EntityTrackerEntry tracker = getTracker();
|
||||
if (tracker != null) {
|
||||
tracker.broadcast(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user