Search in sources :

Example 11 with Material

use of uk.co.wehavecookies56.kk.api.materials.Material in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class TakeSoldItem method process.

@Override
public void process(EntityPlayer player, Side side) {
    int quantityRemaining = quantity;
    for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
        if (player.inventory.getStackInSlot(i).getItem() instanceof ItemSynthesisMaterial) {
            ItemStack invItem = player.inventory.getStackInSlot(i);
            if (invItem.getTagCompound().getString("material").equals(soldItem.getTagCompound().getString("material"))) {
                // System.out.println(invItem.getTagCompound().getString("material")+">"+soldItem.getTagCompound().getString("material"));
                if (quantityRemaining >= player.inventory.getStackInSlot(i).getCount()) {
                    // If the amount you want to sell is bigger or equals to the amount you have
                    // Remove the item
                    player.inventory.removeStackFromSlot(i);
                    quantityRemaining -= player.inventory.getStackInSlot(i).getCount();
                } else if (quantityRemaining < player.inventory.getStackInSlot(i).getCount()) {
                    player.inventory.getStackInSlot(i).shrink(quantityRemaining);
                    quantityRemaining = 0;
                }
            }
        }
    }
    player.getCapability(ModCapabilities.MUNNY, null).addMunny(munnyToGive);
    PacketDispatcher.sendTo(new SyncMunnyData(player.getCapability(ModCapabilities.MUNNY, null)), (EntityPlayerMP) player);
}
Also used : ItemSynthesisMaterial(uk.co.wehavecookies56.kk.common.item.base.ItemSynthesisMaterial) SyncMunnyData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMunnyData) ItemStack(net.minecraft.item.ItemStack)

Example 12 with Material

use of uk.co.wehavecookies56.kk.api.materials.Material in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiSynthesis method drawSelectedFreeDev.

public void drawSelectedFreeDev(int mouseX, int mouseY) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = mc.player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    int posX = 220;
    if (freeDevSelected != -1) {
        Minecraft.getMinecraft().renderEngine.bindTexture(optionsBackground);
        drawGradientRect(posX - 10, 60, 700, height - ((height / 8) + 70 / 16), -1072689136, -804253680);
    }
    GL11.glPushMatrix();
    {
        for (int i = 0; i < RECIPES.getFreeDevRecipes().size(); i++) if (freeDevSelected == i) {
            float scale = 1.0f;
            if (mc.gameSettings.guiScale == Constants.SCALE_LARGE) {
                scale = 0.5f;
            }
            GL11.glPushMatrix();
            {
                GL11.glTranslatef(posX, 70, 0);
                GL11.glScalef(2 * scale, 2 * scale, 2 * scale);
                drawString(fontRenderer, Utils.translateToLocal(RECIPES.getFreeDevRecipes().get(i).toString() + ".name"), 0, 0, 0xFFF700);
            // drawString(fontRendererObj, "Strength: +"+((ItemKeyblade)ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getStrength(), 0, 10, 0xFF0000);
            // drawString(fontRendererObj, "Magic: +"+ ((ItemKeyblade)ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getMagic(), 0, 20, 0x4444FF);
            }
            GL11.glPopMatrix();
            drawString(fontRenderer, Utils.translateToLocal(Strings.Gui_Synthesis_Main_Recipes_ReqMaterials) + TextFormatting.ITALIC, posX, 100, 0x00C3FF);
            int row = 0;
            int column = 0;
            int materialLength = 0;
            Iterator it = FreeDevRecipeRegistry.get(RECIPES.getFreeDevRecipes().get(i)).getRequirements().entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry<Material, Integer> pair = (Map.Entry<Material, Integer>) it.next();
                int distY = (int) (24 * scale);
                int distX = (int) (100 * scale);
                GL11.glPushMatrix();
                {
                    GL11.glColor4f(1, 1, 1, 1);
                    ResourceLocation synthMaterial = pair.getKey().getTexture();
                    if (synthMaterial == null) {
                        GL11.glTranslatef((int) (posX + (materialLength * 1.05f)), 110 + (distY * row), 0);
                        GL11.glScalef(scale, scale, 0);
                        Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(pair.getKey().getItem(), 0, 0);
                    } else {
                        mc.renderEngine.bindTexture(synthMaterial);
                        GL11.glTranslatef(posX + (materialLength * 1.05f * scale), 110 + (distY * row), 0);
                        GL11.glScalef(0.0625f * scale, 0.0625f * scale, 0);
                        drawTexturedModalRect(0, 0, 0, 0, 256, 256);
                    }
                }
                GL11.glPopMatrix();
                String name = pair.getKey().getName();
                String info = "";
                int colour = 0xFFFFFF;
                SynthesisMaterialCapability.ISynthesisMaterial MATS = mc.player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
                if (MATS.getKnownMaterialsMap().containsKey(pair.getKey().getName())) {
                    info = " - You have " + MATS.getKnownMaterialsMap().get(pair.getKey().getName());
                    if (MATS.getKnownMaterialsMap().get(pair.getKey().getName()) >= pair.getValue())
                        colour = 0x00CF18;
                    else
                        colour = 0xB50000;
                } else {
                    info = " - You have 0";
                    colour = 0xB50000;
                }
                String material = Utils.translateToLocal(name + ".name") + " x" + pair.getValue();
                GL11.glPushMatrix();
                {
                    GL11.glTranslatef((int) (posX + 18 + (materialLength * 1.05f * scale)), 114 + (distY * row), 0);
                    GL11.glScalef(scale, scale, 0);
                    drawString(fontRenderer, material, 0, 0, 0xFFFFFF);
                }
                GL11.glPopMatrix();
                GL11.glPushMatrix();
                {
                    GL11.glTranslatef((int) (posX + 18 + (fontRenderer.getStringWidth(material) * scale) + (materialLength * 1.05f * scale)), 114 + (distY * row), 0);
                    GL11.glScalef(scale, scale, 0);
                    drawString(fontRenderer, info, 0, 0, colour);
                }
                GL11.glPopMatrix();
                if (column == 1) {
                    row++;
                    column = 0;
                    materialLength = 0;
                } else {
                    materialLength = (fontRenderer.getStringWidth(Utils.translateToLocal(ModItems.Chain_IncompleteKiblade.getUnlocalizedName() + ".name") + " - You have XXXX")) + 20;
                    column = 1;
                }
            }
        }
    }
    GL11.glPopMatrix();
}
Also used : SynthesisMaterialCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability) Material(uk.co.wehavecookies56.kk.api.materials.Material) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability) ResourceLocation(net.minecraft.util.ResourceLocation) Iterator(java.util.Iterator) Map(java.util.Map)

