mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-20 15:39:17 +00:00
fix: interact packet not on correct packet
This commit is contained in:
@@ -5,10 +5,7 @@ import it.unimi.dsi.fastutil.ints.IntList;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Display;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.ItemDisplay;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -43,6 +40,10 @@ public interface NMSPackets {
|
|||||||
|
|
||||||
void sendSlotUpdate(Player player, int slot);
|
void sendSlotUpdate(Player player, int slot);
|
||||||
|
|
||||||
|
default void sendLookAtPacket(int entityId, Location location, List<Player> sendTo) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void sendEquipmentSlotUpdate(
|
void sendEquipmentSlotUpdate(
|
||||||
int entityId,
|
int entityId,
|
||||||
org.bukkit.inventory.EquipmentSlot slot,
|
org.bukkit.inventory.EquipmentSlot slot,
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public class NMSPacketChannel extends ChannelDuplexHandler {
|
|||||||
case ServerboundContainerClickPacket clickPacket -> msg = handleInventoryClick(clickPacket);
|
case ServerboundContainerClickPacket clickPacket -> msg = handleInventoryClick(clickPacket);
|
||||||
case ServerboundPlayerActionPacket playerActionPacket -> msg = handlePlayerAction(playerActionPacket);
|
case ServerboundPlayerActionPacket playerActionPacket -> msg = handlePlayerAction(playerActionPacket);
|
||||||
case ServerboundSwingPacket swingPacket -> msg = handlePlayerArm(swingPacket);
|
case ServerboundSwingPacket swingPacket -> msg = handlePlayerArm(swingPacket);
|
||||||
case ServerboundUseItemOnPacket useItemOnPacket -> msg = handleEntityUse(useItemOnPacket);
|
case ServerboundInteractPacket interactPacket -> msg = handleInteract(interactPacket);
|
||||||
default -> {}
|
default -> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ public class NMSPacketChannel extends ChannelDuplexHandler {
|
|||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Packet<?> handleEntityUse(ServerboundUseItemOnPacket packet) {
|
private Packet<?> handleInteract(ServerboundInteractPacket packet) {
|
||||||
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
||||||
SubPlugins.getSubPlugins().forEach(plugin -> {
|
SubPlugins.getSubPlugins().forEach(plugin -> {
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.minecraft.advancements.Advancement;
|
import net.minecraft.advancements.Advancement;
|
||||||
import net.minecraft.advancements.AdvancementHolder;
|
import net.minecraft.advancements.AdvancementHolder;
|
||||||
|
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
@@ -126,6 +127,14 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
sendPacket(player, packet);
|
sendPacket(player, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendLookAtPacket(int entityId, Location location, List<Player> sendTo) {
|
||||||
|
fakeNmsEntity.setId(entityId);
|
||||||
|
fakeNmsEntity.getBukkitEntity().teleport(location);
|
||||||
|
ClientboundPlayerLookAtPacket packet = new ClientboundPlayerLookAtPacket(EntityAnchorArgument.Anchor.EYES, fakeNmsEntity, EntityAnchorArgument.Anchor.EYES);
|
||||||
|
for (Player p : sendTo) sendPacket(p, packet);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendRotateHeadPacket(int entityId, Location location, List<Player> sendTo) {
|
public void sendRotateHeadPacket(int entityId, Location location, List<Player> sendTo) {
|
||||||
fakeNmsEntity.setId(entityId);
|
fakeNmsEntity.setId(entityId);
|
||||||
|
|||||||
Reference in New Issue
Block a user