diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseLinePosition.java b/common/src/main/java/me/filoghost/holographicdisplays/common/Position.java similarity index 76% rename from plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseLinePosition.java rename to common/src/main/java/me/filoghost/holographicdisplays/common/Position.java index 5c93ff98..b506aa29 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseLinePosition.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/Position.java @@ -3,13 +3,13 @@ * * SPDX-License-Identifier: GPL-3.0-or-later */ -package me.filoghost.holographicdisplays.plugin.hologram.base; +package me.filoghost.holographicdisplays.common; -public final class BaseLinePosition { +public final class Position { private final double x, y, z; - public BaseLinePosition(double x, double y, double z) { + public Position(double x, double y, double z) { this.x = x; this.y = y; this.z = z; @@ -27,6 +27,14 @@ public final class BaseLinePosition { return z; } + public Position addY(double y) { + if (y == 0) { + return this; + } + + return new Position(this.x, this.y + y, this.z); + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -36,7 +44,7 @@ public final class BaseLinePosition { return false; } - BaseLinePosition other = (BaseLinePosition) obj; + Position other = (Position) obj; return Double.doubleToLongBits(this.x) == Double.doubleToLongBits(other.x) && Double.doubleToLongBits(this.y) == Double.doubleToLongBits(other.y) && Double.doubleToLongBits(this.z) == Double.doubleToLongBits(other.z); diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/ClickableNMSPacketEntity.java b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/ClickableNMSPacketEntity.java index e2c50e4e..72ba2b47 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/ClickableNMSPacketEntity.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/ClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.common.nms.entity; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; @@ -15,6 +16,6 @@ public interface ClickableNMSPacketEntity extends NMSPacketEntity { EntityID getID(); - void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ); + void addSpawnPackets(NMSPacketList packetList, Position position); } diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/ItemNMSPacketEntity.java b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/ItemNMSPacketEntity.java index 14d8c179..8f6cb1b6 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/ItemNMSPacketEntity.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/ItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.common.nms.entity; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import org.bukkit.inventory.ItemStack; @@ -13,7 +14,7 @@ public interface ItemNMSPacketEntity extends NMSPacketEntity { double ITEM_Y_OFFSET = 0; double ITEM_HEIGHT = 0.7; - void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack); + void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack); void addChangePackets(NMSPacketList packetList, ItemStack itemStack); diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSPacketEntity.java b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSPacketEntity.java index eb6f37f6..1af1ed6c 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSPacketEntity.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/NMSPacketEntity.java @@ -5,11 +5,12 @@ */ package me.filoghost.holographicdisplays.common.nms.entity; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; public interface NMSPacketEntity { - void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ); + void addTeleportPackets(NMSPacketList packetList, Position position); void addDestroyPackets(NMSPacketList packetList); diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/TextNMSPacketEntity.java b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/TextNMSPacketEntity.java index 9575d8e4..3adcb4c0 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/TextNMSPacketEntity.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/nms/entity/TextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.common.nms.entity; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.IndividualText; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; @@ -13,9 +14,9 @@ public interface TextNMSPacketEntity extends NMSPacketEntity { double ARMOR_STAND_Y_OFFSET = -0.29; double ARMOR_STAND_TEXT_HEIGHT = 0.23; - void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text); + void addSpawnPackets(NMSPacketList packetList, Position position, String text); - void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText); + void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText); void addChangePackets(NMSPacketList packetList, String text); diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityLivingSpawnNMSPacket.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityLivingSpawnNMSPacket.java index 5fbc7143..de792d5b 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityLivingSpawnNMSPacket.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.nms.v1_10_R1; import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_10_R1.DataWatcher; import net.minecraft.server.v1_10_R1.Packet; @@ -34,7 +35,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { } public static DataWatcherPacketBuilder builder( - EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -42,9 +43,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeByte(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntitySpawnNMSPacket.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntitySpawnNMSPacket.java index 4742d3c2..1b33c601 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntitySpawnNMSPacket.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_10_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_10_R1.Packet; import net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeByte(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityTeleportNMSPacket.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityTeleportNMSPacket.java index 2a1d2677..a992eb0c 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityTeleportNMSPacket.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_10_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_10_R1.Packet; import net.minecraft.server.v1_10_R1.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionClickableNMSPacketEntity.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionClickableNMSPacketEntity.java index a477d3c4..8aa2924e 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionClickableNMSPacketEntity.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_10_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(EntityLivingSpawnNMSPacket.builder( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ) + packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box .build() @@ -42,8 +41,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionItemNMSPacketEntity.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionItemNMSPacketEntity.java index cd91e3ba..19a08bc8 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionItemNMSPacketEntity.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_10_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionTextNMSPacketEntity.java b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionTextNMSPacketEntity.java index 94be6b82..1eb35945 100644 --- a/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionTextNMSPacketEntity.java +++ b/nms/v1_10_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_10_R1/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_10_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityLivingSpawnNMSPacket.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityLivingSpawnNMSPacket.java index 78f3b893..ea531c70 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityLivingSpawnNMSPacket.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.nms.v1_11_R1; import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_11_R1.DataWatcher; import net.minecraft.server.v1_11_R1.Packet; @@ -34,7 +35,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { } public static DataWatcherPacketBuilder builder( - EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -42,9 +43,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntitySpawnNMSPacket.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntitySpawnNMSPacket.java index cc3b1395..f5e57fe1 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntitySpawnNMSPacket.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_11_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_11_R1.Packet; import net.minecraft.server.v1_11_R1.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeByte(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityTeleportNMSPacket.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityTeleportNMSPacket.java index e6bc1e3f..cd8728ed 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityTeleportNMSPacket.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_11_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_11_R1.Packet; import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionClickableNMSPacketEntity.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionClickableNMSPacketEntity.java index d18ea9fd..fa9d6691 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionClickableNMSPacketEntity.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_11_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(EntityLivingSpawnNMSPacket.builder( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ) + packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box .build() @@ -42,8 +41,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionItemNMSPacketEntity.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionItemNMSPacketEntity.java index d66795a3..2b93778b 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionItemNMSPacketEntity.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_11_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionTextNMSPacketEntity.java b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionTextNMSPacketEntity.java index 3bd5d2b5..42a05b65 100644 --- a/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionTextNMSPacketEntity.java +++ b/nms/v1_11_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_11_R1/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_11_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityLivingSpawnNMSPacket.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityLivingSpawnNMSPacket.java index 882deb73..513d0b0f 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityLivingSpawnNMSPacket.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.nms.v1_12_R1; import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_12_R1.DataWatcher; import net.minecraft.server.v1_12_R1.Packet; @@ -34,7 +35,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { } public static DataWatcherPacketBuilder builder( - EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -42,9 +43,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntitySpawnNMSPacket.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntitySpawnNMSPacket.java index a97ab371..42e22426 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntitySpawnNMSPacket.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_12_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_12_R1.Packet; import net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeByte(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityTeleportNMSPacket.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityTeleportNMSPacket.java index 916b122a..a54d29ef 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityTeleportNMSPacket.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_12_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_12_R1.Packet; import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionClickableNMSPacketEntity.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionClickableNMSPacketEntity.java index f5f2a14f..d0da052c 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionClickableNMSPacketEntity.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_12_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(EntityLivingSpawnNMSPacket.builder( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ) + packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box .build() @@ -42,8 +41,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionItemNMSPacketEntity.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionItemNMSPacketEntity.java index 61b70a20..54160479 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionItemNMSPacketEntity.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_12_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionTextNMSPacketEntity.java b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionTextNMSPacketEntity.java index 38ef4a5c..4c8ee413 100644 --- a/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionTextNMSPacketEntity.java +++ b/nms/v1_12_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_12_R1/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_12_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityLivingSpawnNMSPacket.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityLivingSpawnNMSPacket.java index 8adcdd05..215b1344 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityLivingSpawnNMSPacket.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.nms.v1_13_R2; import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_13_R2.DataWatcher; import net.minecraft.server.v1_13_R2.Packet; @@ -34,7 +35,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { } public static DataWatcherPacketBuilder builder( - EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -42,9 +43,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntitySpawnNMSPacket.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntitySpawnNMSPacket.java index a287f1fb..9ed007ca 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntitySpawnNMSPacket.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_13_R2.Packet; import net.minecraft.server.v1_13_R2.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeByte(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityTeleportNMSPacket.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityTeleportNMSPacket.java index 534d1c2c..c7978e2e 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityTeleportNMSPacket.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_13_R2.Packet; import net.minecraft.server.v1_13_R2.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionClickableNMSPacketEntity.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionClickableNMSPacketEntity.java index 8fde7d6b..16b31af9 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionClickableNMSPacketEntity.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(EntityLivingSpawnNMSPacket.builder( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ) + packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box .build() @@ -42,8 +41,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionItemNMSPacketEntity.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionItemNMSPacketEntity.java index a9bf0767..76eb34c1 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionItemNMSPacketEntity.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionTextNMSPacketEntity.java b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionTextNMSPacketEntity.java index 7e9b5c39..d628d18d 100644 --- a/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionTextNMSPacketEntity.java +++ b/nms/v1_13_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_13_R2/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_13_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityLivingSpawnNMSPacket.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityLivingSpawnNMSPacket.java index 824c887d..7fd5aa9f 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityLivingSpawnNMSPacket.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.nms.v1_14_R1; import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_14_R1.DataWatcher; import net.minecraft.server.v1_14_R1.Packet; @@ -34,7 +35,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { } public static DataWatcherPacketBuilder builder( - EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -42,9 +43,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntitySpawnNMSPacket.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntitySpawnNMSPacket.java index 52c20450..8c7ab1e4 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntitySpawnNMSPacket.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_14_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_14_R1.Packet; import net.minecraft.server.v1_14_R1.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityTeleportNMSPacket.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityTeleportNMSPacket.java index acb2d358..838f4241 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityTeleportNMSPacket.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_14_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_14_R1.Packet; import net.minecraft.server.v1_14_R1.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionClickableNMSPacketEntity.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionClickableNMSPacketEntity.java index 1cb75e32..4f801b58 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionClickableNMSPacketEntity.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_14_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,14 +26,12 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(EntityLivingSpawnNMSPacket.builder( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ) + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(EntityLivingSpawnNMSPacket.builder(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET) .setArmorStandMarker() .build() ); - packetList.add(EntityLivingSpawnNMSPacket.builder( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ) + packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box .build() @@ -41,8 +40,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionItemNMSPacketEntity.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionItemNMSPacketEntity.java index 8667d469..6becc41c 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionItemNMSPacketEntity.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_14_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,14 +22,12 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(EntityLivingSpawnNMSPacket.builder( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ) + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(EntityLivingSpawnNMSPacket.builder(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -45,8 +44,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionTextNMSPacketEntity.java b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionTextNMSPacketEntity.java index 9d55f623..6f1d9763 100644 --- a/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionTextNMSPacketEntity.java +++ b/nms/v1_14_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_14_R1/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_14_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(EntityLivingSpawnNMSPacket.builder( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ) + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(EntityLivingSpawnNMSPacket.builder(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET) .setArmorStandMarker() .setCustomName(text) .build() @@ -30,13 +30,12 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityLivingSpawnNMSPacket.builder( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new IndividualNMSPacket(player -> + EntityLivingSpawnNMSPacket.builder(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -50,15 +49,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityLivingSpawnNMSPacket.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityLivingSpawnNMSPacket.java index a79a646a..c7c376d8 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityLivingSpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_15_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_15_R1.Packet; import net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntityLiving; @@ -13,7 +14,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntitySpawnNMSPacket.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntitySpawnNMSPacket.java index 5725153d..87a6fc43 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntitySpawnNMSPacket.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_15_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_15_R1.Packet; import net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityTeleportNMSPacket.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityTeleportNMSPacket.java index 6f6816ae..0fd0cc7e 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityTeleportNMSPacket.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_15_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_15_R1.Packet; import net.minecraft.server.v1_15_R1.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionClickableNMSPacketEntity.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionClickableNMSPacketEntity.java index a22f01e3..90a615b2 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionClickableNMSPacketEntity.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_15_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntityLivingSpawnNMSPacket( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(slimeID) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box @@ -43,8 +42,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionItemNMSPacketEntity.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionItemNMSPacketEntity.java index 92c55414..0bbb0c0a 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionItemNMSPacketEntity.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_15_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionTextNMSPacketEntity.java b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionTextNMSPacketEntity.java index e1b2a1aa..c1574cbc 100644 --- a/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionTextNMSPacketEntity.java +++ b/nms/v1_15_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_15_R1/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_15_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityLivingSpawnNMSPacket.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityLivingSpawnNMSPacket.java index 0a32384b..859ebcee 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityLivingSpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_16_R1.Packet; import net.minecraft.server.v1_16_R1.PacketPlayOutSpawnEntityLiving; @@ -13,7 +14,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntitySpawnNMSPacket.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntitySpawnNMSPacket.java index 48714af6..f42830bd 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntitySpawnNMSPacket.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_16_R1.Packet; import net.minecraft.server.v1_16_R1.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityTeleportNMSPacket.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityTeleportNMSPacket.java index 79ea4838..d1e05310 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityTeleportNMSPacket.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_16_R1.Packet; import net.minecraft.server.v1_16_R1.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionClickableNMSPacketEntity.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionClickableNMSPacketEntity.java index 0af429a5..bf6a43b0 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionClickableNMSPacketEntity.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntityLivingSpawnNMSPacket( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(slimeID) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box @@ -43,8 +42,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionItemNMSPacketEntity.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionItemNMSPacketEntity.java index 67ee95fe..623c9659 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionItemNMSPacketEntity.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionTextNMSPacketEntity.java b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionTextNMSPacketEntity.java index 64159501..70e7d286 100644 --- a/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionTextNMSPacketEntity.java +++ b/nms/v1_16_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R1/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityLivingSpawnNMSPacket.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityLivingSpawnNMSPacket.java index 3dba25aa..94a498ff 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityLivingSpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_16_R2.Packet; import net.minecraft.server.v1_16_R2.PacketPlayOutSpawnEntityLiving; @@ -13,7 +14,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntitySpawnNMSPacket.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntitySpawnNMSPacket.java index a6a11c27..8abd749a 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntitySpawnNMSPacket.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_16_R2.Packet; import net.minecraft.server.v1_16_R2.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityTeleportNMSPacket.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityTeleportNMSPacket.java index 427d6c08..79b36f60 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityTeleportNMSPacket.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_16_R2.Packet; import net.minecraft.server.v1_16_R2.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionClickableNMSPacketEntity.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionClickableNMSPacketEntity.java index a9ca4a14..1820f980 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionClickableNMSPacketEntity.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntityLivingSpawnNMSPacket( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(slimeID) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box @@ -43,8 +42,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionItemNMSPacketEntity.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionItemNMSPacketEntity.java index 21b4c5fc..122f51f8 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionItemNMSPacketEntity.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionTextNMSPacketEntity.java b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionTextNMSPacketEntity.java index d12bfa0e..0d57ede6 100644 --- a/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionTextNMSPacketEntity.java +++ b/nms/v1_16_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R2/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityLivingSpawnNMSPacket.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityLivingSpawnNMSPacket.java index 8691a864..0b69c06f 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityLivingSpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_16_R3.Packet; import net.minecraft.server.v1_16_R3.PacketPlayOutSpawnEntityLiving; @@ -13,7 +14,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntitySpawnNMSPacket.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntitySpawnNMSPacket.java index 91e495cf..bc3e5976 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntitySpawnNMSPacket.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_16_R3.Packet; import net.minecraft.server.v1_16_R3.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityTeleportNMSPacket.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityTeleportNMSPacket.java index 15cffe1c..df3fe4f9 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityTeleportNMSPacket.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_16_R3.Packet; import net.minecraft.server.v1_16_R3.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionClickableNMSPacketEntity.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionClickableNMSPacketEntity.java index db5ed16d..c04f75b3 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionClickableNMSPacketEntity.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntityLivingSpawnNMSPacket( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(slimeID) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box @@ -43,8 +42,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionItemNMSPacketEntity.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionItemNMSPacketEntity.java index 0e2d8e5a..89d3c4ef 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionItemNMSPacketEntity.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionTextNMSPacketEntity.java b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionTextNMSPacketEntity.java index edbd47e5..60280747 100644 --- a/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionTextNMSPacketEntity.java +++ b/nms/v1_16_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_16_R3/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_16_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntityLivingSpawnNMSPacket.java b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntityLivingSpawnNMSPacket.java index bdc7cca4..3d9e6327 100644 --- a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntityLivingSpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_17_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving; @@ -13,7 +14,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityLivingSpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntitySpawnNMSPacket.java b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntitySpawnNMSPacket.java index a00d7705..9f2c24f2 100644 --- a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntitySpawnNMSPacket.java +++ b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_17_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeVarInt(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntityTeleportNMSPacket.java b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntityTeleportNMSPacket.java index 57b1e733..657a9779 100644 --- a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntityTeleportNMSPacket.java +++ b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_17_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionClickableNMSPacketEntity.java b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionClickableNMSPacketEntity.java index f1fd8d5a..37b6bd3d 100644 --- a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionClickableNMSPacketEntity.java +++ b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_17_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntityLivingSpawnNMSPacket( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + packetList.add(new EntityLivingSpawnNMSPacket(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(slimeID) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box @@ -43,8 +42,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionItemNMSPacketEntity.java b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionItemNMSPacketEntity.java index 85ce85c9..4bc1d871 100644 --- a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionItemNMSPacketEntity.java +++ b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_17_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntityLivingSpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntityLivingSpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionTextNMSPacketEntity.java b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionTextNMSPacketEntity.java index e56b790e..71f234f2 100644 --- a/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionTextNMSPacketEntity.java +++ b/nms/v1_17_r1/src/main/java/me/filoghost/holographicdisplays/nms/v1_17_R1/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_17_R1; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntityLivingSpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntityLivingSpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityLivingSpawnNMSPacket.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityLivingSpawnNMSPacket.java index 7ba118b5..1b253a64 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityLivingSpawnNMSPacket.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.nms.v1_8_R3; import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.MathHelper; @@ -35,16 +36,16 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { } public static DataWatcherPacketBuilder builder( - EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); packetByteBuffer.writeByte(entityTypeID); // Position - packetByteBuffer.writeInt(MathHelper.floor(positionX * 32)); - packetByteBuffer.writeInt(MathHelper.floor(positionY * 32)); - packetByteBuffer.writeInt(MathHelper.floor(positionZ * 32)); + packetByteBuffer.writeInt(MathHelper.floor(position.getX() * 32)); + packetByteBuffer.writeInt(MathHelper.floor((position.getY() + positionOffsetY) * 32)); + packetByteBuffer.writeInt(MathHelper.floor(position.getZ() * 32)); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntitySpawnNMSPacket.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntitySpawnNMSPacket.java index 096f7288..b5919afe 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntitySpawnNMSPacket.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_8_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; @@ -14,16 +15,16 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); packetByteBuffer.writeByte(entityTypeID); // Position - packetByteBuffer.writeInt(MathHelper.floor(positionX * 32)); - packetByteBuffer.writeInt(MathHelper.floor(positionY * 32)); - packetByteBuffer.writeInt(MathHelper.floor(positionZ * 32)); + packetByteBuffer.writeInt(MathHelper.floor(position.getX() * 32)); + packetByteBuffer.writeInt(MathHelper.floor((position.getY() + positionOffsetY) * 32)); + packetByteBuffer.writeInt(MathHelper.floor(position.getZ() * 32)); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityTeleportNMSPacket.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityTeleportNMSPacket.java index ffd16eb5..c606f3b9 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityTeleportNMSPacket.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_8_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; @@ -14,15 +15,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeInt(MathHelper.floor(positionX * 32)); - packetByteBuffer.writeInt(MathHelper.floor(positionY * 32)); - packetByteBuffer.writeInt(MathHelper.floor(positionZ * 32)); + packetByteBuffer.writeInt(MathHelper.floor(position.getX() * 32)); + packetByteBuffer.writeInt(MathHelper.floor((position.getY() + positionOffsetY) * 32)); + packetByteBuffer.writeInt(MathHelper.floor(position.getZ() * 32)); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionClickableNMSPacketEntity.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionClickableNMSPacketEntity.java index 6e35e488..55e33567 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionClickableNMSPacketEntity.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_8_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(EntityLivingSpawnNMSPacket.builder( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ) + packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box .build() @@ -42,8 +41,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionItemNMSPacketEntity.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionItemNMSPacketEntity.java index 908235fb..fc5686ee 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionItemNMSPacketEntity.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_8_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionTextNMSPacketEntity.java b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionTextNMSPacketEntity.java index 9d8610fe..8f0c3a98 100644 --- a/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionTextNMSPacketEntity.java +++ b/nms/v1_8_r3/src/main/java/me/filoghost/holographicdisplays/nms/v1_8_R3/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_8_R3; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityLivingSpawnNMSPacket.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityLivingSpawnNMSPacket.java index e4e84073..d1001ba2 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityLivingSpawnNMSPacket.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityLivingSpawnNMSPacket.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.nms.v1_9_R2; import me.filoghost.fcommons.reflection.ReflectField; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_9_R2.DataWatcher; import net.minecraft.server.v1_9_R2.Packet; @@ -34,7 +35,7 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { } public static DataWatcherPacketBuilder builder( - EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -42,9 +43,9 @@ class EntityLivingSpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeByte(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntitySpawnNMSPacket.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntitySpawnNMSPacket.java index f5abfc5e..e8a61759 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntitySpawnNMSPacket.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntitySpawnNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_9_R2.Packet; import net.minecraft.server.v1_9_R2.PacketPlayOutSpawnEntity; @@ -13,7 +14,7 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, double positionX, double positionY, double positionZ) { + EntitySpawnNMSPacket(EntityID entityID, int entityTypeID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); @@ -21,9 +22,9 @@ class EntitySpawnNMSPacket extends VersionNMSPacket { packetByteBuffer.writeByte(entityTypeID); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityTeleportNMSPacket.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityTeleportNMSPacket.java index e4fa3ed9..e6ecbf1d 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityTeleportNMSPacket.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/EntityTeleportNMSPacket.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import net.minecraft.server.v1_9_R2.Packet; import net.minecraft.server.v1_9_R2.PacketPlayOutEntityTeleport; @@ -13,15 +14,15 @@ class EntityTeleportNMSPacket extends VersionNMSPacket { private final Packet rawPacket; - EntityTeleportNMSPacket(EntityID entityID, double positionX, double positionY, double positionZ) { + EntityTeleportNMSPacket(EntityID entityID, Position position, double positionOffsetY) { PacketByteBuffer packetByteBuffer = PacketByteBuffer.get(); packetByteBuffer.writeVarInt(entityID.getNumericID()); // Position - packetByteBuffer.writeDouble(positionX); - packetByteBuffer.writeDouble(positionY); - packetByteBuffer.writeDouble(positionZ); + packetByteBuffer.writeDouble(position.getX()); + packetByteBuffer.writeDouble(position.getY() + positionOffsetY); + packetByteBuffer.writeDouble(position.getZ()); // Rotation packetByteBuffer.writeByte(0); diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionClickableNMSPacketEntity.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionClickableNMSPacketEntity.java index e7c08bc0..2909019c 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionClickableNMSPacketEntity.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionClickableNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -25,15 +26,13 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, SLIME_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(EntityLivingSpawnNMSPacket.builder( - slimeID, EntityTypeID.SLIME, positionX, positionY + SLIME_Y_OFFSET, positionZ) + packetList.add(EntityLivingSpawnNMSPacket.builder(slimeID, EntityTypeID.SLIME, position, SLIME_Y_OFFSET) .setInvisible() .setSlimeSmall() // Required for a correct client-side collision box .build() @@ -42,8 +41,8 @@ public class VersionClickableNMSPacketEntity implements ClickableNMSPacketEntity } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + SLIME_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, SLIME_Y_OFFSET)); } @Override diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionItemNMSPacketEntity.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionItemNMSPacketEntity.java index 4d7cc9ea..ed5d4e4c 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionItemNMSPacketEntity.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionItemNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ItemNMSPacketEntity; @@ -21,15 +22,13 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, ItemStack itemStack) { - packetList.add(new EntitySpawnNMSPacket( - vehicleID, EntityTypeID.ARMOR_STAND, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, ItemStack itemStack) { + packetList.add(new EntitySpawnNMSPacket(vehicleID, EntityTypeID.ARMOR_STAND, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(vehicleID) .setArmorStandMarker() .build() ); - packetList.add(new EntitySpawnNMSPacket( - itemID, EntityTypeID.ITEM, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + packetList.add(new EntitySpawnNMSPacket(itemID, EntityTypeID.ITEM, position, ITEM_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(itemID) .setItemStack(itemStack) .build() @@ -46,8 +45,8 @@ public class VersionItemNMSPacketEntity implements ItemNMSPacketEntity { } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(vehicleID, positionX, positionY + ITEM_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(vehicleID, position, ITEM_Y_OFFSET)); } @Override diff --git a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionTextNMSPacketEntity.java b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionTextNMSPacketEntity.java index 73debdae..8fcc141e 100644 --- a/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionTextNMSPacketEntity.java +++ b/nms/v1_9_r2/src/main/java/me/filoghost/holographicdisplays/nms/v1_9_R2/VersionTextNMSPacketEntity.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.nms.v1_9_R2; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.EntityID; import me.filoghost.holographicdisplays.common.nms.IndividualNMSPacket; import me.filoghost.holographicdisplays.common.nms.IndividualText; @@ -20,9 +21,8 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ, String text) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addSpawnPackets(NMSPacketList packetList, Position position, String text) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); packetList.add(EntityMetadataNMSPacket.builder(armorStandID) .setArmorStandMarker() .setCustomName(text) @@ -31,14 +31,13 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { } @Override - public void addSpawnPackets( - NMSPacketList packetList, double positionX, double positionY, double positionZ, IndividualText individualText) { - packetList.add(new EntitySpawnNMSPacket( - armorStandID, EntityTypeID.ARMOR_STAND, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setArmorStandMarker() - .setCustomName(individualText.get(player)) - .build() + public void addSpawnPackets(NMSPacketList packetList, Position position, IndividualText individualText) { + packetList.add(new EntitySpawnNMSPacket(armorStandID, EntityTypeID.ARMOR_STAND, position, ARMOR_STAND_Y_OFFSET)); + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setArmorStandMarker() + .setCustomName(individualText.get(player)) + .build() )); } @@ -52,15 +51,16 @@ class VersionTextNMSPacketEntity implements TextNMSPacketEntity { @Override public void addChangePackets(NMSPacketList packetList, IndividualText individualText) { - packetList.add(new IndividualNMSPacket(player -> EntityMetadataNMSPacket.builder(armorStandID) - .setCustomName(individualText.get(player)) - .build() + packetList.add(new IndividualNMSPacket(player -> + EntityMetadataNMSPacket.builder(armorStandID) + .setCustomName(individualText.get(player)) + .build() )); } @Override - public void addTeleportPackets(NMSPacketList packetList, double positionX, double positionY, double positionZ) { - packetList.add(new EntityTeleportNMSPacket(armorStandID, positionX, positionY + ARMOR_STAND_Y_OFFSET, positionZ)); + public void addTeleportPackets(NMSPacketList packetList, Position position) { + packetList.add(new EntityTeleportNMSPacket(armorStandID, position, ARMOR_STAND_Y_OFFSET)); } @Override diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseClickableLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseClickableLine.java index 221717f4..3d641ffc 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseClickableLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseClickableLine.java @@ -7,6 +7,7 @@ package me.filoghost.holographicdisplays.plugin.hologram.base; import me.filoghost.fcommons.logging.Log; import me.filoghost.holographicdisplays.api.hologram.ClickListener; +import me.filoghost.holographicdisplays.common.Position; import org.bukkit.Location; import org.bukkit.entity.Player; import org.jetbrains.annotations.MustBeInvokedByOverriders; @@ -48,7 +49,7 @@ public abstract class BaseClickableLine extends BaseHologramLine { private boolean isInClickRange(Player player) { Location playerLocation = player.getLocation(); - BaseLinePosition position = this.getPosition(); + Position position = this.getPosition(); double xDiff = playerLocation.getX() - position.getX(); double yDiff = playerLocation.getY() + 1.3 - position.getY(); // Use shoulder height diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java index 75720ff7..40fcac31 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.plugin.hologram.base; import me.filoghost.fcommons.Preconditions; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTracker; import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager; import org.bukkit.GameMode; @@ -20,7 +21,7 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements private final BaseHologram hologram; private final LineTracker tracker; - private BaseLinePosition position; + private Position position; protected BaseHologramLine(BaseHologram hologram) { Preconditions.notNull(hologram, "parent hologram"); @@ -40,11 +41,11 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements @Override public final void setPosition(double x, double y, double z) { - position = new BaseLinePosition(x, y, z); + position = new Position(x, y, z); setChanged(); } - public @NotNull BaseLinePosition getPosition() { + public @NotNull Position getPosition() { if (position == null) { throw new IllegalStateException("position not set"); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/ClickableLineTracker.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/ClickableLineTracker.java index 2d276c22..d04be9f5 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/ClickableLineTracker.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/ClickableLineTracker.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.plugin.hologram.tracking; +import me.filoghost.holographicdisplays.common.Position; import me.filoghost.holographicdisplays.common.nms.NMSManager; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.common.nms.entity.ClickableNMSPacketEntity; @@ -15,6 +16,7 @@ import org.jetbrains.annotations.MustBeInvokedByOverriders; public abstract class ClickableLineTracker extends PositionBasedLineTracker { private final ClickableNMSPacketEntity clickableEntity; + private final double positionOffsetY; private final LineClickListener lineClickListener; private boolean spawnClickableEntity; @@ -23,6 +25,7 @@ public abstract class ClickableLineTracker extends public ClickableLineTracker(T line, NMSManager nmsManager, LineClickListener lineClickListener) { super(line); this.clickableEntity = nmsManager.newClickablePacketEntity(); + this.positionOffsetY = (line.getHeight() - ClickableNMSPacketEntity.SLIME_HEIGHT) / 2; this.lineClickListener = lineClickListener; } @@ -61,7 +64,7 @@ public abstract class ClickableLineTracker extends @Override protected void addSpawnPackets(NMSPacketList packetList) { if (spawnClickableEntity) { - clickableEntity.addSpawnPackets(packetList, position.getX(), getClickablePositionY(), position.getZ()); + clickableEntity.addSpawnPackets(packetList, getClickableEntityPosition()); } } @@ -80,7 +83,7 @@ public abstract class ClickableLineTracker extends if (spawnClickableEntityChanged) { if (spawnClickableEntity) { - clickableEntity.addSpawnPackets(packetList, position.getX(), getClickablePositionY(), position.getZ()); + clickableEntity.addSpawnPackets(packetList, getClickableEntityPosition()); } else { clickableEntity.addDestroyPackets(packetList); } @@ -91,12 +94,12 @@ public abstract class ClickableLineTracker extends @Override protected void addPositionChangePackets(NMSPacketList packetList) { if (spawnClickableEntity) { - clickableEntity.addTeleportPackets(packetList, position.getX(), getClickablePositionY(), position.getZ()); + clickableEntity.addTeleportPackets(packetList, getClickableEntityPosition()); } } - private double getClickablePositionY() { - return position.getY() + ((line.getHeight() - ClickableNMSPacketEntity.SLIME_HEIGHT) / 2); + private Position getClickableEntityPosition() { + return position.addY(positionOffsetY); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/CollisionHelper.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/CollisionHelper.java index 9e244816..1b4f22a4 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/CollisionHelper.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/CollisionHelper.java @@ -5,7 +5,7 @@ */ package me.filoghost.holographicdisplays.plugin.hologram.tracking; -import me.filoghost.holographicdisplays.plugin.hologram.base.BaseLinePosition; +import me.filoghost.holographicdisplays.common.Position; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -25,7 +25,7 @@ public class CollisionHelper { private static final double REQUIRED_DISTANCE_Z = REQUIRED_DISTANCE_X; private static final double REQUIRED_DISTANCE_Y = PLAYER_HEIGHT_RADIUS + PLAYER_GROW_HEIGHT + ITEM_HEIGHT_RADIUS; - public static boolean isInPickupRange(Player player, BaseLinePosition itemPosition) { + public static boolean isInPickupRange(Player player, Position itemPosition) { /* * Normally, the server determines if a player is picking up a dropped item * by checking if the bounding boxes of the player and the item intersect. diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/ItemLineTracker.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/ItemLineTracker.java index 71dcae57..8b0b149b 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/ItemLineTracker.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/ItemLineTracker.java @@ -83,7 +83,7 @@ public class ItemLineTracker extends ClickableLineTracker { super.addSpawnPackets(packetList); if (spawnItemEntity) { - itemEntity.addSpawnPackets(packetList, position.getX(), position.getY(), position.getZ(), itemStack); + itemEntity.addSpawnPackets(packetList, position, itemStack); } } @@ -104,7 +104,7 @@ public class ItemLineTracker extends ClickableLineTracker { if (spawnItemEntityChanged) { if (spawnItemEntity) { - itemEntity.addSpawnPackets(packetList, position.getX(), position.getY(), position.getZ(), itemStack); + itemEntity.addSpawnPackets(packetList, position, itemStack); } else { itemEntity.addDestroyPackets(packetList); } @@ -120,7 +120,7 @@ public class ItemLineTracker extends ClickableLineTracker { super.addPositionChangePackets(packetList); if (spawnItemEntity) { - itemEntity.addTeleportPackets(packetList, position.getX(), position.getY(), position.getZ()); + itemEntity.addTeleportPackets(packetList, position); } } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/PositionBasedLineTracker.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/PositionBasedLineTracker.java index 183cdbfa..03a19801 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/PositionBasedLineTracker.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/PositionBasedLineTracker.java @@ -7,7 +7,7 @@ package me.filoghost.holographicdisplays.plugin.hologram.tracking; import me.filoghost.holographicdisplays.common.nms.NMSPacketList; import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramLine; -import me.filoghost.holographicdisplays.plugin.hologram.base.BaseLinePosition; +import me.filoghost.holographicdisplays.common.Position; import org.bukkit.Location; import org.bukkit.entity.Player; import org.jetbrains.annotations.MustBeInvokedByOverriders; @@ -18,7 +18,7 @@ abstract class PositionBasedLineTracker extends Line private static final int ENTITY_VIEW_RANGE = 64; - protected BaseLinePosition position; + protected Position position; private boolean positionChanged; PositionBasedLineTracker(T line) { @@ -28,7 +28,7 @@ abstract class PositionBasedLineTracker extends Line @MustBeInvokedByOverriders @Override protected void detectChanges() { - BaseLinePosition position = line.getPosition(); + Position position = line.getPosition(); if (!Objects.equals(this.position, position)) { this.position = position; this.positionChanged = true; diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/TextLineTracker.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/TextLineTracker.java index eec987e4..758c709b 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/TextLineTracker.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/TextLineTracker.java @@ -77,11 +77,11 @@ public class TextLineTracker extends ClickableLineTracker { super.addSpawnPackets(packetList); if (!allowPlaceholders) { - textEntity.addSpawnPackets(packetList, position.getX(), position.getY(), position.getZ(), displayText.getWithoutReplacements()); + textEntity.addSpawnPackets(packetList, position, displayText.getWithoutReplacements()); } else if (displayText.containsIndividualPlaceholders()) { - textEntity.addSpawnPackets(packetList, position.getX(), position.getY(), position.getZ(), displayText::getWithIndividualReplacements); + textEntity.addSpawnPackets(packetList, position, displayText::getWithIndividualReplacements); } else { - textEntity.addSpawnPackets(packetList, position.getX(), position.getY(), position.getZ(), displayText.getWithGlobalReplacements()); + textEntity.addSpawnPackets(packetList, position, displayText.getWithGlobalReplacements()); } } @@ -111,7 +111,7 @@ public class TextLineTracker extends ClickableLineTracker { @Override protected void addPositionChangePackets(NMSPacketList packetList) { super.addPositionChangePackets(packetList); - textEntity.addTeleportPackets(packetList, position.getX(), position.getY(), position.getZ()); + textEntity.addTeleportPackets(packetList, position); } }