Search in sources :

Example 11 with QuestingPacket

use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.

the class GuiQuestLineEditorB method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    super.actionPerformed(button);
    if (button.id == 1) {
        createQuest();
    } else if (button.id > 1) {
        // Line listing (0 = quest, 1 = quest delete, 2 = registry)
        int column = button.id & 7;
        int id = (button.id >> 3) - 2;
        if (// Edit quest
        column == 0 || column == 3) {
            if (id >= 0) {
                IQuest q = QuestDatabase.INSTANCE.getValue(id);
                if (q != null) {
                    mc.displayGuiScreen(new GuiQuest(this, id));
                }
            }
        } else if (// Remove quest
        column == 1 && line != null) {
            line.removeKey(id);
            // RefreshColumns();
            SendChanges(EnumPacketAction.EDIT, lineID);
        } else if (// Delete quest
        column == 4 && id >= 0) {
            NBTTagCompound tags = new NBTTagCompound();
            // Delete quest
            tags.setInteger("action", EnumPacketAction.REMOVE.ordinal());
            tags.setInteger("questID", id);
            PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tags));
        } else if (// Add quest
        column == 2 && line != null && id >= 0) {
            IQuestLineEntry qe = new QuestLineEntry(0, 0);
            int x1 = 0;
            int y1 = 0;
            topLoop: while (true) {
                for (IQuestLineEntry qe2 : line.getAllValues()) {
                    int x2 = qe2.getPosX();
                    int y2 = qe2.getPosY();
                    int s2 = qe2.getSize();
                    if (x1 >= x2 && x1 < x2 + s2 && y1 >= y2 && y1 < y2 + s2) {
                        x1 += s2;
                        x2 += s2;
                        // We're in the way, move over and try again
                        continue topLoop;
                    }
                }
                break;
            }
            qe.setPosition(x1, y1);
            line.add(qe, id);
            RefreshColumns();
            SendChanges(EnumPacketAction.EDIT, lineID);
        }
    }
}
Also used : GuiQuest(betterquesting.client.gui2.GuiQuest) IQuest(betterquesting.api.questing.IQuest) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) QuestLineEntry(betterquesting.questing.QuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 12 with QuestingPacket

use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.

the class GuiManageParty method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    // Finish the button functionality
    super.actionPerformed(button);
    if (// Leave party
    button.id == 1) {
        NBTTagCompound tags = new NBTTagCompound();
        tags.setInteger("action", EnumPacketAction.KICK.ordinal());
        tags.setInteger("partyID", PartyManager.INSTANCE.getKey(party));
        tags.setString("target", QuestingAPI.getQuestingUUID(mc.player).toString());
        PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.PARTY_EDIT.GetLocation(), tags));
    } else if (// Share life
    button.id == 3 && status.ordinal() >= 3) {
        party.getProperties().setProperty(NativeProps.PARTY_LIVES, !party.getProperties().getProperty(NativeProps.PARTY_LIVES));
        SendChanges();
    } else if (// Invite
    button.id == 4 && status.ordinal() >= 3) {
        mc.displayGuiScreen(new GuiPartyInvite(this, party));
    } else if (// Kick
    button.id > 4) {
        // Button index
        int n1 = button.id - 5;
        // Column listing (0 = line)
        int n2 = n1 / maxRows;
        // Format index
        int n3 = n1 % maxRows + rightScroll;
        if (n2 == 0) {
            if (n3 >= 0 && n3 < memList.size()) {
                NBTTagCompound tags = new NBTTagCompound();
                tags.setInteger("action", EnumPacketAction.KICK.ordinal());
                tags.setInteger("partyID", PartyManager.INSTANCE.getKey(party));
                tags.setString("target", memList.get(n3).toString());
                PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.PARTY_EDIT.GetLocation(), tags));
            }
        }
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 13 with QuestingPacket

use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.

the class GuiManageParty method SendChanges.

public // Use this if the name is being edited
void SendChanges() {
    if (status != EnumPartyStatus.OWNER && !NameCache.INSTANCE.isOP(QuestingAPI.getQuestingUUID(mc.player))) {
        // Not allowed to edit the party (Operators may force edit)
        return;
    }
    NBTTagCompound tags = new NBTTagCompound();
    tags.setInteger("action", EnumPacketAction.EDIT.ordinal());
    tags.setInteger("partyID", PartyManager.INSTANCE.getKey(party));
    tags.setTag("data", party.writeToNBT(new NBTTagCompound(), EnumSaveType.CONFIG));
    PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.PARTY_EDIT.GetLocation(), tags));
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 14 with QuestingPacket

use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.

the class GuiNoParty method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    // Finish the button functionality
    super.actionPerformed(button);
    if (// Create party
    button.id == 1) {
        NBTTagCompound tags = new NBTTagCompound();
        tags.setInteger("action", EnumPacketAction.ADD.ordinal());
        tags.setString("name", fieldName.getText());
        PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.PARTY_EDIT.GetLocation(), tags));
    } else if (// Join party
    button.id > 1) {
        // Button index
        int n1 = button.id - 2;
        // Column listing (0 = line)
        int n2 = n1 / maxRows;
        // Party index
        int n3 = n1 % maxRows + rightScroll;
        if (n2 == 0) {
            if (n3 >= 0 && n3 < invites.size()) {
                NBTTagCompound tags = new NBTTagCompound();
                tags.setInteger("action", EnumPacketAction.JOIN.ordinal());
                tags.setInteger("partyID", PartyManager.INSTANCE.getKey(invites.get(n3)));
                PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.PARTY_EDIT.GetLocation(), tags));
            }
        }
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 15 with QuestingPacket

use of betterquesting.api.network.QuestingPacket in project BetterQuesting by Funwayguy.

the class GuiTaskEditor method SendChanges.

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();
    // Action: Update data
    tags.setInteger("action", EnumPacketAction.EDIT.ordinal());
    tags.setInteger("questID", QuestDatabase.INSTANCE.getKey(quest));
    tags.setTag("data", base);
    PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tags));
}
Also used : 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