mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
feat: add nms support for camera packet
This commit is contained in:
@@ -49,4 +49,6 @@ public interface NMSPackets {
|
||||
);
|
||||
|
||||
void sendRotationPacket(int entityId, float yaw, boolean onGround, List<Player> sendTo);
|
||||
|
||||
void sendCameraPacket(int entityId, List<Player> sendTo);
|
||||
}
|
||||
|
||||
@@ -147,9 +147,7 @@ public class PacketManager {
|
||||
* @param sendTo The players that will be sent this packet
|
||||
*/
|
||||
public static void sendCameraPacket(final int entityId, @NotNull List<Player> sendTo) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.CAMERA);
|
||||
packet.getIntegers().write(0, entityId);
|
||||
for (final Player p : sendTo) sendPacket(p, packet);
|
||||
NMSHandlers.getHandler().getPacketHandler().sendCameraPacket(entityId, sendTo);
|
||||
MessagesUtil.sendDebugMessages(sendTo + " | " + entityId + " has had a camera packet on them!");
|
||||
}
|
||||
|
||||
|
||||
@@ -222,4 +222,16 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCameraPacket(int entityId, List<Player> sendTo) {
|
||||
FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeVarInt(entityId);
|
||||
try {
|
||||
ClientboundSetCameraPacket packet = cameraConstructor.newInstance(byteBuf);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,4 +222,16 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCameraPacket(int entityId, List<Player> sendTo) {
|
||||
FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeVarInt(entityId);
|
||||
try {
|
||||
ClientboundSetCameraPacket packet = cameraConstructor.newInstance(byteBuf);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,4 +223,16 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCameraPacket(int entityId, List<Player> sendTo) {
|
||||
FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeVarInt(entityId);
|
||||
try {
|
||||
ClientboundSetCameraPacket packet = cameraConstructor.newInstance(byteBuf);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,4 +222,16 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCameraPacket(int entityId, List<Player> sendTo) {
|
||||
FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeVarInt(entityId);
|
||||
try {
|
||||
ClientboundSetCameraPacket packet = cameraConstructor.newInstance(byteBuf);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -232,4 +231,16 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCameraPacket(int entityId, List<Player> sendTo) {
|
||||
FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeVarInt(entityId);
|
||||
try {
|
||||
ClientboundSetCameraPacket packet = cameraConstructor.newInstance(byteBuf);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,4 +211,16 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCameraPacket(int entityId, List<Player> sendTo) {
|
||||
FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeVarInt(entityId);
|
||||
try {
|
||||
ClientboundSetCameraPacket packet = cameraConstructor.newInstance(byteBuf);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,4 +211,16 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCameraPacket(int entityId, List<Player> sendTo) {
|
||||
FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeVarInt(entityId);
|
||||
try {
|
||||
ClientboundSetCameraPacket packet = cameraConstructor.newInstance(byteBuf);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user