Added recipes for glassware

This commit is contained in:
marcin212 committed 2017-06-21 12:01:51 +02:00
1 parent e9d5c638c7
commit 05308e82c8
4 files changed
+103 -74

No files matched your search

+12 -4
View File
@@ -1,15 +1,15 @@
package binnie.core;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class Mods {
public static ModNonnull Forestry = new ModNonnull("forestry");
@@ -41,6 +41,14 @@ public class Mods {
return ForgeRegistries.BLOCKS.getValue(key);
}
public ItemStack stackWildcard(final String name, int amount) {
return stack(name, amount, OreDictionary.WILDCARD_VALUE);
}
public ItemStack stackWildcard(final String name) {
return stack(name, 1, OreDictionary.WILDCARD_VALUE);
}
public ItemStack stack(final String name) {
Item item = this.item(name);
if (item == null) {
@@ -1,44 +1,51 @@
package binnie.extratrees.alcohol;
import javax.annotation.Nullable;
import java.util.Locale;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.ItemStack;
import binnie.Binnie;
import binnie.Constants;
import binnie.extratrees.ExtraTrees;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Locale;
public enum Glassware {
BeerMug(480, 10, 14),
Pint(600, 6, 20),
Snifter(510, 14, 11),
Flute(180, 13, 15),
Cocktail(240, 20, 8),
Cordial(60, 15, 7),
Collins(360, 8, 18),
Highball(240, 10, 14),
Hurricane(450, 10, 18),
Margarita(360, 18, 9),
OldFashioned(240, 13, 8),
Wine(240, 17, 10),
Shot(30, 13, 7),
Sherry(60, 17, 7),
Coupe(180, 19, 8);
BeerMug(480, 10, 14, " # ", " ", " "),
Pint(600, 6, 20, " # ", " # ", "# #"),
Snifter(510, 14, 11, " # ", " ", "# #"),
Flute(180, 13, 15, "# #", "# #", "# #"),
Cocktail(240, 20, 8, " # ", "# #", "# #"),
Cordial(60, 15, 7, "###", " # ", "# #"),
Collins(360, 8, 18, " # ", " # ", " "),
Highball(240, 10, 14, " # ", " # ", "###"),
Hurricane(450, 10, 18, " ", "# #", " # "),
Margarita(360, 18, 9, "###", " ", "# #"),
OldFashioned(240, 13, 8, " # ", " ", "###"),
Wine(240, 17, 10, " # ", "# #", " "),
Shot(30, 13, 7, "###", " # ", " # "),
Sherry(60, 17, 7, " # ", "# #", "###"),
Coupe(180, 19, 8, " # ", "# #", " # ");
float contentBottom;
float contentHeight;
private int capacity;
private ModelResourceLocation location;
private String recipeRow1, recipeRow2, recipeRow3;
private int recipeGlassCost;
Glassware(final int capacity, final int contentBottom, final int contentHeight) {
Glassware(final int capacity, final int contentBottom, final int contentHeight, String recipeRow1, String recipeRow2, String recipeRow3) {
this.capacity = capacity;
this.contentBottom = contentBottom / 32.0f;
this.contentHeight = contentHeight / 32.0f;
location = new ModelResourceLocation(Constants.EXTRA_TREES_MOD_ID + ":glassware/" + getName(),"inventory");
location = new ModelResourceLocation(Constants.EXTRA_TREES_MOD_ID + ":glassware/" + getName(), "inventory");
this.recipeRow1 = recipeRow1;
this.recipeRow2 = recipeRow2;
this.recipeRow3 = recipeRow3;
recipeGlassCost = (recipeRow1 + recipeRow2 + recipeRow3).replaceAll("#", "").length() * 100;
}
public String getName() {
return name().toLowerCase(Locale.ENGLISH);
}
@@ -53,7 +60,7 @@ public enum Glassware {
public int getCapacity() {
return this.capacity;
}
public ModelResourceLocation getLocation() {
return location;
}
@@ -73,4 +80,12 @@ public enum Glassware {
public int getVolume() {
return this.getCapacity();
}
public Object[] getRecipePattern(Item castingItem) {
return new Object[]{recipeRow1, recipeRow2, recipeRow3, '#', castingItem};
}
public int getRecipeGlassCost() {
return recipeGlassCost;
}
}
@@ -1,21 +1,8 @@
package binnie.extratrees.alcohol;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.recipes.ISqueezerRecipe;
import forestry.api.recipes.RecipeManagers;
import binnie.Binnie;
import binnie.core.IInitializable;
import binnie.core.Mods;
import binnie.core.liquid.IFluidType;
import binnie.core.resource.BinnieSprite;
import binnie.extratrees.ExtraTrees;
@@ -29,6 +16,18 @@ import binnie.extratrees.machines.brewery.BreweryRecipes;
import binnie.extratrees.machines.distillery.DistilleryLogic;
import binnie.extratrees.machines.distillery.DistilleryRecipes;
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
import forestry.api.recipes.ISqueezerRecipe;
import forestry.api.recipes.RecipeManagers;
import forestry.core.fluids.Fluids;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ModuleAlcohol implements IInitializable {
public ItemDrink drink;
@@ -68,6 +67,13 @@ public class ModuleAlcohol implements IInitializable {
@Override
public void postInit() {
ItemStack wax = Mods.Forestry.stack("beeswax");
ItemStack waxCast = Mods.Forestry.stackWildcard("wax_cast");
for (Glassware glassware : Glassware.values()) {
ItemStack result = drink.getStack(glassware, null, 8);
Object[] recipe = glassware.getRecipePattern(wax.getItem());
RecipeManagers.fabricatorManager.addRecipe(waxCast, Fluids.GLASS.getFluid(glassware.getRecipeGlassCost()), result, recipe);
}
for (final Juice juice : Juice.values()) {
final String oreDict = juice.squeezing;
final List<ItemStack> ores = new ArrayList<>();
@@ -102,17 +108,17 @@ public class ModuleAlcohol implements IInitializable {
}
BreweryRecipes.addRecipes(
new BrewedGrainRecipe(Alcohol.Ale, BreweryRecipes.GRAIN_BARLEY, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.Lager, BreweryRecipes.GRAIN_BARLEY, BreweryRecipes.HOPS, ExtraTreeItems.LagerYeast.get(1)),
new BrewedGrainRecipe(Alcohol.Stout, BreweryRecipes.GRAIN_ROASTED, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.CornBeer, BreweryRecipes.GRAIN_CORN, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.RyeBeer, BreweryRecipes.GRAIN_RYE, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.WheatBeer, BreweryRecipes.GRAIN_WHEAT, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.Ale, BreweryRecipes.GRAIN_BARLEY, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.Lager, BreweryRecipes.GRAIN_BARLEY, BreweryRecipes.HOPS, ExtraTreeItems.LagerYeast.get(1)),
new BrewedGrainRecipe(Alcohol.Stout, BreweryRecipes.GRAIN_ROASTED, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.CornBeer, BreweryRecipes.GRAIN_CORN, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.RyeBeer, BreweryRecipes.GRAIN_RYE, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.WheatBeer, BreweryRecipes.GRAIN_WHEAT, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.Barley, BreweryRecipes.GRAIN_BARLEY),
new BrewedGrainRecipe(Alcohol.Corn, BreweryRecipes.GRAIN_CORN),
new BrewedGrainRecipe(Alcohol.Rye, BreweryRecipes.GRAIN_RYE),
new BrewedGrainRecipe(Alcohol.Wheat, BreweryRecipes.GRAIN_WHEAT)
new BrewedGrainRecipe(Alcohol.Barley, BreweryRecipes.GRAIN_BARLEY),
new BrewedGrainRecipe(Alcohol.Corn, BreweryRecipes.GRAIN_CORN),
new BrewedGrainRecipe(Alcohol.Rye, BreweryRecipes.GRAIN_RYE),
new BrewedGrainRecipe(Alcohol.Wheat, BreweryRecipes.GRAIN_WHEAT)
);
this.addDistillery(Alcohol.Apple, Spirit.AppleBrandy, Spirit.AppleLiquor, Spirit.NeutralSpirit);
@@ -1,7 +1,11 @@
package binnie.extratrees.alcohol.drink;
import javax.annotation.Nullable;
import binnie.extratrees.alcohol.Alcohol;
import binnie.extratrees.alcohol.AlcoholEffect;
import binnie.extratrees.alcohol.Glassware;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -14,22 +18,14 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import binnie.extratrees.alcohol.Alcohol;
import binnie.extratrees.alcohol.AlcoholEffect;
import binnie.extratrees.alcohol.Glassware;
import javax.annotation.Nullable;
public class ItemDrink extends ItemFood implements IItemModelRegister {
public ItemDrink() {
@@ -50,13 +46,17 @@ public class ItemDrink extends ItemFood implements IItemModelRegister {
return Glassware.values()[nbt.getShort("glassware")];
}
public ItemStack getStack(final Glassware glass, @Nullable final FluidStack fluid) {
final ItemStack stack = new ItemStack(this);
public ItemStack getStack(final Glassware glass, @Nullable final FluidStack fluid, int amount) {
final ItemStack stack = new ItemStack(this, amount);
this.saveGlassware(glass, stack);
this.saveFluid(fluid, stack);
return stack;
}
public ItemStack getStack(final Glassware glass, @Nullable final FluidStack fluid) {
return getStack(glass, fluid, 1);
}
public void saveGlassware(final Glassware container, final ItemStack stack) {
NBTTagCompound nbt = stack.getTagCompound();
if (nbt == null) {
@@ -81,19 +81,19 @@ public class ItemDrink extends ItemFood implements IItemModelRegister {
nbt.setTag("fluid", liq);
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
for(Glassware glassware : Glassware.values()){
for (Glassware glassware : Glassware.values()) {
ModelLoader.registerItemVariants(item, glassware.getLocation());
}
manager.registerItemModel(item, (ItemStack stack)->{
manager.registerItemModel(item, (ItemStack stack) -> {
Glassware glassware = getGlassware(stack);
return glassware.getLocation();
});
}
@Nullable
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
@@ -127,18 +127,18 @@ public class ItemDrink extends ItemFood implements IItemModelRegister {
}
return this.getGlassware(stack).getName(liquidName);
}
@Override
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
super.onFoodEaten(stack, world, player);
AlcoholEffect.makeDrunk(player, 2.1f);
}
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
return super.onItemUseFinish(stack, worldIn, entityLiving);
}
@Override
public EnumAction getItemUseAction(final ItemStack itemStack) {
if (FluidUtil.getFluidContained(itemStack) != null) {
@@ -152,7 +152,7 @@ public class ItemDrink extends ItemFood implements IItemModelRegister {
public int getMaxItemUseDuration(final ItemStack p_77626_1_) {
return 16;
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
player.setActiveHand(hand);