Search in sources :

Example 1 with TakeMaterials

use of uk.co.wehavecookies56.kk.common.network.packet.server.TakeMaterials in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiSynthesis method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    SynthesisMaterialCapability.ISynthesisMaterial MATS = mc.player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
    List<String> materials = new ArrayList<String>();
    int freeSlots = 0;
    boolean foundMaterial = false;
    switch(button.id) {
        case BACK:
            submenu = MAIN;
            break;
        case RECIPES:
            submenu = RECIPES;
            break;
        case FREEDEV:
            submenu = FREEDEV;
            break;
        case MATERIALS:
            Deposit.visible = true;
            DepositBag.visible = true;
            submenu = MATERIALS;
            break;
        case CREATE:
            if (selected != -1) {
                if (isRecipeUsable(mc.player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getKnownRecipes().get(selected))) {
                    PacketDispatcher.sendToServer(new CreateFromSynthesisRecipe(mc.player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getKnownRecipes().get(selected), 1));
                    mc.player.world.playSound(mc.player, mc.player.getPosition(), ModSounds.itemget, SoundCategory.MASTER, 1.0f, 1.0f);
                }
            } else if (freeDevSelected != -1) {
                if (isFreeDevRecipeUsable(mc.player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes().get(freeDevSelected))) {
                    PacketDispatcher.sendToServer(new CreateFromSynthesisRecipe(mc.player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes().get(freeDevSelected), 1));
                    mc.player.world.playSound(mc.player, mc.player.getPosition(), ModSounds.itemget, SoundCategory.MASTER, 1.0f, 1.0f);
                }
            }
            break;
        case TAKE1:
            materials.addAll(MATS.getKnownMaterialsMap().keySet());
            freeSlots = getFreeSlots();
            foundMaterial = getInventoryMaterial(materials.get(materialSelected));
            if (foundMaterial || freeSlots >= 1) {
                if (MATS.getKnownMaterialsMap().get(materials.get(materialSelected)) > 1) {
                    PacketDispatcher.sendToServer(new TakeMaterials(1, materials.get(materialSelected)));
                } else {
                    PacketDispatcher.sendToServer(new TakeMaterials(1, materials.get(materialSelected)));
                    materialSelected = -1;
                }
            }
            break;
        case TAKEHALFSTACK:
            materials.addAll(MATS.getKnownMaterialsMap().keySet());
            freeSlots = getFreeSlots();
            foundMaterial = getInventoryMaterial(materials.get(materialSelected));
            if (foundMaterial || freeSlots >= 1) {
                if (MATS.getKnownMaterialsMap().get(materials.get(materialSelected)) >= 32)
                    PacketDispatcher.sendToServer(new TakeMaterials(32, materials.get(materialSelected)));
                else {
                    PacketDispatcher.sendToServer(new TakeMaterials(MATS.getKnownMaterialsMap().get(materials.get(materialSelected)), materials.get(materialSelected)));
                    materialSelected = -1;
                }
            }
            break;
        case TAKESTACK:
            materials.addAll(MATS.getKnownMaterialsMap().keySet());
            freeSlots = getFreeSlots();
            if (freeSlots >= 1) {
                if (MATS.getKnownMaterialsMap().get(materials.get(materialSelected)) >= 64)
                    PacketDispatcher.sendToServer(new TakeMaterials(64, materials.get(materialSelected)));
                else {
                    PacketDispatcher.sendToServer(new TakeMaterials(MATS.getKnownMaterialsMap().get(materials.get(materialSelected)), materials.get(materialSelected)));
                    materialSelected = -1;
                }
            }
            break;
        case TAKEALL:
            materials.addAll(MATS.getKnownMaterialsMap().keySet());
            freeSlots = getFreeSlots();
            if (freeSlots >= 1)
                PacketDispatcher.sendToServer(new TakeMaterials(freeSlots * 64, materials.get(materialSelected)));
            materialSelected = -1;
            break;
        case DEPOSIT:
            PacketDispatcher.sendToServer(new OpenMaterials());
            break;
        case DEPOSITBAG:
            PacketDispatcher.sendToServer(new DepositMaterialsFromBag());
            break;
    }
    updateButtons();
}
Also used : DepositMaterialsFromBag(uk.co.wehavecookies56.kk.common.network.packet.server.DepositMaterialsFromBag) SynthesisMaterialCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability) ArrayList(java.util.ArrayList) OpenMaterials(uk.co.wehavecookies56.kk.common.network.packet.server.OpenMaterials) TakeMaterials(uk.co.wehavecookies56.kk.common.network.packet.server.TakeMaterials) CreateFromSynthesisRecipe(uk.co.wehavecookies56.kk.common.network.packet.server.CreateFromSynthesisRecipe)

Aggregations

ArrayList (java.util.ArrayList)1 SynthesisMaterialCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability)1 CreateFromSynthesisRecipe (uk.co.wehavecookies56.kk.common.network.packet.server.CreateFromSynthesisRecipe)1 DepositMaterialsFromBag (uk.co.wehavecookies56.kk.common.network.packet.server.DepositMaterialsFromBag)1 OpenMaterials (uk.co.wehavecookies56.kk.common.network.packet.server.OpenMaterials)1 TakeMaterials (uk.co.wehavecookies56.kk.common.network.packet.server.TakeMaterials)1