Search in sources :

Example 16 with QuestingPacket

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));
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 17 with QuestingPacket

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));
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 18 with QuestingPacket

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));
    }
}
Also used : GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) IQuest(betterquesting.api.questing.IQuest) GuiButtonQuestInstance(betterquesting.api.client.gui.controls.GuiButtonQuestInstance) QuestInstance(betterquesting.questing.QuestInstance) IQuestLine(betterquesting.api.questing.IQuestLine) QuestLineEntry(betterquesting.questing.QuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 19 with QuestingPacket

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;
    }
}
Also used : IQuestLine(betterquesting.api.questing.IQuestLine) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 20 with QuestingPacket

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;
    }
}
Also used : IQuestLine(betterquesting.api.questing.IQuestLine) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Aggregations

QuestingPacket (betterquesting.api.network.QuestingPacket)40 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)40 GuiButtonQuestInstance (betterquesting.api.client.gui.controls.GuiButtonQuestInstance)6 IQuestLine (betterquesting.api.questing.IQuestLine)6 NBTTagList (net.minecraft.nbt.NBTTagList)6 IQuest (betterquesting.api.questing.IQuest)4 IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)3 QuestLineEntry (betterquesting.questing.QuestLineEntry)3 GuiQuest (betterquesting.client.gui2.GuiQuest)2 QuestInstance (betterquesting.questing.QuestInstance)2 IQuestDatabase (betterquesting.api.questing.IQuestDatabase)1 IQuestLineDatabase (betterquesting.api.questing.IQuestLineDatabase)1 IPanelButton (betterquesting.api2.client.gui.controls.IPanelButton)1 GuiQuestEditor (betterquesting.client.gui.editors.GuiQuestEditor)1 ImportedQuestLines (betterquesting.client.importers.ImportedQuestLines)1 ImportedQuests (betterquesting.client.importers.ImportedQuests)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1