Search in sources :

Example 1 with Recipe

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

the class EntityEvents method onLivingDrops.

@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event) {
    for (int i = 0; i < entityDrops.size(); i++) {
        if (entityDrops.get(i).getDroppedFrom().isInstance(event.getEntity())) {
            addEntityDrop(event, entityDrops.get(i));
        }
    }
    // Remove any summoned keyblades or org weapons on death
    if (event.getEntity() instanceof EntityPlayer) {
        for (int i = 0; i < event.getDrops().size(); i++) {
            if (event.getDrops().get(i).getItem().getItem() instanceof ItemKeyblade && (event.getDrops().get(i).getItem().getItem() != ModItems.WoodenKeyblade && event.getDrops().get(i).getItem().getItem() != ModItems.WoodenStick)) {
                event.getDrops().remove(i);
                event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
                i = 0;
            }
            if (event.getDrops().get(i).getItem().getItem() == event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null).currentWeapon()) {
                event.getDrops().remove(i);
                event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null).setWeaponSummoned(((EntityPlayer) event.getEntity()).getActiveHand(), false);
                i = 0;
            }
        }
    }
    if (!MainConfig.entities.disableDrops) {
        if (event.getSource().getTrueSource() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
                if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade) {
                    if (event.getEntity() instanceof EntityMob)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            dropRecipe(event);
                }
            }
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.OFF_HAND), ItemStack.EMPTY)) {
                if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade) {
                    if (event.getEntity() instanceof EntityMob)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            dropRecipe(event);
                }
            }
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
                if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemRealKeyblade) {
                    if (event.getEntity() instanceof EntityAnimal) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("heart"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Heart), 2);
                    } else if (event.getEntity() instanceof EntityMob) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("darkheart")) {
                            if (!(event.getEntityLiving() instanceof IKHMob && ((IKHMob) event.getEntityLiving()).getType() == MobType.HEARTLESS_PUREBLOOD))
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.DarkHeart), 2);
                        }
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("spellorb") && event.getEntity() instanceof EntityWitch) {
                            int rand;
                            rand = Utils.randomWithRange(1, 30);
                            if (rand == 1)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicFire), 1);
                            else if (rand == 5)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicBlizzard), 1);
                            else if (rand == 9)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicThunder), 1);
                            else if (rand == 13)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicCure), 1);
                            else if (rand == 17) {
                            // event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicGravity), 1);
                            } else if (rand == 21)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicAero), 1);
                            else if (rand == 25)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicStop), 1);
                        }
                    } else if (event.getEntity() instanceof EntityAgeable)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("pureheart"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.PureHeart), 2);
                    if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("kingdomhearts"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.KingdomHearts), 1);
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Recipe), 1);
                    }
                }
            }
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.OFF_HAND), ItemStack.EMPTY)) {
                if (player.getHeldItem(EnumHand.OFF_HAND).getItem() instanceof ItemRealKeyblade) {
                    if (event.getEntity() instanceof EntityAnimal)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("heart"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Heart), 2);
                        else if (event.getEntity() instanceof EntityMob) {
                            if (Arrays.asList(MainConfig.entities.dropsList).contains("darkheart"))
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.DarkHeart), 2);
                            if (Arrays.asList(MainConfig.entities.dropsList).contains("spellorb") && event.getEntity() instanceof EntityWitch) {
                                int rand;
                                rand = Utils.randomWithRange(1, 30);
                                if (rand == 1)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicFire), 1);
                                else if (rand == 5)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicBlizzard), 1);
                                else if (rand == 9)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicThunder), 1);
                                else if (rand == 13)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicCure), 1);
                                else if (rand == 17) {
                                // event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicGravity), 1);
                                } else if (rand == 21)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicAero), 1);
                                else if (rand == 25)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicStop), 1);
                            }
                        } else if (event.getEntity() instanceof EntityAgeable)
                            if (Arrays.asList(MainConfig.entities.dropsList).contains("pureheart"))
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.PureHeart), 2);
                    if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("kingdomhearts"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.KingdomHearts), 1);
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Recipe), 1);
                    }
                }
            }
            ItemStack munny = new ItemStack(ModItems.Munny, 1);
            munny.setTagCompound(new NBTTagCompound());
            ItemStack driveOrb = new ItemStack(ModItems.DriveOrb, 1);
            driveOrb.setTagCompound(new NBTTagCompound());
            ItemStack magicOrb = new ItemStack(ModItems.MagicOrb, 1);
            magicOrb.setTagCompound(new NBTTagCompound());
            ItemStack HPOrb = new ItemStack(ModItems.HpOrb, 1);
            if (event.getEntity() instanceof EntityAnimal) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(1, 20));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(2, 8));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            } else if (event.getEntity() instanceof EntityMob) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(5, 50));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", 5);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(5, 15));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            } else if (event.getEntity() instanceof EntityAgeable) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(50, 100));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", 5);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(10, 25));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            } else if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(500, 1000));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(200, 250));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(100, 140));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            }
        }
    }
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) ItemRealKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) IKHMob(uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob) EntityMob(net.minecraft.entity.monster.EntityMob) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityWither(net.minecraft.entity.boss.EntityWither) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) ItemStack(net.minecraft.item.ItemStack) EntityWitch(net.minecraft.entity.monster.EntityWitch) EntityAgeable(net.minecraft.entity.EntityAgeable) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with Recipe

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

