mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 04:57:27 +00:00
Quest Get Packet
This commit is contained in:
1 parent
f950ba0a22
commit
f314d9d826
6 files changed
+76
-20
No files matched your search
@@ -161,6 +161,7 @@ public class PacketHandler {
|
||||
REQUEST_PACKET.registerPacket(new QuestDialogGetTitlePacket());
|
||||
REQUEST_PACKET.registerPacket(new QuestLogToServerPacket());
|
||||
REQUEST_PACKET.registerPacket(new QuestUntrackPacket());
|
||||
REQUEST_PACKET.registerPacket(new QuestGetPacket());
|
||||
|
||||
// Faction Packets
|
||||
REQUEST_PACKET.registerPacket(new FactionSavePacket());
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package kamkeel.npcs.network.packets.request.quest;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.*;
|
||||
import kamkeel.npcs.network.enums.EnumItemPacketType;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class QuestGetPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|QuestGet";
|
||||
|
||||
private int questID;
|
||||
|
||||
public QuestGetPacket() {}
|
||||
|
||||
public QuestGetPacket(int questID) {
|
||||
this.questID = questID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.QuestGet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(this.questID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK))
|
||||
return;
|
||||
|
||||
Quest quest = QuestController.Instance.quests.get(in.readInt());
|
||||
if(quest != null){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(quest.hasNewQuest())
|
||||
compound.setString("NextQuestTitle", quest.getNextQuest().title);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, quest.writeToNBT(compound));
|
||||
}
|
||||
}
|
||||
|
||||
public static void getQuest(int id){
|
||||
PacketClient.sendClient(new QuestGetPacket(id));
|
||||
}
|
||||
}
|
||||
@@ -385,15 +385,6 @@ public class PacketHandlerServer{
|
||||
else if(type == EnumPacketServer.FactionsGet){
|
||||
NoppesUtilServer.sendFactionDataAll(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestGet){
|
||||
Quest quest = QuestController.Instance.quests.get(buffer.readInt());
|
||||
if(quest != null){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(quest.hasNewQuest())
|
||||
compound.setString("NextQuestTitle", quest.getNextQuest().title);
|
||||
GuiDataPacket.sendGuiData(player, quest.writeToNBT(compound));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionGet){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
Faction faction = FactionController.getInstance().get(buffer.readInt());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.quest.QuestGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
@@ -66,16 +67,16 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe
|
||||
getButton(13).setDisplayText("availability.selectquest");
|
||||
|
||||
if(availabitily.questId >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestGet, availabitily.questId);
|
||||
QuestGetPacket.getQuest(availabitily.questId);
|
||||
}
|
||||
if(availabitily.quest2Id >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestGet, availabitily.quest2Id);
|
||||
QuestGetPacket.getQuest(availabitily.quest2Id);
|
||||
}
|
||||
if(availabitily.quest3Id >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestGet, availabitily.quest3Id);
|
||||
QuestGetPacket.getQuest(availabitily.quest3Id);
|
||||
}
|
||||
if(availabitily.quest4Id >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestGet, availabitily.quest4Id);
|
||||
QuestGetPacket.getQuest(availabitily.quest4Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
|
||||
String selected = questScroll.getSelected();
|
||||
if(!selected.equals(prevQuestName) || override){
|
||||
quest = new Quest();
|
||||
Client.sendData(EnumPacketServer.QuestGet, questData.get(selected));
|
||||
QuestGetPacket.getQuest(questData.get(selected));
|
||||
setPrevQuestName(selected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,20 +37,16 @@ public enum EnumPacketServer {
|
||||
EventScriptDataSave(CustomNpcsPermissions.SCRIPT_NPC, true),
|
||||
EventScriptDataGet(true),
|
||||
|
||||
DialogGet,
|
||||
DialogRemove(CustomNpcsPermissions.GLOBAL_DIALOG),
|
||||
|
||||
FactionsGet,
|
||||
FactionGet,
|
||||
QuestCategoriesGet,
|
||||
QuestsGetFromQuest, QuestsGet,
|
||||
MerchantUpdate(CustomNpcsPermissions.EDIT_VILLAGER),
|
||||
QuestsGetFromQuest,
|
||||
QuestsGet,
|
||||
PlayerRider(CustomNpcsPermissions.TOOL_MOUNTER),
|
||||
SpawnRider(CustomNpcsPermissions.TOOL_MOUNTER),
|
||||
MovingPathSave(CustomNpcsPermissions.TOOL_PATHER,true),
|
||||
MovingPathGet(true),
|
||||
|
||||
QuestGet,
|
||||
DimensionTeleport;
|
||||
|
||||
public CustomNpcsPermissions.Permission permission = null;
|
||||
|
||||
Reference in new issue
Block a user