use of uk.co.wehavecookies56.kk.common.network.packet.server.OpenMaterials 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();
}
Aggregations