the class CommonProxy method init.

public void init(FMLInitializationEvent event) {
    // Instance
    MinecraftForge.EVENT_BUS.register(KingdomKeys.instance);
    ModBiomes.init();
    // ModSounds.init();
    // LogHelper.info("Sounds loaded");
    // Update checker
    ModItems.init();
    // Register renders
    KingdomKeys.logger.info("Renders loaded");
    // Tile entity registry
    GameRegistry.registerTileEntity(TileEntitySynthesisTable.class, "synthesistable");
    GameRegistry.registerTileEntity(TileEntityKKChest.class, "kkchest");
    GameRegistry.registerTileEntity(TileEntityStationOfAwakening.class, "stationofawakening");
    GameRegistry.registerTileEntity(TileEntityPedestal.class, "kkpedestal");
    GameRegistry.registerTileEntity(TileEntityOrgPortal.class, "kkorgportal");
    KingdomKeys.logger.info("Tile entity loaded");
    // Proxy used as Gui handler
    NetworkRegistry.INSTANCE.registerGuiHandler(KingdomKeys.instance, new GuiHandler());
    EntityHelper.registerEntity("blastblox", EntityBlastBlox.class);
    EntityHelper.registerEntity("fire", EntityFire.class);
    EntityHelper.registerEntity("thunder", EntityThunder.class);
    EntityHelper.registerEntity("kkOrgPortalE", EntityOrgPortal.class);
    EntityHelper.registerEntity("kkFlyingHeart", EntityFlyingHeart.class);
    // Heartless registry
    EntityHelper.registerEntity(Strings.Shadow, EntityShadow.class, Color.BLACK.getRGB(), Color.YELLOW.getRGB());
    EntityHelper.registerEntity(Strings.MegaShadow, EntityMegaShadow.class, Color.BLACK.getRGB(), Color.GRAY.getRGB());
    EntityHelper.registerEntity(Strings.GigaShadow, EntityGigaShadow.class, Color.BLACK.getRGB(), Color.BLACK.getRGB());
    EntityHelper.registerEntity(Strings.Darkball, EntityDarkball.class, 0x020030, 0x492263);
    EntityHelper.registerEntity(Strings.RedNocturne, EntityRedNocturne.class, Color.RED.getRGB(), Color.PINK.getRGB());
    EntityHelper.registerEntity(Strings.BlueRhapsody, EntityBlueRhapsody.class, Color.BLUE.getRGB(), Color.CYAN.getRGB());
    EntityHelper.registerEntity(Strings.YellowOpera, EntityYellowOpera.class, Color.orange.getRGB(), Color.yellow.getRGB());
    EntityHelper.registerEntity(Strings.GreenRequiem, EntityGreenRequiem.class, Color.LIGHT_GRAY.getRGB(), Color.green.getRGB());
    EntityHelper.registerEntity(Strings.SilverRock, EntitySilverRock.class, Color.LIGHT_GRAY.getRGB(), Color.darkGray.getRGB());
    EntityHelper.registerEntity(Strings.CrimsonJazz, EntityCrimsonJazz.class, Color.black.getRGB(), Color.red.getRGB());
    EntityHelper.registerEntity(Strings.EmeraldBlues, EntityEmeraldBlues.class, Color.green.getRGB(), Color.blue.getRGB());
    EntityHelper.registerEntity(Strings.MinuteBomb, EntityMinuteBomb.class, 0x020030, 0x8B4513);
    EntityHelper.registerEntity(Strings.SkaterBomb, EntitySkaterBomb.class, 0x020030, 0xAAAAFF);
    EntityHelper.registerEntity(Strings.StormBomb, EntityStormBomb.class, 0x020030, Color.CYAN.getRGB());
    EntityHelper.registerEntity(Strings.Detonator, EntityDetonator.class, 0x020030, Color.RED.getRGB());
    EntityHelper.registerEntity(Strings.LargeBody, EntityLargeBody.class, 0x4d177c, 0x29014c);
    EntityHelper.registerEntity(Strings.Moogle, EntityMoogle.class, 0xDACAB0, 0xC50033);
    EntityHelper.registerEntity(Strings.GummiShip, EntityGummiShip.class, 0xFF0000, 0x6666AA);
    Spawnings.init();
    Lists.init();
    ModItemsRecipes.init();
    // Drive forms init
    ModDriveForms.init();
    KingdomKeys.logger.info(DriveFormRegistry.getDriveFormMap().size() + " Drive form(s) loaded");
    // Synthesis Recipes init
    ModSynthesisRecipes.init();
    KingdomKeys.logger.info(RecipeRegistry.getRecipeMap().size() + " Synthesis recipe(s) loaded");
    ModSynthesisFreeDevRecipes.init();
    KingdomKeys.logger.info(FreeDevRecipeRegistry.getFreeDevRecipeMap().size() + " Free Development recipe(s) loaded");
    ModSynthesisMaterials.init();
    KingdomKeys.logger.info(MaterialRegistry.getMaterialMap().size() + " Material(s) loaded");
    Constants.registerCosts();
    Constants.registerMagicLevels();
    if (MainConfig.worldgen.EnableWorldGen) {
        VillagerRegistry.instance().registerVillageCreationHandler(new MoogleHouse.VillageManager());
        MapGenStructureIO.registerStructureComponent(MoogleHouse.class, Reference.MODID + ":moogle_house");
    }
    VillagerRegistry.VillagerProfession librarian = ForgeRegistries.VILLAGER_PROFESSIONS.getValue(new ResourceLocation("minecraft:librarian"));
    librarian.getCareer(1).addTrade(1, new VillagerTrades());
    // Chest loot init
    MinecraftForge.EVENT_BUS.register(new ChestGen());
    KingdomKeys.logger.info("Chest loot loaded");
}
Also used : MoogleHouse(uk.co.wehavecookies56.kk.common.world.MoogleHouse) VillagerTrades(uk.co.wehavecookies56.kk.common.core.handler.VillagerTrades) ChestGen(uk.co.wehavecookies56.kk.common.world.ChestGen) VillagerRegistry(net.minecraftforge.fml.common.registry.VillagerRegistry) ResourceLocation(net.minecraft.util.ResourceLocation) GuiHandler(uk.co.wehavecookies56.kk.common.core.handler.GuiHandler)

