use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.
the class GuiQuestLineEditProxy method SendChanges.
public void SendChanges(EnumPacketAction action) {
if (action == null) {
return;
}
NBTTagCompound tags = new NBTTagCompound();
if (action == EnumPacketAction.EDIT && line != null) {
NBTTagCompound base = new NBTTagCompound();
base.setTag("line", line.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
tags.setTag("data", base);
}
tags.setInteger("action", action.ordinal());
tags.setInteger("lineID", QuestLineDatabase.INSTANCE.getKey(line));
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tags));
}
use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.
the class GuiToolIconProxy method SendChanges.
// If the changes are approved by the server, it will be broadcast to all players including the editor
public void SendChanges() {
NBTTagCompound base = new NBTTagCompound();
base.setTag("config", quest.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
base.setTag("progress", quest.writeToNBT(new NBTTagCompound(), EnumSaveType.PROGRESS));
NBTTagCompound tags = new NBTTagCompound();
tags.setTag("data", base);
tags.setInteger("action", EnumPacketAction.EDIT.ordinal());
tags.setInteger("questID", QuestDatabase.INSTANCE.getKey(quest));
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tags));
}
use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.
the class ToolboxToolCopy method onMouseClick.
@Override
public void onMouseClick(int mx, int my, int click) {
if (click == 1 && btnQuest != null) {
btnQuest = null;
} else if (click != 0) {
return;
}
int snap = ToolboxGuiMain.getSnapValue();
int modX = ((mx % snap) + snap) % snap;
int modY = ((my % snap) + snap) % snap;
mx -= modX;
my -= modY;
if (btnQuest == null) {
GuiButtonQuestInstance tmpBtn = gui.getQuestLine().getButtonAt(mx, my);
if (tmpBtn != null) {
// Unregistered but setup
QuestInstance tmpQ = new QuestInstance();
tmpQ.readFromNBT(tmpBtn.getQuest().writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG), EnumSaveType.CONFIG);
btnQuest = new GuiButtonQuestInstance(0, mx, my, tmpBtn.width, tmpBtn.height, tmpQ);
}
} else {
// Pre-sync
IQuest quest = btnQuest.getQuest();
IQuestLine qLine = gui.getQuestLine().getQuestLine();
int qID = QuestDatabase.INSTANCE.nextKey();
int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
QuestLineEntry qe = new QuestLineEntry(mx, my, Math.max(btnQuest.width, btnQuest.height));
qLine.add(qe, qID);
btnQuest = null;
// Sync Quest
NBTTagCompound tag1 = new NBTTagCompound();
NBTTagCompound base1 = new NBTTagCompound();
base1.setTag("config", quest.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
tag1.setTag("data", base1);
tag1.setInteger("action", EnumPacketAction.ADD.ordinal());
tag1.setInteger("questID", qID);
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tag1));
// Sync Line
NBTTagCompound tag2 = new NBTTagCompound();
NBTTagCompound base2 = new NBTTagCompound();
base2.setTag("line", qLine.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
tag2.setTag("data", base2);
tag2.setInteger("action", EnumPacketAction.EDIT.ordinal());
tag2.setInteger("lineID", lID);
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tag2));
}
}
use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.
the class ToolboxToolGrab method onMouseClick.
@Override
public void onMouseClick(int mx, int my, int click) {
if (click == 1 && grabbed != null) {
IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
if (qle != null) {
// Reset position
grabbed.x = qle.getPosX();
grabbed.y = qle.getPosY();
}
grabbed = null;
return;
} else if (click != 0) {
return;
}
if (grabbed == null) {
grabbed = gui.getQuestLine().getButtonAt(mx, my);
grabID = grabbed == null ? -1 : QuestDatabase.INSTANCE.getKey(grabbed.getQuest());
} else {
IQuestLine qLine = gui.getQuestLine().getQuestLine();
int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
if (qle != null) {
qle.setPosition(grabbed.x, grabbed.y);
// Sync Line
NBTTagCompound tag2 = new NBTTagCompound();
NBTTagCompound base2 = new NBTTagCompound();
base2.setTag("line", qLine.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
tag2.setTag("data", base2);
tag2.setInteger("action", EnumPacketAction.EDIT.ordinal());
tag2.setInteger("lineID", lID);
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tag2));
}
grabbed = null;
grabID = -1;
}
}
use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.
the class ToolboxToolScale method onMouseClick.
@Override
public void onMouseClick(int mx, int my, int click) {
if (click == 1) {
IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
if (qle != null) {
// Reset size
grabbed.width = qle.getSize();
grabbed.height = qle.getSize();
}
grabbed = null;
return;
} else if (click != 0) {
return;
}
if (grabbed == null) {
grabbed = gui.getQuestLine().getButtonAt(mx, my);
grabID = grabbed == null ? -1 : QuestDatabase.INSTANCE.getKey(grabbed.getQuest());
} else {
IQuestLine qLine = gui.getQuestLine().getQuestLine();
int lID = QuestLineDatabase.INSTANCE.getKey(qLine);
IQuestLineEntry qle = gui.getQuestLine().getQuestLine().getValue(grabID);
if (qle != null) {
qle.setSize(Math.max(grabbed.width, grabbed.height));
// Sync Line
NBTTagCompound tag2 = new NBTTagCompound();
NBTTagCompound base2 = new NBTTagCompound();
base2.setTag("line", qLine.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
tag2.setTag("data", base2);
tag2.setInteger("action", EnumPacketAction.EDIT.ordinal());
tag2.setInteger("lineID", lID);
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.LINE_EDIT.GetLocation(), tag2));
}
grabbed = null;
grabID = -1;
}
}
Aggregations