mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 03:07:34 +00:00
Dialog packet
This commit is contained in:
1 parent
c5329a1c63
commit
ea1f5b259d
6 files changed
+67
-10
No files matched your search
@@ -348,6 +348,8 @@ public class PacketHandler {
|
||||
|
||||
PLAYER_PACKET.registerPacket(new BankActionPacket());
|
||||
|
||||
PLAYER_PACKET.registerPacket(new DialogSelectPacket());
|
||||
|
||||
PLAYER_PACKET.registerPacket(new CheckPlayerValue());
|
||||
|
||||
PLAYER_PACKET.registerPacket(new MailActionPacket());
|
||||
|
||||
@@ -4,7 +4,7 @@ public enum EnumPlayerPacket {
|
||||
FollowerAction,
|
||||
Transport,
|
||||
BankAction,
|
||||
Dialog, // TODO
|
||||
DialogSelect,
|
||||
GetPlayerValue,
|
||||
MailBoxAction,
|
||||
MailSend,
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package kamkeel.npcs.network.packets.player;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumPlayerPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DialogSelectPacket extends AbstractPacket {
|
||||
public static final String packetName = "Player|DialogSelect";
|
||||
|
||||
private int dialogID, optionID;
|
||||
|
||||
public DialogSelectPacket(){
|
||||
}
|
||||
public DialogSelectPacket(int dialogID, int optionID) {
|
||||
this.dialogID = dialogID;
|
||||
this.optionID = optionID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumPlayerPacket.DialogSelect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.PLAYER_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(dialogID);
|
||||
out.writeInt(optionID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(playerMP);
|
||||
if(npc == null)
|
||||
return;
|
||||
NoppesUtilPlayer.dialogSelected(in.readInt(), in.readInt(), playerMP, npc);
|
||||
}
|
||||
}
|
||||
@@ -179,12 +179,12 @@ public class PacketHandlerPlayer{
|
||||
// BankData data = PlayerDataController.Instance.getBankData(player,bankId).getBankOrDefault(bankId);
|
||||
// data.openBankGui(player, npc, bankId, slot);
|
||||
// }
|
||||
else if(type == EnumPlayerPacket.Dialog){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null)
|
||||
return;
|
||||
NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc);
|
||||
}
|
||||
// else if(type == EnumPlayerPacket.Dialog){
|
||||
// EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
// if(npc == null)
|
||||
// return;
|
||||
// NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc);
|
||||
// }
|
||||
// else if(type == EnumPlayerPacket.CheckQuestCompletion){
|
||||
// PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
// PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.client.gui.player;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import kamkeel.npcs.network.packets.player.DialogSelectPacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -595,7 +596,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
|
||||
handleDialogSelection();
|
||||
}
|
||||
if (closeOnEsc && (i == 1 || isInventoryKey(i))){
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.Dialog, dialog.id, -1);
|
||||
PacketClient.sendClient(new DialogSelectPacket(dialog.id, -1));
|
||||
closed();
|
||||
close();
|
||||
}
|
||||
@@ -615,7 +616,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
|
||||
optionId = selected;
|
||||
else if(!options.isEmpty())
|
||||
optionId = options.get(selected);
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.Dialog, dialog.id, optionId);
|
||||
PacketClient.sendClient(new DialogSelectPacket(dialog.id, optionId));
|
||||
if(dialog == null || !dialog.hasOtherOptions() || options.isEmpty()){
|
||||
closed();
|
||||
close();
|
||||
|
||||
@@ -7,7 +7,7 @@ public enum EnumPlayerPacket {
|
||||
// Transport,
|
||||
// BankUnlock,
|
||||
// BankUpgrade,
|
||||
Dialog,
|
||||
// Dialog,
|
||||
// QuestLog,
|
||||
// TrackedQuest,
|
||||
// CheckQuestCompletion,
|
||||
|
||||
Reference in new issue
Block a user