Example 13 with Material

use of uk.co.wehavecookies56.kk.api.materials.Material in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiMaterialList method drawSlot.

@Override
protected void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5) {
    ISynthesisMaterial MATS = Minecraft.getMinecraft().player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
    List<String> materials = new ArrayList<String>();
    materials.addAll(MATS.getKnownMaterialsMap().keySet());
    this.f.drawString(f.trimStringToWidth(Utils.translateToLocal(materials.get(var1).toString() + ".name") + " x" + MATS.getKnownMaterialsMap().get(materials.get(var1)), listWidth - 10), this.left + 3, var3 + 2, 0xFFFFFF);
    Material m = MaterialRegistry.get(materials.get(var1).toString());
    if (m.getTexture() != null) {
        GL11.glPushMatrix();
        {
            ResourceLocation texture = m.getTexture();
            Minecraft.getMinecraft().renderEngine.bindTexture(texture);
            GL11.glTranslatef(this.left + 3, var3 + 12, 0);
            GL11.glScalef(0.0625f, 0.0625f, 0.0625f);
            parent.drawTexturedModalRect(0, 0, 0, 0, 256, 256);
        }
        GL11.glPopMatrix();
    } else {
        ItemStack item = m.getItem();
        this.ir.renderItemAndEffectIntoGUI(item, this.left + 3, var3 + 12);
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) ISynthesisMaterial(uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability.ISynthesisMaterial) Material(uk.co.wehavecookies56.kk.api.materials.Material) ItemStack(net.minecraft.item.ItemStack) ISynthesisMaterial(uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability.ISynthesisMaterial)

Aggregations

Material (uk.co.wehavecookies56.kk.api.materials.Material)7 Map (java.util.Map)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 SynthesisMaterialCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability)6 Iterator (java.util.Iterator)5 ItemStack (net.minecraft.item.ItemStack)5 ArrayList (java.util.ArrayList)4 SyncMaterialData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)4 Recipe (uk.co.wehavecookies56.kk.api.recipes.Recipe)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ISynthesisMaterial (uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability.ISynthesisMaterial)2 SynthesisRecipeCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)2 ItemSynthesisMaterial (uk.co.wehavecookies56.kk.common.item.base.ItemSynthesisMaterial)2 CreateFromSynthesisRecipe (uk.co.wehavecookies56.kk.common.network.packet.server.CreateFromSynthesisRecipe)2 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 Item (net.minecraft.item.Item)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 VillagerRegistry (net.minecraftforge.fml.common.registry.VillagerRegistry)1 GuiHandler (uk.co.wehavecookies56.kk.common.core.handler.GuiHandler)1