From a6e60e872c2601a050c9f33047ca50d628f3c317 Mon Sep 17 00:00:00 2001 From: Stefan Wimmer Date: Sun, 24 Jul 2016 15:39:56 +0200 Subject: [PATCH] Rewrite in Scala, Release Candidate 2.0.0-rc.1 --- LICENSE | 13 -- README.md | 30 ----- build.gradle | 5 +- gradle/wrapper/gradle-wrapper.properties | 2 +- package.json | 25 ---- .../java/io/teammion/morefood/Blocks.java | 15 --- .../java/io/teammion/morefood/Config.java | 25 ---- .../io/teammion/morefood/CreativeTabs.java | 24 ---- .../io/teammion/morefood/EventHandler.java | 33 ------ src/main/java/io/teammion/morefood/Items.java | 93 --------------- .../java/io/teammion/morefood/MoreFood.java | 65 ---------- .../java/io/teammion/morefood/Registry.java | 43 ------- .../io/teammion/morefood/block/Block.java | 29 ----- .../java/io/teammion/morefood/item/Item.java | 17 --- .../io/teammion/morefood/item/ItemDrink.java | 58 --------- .../io/teammion/morefood/item/ItemFood.java | 39 ------ .../morefood/item/ItemMilkBottle.java | 24 ---- .../morefood/item/ItemStrawberry.java | 28 ----- .../morefood/recipes/ShapedRecipes.java | 64 ---------- .../morefood/recipes/ShapelessRecipes.java | 93 --------------- .../morefood/recipes/SmeltingRecipes.java | 54 --------- .../scala/io/teammion/morefood/Config.scala | 23 ++++ .../io/teammion/morefood/EventHandler.scala | 27 +++++ .../scala/io/teammion/morefood/Items.scala | 111 ++++++++++++++++++ .../scala/io/teammion/morefood/MoreFood.scala | 64 ++++++++++ .../scala/io/teammion/morefood/Registry.scala | 34 ++++++ .../io/teammion/morefood/item/Item.scala | 21 ++++ .../io/teammion/morefood/item/ItemDrink.scala | 29 +++++ .../io/teammion/morefood/item/ItemFood.scala | 23 ++++ .../morefood/item/ItemMilkBottle.scala | 19 +++ .../morefood/item/ItemStrawberry.scala | 21 ++++ .../morefood/recipes/ShapedRecipes.scala | 76 ++++++++++++ .../morefood/recipes/ShapelessRecipes.scala | 91 ++++++++++++++ .../morefood/recipes/SmeltingRecipes.scala | 53 +++++++++ 34 files changed, 596 insertions(+), 775 deletions(-) delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 package.json delete mode 100644 src/main/java/io/teammion/morefood/Blocks.java delete mode 100644 src/main/java/io/teammion/morefood/Config.java delete mode 100644 src/main/java/io/teammion/morefood/CreativeTabs.java delete mode 100644 src/main/java/io/teammion/morefood/EventHandler.java delete mode 100644 src/main/java/io/teammion/morefood/Items.java delete mode 100644 src/main/java/io/teammion/morefood/MoreFood.java delete mode 100644 src/main/java/io/teammion/morefood/Registry.java delete mode 100644 src/main/java/io/teammion/morefood/block/Block.java delete mode 100644 src/main/java/io/teammion/morefood/item/Item.java delete mode 100644 src/main/java/io/teammion/morefood/item/ItemDrink.java delete mode 100644 src/main/java/io/teammion/morefood/item/ItemFood.java delete mode 100644 src/main/java/io/teammion/morefood/item/ItemMilkBottle.java delete mode 100644 src/main/java/io/teammion/morefood/item/ItemStrawberry.java delete mode 100644 src/main/java/io/teammion/morefood/recipes/ShapedRecipes.java delete mode 100644 src/main/java/io/teammion/morefood/recipes/ShapelessRecipes.java delete mode 100644 src/main/java/io/teammion/morefood/recipes/SmeltingRecipes.java create mode 100644 src/main/scala/io/teammion/morefood/Config.scala create mode 100644 src/main/scala/io/teammion/morefood/EventHandler.scala create mode 100644 src/main/scala/io/teammion/morefood/Items.scala create mode 100644 src/main/scala/io/teammion/morefood/MoreFood.scala create mode 100644 src/main/scala/io/teammion/morefood/Registry.scala create mode 100644 src/main/scala/io/teammion/morefood/item/Item.scala create mode 100644 src/main/scala/io/teammion/morefood/item/ItemDrink.scala create mode 100644 src/main/scala/io/teammion/morefood/item/ItemFood.scala create mode 100644 src/main/scala/io/teammion/morefood/item/ItemMilkBottle.scala create mode 100644 src/main/scala/io/teammion/morefood/item/ItemStrawberry.scala create mode 100644 src/main/scala/io/teammion/morefood/recipes/ShapedRecipes.scala create mode 100644 src/main/scala/io/teammion/morefood/recipes/ShapelessRecipes.scala create mode 100644 src/main/scala/io/teammion/morefood/recipes/SmeltingRecipes.scala diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 6411d20..0000000 --- a/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2016, Team Mion - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index 0e7c994..0000000 --- a/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# MoreFood - -For more information visit the [Curse Project](http://minecraft.curseforge.com/projects/tm-morefood) - -## How to contribute? - -### Prerequisites - -- Node, NPM -- Git (On windows: Git Bash) - -### How to do it - -Since I'm using a customized build system, I should tell you how to use it. - -``` bash -# Setup gradle workspace and configure for IDE -npm run setup - -# Run Minecraft Client -npm run client - -# Run Minecraft Server -npm run server - -# Build project -npm run build -``` - -The version must be changed in the "package.json" file. diff --git a/build.gradle b/build.gradle index e1375bf..f65f2ad 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,8 @@ buildscript { } } -apply plugin: 'net.minecraftforge.gradle.forge' +apply plugin: "scala" +apply plugin: "net.minecraftforge.gradle.forge" /* // for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot @@ -21,7 +22,7 @@ plugins { id "net.minecraftforge.gradle.forge" version "2.0.2" } */ -version = "1.2.0" +version = "2.0.0-rc.1" group = "io.teammion.morefood" archivesBaseName = "tm-morefood" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 231dfc4..3c773af 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Sat Jul 23 22:21:39 CEST 2016 +#Sun Jul 24 00:30:36 CEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/package.json b/package.json deleted file mode 100644 index c92c619..0000000 --- a/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "tm-morefood", - "version": "1.2.0", - "description": "This Minecraft Mod will add additional food to Mincraft to provide a healthy variety.", - "scripts": { - "setup": "bin/setup", - "build": "bin/build", - "update": "bin/update", - "client": "./gradlew runClient", - "server": "./gradlew runServer" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/teammion/tm-morefood.git" - }, - "keywords": [ - "morefood" - ], - "author": "Stefan Wimmer ", - "license": "ISC", - "bugs": { - "url": "https://github.com/teammion/tm-morefood/issues" - }, - "homepage": "https://github.com/teammion/tm-morefood#readme" -} diff --git a/src/main/java/io/teammion/morefood/Blocks.java b/src/main/java/io/teammion/morefood/Blocks.java deleted file mode 100644 index 09a98ae..0000000 --- a/src/main/java/io/teammion/morefood/Blocks.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.teammion.morefood; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class Blocks extends net.minecraft.init.Blocks -{ - static void register() - { - } - - static void render() - { - } -} diff --git a/src/main/java/io/teammion/morefood/Config.java b/src/main/java/io/teammion/morefood/Config.java deleted file mode 100644 index 74abf2a..0000000 --- a/src/main/java/io/teammion/morefood/Config.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.teammion.morefood; - -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -import java.io.File; - -/** - * Created by Stefan Wimmer on 19.07.16. - */ -public class Config -{ - public static boolean OVERRIDE_BREAD_RECIPE; - - static void load(FMLPreInitializationEvent e) - { - Configuration config = new Configuration(e.getSuggestedConfigurationFile()); - - config.load(); - - OVERRIDE_BREAD_RECIPE = config.get("food", "override_bread_recipe", false).getBoolean(); - - config.save(); - } -} diff --git a/src/main/java/io/teammion/morefood/CreativeTabs.java b/src/main/java/io/teammion/morefood/CreativeTabs.java deleted file mode 100644 index c93b38e..0000000 --- a/src/main/java/io/teammion/morefood/CreativeTabs.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.teammion.morefood; - -import net.minecraft.item.Item; - -/** - * Created by Stefan Wimmer on 23.07.16. - */ -public class CreativeTabs extends net.minecraft.creativetab.CreativeTabs -{ - private Item tabIconItem; - - public CreativeTabs(String label, Item tabIconItem) - { - super(label); - - this.tabIconItem = tabIconItem; - } - - @Override - public Item getTabIconItem() - { - return tabIconItem; - } -} diff --git a/src/main/java/io/teammion/morefood/EventHandler.java b/src/main/java/io/teammion/morefood/EventHandler.java deleted file mode 100644 index 4295434..0000000 --- a/src/main/java/io/teammion/morefood/EventHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.teammion.morefood; - -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.event.entity.living.LivingDropsEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.Random; - -/** - * Created by Stefan Wimmer on 02.07.16. - */ -public class EventHandler -{ - @SubscribeEvent - public void onDrop(LivingDropsEvent e) - { - World world = e.getEntity().worldObj; - - if (! world.isRemote) - { - world.spawnEntityInWorld(new EntityItem( - world, - e.getEntity().posX, - e.getEntity().posY, - e.getEntity().posZ, - new ItemStack(Items.STRAWBERRY, new Random().nextInt(2)) - )); - } - } -} diff --git a/src/main/java/io/teammion/morefood/Items.java b/src/main/java/io/teammion/morefood/Items.java deleted file mode 100644 index d95e294..0000000 --- a/src/main/java/io/teammion/morefood/Items.java +++ /dev/null @@ -1,93 +0,0 @@ -package io.teammion.morefood; - -import io.teammion.morefood.item.*; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class Items extends net.minecraft.init.Items -{ - public static final ItemMilkBottle MILK_BOTTLE = new ItemMilkBottle(); - public static final Item COCOA_BEAN_ROASTED = new Item("cocoa_bean_roasted"); - public static final Item COCOA_BEAN_GROUND = new Item("cocoa_bean_ground"); - public static final ItemFood CHOCOLATE = new ItemFood("chocolate", 8); - public static final ItemFood CHOCOLATE_PIECE = new ItemFood("chocolate_piece", 1); - public static final ItemDrink CHOCOLATE_DRINK = new ItemDrink("chocolate_drink", 4); - public static final Item FLOUR = new Item("flour"); - public static final Item SCHNITZEL_RAW = new Item("schnitzel_raw"); - public static final ItemFood SCHNITZEL = new ItemFood("schnitzel", 4); - public static final ItemFood EGG_BOILED = new ItemFood("egg_boiled", 3); - public static final Item APPLE_CHOCOLATE = new Item("apple_chocolate"); - public static final ItemFood APPLE_CHOCOLATE_COATED = new ItemFood("apple_chocolate_coated", 8); - public static final Item FISH_STICK_RAW = new Item("fish_stick_raw"); - public static final ItemFood FISH_STICK = new ItemFood("fish_stick", 6); - public static final Item BREAD_SLICE = new Item("bread_slice"); - public static final ItemFood SANDWICH_SCHNITZEL = new ItemFood("sandwich_schnitzel", 5); - public static final ItemFood SANDWICH_PORKCHOP = new ItemFood("sandwich_porkchop", 5); - public static final ItemFood SANDWICH_CHICKEN = new ItemFood("sandwich_chicken", 5); - public static final ItemFood SANDWICH_FISH = new ItemFood("sandwich_fish", 5); - public static final ItemFood STRAWBERRY = new ItemStrawberry(); - public static final Item STRAWBERRY_CHOCOLATE = new Item("strawberry_chocolate"); - public static final ItemFood STRAWBERRY_CHOCOLATE_COATED = new ItemFood("strawberry_chocolate_coated", 8); - public static final Item FRENCH_FRIES_RAW = new Item("french_fries_raw"); - public static final ItemFood FRENCH_FRIES = new ItemFood("french_fries", 6); - public static final Item BREAD_DOUGH = new Item("bread_dough"); - - static void register() - { - Registry.register(MILK_BOTTLE); - Registry.register(COCOA_BEAN_ROASTED); - Registry.register(COCOA_BEAN_GROUND); - Registry.register(CHOCOLATE); - Registry.register(CHOCOLATE_PIECE); - Registry.register(CHOCOLATE_DRINK); - Registry.register(FLOUR); - Registry.register(SCHNITZEL_RAW); - Registry.register(SCHNITZEL); - Registry.register(EGG_BOILED); - Registry.register(APPLE_CHOCOLATE); - Registry.register(APPLE_CHOCOLATE_COATED); - Registry.register(FISH_STICK_RAW); - Registry.register(FISH_STICK); - Registry.register(BREAD_SLICE); - Registry.register(SANDWICH_SCHNITZEL); - Registry.register(SANDWICH_PORKCHOP); - Registry.register(SANDWICH_CHICKEN); - Registry.register(SANDWICH_FISH); - Registry.register(STRAWBERRY); - Registry.register(STRAWBERRY_CHOCOLATE); - Registry.register(STRAWBERRY_CHOCOLATE_COATED); - Registry.register(FRENCH_FRIES_RAW); - Registry.register(FRENCH_FRIES); - Registry.register(BREAD_DOUGH); - } - - static void render() - { - Registry.render(MILK_BOTTLE); - Registry.render(COCOA_BEAN_ROASTED); - Registry.render(COCOA_BEAN_GROUND); - Registry.render(CHOCOLATE); - Registry.render(CHOCOLATE_PIECE); - Registry.render(CHOCOLATE_DRINK); - Registry.render(FLOUR); - Registry.render(SCHNITZEL_RAW); - Registry.render(SCHNITZEL); - Registry.render(EGG_BOILED); - Registry.render(APPLE_CHOCOLATE); - Registry.render(APPLE_CHOCOLATE_COATED); - Registry.render(FISH_STICK_RAW); - Registry.render(FISH_STICK); - Registry.render(BREAD_SLICE); - Registry.render(SANDWICH_SCHNITZEL); - Registry.render(SANDWICH_PORKCHOP); - Registry.render(SANDWICH_CHICKEN); - Registry.render(SANDWICH_FISH); - Registry.render(STRAWBERRY); - Registry.render(STRAWBERRY_CHOCOLATE); - Registry.render(STRAWBERRY_CHOCOLATE_COATED); - Registry.render(FRENCH_FRIES_RAW); - Registry.render(FRENCH_FRIES); - Registry.render(BREAD_DOUGH); - } -} diff --git a/src/main/java/io/teammion/morefood/MoreFood.java b/src/main/java/io/teammion/morefood/MoreFood.java deleted file mode 100644 index a95d763..0000000 --- a/src/main/java/io/teammion/morefood/MoreFood.java +++ /dev/null @@ -1,65 +0,0 @@ -package io.teammion.morefood; - -import io.teammion.morefood.recipes.ShapedRecipes; -import io.teammion.morefood.recipes.ShapelessRecipes; -import io.teammion.morefood.recipes.SmeltingRecipes; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.relauncher.Side; - -import java.util.Iterator; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -@Mod(modid = "tm-morefood") -public class MoreFood -{ - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent e) - { - Config.load(e); - - Items.register(); - Blocks.register(); - } - - @Mod.EventHandler - public void init(FMLInitializationEvent e) - { - if (e.getSide() == Side.CLIENT) - { - Items.render(); - Blocks.render(); - } - - ShapedRecipes.register(); - ShapelessRecipes.register(); - SmeltingRecipes.register(); - - MinecraftForge.EVENT_BUS.register(new EventHandler()); - } - - @Mod.EventHandler - public void postInit(FMLPostInitializationEvent e) - { - if (Config.OVERRIDE_BREAD_RECIPE) - { - Iterator itr = CraftingManager.getInstance().getRecipeList().iterator(); - - while (itr.hasNext()) - { - ItemStack itemStack = itr.next().getRecipeOutput(); - - if (itemStack != null && itemStack.getItem() == Items.BREAD) - itr.remove(); - } - } - } -} diff --git a/src/main/java/io/teammion/morefood/Registry.java b/src/main/java/io/teammion/morefood/Registry.java deleted file mode 100644 index 53ac993..0000000 --- a/src/main/java/io/teammion/morefood/Registry.java +++ /dev/null @@ -1,43 +0,0 @@ -package io.teammion.morefood; - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.GameRegistry; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class Registry extends GameRegistry -{ - public static void render(Item item) - { - render(item, 0, item.getUnlocalizedName().substring(5)); - } - - public static void render(Item item, int meta, String modelResourceLocation) - { - Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( - item, meta, new ModelResourceLocation( - "tm-morefood:" + modelResourceLocation, "inventory" - ) - ); - } - - public static void addSmelting(Item item, ItemStack stack) - { - addSmelting(item, stack, .8f); - } - - public static void addSmelting(ItemStack stack0, ItemStack stack1) - { - addSmelting(stack0, stack1, .8f); - } - - public static void addSmelting(Block item, ItemStack stack) - { - addSmelting(item, stack, .8f); - } -} diff --git a/src/main/java/io/teammion/morefood/block/Block.java b/src/main/java/io/teammion/morefood/block/Block.java deleted file mode 100644 index 426de9c..0000000 --- a/src/main/java/io/teammion/morefood/block/Block.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.teammion.morefood.block; - -import io.teammion.morefood.Registry; -import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class Block extends net.minecraft.block.Block -{ - public Block(String name, Material blockMaterialIn, MapColor blockMapColorIn) - { - super(blockMaterialIn, blockMapColorIn); - - setUnlocalizedName(name); - - Registry.register(this); - } - - public Block(String name, Material materialIn) - { - super(materialIn); - - setUnlocalizedName(name); - - Registry.register(this); - } -} diff --git a/src/main/java/io/teammion/morefood/item/Item.java b/src/main/java/io/teammion/morefood/item/Item.java deleted file mode 100644 index fb62368..0000000 --- a/src/main/java/io/teammion/morefood/item/Item.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.teammion.morefood.item; - -import io.teammion.morefood.CreativeTabs; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class Item extends net.minecraft.item.Item -{ - public Item(String name) - { - setUnlocalizedName(name); - setRegistryName(name); - - setCreativeTab(CreativeTabs.FOOD); - } -} diff --git a/src/main/java/io/teammion/morefood/item/ItemDrink.java b/src/main/java/io/teammion/morefood/item/ItemDrink.java deleted file mode 100644 index 7f7c6bd..0000000 --- a/src/main/java/io/teammion/morefood/item/ItemDrink.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.teammion.morefood.item; - -import io.teammion.morefood.Items; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumAction; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class ItemDrink extends ItemFood -{ - public ItemDrink(String name, int amount, float saturation, boolean isWolfFood) - { - super(name, amount, saturation, isWolfFood); - } - - public ItemDrink(String name, int amount, boolean isWolfFood) - { - super(name, amount, isWolfFood); - } - - public ItemDrink(String name, int amount) - { - super(name, amount); - } - - @Override - public EnumAction getItemUseAction(ItemStack stack) - { - return EnumAction.DRINK; - } - - @Override - protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) - { - stack.stackSize--; - - ItemStack bottle = new ItemStack(Items.GLASS_BOTTLE); - if (! player.inventory.addItemStackToInventory(bottle)) - { - if (! worldIn.isRemote) - { - worldIn.spawnEntityInWorld(new EntityItem( - worldIn, - player.posX, - player.posY, - player.posZ, - bottle - )); - } - } - - super.onFoodEaten(stack, worldIn, player); - } -} diff --git a/src/main/java/io/teammion/morefood/item/ItemFood.java b/src/main/java/io/teammion/morefood/item/ItemFood.java deleted file mode 100644 index a8fa5e4..0000000 --- a/src/main/java/io/teammion/morefood/item/ItemFood.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.teammion.morefood.item; - -import io.teammion.morefood.CreativeTabs; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class ItemFood extends net.minecraft.item.ItemFood -{ - public ItemFood(String name, int amount, float saturation, boolean isWolfFood) - { - super(amount, saturation, isWolfFood); - - setUnlocalizedName(name); - setRegistryName(name); - - setCreativeTab(CreativeTabs.FOOD); - } - - public ItemFood(String name, int amount, boolean isWolfFood) - { - super(amount, isWolfFood); - - setUnlocalizedName(name); - setRegistryName(name); - - setCreativeTab(CreativeTabs.FOOD); - } - - public ItemFood(String name, int amount) - { - super(amount, false); - - setUnlocalizedName(name); - setRegistryName(name); - - setCreativeTab(CreativeTabs.FOOD); - } -} diff --git a/src/main/java/io/teammion/morefood/item/ItemMilkBottle.java b/src/main/java/io/teammion/morefood/item/ItemMilkBottle.java deleted file mode 100644 index 681fa15..0000000 --- a/src/main/java/io/teammion/morefood/item/ItemMilkBottle.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.teammion.morefood.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class ItemMilkBottle extends ItemDrink -{ - public ItemMilkBottle() - { - super("milk_bottle", 2, false); - } - - @Override - protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) - { - player.clearActivePotions(); - - super.onFoodEaten(stack, worldIn, player); - } -} diff --git a/src/main/java/io/teammion/morefood/item/ItemStrawberry.java b/src/main/java/io/teammion/morefood/item/ItemStrawberry.java deleted file mode 100644 index 95aaa42..0000000 --- a/src/main/java/io/teammion/morefood/item/ItemStrawberry.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.teammion.morefood.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Created by Stefan Wimmer on 02.07.16. - */ -public class ItemStrawberry extends ItemFood -{ - public ItemStrawberry() - { - super("strawberry", 2); - - setAlwaysEdible(); - } - - @Override - protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) - { - player.heal(2); - - super.onFoodEaten(stack, worldIn, player); - } -} diff --git a/src/main/java/io/teammion/morefood/recipes/ShapedRecipes.java b/src/main/java/io/teammion/morefood/recipes/ShapedRecipes.java deleted file mode 100644 index d23a15a..0000000 --- a/src/main/java/io/teammion/morefood/recipes/ShapedRecipes.java +++ /dev/null @@ -1,64 +0,0 @@ -package io.teammion.morefood.recipes; - -import io.teammion.morefood.Items; -import io.teammion.morefood.Registry; -import net.minecraft.item.ItemStack; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class ShapedRecipes -{ - public static void register() - { - Registry.addShapedRecipe( - new ItemStack(Items.COCOA_BEAN_GROUND), - "AA", "AA", - 'A', Items.COCOA_BEAN_ROASTED - ); - - Registry.addShapedRecipe( - new ItemStack(Items.CHOCOLATE), - "AAA", "BCB", "AAA", - 'A', Items.COCOA_BEAN_GROUND, - 'B', Items.SUGAR, - 'C', Items.MILK_BUCKET - ); - - Registry.addShapedRecipe( - new ItemStack(Items.CHOCOLATE), - "ABA", "ACA", "ABA", - 'A', Items.COCOA_BEAN_GROUND, - 'B', Items.SUGAR, - 'C', Items.MILK_BUCKET - ); - - Registry.addShapedRecipe( - new ItemStack(Items.SANDWICH_SCHNITZEL), - "A", "B", "A", - 'A', Items.BREAD_SLICE, - 'B', Items.SCHNITZEL - ); - - Registry.addShapedRecipe( - new ItemStack(Items.SANDWICH_PORKCHOP), - "A", "B", "A", - 'A', Items.BREAD_SLICE, - 'B', Items.COOKED_PORKCHOP - ); - - Registry.addShapedRecipe( - new ItemStack(Items.SANDWICH_CHICKEN), - "A", "B", "A", - 'A', Items.BREAD_SLICE, - 'B', Items.COOKED_CHICKEN - ); - - Registry.addShapedRecipe( - new ItemStack(Items.SANDWICH_FISH), - "A", "B", "A", - 'A', Items.BREAD_SLICE, - 'B', Items.COOKED_FISH - ); - } -} diff --git a/src/main/java/io/teammion/morefood/recipes/ShapelessRecipes.java b/src/main/java/io/teammion/morefood/recipes/ShapelessRecipes.java deleted file mode 100644 index b3aeb5f..0000000 --- a/src/main/java/io/teammion/morefood/recipes/ShapelessRecipes.java +++ /dev/null @@ -1,93 +0,0 @@ -package io.teammion.morefood.recipes; - -import io.teammion.morefood.Config; -import io.teammion.morefood.Items; -import io.teammion.morefood.Registry; -import net.minecraft.item.ItemStack; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class ShapelessRecipes -{ - public static void register() - { - Registry.addShapelessRecipe( - new ItemStack(Items.MILK_BOTTLE, 4), - Items.MILK_BUCKET, - Items.GLASS_BOTTLE, - Items.GLASS_BOTTLE, - Items.GLASS_BOTTLE, - Items.GLASS_BOTTLE - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.CHOCOLATE_PIECE, 8), - Items.CHOCOLATE - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.CHOCOLATE_DRINK), - Items.MILK_BOTTLE, - Items.COCOA_BEAN_GROUND, - Items.COCOA_BEAN_GROUND, - Items.SUGAR, - Items.SUGAR - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.FLOUR, 2), - Items.WHEAT - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.SCHNITZEL_RAW), - Items.PORKCHOP, - Items.EGG, - Items.FLOUR, - Items.FLOUR - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.APPLE_CHOCOLATE), - Items.APPLE, - Items.CHOCOLATE_PIECE, - Items.CHOCOLATE_PIECE - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.FISH_STICK_RAW), - Items.FISH, - Items.EGG, - Items.FLOUR, - Items.FLOUR - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.BREAD_SLICE, 2), - Items.BREAD - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.STRAWBERRY_CHOCOLATE), - Items.STRAWBERRY, - Items.CHOCOLATE_PIECE, - Items.CHOCOLATE_PIECE - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.FRENCH_FRIES_RAW, 8), - Items.POTATO, - Items.POTATO - ); - - Registry.addShapelessRecipe( - new ItemStack(Items.BREAD_DOUGH, 2), - Items.FLOUR, - Items.FLOUR, - Items.FLOUR, - Items.FLOUR, - Items.WATER_BUCKET - ); - } -} diff --git a/src/main/java/io/teammion/morefood/recipes/SmeltingRecipes.java b/src/main/java/io/teammion/morefood/recipes/SmeltingRecipes.java deleted file mode 100644 index 3b355d7..0000000 --- a/src/main/java/io/teammion/morefood/recipes/SmeltingRecipes.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.teammion.morefood.recipes; - -import io.teammion.morefood.Items; -import io.teammion.morefood.Registry; -import net.minecraft.item.ItemStack; - -/** - * Created by Stefan Wimmer on 05.06.16. - */ -public class SmeltingRecipes -{ - public static void register() - { - Registry.addSmelting( - new ItemStack(Items.DYE, 1, 3), - new ItemStack(Items.COCOA_BEAN_ROASTED) - ); - - Registry.addSmelting( - Items.SCHNITZEL_RAW, - new ItemStack(Items.SCHNITZEL) - ); - - Registry.addSmelting( - Items.EGG, - new ItemStack(Items.EGG_BOILED) - ); - - Registry.addSmelting( - Items.APPLE_CHOCOLATE, - new ItemStack(Items.APPLE_CHOCOLATE_COATED) - ); - - Registry.addSmelting( - Items.FISH_STICK_RAW, - new ItemStack(Items.FISH_STICK) - ); - - Registry.addSmelting( - Items.STRAWBERRY_CHOCOLATE, - new ItemStack(Items.STRAWBERRY_CHOCOLATE_COATED) - ); - - Registry.addSmelting( - Items.FRENCH_FRIES_RAW, - new ItemStack(Items.FRENCH_FRIES) - ); - - Registry.addSmelting( - Items.BREAD_DOUGH, - new ItemStack(Items.BREAD) - ); - } -} diff --git a/src/main/scala/io/teammion/morefood/Config.scala b/src/main/scala/io/teammion/morefood/Config.scala new file mode 100644 index 0000000..5eaf34a --- /dev/null +++ b/src/main/scala/io/teammion/morefood/Config.scala @@ -0,0 +1,23 @@ +package io.teammion.morefood + +import net.minecraftforge.common.config.Configuration +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +object Config +{ + var OVERRIDE_BREAD_RECIPE : Boolean = true + + def load(e : FMLPreInitializationEvent) + { + val config: Configuration = new Configuration(e.getSuggestedConfigurationFile) + + config.load() + + OVERRIDE_BREAD_RECIPE = config.get("general", "override_bread_recipe", OVERRIDE_BREAD_RECIPE, "If true the bread recipe will be overridden").getBoolean + + config.save() + } +} diff --git a/src/main/scala/io/teammion/morefood/EventHandler.scala b/src/main/scala/io/teammion/morefood/EventHandler.scala new file mode 100644 index 0000000..dc7dec3 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/EventHandler.scala @@ -0,0 +1,27 @@ +package io.teammion.morefood + +import java.util.Random + +import net.minecraft.entity.item.EntityItem +import net.minecraft.item.ItemStack +import net.minecraft.world.World +import net.minecraftforge.event.entity.living.LivingDropsEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +class EventHandler +{ + @SubscribeEvent + def onDrop(e : LivingDropsEvent) + { + val world : World = e.getEntity.worldObj + + if (!world.isRemote) + world.spawnEntityInWorld(new EntityItem( + world, e.getEntity.posX, e.getEntity.posY, e.getEntity.posZ, + new ItemStack(Items.STRAWBERRY, new Random().nextInt(2)) + )) + } +} diff --git a/src/main/scala/io/teammion/morefood/Items.scala b/src/main/scala/io/teammion/morefood/Items.scala new file mode 100644 index 0000000..79950cb --- /dev/null +++ b/src/main/scala/io/teammion/morefood/Items.scala @@ -0,0 +1,111 @@ +package io.teammion.morefood + +import io.teammion.morefood.item._ + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +object Items +{ + import net.minecraft.init + + val APPLE = init.Items.APPLE + val BREAD = init.Items.BREAD + val COOKED_CHICKEN = init.Items.COOKED_CHICKEN + val COOKED_FISH = init.Items.COOKED_FISH + val COOKED_PORKCHOP = init.Items.COOKED_PORKCHOP + val DYE = init.Items.DYE + val EGG = init.Items.EGG + val FISH = init.Items.FISH + val GLASS_BOTTLE = init.Items.GLASS_BOTTLE + val MILK_BUCKET = init.Items.MILK_BUCKET + val PORKCHOP = init.Items.PORKCHOP + val POTATO = init.Items.POTATO + val SUGAR = init.Items.SUGAR + val WATER_BUCKET = init.Items.WATER_BUCKET + val WHEAT = init.Items.WHEAT + + val MILK_BOTTLE = new ItemMilkBottle + val COCOA_BEAN_ROASTED = new Item("cocoa_bean_roasted") + val COCOA_BEAN_GROUND = new Item("cocoa_bean_ground") + val CHOCOLATE = new ItemFood("chocolate", 8) + val CHOCOLATE_PIECE = new ItemFood("chocolate_piece", 1) + val CHOCOLATE_DRINK = new ItemDrink("chocolate_drink", 4) + val FLOUR = new Item("flour") + val SCHNITZEL_RAW = new Item("schnitzel_raw") + val SCHNITZEL = new ItemFood("schnitzel", 4) + val EGG_BOILED = new ItemFood("egg_boiled", 3) + val APPLE_CHOCOLATE = new Item("apple_chocolate") + val APPLE_CHOCOLATE_COATED = new ItemFood("apple_chocolate_coated", 8) + val FISH_STICK_RAW = new Item("fish_stick_raw") + val FISH_STICK = new ItemFood("fish_stick", 6) + val BREAD_SLICE = new Item("bread_slice") + val SANDWICH_SCHNITZEL = new ItemFood("sandwich_schnitzel", 5) + val SANDWICH_PORKCHOP = new ItemFood("sandwich_porkchop", 5) + val SANDWICH_CHICKEN = new ItemFood("sandwich_chicken", 5) + val SANDWICH_FISH = new ItemFood("sandwich_fish", 5) + val STRAWBERRY = new ItemStrawberry + val STRAWBERRY_CHOCOLATE = new Item("strawberry_chocolate") + val STRAWBERRY_CHOCOLATE_COATED = new ItemFood("strawberry_chocolate_coated", 8) + val FRENCH_FRIES_RAW = new Item("french_fries_raw") + val FRENCH_FRIES = new ItemFood("french_fries", 6) + val BREAD_DOUGH = new Item("bread_dough") + + def register() + { + Registry.register(MILK_BOTTLE) + Registry.register(COCOA_BEAN_ROASTED) + Registry.register(COCOA_BEAN_GROUND) + Registry.register(CHOCOLATE) + Registry.register(CHOCOLATE_PIECE) + Registry.register(CHOCOLATE_DRINK) + Registry.register(FLOUR) + Registry.register(SCHNITZEL_RAW) + Registry.register(SCHNITZEL) + Registry.register(EGG_BOILED) + Registry.register(APPLE_CHOCOLATE) + Registry.register(APPLE_CHOCOLATE_COATED) + Registry.register(FISH_STICK_RAW) + Registry.register(FISH_STICK) + Registry.register(BREAD_SLICE) + Registry.register(SANDWICH_SCHNITZEL) + Registry.register(SANDWICH_PORKCHOP) + Registry.register(SANDWICH_CHICKEN) + Registry.register(SANDWICH_FISH) + Registry.register(STRAWBERRY) + Registry.register(STRAWBERRY_CHOCOLATE) + Registry.register(STRAWBERRY_CHOCOLATE_COATED) + Registry.register(FRENCH_FRIES_RAW) + Registry.register(FRENCH_FRIES) + Registry.register(BREAD_DOUGH) + } + + def render() + { + Registry.render(MILK_BOTTLE) + Registry.render(COCOA_BEAN_ROASTED) + Registry.render(COCOA_BEAN_GROUND) + Registry.render(CHOCOLATE) + Registry.render(CHOCOLATE_PIECE) + Registry.render(CHOCOLATE_DRINK) + Registry.render(FLOUR) + Registry.render(SCHNITZEL_RAW) + Registry.render(SCHNITZEL) + Registry.render(EGG_BOILED) + Registry.render(APPLE_CHOCOLATE) + Registry.render(APPLE_CHOCOLATE_COATED) + Registry.render(FISH_STICK_RAW) + Registry.render(FISH_STICK) + Registry.render(BREAD_SLICE) + Registry.render(SANDWICH_SCHNITZEL) + Registry.render(SANDWICH_PORKCHOP) + Registry.render(SANDWICH_CHICKEN) + Registry.render(SANDWICH_FISH) + Registry.render(STRAWBERRY) + Registry.render(STRAWBERRY_CHOCOLATE) + Registry.render(STRAWBERRY_CHOCOLATE_COATED) + Registry.render(FRENCH_FRIES_RAW) + Registry.render(FRENCH_FRIES) + Registry.render(BREAD_DOUGH) + } +} diff --git a/src/main/scala/io/teammion/morefood/MoreFood.scala b/src/main/scala/io/teammion/morefood/MoreFood.scala new file mode 100644 index 0000000..50b4137 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/MoreFood.scala @@ -0,0 +1,64 @@ +package io.teammion.morefood + +import java.util +import java.util.logging.Logger + +import io.teammion.morefood.recipes.{ShapedRecipes, ShapelessRecipes, SmeltingRecipes} +import net.minecraft +import net.minecraft.item.ItemStack +import net.minecraft.item.crafting.{CraftingManager, IRecipe} +import net.minecraftforge.common.MinecraftForge +import net.minecraftforge.fml.common.Mod +import net.minecraftforge.fml.common.event.{FMLInitializationEvent, FMLPostInitializationEvent, FMLPreInitializationEvent} + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +@Mod(modid = "tm-morefood", modLanguage = "scala") +object MoreFood +{ + val logger : Logger = Logger.getLogger(getClass.getName) + + logger.info("MoreFood initialized") + + @Mod.EventHandler + def preInit(e : FMLPreInitializationEvent) + { + logger.info("PreInitialization") + + Config.load(e) + + Items.register() + } + + def init(e : FMLInitializationEvent) + { + logger.info("Initialization") + + Items.render() + + ShapedRecipes.register() + ShapelessRecipes.register() + SmeltingRecipes.register() + + MinecraftForge.EVENT_BUS.register(new EventHandler) + } + + def postInit(e : FMLPostInitializationEvent) + { + logger.info("PostInitialization") + + if (Config.OVERRIDE_BREAD_RECIPE) + { + val itr : util.Iterator[IRecipe] = CraftingManager.getInstance().getRecipeList.iterator() + + while (itr.hasNext) + { + val stack : ItemStack = itr.next().getRecipeOutput + + if (stack != null && stack.getItem == minecraft.init.Items.BREAD) + itr.remove() + } + } + } +} diff --git a/src/main/scala/io/teammion/morefood/Registry.scala b/src/main/scala/io/teammion/morefood/Registry.scala new file mode 100644 index 0000000..91c9985 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/Registry.scala @@ -0,0 +1,34 @@ +package io.teammion.morefood + +import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.block.model.ModelResourceLocation +import net.minecraft.item.{Item, ItemStack} +import net.minecraftforge.fml.common.registry.GameRegistry + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +object Registry +{ + def register(item : Item) : Unit = + GameRegistry.register(item) + + def render(item : Item, meta : Int = 0, name : String = null) : Unit = + Minecraft.getMinecraft.getRenderItem.getItemModelMesher.register( + item, meta, new ModelResourceLocation( + "tm-morefood:" + Option(name).getOrElse(item.getUnlocalizedName.substring(5)), "inventory" + ) + ) + + def addSmelting(in : Item, out : ItemStack) = + GameRegistry.addSmelting(in, out, .2f) + + def addSmelting(in : ItemStack, out : ItemStack) = + GameRegistry.addSmelting(in, out, .2f) + + def addShapelessRecipe(out : ItemStack, params : AnyRef*) : Unit = + GameRegistry.addShapelessRecipe(out, params) + + def addShapedRecipe(out : ItemStack, params : AnyRef*) = + GameRegistry.addShapedRecipe(out, params) +} diff --git a/src/main/scala/io/teammion/morefood/item/Item.scala b/src/main/scala/io/teammion/morefood/item/Item.scala new file mode 100644 index 0000000..bdec799 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/item/Item.scala @@ -0,0 +1,21 @@ +package io.teammion.morefood.item + +import net.minecraft.creativetab.CreativeTabs +import net.minecraft.item.ItemStack + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +class Item(name : String) extends net.minecraft.item.Item +{ + setRegistryName(name) + setUnlocalizedName(name) + + setCreativeTab(CreativeTabs.FOOD) + + def createStack(i : Int) : ItemStack = + new ItemStack(this, i) + + def createStack : ItemStack = + createStack(0) +} diff --git a/src/main/scala/io/teammion/morefood/item/ItemDrink.scala b/src/main/scala/io/teammion/morefood/item/ItemDrink.scala new file mode 100644 index 0000000..e98ce49 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/item/ItemDrink.scala @@ -0,0 +1,29 @@ +package io.teammion.morefood.item + +import net.minecraft.entity.item.EntityItem +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.init.Items +import net.minecraft.item.ItemStack +import net.minecraft.world.World + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +class ItemDrink(name : String, amount : Int, saturation : Float, isWolfFood : Boolean) + extends ItemFood(name, amount, saturation, isWolfFood) +{ + def this(name : String, amount : Int) = + this(name, amount, .6f, false) + + override def onFoodEaten(stack: ItemStack, worldIn: World, player: EntityPlayer) + { + val bottle : ItemStack = new ItemStack(Items.GLASS_BOTTLE) + + if (! player.inventory.addItemStackToInventory(bottle)) + worldIn.spawnEntityInWorld(new EntityItem( + worldIn, player.posX, player.posY, player.posZ, bottle + )) + + super.onFoodEaten(stack, worldIn, player) + } +} diff --git a/src/main/scala/io/teammion/morefood/item/ItemFood.scala b/src/main/scala/io/teammion/morefood/item/ItemFood.scala new file mode 100644 index 0000000..265321a --- /dev/null +++ b/src/main/scala/io/teammion/morefood/item/ItemFood.scala @@ -0,0 +1,23 @@ +package io.teammion.morefood.item + +import net.minecraft.creativetab.CreativeTabs +import net.minecraft.item +import net.minecraft.item.ItemStack + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +class ItemFood(name : String, amount : Int, saturation : Float = .6f, isWolfFood : Boolean = false) + extends item.ItemFood(amount, saturation, isWolfFood) +{ + setRegistryName(name) + setUnlocalizedName(name) + + setCreativeTab(CreativeTabs.FOOD) + + def createStack(i : Int) : ItemStack = + new ItemStack(this, i) + + def createStack : ItemStack = + createStack(0) +} diff --git a/src/main/scala/io/teammion/morefood/item/ItemMilkBottle.scala b/src/main/scala/io/teammion/morefood/item/ItemMilkBottle.scala new file mode 100644 index 0000000..26bfe49 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/item/ItemMilkBottle.scala @@ -0,0 +1,19 @@ +package io.teammion.morefood.item + +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.item.ItemStack +import net.minecraft.world.World + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +class ItemMilkBottle + extends ItemDrink("milk_bottle", 2) +{ + override def onFoodEaten(stack: ItemStack, worldIn: World, player: EntityPlayer) + { + player.clearActivePotions() + + super.onFoodEaten(stack, worldIn, player) + } +} diff --git a/src/main/scala/io/teammion/morefood/item/ItemStrawberry.scala b/src/main/scala/io/teammion/morefood/item/ItemStrawberry.scala new file mode 100644 index 0000000..bf4dc02 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/item/ItemStrawberry.scala @@ -0,0 +1,21 @@ +package io.teammion.morefood.item + +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.item.ItemStack +import net.minecraft.world.World + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +class ItemStrawberry + extends ItemFood("strawberry", 2) +{ + setAlwaysEdible() + + override def onFoodEaten(stack: ItemStack, worldIn: World, player: EntityPlayer) + { + player.heal(2) + + super.onFoodEaten(stack, worldIn, player) + } +} diff --git a/src/main/scala/io/teammion/morefood/recipes/ShapedRecipes.scala b/src/main/scala/io/teammion/morefood/recipes/ShapedRecipes.scala new file mode 100644 index 0000000..2849910 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/recipes/ShapedRecipes.scala @@ -0,0 +1,76 @@ +package io.teammion.morefood.recipes + +import io.teammion.morefood.{Items, Registry} +import net.minecraft.item.ItemStack + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +object ShapedRecipes +{ + def register() + { + Registry.addShapedRecipe( + new ItemStack(Items.COCOA_BEAN_GROUND), + "AA", + "AA", + char2Character('A'), Items.COCOA_BEAN_ROASTED + ) + + Registry.addShapedRecipe( + new ItemStack(Items.CHOCOLATE), + "AAA", + "BCB", + "AAA", + char2Character('A'), Items.COCOA_BEAN_GROUND, + char2Character('B'), Items.SUGAR, + char2Character('C'), Items.MILK_BUCKET + ) + + Registry.addShapedRecipe( + new ItemStack(Items.CHOCOLATE), + "ABA", + "ACA", + "ABA", + char2Character('A'), Items.COCOA_BEAN_GROUND, + char2Character('B'), Items.SUGAR, + char2Character('C'), Items.MILK_BUCKET + ) + + Registry.addShapedRecipe( + new ItemStack(Items.SANDWICH_SCHNITZEL), + "A", + "B", + "A", + char2Character('A'), Items.BREAD_SLICE, + char2Character('B'), Items.SCHNITZEL + ) + + Registry.addShapedRecipe( + new ItemStack(Items.SANDWICH_PORKCHOP), + "A", + "B", + "A", + char2Character('A'), Items.BREAD_SLICE, + char2Character('B'), Items.COOKED_PORKCHOP + ) + + Registry.addShapedRecipe( + new ItemStack(Items.SANDWICH_CHICKEN), + "A", + "B", + "A", + char2Character('A'), Items.BREAD_SLICE, + char2Character('B'), Items.COOKED_CHICKEN + ) + + Registry.addShapedRecipe( + new ItemStack(Items.SANDWICH_FISH), + "A", + "B", + "A", + char2Character('A'), Items.BREAD_SLICE, + char2Character('B'), Items.COOKED_FISH + ) + } +} diff --git a/src/main/scala/io/teammion/morefood/recipes/ShapelessRecipes.scala b/src/main/scala/io/teammion/morefood/recipes/ShapelessRecipes.scala new file mode 100644 index 0000000..9185518 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/recipes/ShapelessRecipes.scala @@ -0,0 +1,91 @@ +package io.teammion.morefood.recipes + +import io.teammion.morefood.{Items, Registry} +import net.minecraft.item.ItemStack + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +object ShapelessRecipes +{ + def register() + { + Registry.addShapelessRecipe( + new ItemStack(Items.MILK_BOTTLE, 4), + Items.MILK_BUCKET, + Items.GLASS_BOTTLE, + Items.GLASS_BOTTLE, + Items.GLASS_BOTTLE, + Items.GLASS_BOTTLE + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.CHOCOLATE_PIECE, 8), + Items.CHOCOLATE + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.CHOCOLATE_DRINK), + Items.MILK_BOTTLE, + Items.COCOA_BEAN_GROUND, + Items.COCOA_BEAN_GROUND, + Items.SUGAR, + Items.SUGAR + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.FLOUR, 2), + Items.WHEAT + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.SCHNITZEL_RAW), + Items.PORKCHOP, + Items.EGG, + Items.FLOUR, + Items.FLOUR + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.APPLE_CHOCOLATE), + Items.APPLE, + Items.CHOCOLATE_PIECE, + Items.CHOCOLATE_PIECE + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.FISH_STICK_RAW), + Items.FISH, + Items.EGG, + Items.FLOUR, + Items.FLOUR + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.BREAD_SLICE, 2), + Items.BREAD + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.STRAWBERRY_CHOCOLATE), + Items.STRAWBERRY, + Items.CHOCOLATE_PIECE, + Items.CHOCOLATE_PIECE + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.FRENCH_FRIES_RAW, 8), + Items.POTATO, + Items.POTATO + ) + + Registry.addShapelessRecipe( + new ItemStack(Items.BREAD_DOUGH, 2), + Items.FLOUR, + Items.FLOUR, + Items.FLOUR, + Items.FLOUR, + Items.WATER_BUCKET + ) + } +} diff --git a/src/main/scala/io/teammion/morefood/recipes/SmeltingRecipes.scala b/src/main/scala/io/teammion/morefood/recipes/SmeltingRecipes.scala new file mode 100644 index 0000000..e84b601 --- /dev/null +++ b/src/main/scala/io/teammion/morefood/recipes/SmeltingRecipes.scala @@ -0,0 +1,53 @@ +package io.teammion.morefood.recipes + +import io.teammion.morefood.{Items, Registry} +import net.minecraft.item.ItemStack + +/** + * Created by Stefan Wimmer on 24.07.16. + */ +object SmeltingRecipes +{ + def register() + { + Registry.addSmelting( + new ItemStack(Items.DYE, 1, 3), + new ItemStack(Items.COCOA_BEAN_ROASTED) + ) + + Registry.addSmelting( + Items.SCHNITZEL_RAW, + new ItemStack(Items.SCHNITZEL) + ) + + Registry.addSmelting( + net.minecraft.init.Items.EGG, + new ItemStack(Items.EGG_BOILED) + ) + + Registry.addSmelting( + Items.APPLE_CHOCOLATE, + new ItemStack(Items.APPLE_CHOCOLATE_COATED) + ) + + Registry.addSmelting( + Items.FISH_STICK_RAW, + new ItemStack(Items.FISH_STICK) + ) + + Registry.addSmelting( + Items.STRAWBERRY_CHOCOLATE, + new ItemStack(Items.STRAWBERRY_CHOCOLATE_COATED) + ) + + Registry.addSmelting( + Items.FRENCH_FRIES_RAW, + new ItemStack(Items.FRENCH_FRIES) + ) + + Registry.addSmelting( + Items.BREAD_DOUGH, + new ItemStack(Items.BREAD) + ) + } +}