Search in sources :

Example 1 with IOrgWeapon

use of uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiRecipeList method drawSlot.

@Override
protected void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = Minecraft.getMinecraft().player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    int colour = 0xFFFFFF;
    if (parent.isRecipeUsable(RECIPES.getKnownRecipes().get(var1))) {
        colour = 0x55FF55;
    }
    Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(var1).substring(5)));
    if (item instanceof ItemKeyblade) {
        drawStats((ItemKeyblade) item, var1, var3, colour);
    } else if (item instanceof IOrgWeapon) {
        drawStats((IOrgWeapon) item, var1, var3, colour);
    } else {
        this.f.drawString(f.trimStringToWidth(Utils.translateToLocal(RECIPES.getKnownRecipes().get(var1).toString() + ".name"), listWidth - 1), this.left + 3, var3 + 2, colour);
        this.ir.renderItemAndEffectIntoGUI(new ItemStack(item), this.left + 3, var3 + 12);
    }
}
Also used : Item(net.minecraft.item.Item) RenderItem(net.minecraft.client.renderer.RenderItem) ResourceLocation(net.minecraft.util.ResourceLocation) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) ItemStack(net.minecraft.item.ItemStack) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)

Example 2 with IOrgWeapon

use of uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiRecipeList method drawStats.

public void drawStats(IOrgWeapon item, int var1, int var3, int colour) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = Minecraft.getMinecraft().player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    this.f.drawString(f.trimStringToWidth(Utils.translateToLocal(RECIPES.getKnownRecipes().get(var1).toString() + ".name"), listWidth - 1), this.left + 3, var3 + 2, colour);
    this.ir.renderItemAndEffectIntoGUI(new ItemStack(item.getItem()), this.left + 3, var3 + 12);
    String plus = item.getStrength() < 0 ? "" : "+";
    this.f.drawString("Str: " + plus + item.getStrength(), this.left + 25, var3 + 12, 0xFF0000);
    plus = item.getMagic() < 0 ? "" : "+";
    this.f.drawString("Mag: " + plus + item.getMagic(), this.left + 25, var3 + 20, 0x4444FF);
}
Also used : ItemStack(net.minecraft.item.ItemStack) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)

Example 3 with IOrgWeapon

use of uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiSynthesis method drawSelected.

public void drawSelected(int mouseX, int mouseY) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = mc.player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    int posX = 220;
    if (selected != -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.getKnownRecipes().size(); i++) if (selected == 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.getKnownRecipes().get(i).toString() + ".name"), 0, 0, 0xFFF700);
                Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)));
                if (item instanceof ItemKeyblade) {
                    drawString(fontRenderer, "Strength: +" + ((ItemKeyblade) ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getStrength(), 0, 10, 0xFF0000);
                    drawString(fontRenderer, "Magic: +" + ((ItemKeyblade) ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getMagic(), 0, 20, 0x4444FF);
                } else if (item instanceof IOrgWeapon) {
                    drawString(fontRenderer, "Strength: +" + ((IOrgWeapon) ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getStrength(), 0, 10, 0xFF0000);
                    drawString(fontRenderer, "Magic: +" + ((IOrgWeapon) 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, 130, 0x00C3FF);
            int row = 0;
            int column = 0;
            int materialLength = 0;
            Iterator it = RecipeRegistry.get(RECIPES.getKnownRecipes().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)), 140 + (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), 140 + (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)), 144 + (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)), 144 + (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) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) Material(uk.co.wehavecookies56.kk.api.materials.Material) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability) Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) Iterator(java.util.Iterator) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) Map(java.util.Map)

Example 4 with IOrgWeapon

use of uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class EntityEvents method onLivingDeathEvent.

