Refactoring

This commit is contained in:
filoghost 2021-08-19 11:56:28 +02:00
parent 163b881837
commit 9e966ea185
84 changed files with 562 additions and 533 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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<EntityLivingSpawnNMSPacket> 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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<EntityLivingSpawnNMSPacket> 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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<EntityLivingSpawnNMSPacket> 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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<EntityLivingSpawnNMSPacket> 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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<EntityLivingSpawnNMSPacket> 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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<EntityLivingSpawnNMSPacket> 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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<EntityLivingSpawnNMSPacket> 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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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");
}

View File

@ -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<T extends BaseClickableLine> extends PositionBasedLineTracker<T> {
private final ClickableNMSPacketEntity clickableEntity;
private final double positionOffsetY;
private final LineClickListener lineClickListener;
private boolean spawnClickableEntity;
@ -23,6 +25,7 @@ public abstract class ClickableLineTracker<T extends BaseClickableLine> 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<T extends BaseClickableLine> 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<T extends BaseClickableLine> 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<T extends BaseClickableLine> 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);
}
}

View File

@ -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.

View File

@ -83,7 +83,7 @@ public class ItemLineTracker extends ClickableLineTracker<BaseItemLine> {
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<BaseItemLine> {
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<BaseItemLine> {
super.addPositionChangePackets(packetList);
if (spawnItemEntity) {
itemEntity.addTeleportPackets(packetList, position.getX(), position.getY(), position.getZ());
itemEntity.addTeleportPackets(packetList, position);
}
}

View File

@ -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<T extends BaseHologramLine> 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<T extends BaseHologramLine> 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;

View File

@ -77,11 +77,11 @@ public class TextLineTracker extends ClickableLineTracker<BaseTextLine> {
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<BaseTextLine> {
@Override
protected void addPositionChangePackets(NMSPacketList packetList) {
super.addPositionChangePackets(packetList);
textEntity.addTeleportPackets(packetList, position.getX(), position.getY(), position.getZ());
textEntity.addTeleportPackets(packetList, position);
}
}