Example 3 with Recipe

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

the class ItemRecipe method shuffleRecipes.

public void shuffleRecipes(ItemStack stack, EntityPlayer player) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    long seed = System.nanoTime();
    // Shuffles the list of recipe to increase randomness
    Collections.shuffle(Lists.recipes, new Random(seed));
    String Recipe1, Recipe2, Recipe3;
    // System.out.println();
    Recipe1 = Lists.recipes.get(Utils.randomWithRange(0, Lists.recipes.size() - 1));
    if (RECIPES.getKnownRecipes().size() < Lists.recipes.size() - 2) {
        while (RecipeRegistry.isRecipeKnown(RECIPES.getKnownRecipes(), Recipe1)) Recipe1 = Lists.recipes.get(Utils.randomWithRange(0, Lists.recipes.size() - 1));
    }
    Recipe2 = Lists.recipes.get(Utils.randomWithRange(0, Lists.recipes.size() - 1));
    if (RECIPES.getKnownRecipes().size() < Lists.recipes.size() - 1) {
        while (Recipe2.equals(Recipe1) || RecipeRegistry.isRecipeKnown(RECIPES.getKnownRecipes(), Recipe2)) Recipe2 = Lists.recipes.get(Utils.randomWithRange(0, Lists.recipes.size() - 1));
    }
    Recipe3 = Lists.recipes.get(Utils.randomWithRange(0, Lists.recipes.size() - 1));
    if (RECIPES.getKnownRecipes().size() < Lists.recipes.size()) {
        while ((Recipe3.equals(Recipe2) || Recipe3.equals(Recipe1)) || RecipeRegistry.isRecipeKnown(RECIPES.getKnownRecipes(), Recipe3)) Recipe3 = Lists.recipes.get(Utils.randomWithRange(0, Lists.recipes.size() - 1));
    }
    stack.setTagCompound(new NBTTagCompound());
    stack.getTagCompound().setString("recipe1", Recipe1);
    stack.getTagCompound().setString("recipe2", Recipe2);
    stack.getTagCompound().setString("recipe3", Recipe3);
}
Also used : Random(java.util.Random) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)