@SubscribeEvent
public void onLivingDeathEvent(LivingDeathEvent event) {
    if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntity();
        SummonKeybladeCapability.ISummonKeyblade SUMMON = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null);
        IOrganizationXIII ORG = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null);
        if (SUMMON.getIsKeybladeSummoned(EnumHand.MAIN_HAND)) {
            if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
                PacketDispatcher.sendToServer(new DeSummonKeyblade());
                PacketDispatcher.sendTo(new SyncKeybladeData(SUMMON), (EntityPlayerMP) player);
            } else {
                SUMMON.setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
                if (event.getEntity().world.getGameRules().getBoolean("keepInventory")) {
                    for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
                        if (!ItemStack.areItemStacksEqual(player.inventory.getStackInSlot(i), ItemStack.EMPTY)) {
                            if (player.inventory.getStackInSlot(i).getItem() instanceof ItemRealKeyblade) {
                                player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
                            }
                        }
                    }
                }
            }
        } else if (ORG.summonedWeapon(EnumHand.MAIN_HAND)) {
            if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
                PacketDispatcher.sendToServer(new DeSummonOrgWeapon());
                PacketDispatcher.sendTo(new SyncOrgXIIIData(ORG), (EntityPlayerMP) player);
            } else {
                SUMMON.setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
                if (event.getEntity().world.getGameRules().getBoolean("keepInventory")) {
                    for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
                        if (!ItemStack.areItemStacksEqual(player.inventory.getStackInSlot(i), ItemStack.EMPTY)) {
                            if (player.inventory.getStackInSlot(i).getItem() instanceof IOrgWeapon) {
                                player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
                            }
                        }
                    }
                }
            }
        }
    }
    if (event.getEntity() instanceof EntityDragon) {
        WorldSavedDataKingdomKeys.get(DimensionManager.getWorld(DimensionType.OVERWORLD.getId())).setSpawnHeartless(true);
    }
    if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityMob)
        if (event.getSource().getTrueSource() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
            EntityMob mob = (EntityMob) event.getEntity();
            player.getCapability(ModCapabilities.PLAYER_STATS, null).addExperience(player, (int) (mob.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getAttributeValue() / 2));
            if (!player.getCapability(ModCapabilities.PLAYER_STATS, null).enderDragonDefeated()) {
                player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() + 1);
                player.getCapability(ModCapabilities.DRIVE_STATE, null).setDP(player.getCapability(ModCapabilities.DRIVE_STATE, null).getMaxDP());
                PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
                TextComponentTranslation driMessage = new TextComponentTranslation(Strings.Chat_DriveBoost, new TextComponentTranslation("" + player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel()));
                driMessage.getStyle().setColor(TextFormatting.GREEN);
                player.sendMessage(driMessage);
                player.getCapability(ModCapabilities.PLAYER_STATS, null).setEnderDragonDefeated(true);
            }
            if (event.getEntity() instanceof EntityDragon) {
                player.getCapability(ModCapabilities.PLAYER_STATS, null).addExperience(player, 2000);
            }
            if (event.getEntity() instanceof EntityWither) {
                player.getCapability(ModCapabilities.PLAYER_STATS, null).addExperience(player, 1500);
            }
            PacketDispatcher.sendTo(new SyncLevelData(player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
        }
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) SyncLevelData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncLevelData) DeSummonKeyblade(uk.co.wehavecookies56.kk.common.network.packet.server.DeSummonKeyblade) SyncKeybladeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncKeybladeData) ItemRealKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade) SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData) EntityMob(net.minecraft.entity.monster.EntityMob) SummonKeybladeCapability(uk.co.wehavecookies56.kk.common.capability.SummonKeybladeCapability) SyncDriveData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData) DeSummonOrgWeapon(uk.co.wehavecookies56.kk.common.network.packet.server.DeSummonOrgWeapon) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) EntityWither(net.minecraft.entity.boss.EntityWither) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) IOrganizationXIII(uk.co.wehavecookies56.kk.common.capability.OrganizationXIIICapability.IOrganizationXIII) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with IOrgWeapon

use of uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class EntityEvents method onHurt.

/* @SubscribeEvent
    public void onLivingUpdate (LivingEvent.LivingUpdateEvent event) {
        if (event.getEntityLiving() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getEntityLiving();

            if(player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue() == 0 && player.isAirBorne){
                player.motionX=0;
                player.motionY=0;
                player.motionZ=0;
            }
        }
    }*/
@SubscribeEvent
public void onHurt(LivingHurtEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        PlayerStatsCapability.IPlayerStats STATS = event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null);
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        if (event.getAmount() - STATS.getDefense() <= 0)
            event.setAmount(1);
        else
            event.setAmount((float) (event.getAmount() - (STATS.getDefense() * 0.25)));
        if (event.getSource().getDamageType().equals("lightningBolt"))
            if (EntityThunder.summonLightning)
                event.setCanceled(true);
    }
    if (event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        player.getCapability(ModCapabilities.DRIVE_STATE, null).addDP(1);
        PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
    }
    if (event.getEntityLiving() instanceof IKHMob) {
        EntityPlayer player = null;
        IKHMob khMob = (IKHMob) event.getEntityLiving();
        if (event.getSource().getImmediateSource() instanceof EntityPlayer) {
            player = (EntityPlayer) event.getSource().getImmediateSource();
        }
        if (player != null) {
            if (khMob.getType() == MobType.HEARTLESS_EMBLEM || khMob.getType() == MobType.HEARTLESS_PUREBLOOD || khMob.getType() == MobType.NOBODY) {
                // If the player has a real weapon in any slot
                if (!(player.getHeldItemMainhand().getItem() instanceof ItemKeyblade || player.getHeldItemMainhand().getItem() instanceof IOrgWeapon || player.getHeldItemOffhand().getItem() instanceof ItemKeyblade || player.getHeldItemOffhand().getItem() instanceof IOrgWeapon)) {
                    event.setCanceled(true);
                }
            // }
            }
        }
    }
    if (event.getSource().getImmediateSource() instanceof EntityPlayer && !event.getSource().damageType.equals(EnumHand.OFF_HAND.name())) {
        EntityPlayer player = (EntityPlayer) event.getSource().getImmediateSource();
        if (event.getSource().getDamageType().equals("thorns"))
            return;
        if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
            if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade || player.getHeldItem(player.getActiveHand()).getItem() instanceof IOrgWeapon) {
                event.setAmount(event.getAmount() - 4 + DamageCalculation.getStrengthDamage(player));
            }
        }
    }
}
Also used : IPlayerStats(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats) SyncDriveData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData) PlayerStatsCapability(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) IKHMob(uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IOrgWeapon (uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon)6 ItemKeyblade (uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade)5 ItemStack (net.minecraft.item.ItemStack)4 Item (net.minecraft.item.Item)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 SynthesisRecipeCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)3 Map (java.util.Map)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 SummonKeybladeCapability (uk.co.wehavecookies56.kk.common.capability.SummonKeybladeCapability)2 ItemKeychain (uk.co.wehavecookies56.kk.common.item.base.ItemKeychain)2 ItemRealKeyblade (uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade)2 SyncDriveData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData)2 DeSummonKeyblade (uk.co.wehavecookies56.kk.common.network.packet.server.DeSummonKeyblade)2 DeSummonOrgWeapon (uk.co.wehavecookies56.kk.common.network.packet.server.DeSummonOrgWeapon)2 Iterator (java.util.Iterator)1 RenderItem (net.minecraft.client.renderer.RenderItem)1 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1