mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-22 04:52:26 +00:00
Remove the infuser and associated gui. Port recipes to potions.
This commit is contained in:
1 parent
e075fe8fbf
commit
d97f6f69b0
18 files changed
+19
-593
No files matched your search
@@ -1,13 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.food;
|
||||
|
||||
public class BeverageManager {
|
||||
public static final IBeverageEffect[] effectList = new IBeverageEffect[128];
|
||||
|
||||
public static IInfuserManager infuserManager;
|
||||
public static IIngredientManager ingredientManager;
|
||||
}
|
||||
@@ -101,7 +101,10 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.PotionTypes;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionType;
|
||||
import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -112,6 +115,7 @@ import net.minecraft.world.storage.loot.LootTableList;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -503,6 +507,7 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
'#', items.honeydew,
|
||||
'X', items.royalJelly,
|
||||
'Y', fluidItems.waxCapsuleEmpty);
|
||||
|
||||
}
|
||||
|
||||
// / CAPSULES
|
||||
@@ -761,6 +766,17 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
'X', OreDictUtil.SLAB_WOOD,
|
||||
'#', OreDictUtil.PLANK_WOOD,
|
||||
'C', OreDictUtil.BEE_COMB);
|
||||
|
||||
// BREWING RECIPES
|
||||
BrewingRecipeRegistry.addRecipe(
|
||||
PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD),
|
||||
items.pollenCluster.get(EnumPollenCluster.NORMAL, 1),
|
||||
PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.HEALING));
|
||||
BrewingRecipeRegistry.addRecipe(
|
||||
PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD),
|
||||
items.pollenCluster.get(EnumPollenCluster.CRYSTALLINE, 1),
|
||||
PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.REGENERATION));
|
||||
|
||||
}
|
||||
|
||||
private static void registerBeehiveDrops() {
|
||||
|
||||
@@ -44,7 +44,6 @@ import forestry.factory.tiles.TileSqueezer;
|
||||
import forestry.factory.tiles.TileStill;
|
||||
import forestry.factory.tiles.TileWorktable;
|
||||
import forestry.farming.tiles.TileFarm;
|
||||
import forestry.food.items.ItemInfuser;
|
||||
import forestry.greenhouse.tiles.TileGreenhouse;
|
||||
import forestry.mail.items.ItemCatalogue;
|
||||
import forestry.mail.items.ItemLetter;
|
||||
@@ -103,7 +102,6 @@ public class GuiIdRegistry {
|
||||
ItemCatalogue.class,
|
||||
ItemHabitatLocator.class,
|
||||
ItemImprinter.class,
|
||||
ItemInfuser.class,
|
||||
ItemLetter.class,
|
||||
ItemSolderingIron.class,
|
||||
ItemCamouflageSprayCan.class
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.food.BeverageManager;
|
||||
import forestry.api.food.IBeverageEffect;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -30,11 +29,13 @@ public abstract class BeverageEffect implements IBeverageEffect {
|
||||
this.id = id;
|
||||
this.unlocalizedDescription = unlocalizedDescription;
|
||||
|
||||
/*
|
||||
if (BeverageManager.effectList[id] != null) {
|
||||
throw new RuntimeException("Beverage effect slot " + id + " was already occupied by " + BeverageManager.effectList[id] + " when trying to add " + this);
|
||||
} else {
|
||||
BeverageManager.effectList[id] = this;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,7 +73,7 @@ public abstract class BeverageEffect implements IBeverageEffect {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
byte byte0 = nbttagcompound1.getByte("S");
|
||||
if (byte0 >= 0 && byte0 < effects.length) {
|
||||
effects[byte0] = BeverageManager.effectList[nbttagcompound1.getInteger("ID")];
|
||||
//effects[byte0] = BeverageManager.effectList[nbttagcompound1.getInteger("ID")];
|
||||
}
|
||||
}
|
||||
effectsList = Arrays.asList(effects);
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InfuserIngredient {
|
||||
private final ItemStack ingredient;
|
||||
private final String description;
|
||||
|
||||
public InfuserIngredient(ItemStack ingredient, String description) {
|
||||
this.ingredient = ingredient;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ItemStack getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.food.IIngredientManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InfuserIngredientManager implements IIngredientManager {
|
||||
private final List<InfuserIngredient> ingredients = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void addIngredient(ItemStack ingredient, String description) {
|
||||
this.ingredients.add(new InfuserIngredient(ingredient, description));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getDescription(ItemStack itemstack) {
|
||||
if (itemstack.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (InfuserIngredient ingredient : ingredients) {
|
||||
if (ingredient.getIngredient().getItemDamage() < 0 && ingredient.getIngredient().getItem() == itemstack.getItem()) {
|
||||
return ingredient.getDescription();
|
||||
} else if (ingredient.getIngredient().getItemDamage() >= 0 && ingredient.getIngredient().isItemEqual(itemstack)) {
|
||||
return ingredient.getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food;
|
||||
|
||||
import forestry.api.food.IBeverageEffect;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
/**
|
||||
* describes the itemstacks required to achieve a certain effect.
|
||||
*/
|
||||
public class InfuserMixture {
|
||||
private final int meta;
|
||||
private final NonNullList<ItemStack> ingredients;
|
||||
private final IBeverageEffect effect;
|
||||
|
||||
public InfuserMixture(int meta, NonNullList<ItemStack> ingredients, IBeverageEffect effect) {
|
||||
this.meta = meta;
|
||||
this.ingredients = ingredients;
|
||||
this.effect = effect;
|
||||
}
|
||||
|
||||
public NonNullList<ItemStack> getIngredients() {
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
public boolean isIngredient(ItemStack itemstack) {
|
||||
for (ItemStack ingredient : ingredients) {
|
||||
if (ingredient.getItemDamage() < 0 && ingredient.getItem() == itemstack.getItem()) {
|
||||
return true;
|
||||
} else if (ingredient.getItemDamage() >= 0 && ingredient.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean matches(NonNullList<ItemStack> res) {
|
||||
|
||||
// No recipe without resource!
|
||||
if (res.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean matchedAll = true;
|
||||
|
||||
for (ItemStack stack : ingredients) {
|
||||
boolean matched = false;
|
||||
for (ItemStack matchStack : res) {
|
||||
if (matchStack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check item matching
|
||||
if (stack.getItemDamage() < 0 && stack.getItem() == matchStack.getItem()) {
|
||||
if (stack.getCount() <= matchStack.getCount()) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
} else if (stack.getItemDamage() >= 0 && stack.isItemEqual(matchStack)) {
|
||||
if (stack.getCount() <= matchStack.getCount()) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
matchedAll = false;
|
||||
}
|
||||
}
|
||||
return matchedAll;
|
||||
|
||||
}
|
||||
|
||||
public IBeverageEffect getEffect() {
|
||||
return this.effect;
|
||||
}
|
||||
|
||||
public int getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
return ingredients.size();
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.food.IBeverageEffect;
|
||||
import forestry.api.food.IInfuserManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
/**
|
||||
* contains the available mixtures.
|
||||
*/
|
||||
public class InfuserMixtureManager implements IInfuserManager {
|
||||
|
||||
private final List<InfuserMixture> mixtures = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void addMixture(int meta, ItemStack ingredient, IBeverageEffect effect) {
|
||||
NonNullList<ItemStack> ingredients = NonNullList.create();
|
||||
ingredients.add(ingredient);
|
||||
this.mixtures.add(new InfuserMixture(meta, ingredients, effect));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMixture(int meta, NonNullList<ItemStack> ingredients, IBeverageEffect effect) {
|
||||
this.mixtures.add(new InfuserMixture(meta, ingredients, effect));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIngredient(ItemStack itemstack) {
|
||||
for (InfuserMixture ingredient : mixtures) {
|
||||
if (ingredient.isIngredient(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<InfuserMixture> getMatchingMixtures(NonNullList<ItemStack> ingredients) {
|
||||
|
||||
List<InfuserMixture> matches = new ArrayList<>();
|
||||
|
||||
for (InfuserMixture mixture : mixtures) {
|
||||
if (mixture.matches(ingredients)) {
|
||||
matches.add(mixture);
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMixtures(NonNullList<ItemStack> ingredients) {
|
||||
return !getMatchingMixtures(ingredients).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRequired(NonNullList<ItemStack> ingredients) {
|
||||
List<InfuserMixture> mixtures = getMatchingMixtures(ingredients);
|
||||
NonNullList<ItemStack> required = NonNullList.create();
|
||||
|
||||
for (InfuserMixture mixture : mixtures) {
|
||||
required.addAll(mixture.getIngredients());
|
||||
}
|
||||
|
||||
return required;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSeasoned(ItemStack base, NonNullList<ItemStack> ingredients) {
|
||||
List<InfuserMixture> mixtures = getMatchingMixtures(ingredients);
|
||||
List<IBeverageEffect> effects = BeverageEffect.loadEffects(base);
|
||||
|
||||
int weight = 0;
|
||||
int meta = 0;
|
||||
for (InfuserMixture mixture : mixtures) {
|
||||
effects.add(mixture.getEffect());
|
||||
if (mixture.getWeight() > weight) {
|
||||
weight = mixture.getWeight();
|
||||
meta = mixture.getMeta();
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack seasoned = base.copy();
|
||||
seasoned.setItemDamage(meta);
|
||||
BeverageEffect.saveEffects(seasoned, effects);
|
||||
return seasoned;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.food.BeverageManager;
|
||||
import forestry.apiculture.PluginApiculture;
|
||||
import forestry.apiculture.items.EnumPollenCluster;
|
||||
import forestry.apiculture.items.ItemRegistryApiculture;
|
||||
@@ -36,42 +35,9 @@ public class PluginFood extends BlankForestryPlugin {
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupAPI() {
|
||||
super.setupAPI();
|
||||
|
||||
// Init seasoner
|
||||
BeverageManager.infuserManager = new InfuserMixtureManager();
|
||||
BeverageManager.ingredientManager = new InfuserIngredientManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemsAndBlocks() {
|
||||
items = new ItemRegistryFood();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
// LiquidRegistryHelper.registerLiquidContainer(Fluids.SHORT_MEAD, Constants.BUCKET_VOLUME, items.beverage.get(EnumBeverage.MEAD_SHORT, 1), new ItemStack(Items.GLASS_BOTTLE));
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.APICULTURE)) {
|
||||
ItemRegistryApiculture beeItems = PluginApiculture.getItems();
|
||||
ItemStack normalPollenCluster = beeItems.pollenCluster.get(EnumPollenCluster.NORMAL, 1);
|
||||
ItemStack crystallinePollenCluster = beeItems.pollenCluster.get(EnumPollenCluster.CRYSTALLINE, 1);
|
||||
|
||||
BeverageManager.ingredientManager.addIngredient(normalPollenCluster, "Strong Curative");
|
||||
BeverageManager.ingredientManager.addIngredient(crystallinePollenCluster, "Weak Curative");
|
||||
BeverageManager.infuserManager.addMixture(1, normalPollenCluster, BeverageEffects.strongAntidote);
|
||||
BeverageManager.infuserManager.addMixture(1, crystallinePollenCluster, BeverageEffects.weakAntidote);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
// INFUSER
|
||||
RecipeUtil.addRecipe(getItems().infuser.getItemStack(),
|
||||
"X", "#", "X",
|
||||
'#', "ingotIron",
|
||||
'X', "ingotBronze");
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package forestry.food.compat;
|
||||
|
||||
import forestry.core.utils.JeiUtil;
|
||||
import forestry.food.PluginFood;
|
||||
import forestry.food.items.ItemRegistryFood;
|
||||
import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
|
||||
@JEIPlugin
|
||||
public class FoodJeiPlugin extends BlankModPlugin {
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
ItemRegistryFood items = PluginFood.getItems();
|
||||
JeiUtil.addDescription(registry,
|
||||
items.infuser
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package forestry.food.compat;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import forestry.core.utils.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,36 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food.gui;
|
||||
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.food.inventory.ItemInventoryInfuser;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class ContainerInfuser extends ContainerItemInventory<ItemInventoryInfuser> {
|
||||
|
||||
public ContainerInfuser(InventoryPlayer inventoryplayer, ItemInventoryInfuser inventory) {
|
||||
super(inventory, inventoryplayer, 8, 103);
|
||||
|
||||
// Input
|
||||
this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 12));
|
||||
|
||||
// Output
|
||||
this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 72));
|
||||
|
||||
// Ingredients
|
||||
this.addSlotToContainer(new SlotFiltered(inventory, 2, 12, 12));
|
||||
this.addSlotToContainer(new SlotFiltered(inventory, 3, 12, 32));
|
||||
this.addSlotToContainer(new SlotFiltered(inventory, 4, 12, 52));
|
||||
this.addSlotToContainer(new SlotFiltered(inventory, 5, 12, 72));
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food.gui;
|
||||
|
||||
import forestry.api.food.BeverageManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.food.inventory.ItemInventoryInfuser;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class GuiInfuser extends GuiForestry<ContainerInfuser> {
|
||||
private final ItemInventoryInfuser itemInventory;
|
||||
private int startX;
|
||||
private int startY;
|
||||
|
||||
public GuiInfuser(InventoryPlayer inventoryplayer, ItemInventoryInfuser itemInventory) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/infuser.png", new ContainerInfuser(inventoryplayer, itemInventory));
|
||||
|
||||
this.itemInventory = itemInventory;
|
||||
this.xSize = 176;
|
||||
this.ySize = 185;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
for (int l = 2; l < itemInventory.getSizeInventory(); l++) {
|
||||
String description = BeverageManager.ingredientManager.getDescription(itemInventory.getStackInSlot(l));
|
||||
if (description == null) {
|
||||
description = "(No effect)";
|
||||
}
|
||||
|
||||
int row = (l - 2) * 20;
|
||||
fontRendererObj.drawString(description, startX + 32, startY + 16 + row, ColourProperties.INSTANCE.get("gui.screen"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
startX = (this.width - this.xSize) / 2;
|
||||
startY = (this.height - this.ySize) / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addLedgers() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package forestry.food.gui;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import forestry.core.utils.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,87 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food.inventory;
|
||||
|
||||
import forestry.api.food.BeverageManager;
|
||||
import forestry.core.inventory.ItemInventory;
|
||||
import forestry.food.PluginFood;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class ItemInventoryInfuser extends ItemInventory {
|
||||
private static final short inputSlot = 0;
|
||||
private static final short outputSlot = 1;
|
||||
private static final short ingredientSlot1 = 2;
|
||||
private static final short ingredientSlotCount = 4;
|
||||
|
||||
public ItemInventoryInfuser(EntityPlayer player, ItemStack itemStack) {
|
||||
super(player, 6, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotClick(int slotIndex, EntityPlayer player) {
|
||||
|
||||
// Need input
|
||||
ItemStack input = getStackInSlot(inputSlot);
|
||||
if (!input.isEmpty() &&
|
||||
getStackInSlot(outputSlot).isEmpty() &&
|
||||
PluginFood.getItems().beverage == input.getItem()) {
|
||||
|
||||
// Create the seasoned item
|
||||
NonNullList<ItemStack> ingredients = NonNullList.create();
|
||||
for (int i = 0; i < ingredientSlotCount; i++) {
|
||||
ingredients.add(getStackInSlot(i + ingredientSlot1));
|
||||
}
|
||||
|
||||
// Only continue if there is anything to season
|
||||
if (BeverageManager.infuserManager.hasMixtures(ingredients)) {
|
||||
|
||||
ItemStack seasoned = BeverageManager.infuserManager.getSeasoned(input, ingredients);
|
||||
if (!seasoned.isEmpty()) {
|
||||
|
||||
// Remove required ingredients.
|
||||
NonNullList<ItemStack> toRemove = BeverageManager.infuserManager.getRequired(ingredients);
|
||||
for (ItemStack templ : toRemove) {
|
||||
ItemStack ghost = templ.copy();
|
||||
|
||||
for (int i = ingredientSlot1; i < this.getSizeInventory() && !ghost.isEmpty(); i++) {
|
||||
ItemStack ingredient = getStackInSlot(i);
|
||||
if (!ingredient.isEmpty() && OreDictionary.itemMatches(ghost, ingredient, false)) {
|
||||
ItemStack removed = decrStackSize(i, 1);
|
||||
ghost.shrink(removed.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
decrStackSize(inputSlot, 1);
|
||||
setInventorySlotContents(outputSlot, seasoned);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Infuser";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == inputSlot) {
|
||||
return PluginFood.getItems().beverage == itemStack.getItem();
|
||||
} else if (slotIndex >= ingredientSlot1 && slotIndex < ingredientSlot1 + ingredientSlotCount) {
|
||||
return BeverageManager.infuserManager.isIngredient(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package forestry.food.inventory;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import forestry.core.utils.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,36 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food.items;
|
||||
|
||||
import forestry.core.items.ItemWithGui;
|
||||
import forestry.food.gui.ContainerInfuser;
|
||||
import forestry.food.gui.GuiInfuser;
|
||||
import forestry.food.inventory.ItemInventoryInfuser;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemInfuser extends ItemWithGui {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiContainer getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
return new GuiInfuser(player.inventory, new ItemInventoryInfuser(player, heldItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
return new ContainerInfuser(player.inventory, new ItemInventoryInfuser(player, heldItem));
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ public class ItemRegistryFood extends ItemRegistry {
|
||||
public final ItemBeverage beverage;
|
||||
public final ItemForestryFood ambrosia;
|
||||
public final ItemForestryFood honeyPot;
|
||||
public final ItemInfuser infuser;
|
||||
|
||||
public ItemRegistryFood() {
|
||||
// / FOOD ITEMS
|
||||
@@ -32,10 +31,6 @@ public class ItemRegistryFood extends ItemRegistry {
|
||||
ambrosia = registerItem(new ItemAmbrosia().setIsDrink(), "ambrosia");
|
||||
honeyPot = registerItem(new ItemForestryFood(2, 0.2f).setIsDrink(), "honey_pot");
|
||||
|
||||
// / SEASONER
|
||||
infuser = new ItemInfuser();
|
||||
registerItem(infuser, "infuser");
|
||||
|
||||
// Mead
|
||||
BeverageEffect.saveEffects(new ItemStack(beverage), Collections.singletonList(BeverageEffects.weakAlcoholic));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user