Example 4 with Recipe

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

the class UseRecipe method process.

@Override
public void process(EntityPlayer player, Side side) {
    boolean consume = false;
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    if (RecipeRegistry.get(recipe1) == null) {
        String message = "ERROR: Recipe for " + Utils.translateToLocal(recipe1 + ".name") + " was not learnt because it is not a valid recipe, Report this to Wehavecookies56";
        TextHelper.sendFormattedChatMessage(message, TextFormatting.RED, player);
    } else if (RecipeRegistry.isRecipeKnown(RECIPES.getKnownRecipes(), recipe1)) {
        TextComponentTranslation repeatMessage = new TextComponentTranslation(Strings.Chat_Recipe_Repeat, new TextComponentTranslation(recipe1 + ".name"));
        repeatMessage.getStyle().setColor(TextFormatting.YELLOW);
        player.sendMessage(repeatMessage);
    // TextHelper.sendFormattedChatMessage(message, TextFormatting.YELLOW, player);
    } else {
        RecipeRegistry.learnrecipe(RECIPES.getKnownRecipes(), player, recipe1);
        TextComponentTranslation learnMessage = new TextComponentTranslation(Strings.Chat_Recipe_Learn, new TextComponentTranslation(recipe1 + ".name"));
        learnMessage.getStyle().setColor(TextFormatting.GREEN);
        player.sendMessage(learnMessage);
        consume = true;
    }
    if (RecipeRegistry.get(recipe2) == null) {
        String message = "ERROR: Recipe for " + Utils.translateToLocal(recipe2 + ".name") + " was not learnt because it is not a valid recipe, Report this to Wehavecookies56";
        TextHelper.sendFormattedChatMessage(message, TextFormatting.RED, player);
    } else if (RecipeRegistry.isRecipeKnown(RECIPES.getKnownRecipes(), recipe2)) {
        TextComponentTranslation repeatMessage = new TextComponentTranslation(Strings.Chat_Recipe_Repeat, new TextComponentTranslation(recipe2 + ".name"));
        repeatMessage.getStyle().setColor(TextFormatting.YELLOW);
        player.sendMessage(repeatMessage);
    } else {
        RecipeRegistry.learnrecipe(RECIPES.getKnownRecipes(), player, recipe2);
        TextComponentTranslation learnMessage = new TextComponentTranslation(Strings.Chat_Recipe_Learn, new TextComponentTranslation(recipe2 + ".name"));
        learnMessage.getStyle().setColor(TextFormatting.GREEN);
        player.sendMessage(learnMessage);
        consume = true;
    }
    if (RecipeRegistry.get(recipe3) == null) {
        String message = "ERROR: Recipe for " + Utils.translateToLocal(recipe3 + ".name") + " was not learnt because it is not a valid recipe, Report this to Wehavecookies56";
        TextHelper.sendFormattedChatMessage(message, TextFormatting.RED, player);
    } else if (RecipeRegistry.isRecipeKnown(RECIPES.getKnownRecipes(), recipe3)) {
        TextComponentTranslation repeatMessage = new TextComponentTranslation(Strings.Chat_Recipe_Repeat, new TextComponentTranslation(recipe3 + ".name"));
        repeatMessage.getStyle().setColor(TextFormatting.YELLOW);
        player.sendMessage(repeatMessage);
    } else {
        RecipeRegistry.learnrecipe(RECIPES.getKnownRecipes(), player, recipe3);
        TextComponentTranslation learnMessage = new TextComponentTranslation(Strings.Chat_Recipe_Learn, new TextComponentTranslation(recipe3 + ".name"));
        learnMessage.getStyle().setColor(TextFormatting.GREEN);
        player.sendMessage(learnMessage);
        consume = true;
    }
    if (consume)
        if (!player.capabilities.isCreativeMode)
            player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
    if (RECIPES.getKnownRecipes().size() == 120) {
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)

Example 5 with Recipe

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

the class GuiSynthesis method isRecipeUsable.

public boolean isRecipeUsable(String name) {
    EntityPlayer player = Minecraft.getMinecraft().player;
    SynthesisMaterialCapability.ISynthesisMaterial MATS = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
    Recipe r = RecipeRegistry.get(name);
    List<Boolean> hasMaterials = new ArrayList<Boolean>();
    if (isInventoryFull())
        return false;
    Iterator it = r.getRequirements().entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<Material, Integer> pair = (Map.Entry<Material, Integer>) it.next();
        if (MATS.getKnownMaterialsMap().containsKey(pair.getKey().getName())) {
            if (pair.getValue() != null && MATS.getKnownMaterialsMap().get(pair.getKey().getName()) != null) {
                if (pair.getValue() <= MATS.getKnownMaterialsMap().get(pair.getKey().getName())) {
                    hasMaterials.add(true);
                }
            }
        }
    }
    if (r.getRequirements().size() > 0) {
        if (hasMaterials.size() == r.getRequirements().size()) {
            return true;
        }
    }
    return false;
}
Also used : SynthesisMaterialCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability) Recipe(uk.co.wehavecookies56.kk.api.recipes.Recipe) CreateFromSynthesisRecipe(uk.co.wehavecookies56.kk.common.network.packet.server.CreateFromSynthesisRecipe) ArrayList(java.util.ArrayList) Material(uk.co.wehavecookies56.kk.api.materials.Material) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Map(java.util.Map)

Aggregations

Iterator (java.util.Iterator)3 Map (java.util.Map)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 Material (uk.co.wehavecookies56.kk.api.materials.Material)3 Recipe (uk.co.wehavecookies56.kk.api.recipes.Recipe)3 SynthesisMaterialCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability)3 ArrayList (java.util.ArrayList)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 SynthesisRecipeCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)2 CreateFromSynthesisRecipe (uk.co.wehavecookies56.kk.common.network.packet.server.CreateFromSynthesisRecipe)2 Random (java.util.Random)1 EntityAgeable (net.minecraft.entity.EntityAgeable)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 EntityWither (net.minecraft.entity.boss.EntityWither)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntityWitch (net.minecraft.entity.monster.EntityWitch)1 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1