Update for 1.11. Missing assets, unstable.

This commit is contained in:
mezz committed 2016-12-22 16:47:56 -08:00
1 parent 30d7365518
commit 9611ae08ae
1145 files changed
+15561 -18107

No files matched your search

@@ -18,6 +18,7 @@ import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.recipes.ICarpenterManager;
@@ -71,7 +72,7 @@ public class DummyManagers {
}
@Override
public void addRecipe(int packagingTime, FluidStack liquid, ItemStack box, ItemStack product, Object... materials) {
public void addRecipe(int packagingTime, @Nullable FluidStack liquid, ItemStack box, ItemStack product, Object... materials) {
}
}
@@ -125,12 +126,22 @@ public class DummyManagers {
public static class DummySqueezerManager extends DummyCraftingProvider<ISqueezerRecipe> implements ISqueezerManager {
@Override
public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid, ItemStack remnants, int chance) {
public void addRecipe(int timePerItem, NonNullList<ItemStack> resources, FluidStack liquid, ItemStack remnants, int chance) {
}
@Override
public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid) {
public void addRecipe(int timePerItem, ItemStack resources, FluidStack liquid, ItemStack remnants, int chance) {
}
@Override
public void addRecipe(int timePerItem, NonNullList<ItemStack> resources, FluidStack liquid) {
}
@Override
public void addRecipe(int timePerItem, ItemStack resources, FluidStack liquid) {
}
+206 -111
View File
@@ -10,16 +10,10 @@
******************************************************************************/
package forestry.factory;
import javax.annotation.Nullable;
import java.util.Set;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import com.google.common.base.Preconditions;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuit;
@@ -37,8 +31,9 @@ import forestry.apiculture.items.ItemRegistryApiculture;
import forestry.core.PluginCore;
import forestry.core.PluginFluids;
import forestry.core.blocks.BlockBogEarth;
import forestry.core.circuits.Circuit;
import forestry.core.blocks.BlockRegistryCore;
import forestry.core.circuits.CircuitLayout;
import forestry.core.circuits.Circuits;
import forestry.core.circuits.EnumCircuitBoardType;
import forestry.core.circuits.ItemCircuitBoard;
import forestry.core.config.Constants;
@@ -46,6 +41,7 @@ import forestry.core.fluids.Fluids;
import forestry.core.items.EnumElectronTube;
import forestry.core.items.ItemElectronTube;
import forestry.core.items.ItemRegistryCore;
import forestry.core.items.ItemRegistryFluids;
import forestry.core.network.IPacketRegistry;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.datastructures.FluidMap;
@@ -66,9 +62,17 @@ import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import forestry.storage.PluginStorage;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
@ForestryPlugin(pluginID = ForestryPluginUids.FACTORY, name = "Factory", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.factory.description")
public class PluginFactory extends BlankForestryPlugin {
@Nullable
public static BlockRegistryFactory blocks;
@Override
@@ -123,6 +127,7 @@ public class PluginFactory extends BlankForestryPlugin {
super.preInit();
ItemRegistryCore coreItems = PluginCore.items;
Preconditions.checkState(coreItems != null);
// Set fuels and resources for the fermenter
ItemStack fertilizerCompound = coreItems.fertilizerCompound.getItemStack();
@@ -151,18 +156,38 @@ public class PluginFactory extends BlankForestryPlugin {
ItemStack bituminousPeat = coreItems.bituminousPeat.getItemStack();
FuelManager.copperEngineFuel.put(bituminousPeat, new EngineCopperFuel(bituminousPeat, Constants.ENGINE_COPPER_FUEL_VALUE_BITUMINOUS_PEAT, Constants.ENGINE_COPPER_CYCLE_DURATION_BITUMINOUS_PEAT));
FuelManager.bronzeEngineFuel.put(Fluids.BIOMASS.getFluid(), new EngineBronzeFuel(Fluids.BIOMASS.getFluid(),
Constants.ENGINE_FUEL_VALUE_BIOMASS, (int) (Constants.ENGINE_CYCLE_DURATION_BIOMASS * ForestryAPI.activeMode.getFloatSetting("fuel.biomass.biogas")), 1));
Fluid biomass = Fluids.BIOMASS.getFluid();
if (biomass != null) {
FuelManager.bronzeEngineFuel.put(biomass, new EngineBronzeFuel(biomass,
Constants.ENGINE_FUEL_VALUE_BIOMASS, (int) (Constants.ENGINE_CYCLE_DURATION_BIOMASS * ForestryAPI.activeMode.getFloatSetting("fuel.biomass.biogas")), 1));
}
FuelManager.bronzeEngineFuel.put(FluidRegistry.WATER, new EngineBronzeFuel(FluidRegistry.WATER,
Constants.ENGINE_FUEL_VALUE_WATER, Constants.ENGINE_CYCLE_DURATION_WATER, 3));
FuelManager.bronzeEngineFuel.put(Fluids.MILK.getFluid(), new EngineBronzeFuel(Fluids.MILK.getFluid(),
Constants.ENGINE_FUEL_VALUE_MILK, Constants.ENGINE_CYCLE_DURATION_MILK, 3));
FuelManager.bronzeEngineFuel.put(Fluids.SEED_OIL.getFluid(), new EngineBronzeFuel(Fluids.SEED_OIL.getFluid(),
Constants.ENGINE_FUEL_VALUE_SEED_OIL, Constants.ENGINE_CYCLE_DURATION_SEED_OIL, 1));
FuelManager.bronzeEngineFuel.put(Fluids.FOR_HONEY.getFluid(), new EngineBronzeFuel(Fluids.FOR_HONEY.getFluid(),
Constants.ENGINE_FUEL_VALUE_HONEY, Constants.ENGINE_CYCLE_DURATION_HONEY, 1));
FuelManager.bronzeEngineFuel.put(Fluids.JUICE.getFluid(), new EngineBronzeFuel(Fluids.JUICE.getFluid(),
Constants.ENGINE_FUEL_VALUE_JUICE, Constants.ENGINE_CYCLE_DURATION_JUICE, 1));
Fluid milk = Fluids.MILK.getFluid();
if (milk != null) {
FuelManager.bronzeEngineFuel.put(milk, new EngineBronzeFuel(milk,
Constants.ENGINE_FUEL_VALUE_MILK, Constants.ENGINE_CYCLE_DURATION_MILK, 3));
}
Fluid seedOil = Fluids.SEED_OIL.getFluid();
if (seedOil != null) {
FuelManager.bronzeEngineFuel.put(seedOil, new EngineBronzeFuel(seedOil,
Constants.ENGINE_FUEL_VALUE_SEED_OIL, Constants.ENGINE_CYCLE_DURATION_SEED_OIL, 1));
}
Fluid honey = Fluids.FOR_HONEY.getFluid();
if (honey != null) {
FuelManager.bronzeEngineFuel.put(honey, new EngineBronzeFuel(honey,
Constants.ENGINE_FUEL_VALUE_HONEY, Constants.ENGINE_CYCLE_DURATION_HONEY, 1));
}
Fluid juice = Fluids.JUICE.getFluid();
if (juice != null) {
FuelManager.bronzeEngineFuel.put(juice, new EngineBronzeFuel(juice,
Constants.ENGINE_FUEL_VALUE_JUICE, Constants.ENGINE_CYCLE_DURATION_JUICE, 1));
}
// Set rain substrates
ItemStack iodineCharge = coreItems.iodineCharge.getItemStack();
@@ -183,12 +208,13 @@ public class PluginFactory extends BlankForestryPlugin {
@Override
public void registerTriggers() {
FactoryTriggers.initialize();
// FactoryTriggers.initialize();
}
@Override
public void doInit() {
super.doInit();
Preconditions.checkState(blocks != null);
blocks.bottler.init();
blocks.carpenter.init();
@@ -203,47 +229,106 @@ public class PluginFactory extends BlankForestryPlugin {
blocks.raintank.init();
blocks.worktable.init();
Circuit.machineSpeedUpgrade1 = new CircuitSpeedUpgrade("machine.speed.boost.1", 0.125f, 0.05f);
Circuit.machineSpeedUpgrade2 = new CircuitSpeedUpgrade("machine.speed.boost.2", 0.250f, 0.10f);
Circuit.machineEfficiencyUpgrade1 = new CircuitSpeedUpgrade("machine.efficiency.1", 0, -0.10f);
Circuits.machineSpeedUpgrade1 = new CircuitSpeedUpgrade("machine.speed.boost.1", 0.125f, 0.05f);
Circuits.machineSpeedUpgrade2 = new CircuitSpeedUpgrade("machine.speed.boost.2", 0.250f, 0.10f);
Circuits.machineEfficiencyUpgrade1 = new CircuitSpeedUpgrade("machine.efficiency.1", 0, -0.10f);
}
@Override
public void registerRecipes() {
// / FABRICATOR
ItemElectronTube electronTube = PluginCore.items.tubes;
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.COPPER, 4), new Object[]{
" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "ingotCopper"});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.TIN, 4), new Object[]{
" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "ingotTin"});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.BRONZE, 4), new Object[]{
" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "ingotBronze"});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.IRON, 4), new Object[]{
" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "ingotIron"});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.GOLD, 4), new Object[]{
" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "ingotGold"});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.DIAMOND, 4), new Object[]{
" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "gemDiamond"});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.OBSIDIAN, 4), new Object[]{
" X ", "#X#", "XXX", '#', "dustRedstone", 'X', Blocks.OBSIDIAN});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.BLAZE, 4), new Object[]{
" X ", "#X#", "XXX", '#', "dustRedstone", 'X', Items.BLAZE_POWDER});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.EMERALD, 4), new Object[]{
" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "gemEmerald"});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.APATITE, 4),
new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "gemApatite"});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.LAPIS, 4),
new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', new ItemStack(Items.DYE, 1, 4)});
RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.ENDER, 4),
new Object[]{" X ", "#X#", "XXX", '#', new ItemStack(Items.ENDER_EYE, 1, 0), 'X', new ItemStack(Blocks.END_STONE, 1, 0)});
ItemRegistryCore coreItems = PluginCore.items;
BlockRegistryCore coreBlocks = PluginCore.blocks;
ItemRegistryFluids fluidItems = PluginFluids.items;
Preconditions.checkState(coreItems != null);
Preconditions.checkState(coreBlocks != null);
Preconditions.checkState(fluidItems != null);
Preconditions.checkState(blocks != null);
ItemElectronTube electronTube = coreItems.tubes;
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.COPPER, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', "ingotCopper"});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.TIN, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', "ingotTin"});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.BRONZE, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', "ingotBronze"});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.IRON, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', "ingotIron"});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.GOLD, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', "ingotGold"});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.DIAMOND, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', "gemDiamond"});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.OBSIDIAN, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', Blocks.OBSIDIAN});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.BLAZE, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', Items.BLAZE_POWDER});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.EMERALD, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', "gemEmerald"});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.APATITE, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', "gemApatite"});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.LAPIS, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', "dustRedstone",
'X', new ItemStack(Items.DYE, 1, 4)});
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.ENDER, 4), new Object[]{
" X ",
"#X#",
"XXX",
'#', new ItemStack(Items.ENDER_EYE, 1, 0),
'X', new ItemStack(Blocks.END_STONE, 1, 0)});
String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime",
"dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"};
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.APICULTURE)) {
ItemRegistryApiculture beeItems = PluginApiculture.items;
Preconditions.checkState(beeItems != null);
FluidStack liquidGlass = Fluids.GLASS.getFluid(Fluid.BUCKET_VOLUME);
FluidStack liquidGlassX4 = Fluids.GLASS.getFluid(Fluid.BUCKET_VOLUME * 4);
for (int i = 0; i < 16; i++) {
@@ -260,20 +345,29 @@ public class PluginFactory extends BlankForestryPlugin {
// / SQUEEZER
int appleMulchAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.mulch.apple");
int appleJuiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple");
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.APPLE)}, Fluids.JUICE.getFluid(appleJuiceAmount),
PluginCore.items.mulch.getItemStack(), appleMulchAmount);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.CARROT)}, Fluids.JUICE.getFluid(appleJuiceAmount),
PluginCore.items.mulch.getItemStack(), appleMulchAmount);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack(Items.APPLE), Fluids.JUICE.getFluid(appleJuiceAmount),
coreItems.mulch.getItemStack(), appleMulchAmount);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack(Items.CARROT), Fluids.JUICE.getFluid(appleJuiceAmount),
coreItems.mulch.getItemStack(), appleMulchAmount);
int seedOilAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
FluidStack seedOil = Fluids.SEED_OIL.getFluid(seedOilAmount);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.WHEAT_SEEDS)}, seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.PUMPKIN_SEEDS)}, seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.MELON_SEEDS)}, seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.BEETROOT_SEEDS)}, seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{PluginCore.items.phosphor.getItemStack(2), new ItemStack(Blocks.COBBLESTONE)}, new FluidStack(FluidRegistry.LAVA, 1600));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.CACTUS)}, new FluidStack(FluidRegistry.WATER, 500));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.SNOWBALL), PluginCore.items.craftingMaterial.getIceShard(4)}, Fluids.ICE.getFluid(4000));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack(Items.WHEAT_SEEDS), seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack(Items.PUMPKIN_SEEDS), seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack(Items.MELON_SEEDS), seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack(Items.BEETROOT_SEEDS), seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack(Blocks.CACTUS), new FluidStack(FluidRegistry.WATER, 500));
NonNullList<ItemStack> lavaRecipeResources = NonNullList.create();
lavaRecipeResources.add(coreItems.phosphor.getItemStack(2));
lavaRecipeResources.add(new ItemStack(Blocks.COBBLESTONE));
RecipeManagers.squeezerManager.addRecipe(10, lavaRecipeResources, new FluidStack(FluidRegistry.LAVA, 1600));
NonNullList<ItemStack> iceRecipeResources = NonNullList.create();
iceRecipeResources.add(new ItemStack(Items.SNOWBALL));
iceRecipeResources.add(coreItems.craftingMaterial.getIceShard(4));
RecipeManagers.squeezerManager.addRecipe(10, iceRecipeResources, Fluids.ICE.getFluid(4000));
// STILL
RecipeManagers.stillManager.addRecipe(Constants.STILL_DESTILLATION_DURATION, Fluids.BIOMASS.getFluid(Constants.STILL_DESTILLATION_INPUT),
@@ -307,53 +401,53 @@ public class PluginFactory extends BlankForestryPlugin {
RecipeManagers.fabricatorSmeltingManager.addSmelting(new ItemStack(Blocks.SANDSTONE, 1, 2), Fluids.GLASS.getFluid(4000), 4800);
// / CARPENTER
RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEED_OIL.getFluid(250), null, PluginCore.items.impregnatedCasing.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEED_OIL.getFluid(250), ItemStack.EMPTY, coreItems.impregnatedCasing.getItemStack(),
"###",
"# #",
"###",
'#', "logWood");
RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEED_OIL.getFluid(500), null,
new ItemStack(PluginCore.blocks.escritoire),
RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEED_OIL.getFluid(500), ItemStack.EMPTY,
new ItemStack(coreBlocks.escritoire),
"# ",
"###",
"# #",
'#', "plankWood");
// RESOURCES
RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEED_OIL.getFluid(100), null,
PluginCore.items.stickImpregnated.getItemStack(2),
RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEED_OIL.getFluid(100), ItemStack.EMPTY,
coreItems.stickImpregnated.getItemStack(2),
"#",
"#",
'#', "logWood");
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 250), null,
PluginCore.items.woodPulp.getItemStack(4),
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 250), ItemStack.EMPTY,
coreItems.woodPulp.getItemStack(4),
"#",
'#', "logWood");
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 250), null,
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 250), ItemStack.EMPTY,
new ItemStack(Items.PAPER, 1),
"#",
"#",
'#', "pulpWood");
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), null,
new ItemStack(PluginCore.blocks.humus, 9),
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY,
new ItemStack(coreBlocks.humus, 9),
"###",
"#X#",
"###",
'#', Blocks.DIRT,
'X', PluginCore.items.mulch);
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), null,
PluginCore.blocks.bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, 8),
'X', coreItems.mulch);
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY,
coreBlocks.bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, 8),
"#X#",
"XYX", "#X#",
'#', Blocks.DIRT,
'X', "sand",
'Y', PluginCore.items.mulch);
RecipeManagers.carpenterManager.addRecipe(75, new FluidStack(FluidRegistry.WATER, 5000), null, PluginCore.items.hardenedCasing.getItemStack(),
'Y', coreItems.mulch);
RecipeManagers.carpenterManager.addRecipe(75, new FluidStack(FluidRegistry.WATER, 5000), ItemStack.EMPTY, coreItems.hardenedCasing.getItemStack(),
"# #",
" Y ",
"# #",
'#', "gemDiamond",
'Y', PluginCore.items.sturdyCasing);
'Y', coreItems.sturdyCasing);
// / CHIPSETS
ItemStack basicCircuitboard = ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.BASIC, null, new ICircuit[]{});
@@ -361,75 +455,76 @@ public class PluginFactory extends BlankForestryPlugin {
ItemStack refinedCircuitboard = ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.REFINED, null, new ICircuit[]{});
ItemStack intricateCircuitboard = ItemCircuitBoard.createCircuitboard(EnumCircuitBoardType.INTRICATE, null, new ICircuit[]{});
RecipeManagers.carpenterManager.addRecipe(20, new FluidStack(FluidRegistry.WATER, 1000), null, basicCircuitboard,
RecipeManagers.carpenterManager.addRecipe(20, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY, basicCircuitboard,
"R R", "R#R", "R R", '#', "ingotTin", 'R', "dustRedstone");
RecipeManagers.carpenterManager.addRecipe(40, new FluidStack(FluidRegistry.WATER, 1000), null, enhancedCircuitboard,
RecipeManagers.carpenterManager.addRecipe(40, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY, enhancedCircuitboard,
"R#R", "R#R", "R#R", '#', "ingotBronze", 'R', "dustRedstone");
RecipeManagers.carpenterManager.addRecipe(80, new FluidStack(FluidRegistry.WATER, 1000), null, refinedCircuitboard,
RecipeManagers.carpenterManager.addRecipe(80, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY, refinedCircuitboard,
"R#R", "R#R", "R#R", '#', "ingotIron", 'R', "dustRedstone");
RecipeManagers.carpenterManager.addRecipe(80, new FluidStack(FluidRegistry.WATER, 1000), null, intricateCircuitboard,
RecipeManagers.carpenterManager.addRecipe(80, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY, intricateCircuitboard,
"R#R", "R#R", "R#R", '#', "ingotGold", 'R', "dustRedstone");
RecipeManagers.carpenterManager.addRecipe(40, new FluidStack(FluidRegistry.WATER, 1000), null, PluginCore.items.solderingIron.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(40, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY, coreItems.solderingIron.getItemStack(),
" # ", "# #", " B", '#', "ingotIron", 'B', "ingotBronze");
// RAIN SUBSTRATES
ItemRegistryApiculture beeItems = PluginApiculture.items;
if (beeItems != null) {
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), null, PluginCore.items.iodineCharge.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY, coreItems.iodineCharge.getItemStack(),
"Z#Z",
"#Y#",
"X#X",
'#', beeItems.pollenCluster.getWildcard(),
'X', Items.GUNPOWDER,
'Y', PluginFluids.items.canEmpty,
'Y', fluidItems.canEmpty,
'Z', beeItems.honeyDrop);
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), null, PluginCore.items.craftingMaterial.getDissipationCharge(),
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY, coreItems.craftingMaterial.getDissipationCharge(),
"Z#Z",
"#Y#",
"X#X",
'#', beeItems.royalJelly,
'X', Items.GUNPOWDER,
'Y', PluginFluids.items.canEmpty,
'Y', fluidItems.canEmpty,
'Z', beeItems.honeydew);
}
// Ender pearl
RecipeManagers.carpenterManager.addRecipe(100, null, new ItemStack(Items.ENDER_PEARL, 1), " # ", "###", " # ", '#',
PluginCore.items.craftingMaterial.getPulsatingMesh());
RecipeManagers.carpenterManager.addRecipe(100, ItemStack.EMPTY, new ItemStack(Items.ENDER_PEARL, 1), " # ", "###", " # ", '#',
coreItems.craftingMaterial.getPulsatingMesh());
// Woven Silk
RecipeManagers.carpenterManager.addRecipe(10, new FluidStack(FluidRegistry.WATER, 500), null, PluginCore.items.craftingMaterial.getWovenSilk(),
RecipeManagers.carpenterManager.addRecipe(10, new FluidStack(FluidRegistry.WATER, 500), ItemStack.EMPTY, coreItems.craftingMaterial.getWovenSilk(),
"###",
"###",
"###",
'#', PluginCore.items.craftingMaterial.getSilkWisp());
'#', coreItems.craftingMaterial.getSilkWisp());
// Boxes
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), null, PluginCore.items.carton.getItemStack(2),
RecipeManagers.carpenterManager.addRecipe(5, new FluidStack(FluidRegistry.WATER, 1000), ItemStack.EMPTY, coreItems.carton.getItemStack(2),
" # ", "# #", " # ", '#', "pulpWood");
// Assembly Kits
RecipeManagers.carpenterManager.addRecipe(20, null, PluginCore.items.carton.getItemStack(), PluginCore.items.kitPickaxe.getItemStack(), new Object[]{
RecipeManagers.carpenterManager.addRecipe(20, null, coreItems.carton.getItemStack(), coreItems.kitPickaxe.getItemStack(), new Object[]{
"###",
" X ",
" X ",
'#', "ingotBronze",
'X', "stickWood"});
RecipeManagers.carpenterManager.addRecipe(20, null, PluginCore.items.carton.getItemStack(), PluginCore.items.kitShovel.getItemStack(),
RecipeManagers.carpenterManager.addRecipe(20, null, coreItems.carton.getItemStack(), coreItems.kitShovel.getItemStack(),
new Object[]{" # ", " X ", " X ", '#', "ingotBronze", 'X', "stickWood"});
// Reclamation
ItemStack ingotBronze = PluginCore.items.ingotBronze.copy();
ingotBronze.stackSize = 2;
RecipeManagers.carpenterManager.addRecipe(null, ingotBronze, "#", '#', PluginCore.items.brokenBronzePickaxe);
ItemStack ingotBronze = coreItems.ingotBronze.copy();
ingotBronze.setCount(2);
RecipeManagers.carpenterManager.addRecipe(ItemStack.EMPTY, ingotBronze, "#", '#', coreItems.brokenBronzePickaxe);
ingotBronze = ingotBronze.copy();
ingotBronze.stackSize = 1;
RecipeManagers.carpenterManager.addRecipe(null, ingotBronze, "#", '#', PluginCore.items.brokenBronzeShovel);
ingotBronze.setCount(1);
RecipeManagers.carpenterManager.addRecipe(ItemStack.EMPTY, ingotBronze, "#", '#', coreItems.brokenBronzeShovel);
// Crating and uncrating
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.STORAGE)) {
@@ -438,17 +533,17 @@ public class PluginFactory extends BlankForestryPlugin {
ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout("forestry.machine.upgrade");
// / Solder Manager
ChipsetManager.solderManager.addRecipe(layout, PluginCore.items.tubes.get(EnumElectronTube.EMERALD, 1), Circuit.machineSpeedUpgrade1);
ChipsetManager.solderManager.addRecipe(layout, PluginCore.items.tubes.get(EnumElectronTube.BLAZE, 1), Circuit.machineSpeedUpgrade2);
ChipsetManager.solderManager.addRecipe(layout, PluginCore.items.tubes.get(EnumElectronTube.GOLD, 1), Circuit.machineEfficiencyUpgrade1);
ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.EMERALD, 1), Circuits.machineSpeedUpgrade1);
ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.BLAZE, 1), Circuits.machineSpeedUpgrade2);
ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.GOLD, 1), Circuits.machineEfficiencyUpgrade1);
RecipeUtil.addRecipe(blocks.bottler,
"X#X",
"#Y#",
"X#X",
'#', "blockGlass",
'X', PluginFluids.items.canEmpty,
'Y', PluginCore.items.sturdyCasing);
'X', fluidItems.canEmpty,
'Y', coreItems.sturdyCasing);
RecipeUtil.addRecipe(blocks.carpenter,
"X#X",
@@ -456,7 +551,7 @@ public class PluginFactory extends BlankForestryPlugin {
"X#X",
'#', "blockGlass",
'X', "ingotBronze",
'Y', PluginCore.items.sturdyCasing);
'Y', coreItems.sturdyCasing);
RecipeUtil.addRecipe(blocks.centrifuge,
"X#X",
@@ -464,7 +559,7 @@ public class PluginFactory extends BlankForestryPlugin {
"X#X",
'#', "blockGlass",
'X', "ingotCopper",
'Y', PluginCore.items.sturdyCasing);
'Y', coreItems.sturdyCasing);
RecipeUtil.addRecipe(blocks.fermenter,
"X#X",
@@ -472,7 +567,7 @@ public class PluginFactory extends BlankForestryPlugin {
"X#X",
'#', "blockGlass",
'X', "gearBronze",
'Y', PluginCore.items.sturdyCasing);
'Y', coreItems.sturdyCasing);
RecipeUtil.addRecipe(blocks.moistener,
"X#X",
@@ -480,7 +575,7 @@ public class PluginFactory extends BlankForestryPlugin {
"X#X",
'#', "blockGlass",
'X', "gearCopper",
'Y', PluginCore.items.sturdyCasing);
'Y', coreItems.sturdyCasing);
RecipeUtil.addRecipe(blocks.squeezer,
"X#X",
@@ -488,7 +583,7 @@ public class PluginFactory extends BlankForestryPlugin {
"X#X",
'#', "blockGlass",
'X', "ingotTin",
'Y', PluginCore.items.sturdyCasing);
'Y', coreItems.sturdyCasing);
RecipeUtil.addRecipe(blocks.still,
"X#X",
@@ -496,7 +591,7 @@ public class PluginFactory extends BlankForestryPlugin {
"X#X",
'#', "blockGlass",
'X', "dustRedstone",
'Y', PluginCore.items.sturdyCasing);
'Y', coreItems.sturdyCasing);
RecipeUtil.addRecipe(blocks.rainmaker,
"X#X",
@@ -504,7 +599,7 @@ public class PluginFactory extends BlankForestryPlugin {
"X#X",
'#', "blockGlass",
'X', "gearTin",
'Y', PluginCore.items.hardenedCasing);
'Y', coreItems.hardenedCasing);
RecipeUtil.addRecipe(blocks.fabricator,
"X#X",
@@ -512,7 +607,7 @@ public class PluginFactory extends BlankForestryPlugin {
"XZX",
'#', "blockGlass",
'X', "ingotGold",
'Y', PluginCore.items.sturdyCasing,
'Y', coreItems.sturdyCasing,
'Z', "chestWood");
RecipeUtil.addRecipe(blocks.raintank,
@@ -521,7 +616,7 @@ public class PluginFactory extends BlankForestryPlugin {
"X#X",
'#', "blockGlass",
'X', "ingotIron",
'Y', PluginCore.items.sturdyCasing);
'Y', coreItems.sturdyCasing);
RecipeUtil.addRecipe(blocks.worktable,
"B",
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.factory.blocks;
import javax.annotation.Nonnull;
import forestry.core.blocks.IBlockType;
import forestry.core.blocks.IMachineProperties;
import forestry.core.blocks.MachineProperties;
@@ -27,14 +25,12 @@ public enum BlockTypeFactoryPlain implements IBlockType {
public static final BlockTypeFactoryPlain[] VALUES = values();
@Nonnull
private final IMachineProperties machineProperties;
<T extends TileForestry> BlockTypeFactoryPlain(@Nonnull Class<T> teClass, @Nonnull String name) {
<T extends TileForestry> BlockTypeFactoryPlain(Class<T> teClass, String name) {
this.machineProperties = new MachineProperties<>(teClass, name);
}
@Nonnull
@Override
public IMachineProperties getMachineProperties() {
return machineProperties;
@@ -10,11 +10,8 @@
******************************************************************************/
package forestry.factory.blocks;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import forestry.core.blocks.IBlockTypeTesr;
import forestry.core.blocks.IMachinePropertiesTesr;
import forestry.core.blocks.MachinePropertiesTesr;
@@ -29,6 +26,7 @@ import forestry.factory.tiles.TileMillRainmaker;
import forestry.factory.tiles.TileMoistener;
import forestry.factory.tiles.TileSqueezer;
import forestry.factory.tiles.TileStill;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
public enum BlockTypeFactoryTesr implements IBlockTypeTesr {
BOTTLER(TileBottler.class, "bottler"),
@@ -42,19 +40,17 @@ public enum BlockTypeFactoryTesr implements IBlockTypeTesr {
public static final BlockTypeFactoryTesr[] VALUES = values();
@Nonnull
private final IMachinePropertiesTesr<?> machineProperties;
<T extends TileBase> BlockTypeFactoryTesr(@Nonnull Class<T> teClass, @Nonnull String name) {
<T extends TileBase> BlockTypeFactoryTesr(Class<T> teClass, String name) {
TileEntitySpecialRenderer<TileBase> renderer = Proxies.render.getRenderDefaultMachine(Constants.TEXTURE_PATH_BLOCKS + "/" + name + "_");
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0");
}
<T extends TileBase> BlockTypeFactoryTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer) {
<T extends TileBase> BlockTypeFactoryTesr(Class<T> teClass, String name, @Nullable TileEntitySpecialRenderer<? super T> renderer) {
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0");
}
@Nonnull
@Override
public IMachinePropertiesTesr<?> getMachineProperties() {
return machineProperties;
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.blocks;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.circuits;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -61,7 +61,7 @@ public class ContainerCarpenter extends ContainerLiquidTanks<TileCarpenter> impl
tile.checkRecipe();
}
private ItemStack oldCraftPreview;
private ItemStack oldCraftPreview = ItemStack.EMPTY;
@Override
public void detectAndSendChanges() {
@@ -39,7 +39,7 @@ public class ContainerCentrifuge extends ContainerSocketed<TileCentrifuge> {
}
}
private ItemStack oldCraftPreview;
private ItemStack oldCraftPreview = ItemStack.EMPTY;
@Override
public void detectAndSendChanges() {
@@ -122,10 +122,7 @@ public class ContainerWorktable extends ContainerTile<TileWorktable> implements
}
@Override
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packet) {
int primary = packet.getPrimaryIndex();
int secondary = packet.getSecondaryIndex();
public void handleSelectionRequest(EntityPlayerMP player, int primary, int secondary) {
switch (primary) {
case -1: { // clicked clear button
tile.clearCraftMatrix();
@@ -140,7 +137,7 @@ public class ContainerWorktable extends ContainerTile<TileWorktable> implements
break;
}
case 1: { // right clicked a memorized recipe
long time = player.worldObj.getTotalWorldTime();
long time = player.world.getTotalWorldTime();
RecipeMemory memory = tile.getMemory();
memory.toggleLock(time, secondary);
break;
@@ -10,15 +10,15 @@
******************************************************************************/
package forestry.factory.gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.widgets.TankWidget;
import forestry.core.render.ColourProperties;
import forestry.core.utils.Translator;
import forestry.factory.tiles.TileBottler;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiBottler extends GuiForestryTitled<ContainerBottler, TileBottler> {
@@ -50,15 +50,15 @@ public class GuiBottler extends GuiForestryTitled<ContainerBottler, TileBottler>
textLayout.line = 5;
textLayout.drawCenteredLine(name, 0, ColourProperties.INSTANCE.get("gui.title"));
bindTexture(textureFile);
bindTexture(textureFile);
TileBottler bottler = inventory;
int progressArrow = bottler.getProgressScaled(22);
if(progressArrow > 0){
if(bottler.isFillRecipe){
if (progressArrow > 0) {
if (bottler.isFillRecipe) {
drawTexturedModalRect(guiLeft + 108, guiTop + 35, 177, 74, progressArrow, 16);
}else{
} else {
drawTexturedModalRect(guiLeft + 46, guiTop + 35, 177, 74, progressArrow, 16);
}
}
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.gui;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -52,7 +52,7 @@ public class MemorizedRecipeSlot extends ItemStackWidgetBase {
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
if (getItemStack() != null) {
if (!getItemStack().isEmpty()) {
ContainerWorktable.sendRecipeClick(mouseButton, slotNumber);
Proxies.common.playButtonClick();
}
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.gui.widgets;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -10,16 +10,14 @@
******************************************************************************/
package forestry.factory.inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.core.utils.SlotUtil;
import forestry.factory.recipes.CarpenterRecipeManager;
import forestry.factory.tiles.TileCarpenter;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
public class InventoryCarpenter extends InventoryAdapterTile<TileCarpenter> {
public final static int SLOT_BOX = 9;
@@ -37,7 +35,7 @@ public class InventoryCarpenter extends InventoryAdapterTile<TileCarpenter> {
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_CAN_INPUT) {
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
return tile.getTankManager().canFillFluidType(fluid);
return fluid != null && tile.getTankManager().canFillFluidType(fluid);
} else if (slotIndex == SLOT_BOX) {
return CarpenterRecipeManager.isBox(itemStack);
} else if (canSlotAccept(SLOT_CAN_INPUT, itemStack) || canSlotAccept(SLOT_BOX, itemStack)) {
@@ -10,13 +10,12 @@
******************************************************************************/
package forestry.factory.inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.core.utils.SlotUtil;
import forestry.factory.recipes.CentrifugeRecipeManager;
import forestry.factory.tiles.TileCentrifuge;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
public class InventoryCentrifuge extends InventoryAdapterTile<TileCentrifuge> {
public static final int SLOT_RESOURCE = 0;
@@ -10,14 +10,13 @@
******************************************************************************/
package forestry.factory.inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.core.utils.SlotUtil;
import forestry.factory.recipes.FabricatorRecipeManager;
import forestry.factory.recipes.FabricatorSmeltingRecipeManager;
import forestry.factory.tiles.TileFabricator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
public class InventoryFabricator extends InventoryAdapterTile<TileFabricator> {
public static final short SLOT_METAL = 0;
@@ -10,17 +10,15 @@
******************************************************************************/
package forestry.factory.inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import forestry.api.fuels.FuelManager;
import forestry.core.fluids.FluidHelper;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.factory.recipes.FermenterRecipeManager;
import forestry.factory.tiles.TileFermenter;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
public class InventoryFermenter extends InventoryAdapterTile<TileFermenter> {
public static final short SLOT_RESOURCE = 0;
@@ -39,7 +37,7 @@ public class InventoryFermenter extends InventoryAdapterTile<TileFermenter> {
return FermenterRecipeManager.isResource(itemStack);
} else if (slotIndex == SLOT_INPUT) {
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
return tile.getTankManager().canFillFluidType(fluid);
return fluid != null && tile.getTankManager().canFillFluidType(fluid);
} else if (slotIndex == SLOT_CAN_INPUT) {
return FluidHelper.isFillableContainerWithRoom(itemStack);
} else if (slotIndex == SLOT_FUEL) {
@@ -10,17 +10,15 @@
******************************************************************************/
package forestry.factory.inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import forestry.api.fuels.FuelManager;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.core.utils.SlotUtil;
import forestry.factory.recipes.MoistenerRecipeManager;
import forestry.factory.tiles.TileMoistener;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
public class InventoryMoistener extends InventoryAdapterTile<TileMoistener> {
public static final short SLOT_STASH_1 = 0;
@@ -47,7 +45,7 @@ public class InventoryMoistener extends InventoryAdapterTile<TileMoistener> {
if (slotIndex == SLOT_PRODUCT) {
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
return tile.getTankManager().canFillFluidType(fluid);
return fluid != null && tile.getTankManager().canFillFluidType(fluid);
}
return false;
@@ -10,12 +10,11 @@
******************************************************************************/
package forestry.factory.inventory;
import net.minecraft.item.ItemStack;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.RainSubstrate;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.factory.tiles.TileMillRainmaker;
import net.minecraft.item.ItemStack;
public class InventoryRainmaker extends InventoryAdapterTile<TileMillRainmaker> {
private static final int SLOT_SUBSTRATE = 0;
@@ -10,17 +10,15 @@
******************************************************************************/
package forestry.factory.inventory;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.factory.tiles.TileRaintank;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandler;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.factory.tiles.TileRaintank;
public class InventoryRaintank extends InventoryAdapterTile<TileRaintank> {
public static final short SLOT_RESOURCE = 0;
public static final short SLOT_PRODUCT = 1;
@@ -10,12 +10,6 @@
******************************************************************************/
package forestry.factory.inventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.inventory.InventoryAdapterTile;
@@ -23,6 +17,11 @@ import forestry.core.inventory.wrappers.InventoryMapper;
import forestry.core.utils.InventoryUtil;
import forestry.factory.recipes.SqueezerRecipeManager;
import forestry.factory.tiles.TileSqueezer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
public class InventorySqueezer extends InventoryAdapterTile<TileSqueezer> {
public static final short SLOT_RESOURCE_1 = 0;
@@ -64,11 +63,11 @@ public class InventorySqueezer extends InventoryAdapterTile<TileSqueezer> {
return !InventoryUtil.isEmpty(this, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT);
}
public ItemStack[] getResources() {
public NonNullList<ItemStack> getResources() {
return InventoryUtil.getStacks(this, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT);
}
public boolean removeResources(ItemStack[] stacks) {
public boolean removeResources(NonNullList<ItemStack> stacks) {
IInventory inventory = new InventoryMapper(this, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT);
return InventoryUtil.removeSets(inventory, 1, stacks, null, false, true, false, true);
}
@@ -78,7 +77,7 @@ public class InventorySqueezer extends InventoryAdapterTile<TileSqueezer> {
}
public void fillContainers(FluidStack fluidStack, TankManager tankManager) {
if (getStackInSlot(SLOT_CAN_INPUT) == null || fluidStack == null) {
if (getStackInSlot(SLOT_CAN_INPUT).isEmpty()) {
return;
}
FluidHelper.fillContainers(tankManager, this, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid(), true);
@@ -10,15 +10,13 @@
******************************************************************************/
package forestry.factory.inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import forestry.core.fluids.FluidHelper;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.factory.tiles.TileStill;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
public class InventoryStill extends InventoryAdapterTile<TileStill> {
public static final short SLOT_PRODUCT = 0;
@@ -35,7 +33,7 @@ public class InventoryStill extends InventoryAdapterTile<TileStill> {
return FluidHelper.isFillableEmptyContainer(itemStack);
} else if (slotIndex == SLOT_CAN) {
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
return tile.getTankManager().canFillFluidType(fluid);
return fluid != null && tile.getTankManager().canFillFluidType(fluid);
}
return false;
}
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.inventory;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -10,22 +10,23 @@
******************************************************************************/
package forestry.factory.network;
import forestry.core.network.PacketRegistry;
import forestry.core.network.IPacketRegistry;
import forestry.core.network.PacketIdClient;
import forestry.core.network.PacketIdServer;
import forestry.factory.network.packets.PacketRecipeTransferRequest;
import forestry.factory.network.packets.PacketRecipeTransferUpdate;
import forestry.factory.network.packets.PacketWorktableMemoryUpdate;
import forestry.factory.network.packets.PacketWorktableRecipeRequest;
import forestry.factory.network.packets.PacketWorktableRecipeUpdate;
public class PacketRegistryFactory extends PacketRegistry {
public class PacketRegistryFactory implements IPacketRegistry {
@Override
public void registerPackets() {
PacketIdClient.WORKTABLE_MEMORY_UPDATE.setPacketHandler(new PacketWorktableMemoryUpdate.Handler());
PacketIdClient.WORKTABLE_CRAFTING_UPDATE.setPacketHandler(new PacketWorktableRecipeUpdate.Handler());
PacketIdClient.RECIPE_TRANSFER_UPDATE.setPacketHandler(new PacketRecipeTransferUpdate.Handler());
registerClientPacket(new PacketWorktableMemoryUpdate());
registerClientPacket(new PacketWorktableRecipeUpdate());
registerClientPacket(new PacketRecipeTransferUpdate());
registerServerPacket(new PacketWorktableRecipeRequest());
registerServerPacket(new PacketRecipeTransferRequest());
PacketIdServer.WORKTABLE_RECIPE_REQUEST.setPacketHandler(new PacketWorktableRecipeRequest.Handler());
PacketIdServer.RECIPE_TRANSFER_REQUEST.setPacketHandler(new PacketRecipeTransferRequest.Handler());
}
}
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.network;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -12,68 +12,67 @@ package forestry.factory.network.packets;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.ForestryPacket;
import forestry.core.network.IForestryPacketHandlerServer;
import forestry.core.network.IForestryPacketServer;
import forestry.core.network.PacketBufferForestry;
import forestry.core.network.PacketIdServer;
import forestry.core.network.packets.PacketCoordinates;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileBase;
import forestry.factory.tiles.TileCarpenter;
import forestry.factory.tiles.TileFabricator;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
public class PacketRecipeTransferRequest extends PacketCoordinates implements IForestryPacketServer {
private ItemStack[] craftingInventory;
public class PacketRecipeTransferRequest extends ForestryPacket implements IForestryPacketServer {
private final BlockPos pos;
private final NonNullList<ItemStack> craftingInventory;
public PacketRecipeTransferRequest() {
}
public PacketRecipeTransferRequest(TileBase base, ItemStack[] craftingInventory) {
super(base);
public PacketRecipeTransferRequest(TileBase base, NonNullList<ItemStack> craftingInventory) {
this.pos = base.getPos();
this.craftingInventory = craftingInventory;
}
@Override
protected void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
protected void writeData(PacketBufferForestry data) throws IOException {
data.writeBlockPos(pos);
data.writeItemStacks(craftingInventory);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
craftingInventory = data.readItemStacks();
}
@Override
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
TileEntity tile = getTarget(player.worldObj);
if (tile instanceof TileCarpenter) {
TileCarpenter carpenter = (TileCarpenter) tile;
int index = 0;
for(ItemStack stack : craftingInventory){
carpenter.getCraftingInventory().setInventorySlotContents(index, stack);
index++;
}
Proxies.net.sendNetworkPacket(new PacketRecipeTransferUpdate(carpenter, craftingInventory), player.worldObj);
}else if(tile instanceof TileFabricator){
TileFabricator fabricator = (TileFabricator) tile;
int index = 0;
for(ItemStack stack : craftingInventory){
fabricator.getCraftingInventory().setInventorySlotContents(index, stack);
index++;
}
Proxies.net.sendNetworkPacket(new PacketRecipeTransferUpdate(fabricator, craftingInventory), player.worldObj);
}
}
@Override
public PacketIdServer getPacketId() {
return PacketIdServer.RECIPE_TRANSFER_REQUEST;
}
public static class Handler implements IForestryPacketHandlerServer {
@Override
public void onPacketData(PacketBufferForestry data, EntityPlayerMP player) throws IOException {
BlockPos pos = data.readBlockPos();
NonNullList<ItemStack> craftingInventory = data.readItemStacks();
TileEntity tile = player.world.getTileEntity(pos);
if (tile instanceof TileCarpenter) {
TileCarpenter carpenter = (TileCarpenter) tile;
int index = 0;
for (ItemStack stack : craftingInventory) {
carpenter.getCraftingInventory().setInventorySlotContents(index, stack);
index++;
}
Proxies.net.sendNetworkPacket(new PacketRecipeTransferUpdate(carpenter, craftingInventory), pos, player.world);
} else if (tile instanceof TileFabricator) {
TileFabricator fabricator = (TileFabricator) tile;
int index = 0;
for (ItemStack stack : craftingInventory) {
fabricator.getCraftingInventory().setInventorySlotContents(index, stack);
index++;
}
Proxies.net.sendNetworkPacket(new PacketRecipeTransferUpdate(fabricator, craftingInventory), pos, player.world);
}
}
}
}
@@ -12,63 +12,62 @@ package forestry.factory.network.packets;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.ForestryPacket;
import forestry.core.network.IForestryPacketClient;
import forestry.core.network.IForestryPacketHandlerClient;
import forestry.core.network.PacketBufferForestry;
import forestry.core.network.PacketIdClient;
import forestry.core.network.packets.PacketCoordinates;
import forestry.core.tiles.TileBase;
import forestry.factory.tiles.TileCarpenter;
import forestry.factory.tiles.TileFabricator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
public class PacketRecipeTransferUpdate extends PacketCoordinates implements IForestryPacketClient {
private ItemStack[] craftingInventory;
public class PacketRecipeTransferUpdate extends ForestryPacket implements IForestryPacketClient {
private final BlockPos pos;
private final NonNullList<ItemStack> craftingInventory;
public PacketRecipeTransferUpdate() {
}
public PacketRecipeTransferUpdate(TileBase base, ItemStack[] craftingInventory) {
super(base);
public PacketRecipeTransferUpdate(TileBase base, NonNullList<ItemStack> craftingInventory) {
this.pos = base.getPos();
this.craftingInventory = craftingInventory;
}
@Override
protected void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
protected void writeData(PacketBufferForestry data) throws IOException {
data.writeBlockPos(pos);
data.writeItemStacks(craftingInventory);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
craftingInventory = data.readItemStacks();
}
@Override
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
TileEntity tile = getTarget(player.worldObj);
if (tile instanceof TileCarpenter) {
TileCarpenter carpenter = (TileCarpenter) tile;
int index = 0;
for(ItemStack stack : craftingInventory){
carpenter.getCraftingInventory().setInventorySlotContents(index, stack);
index++;
}
}else if(tile instanceof TileFabricator){
TileFabricator fabricator = (TileFabricator) tile;
int index = 0;
for(ItemStack stack : craftingInventory){
fabricator.getCraftingInventory().setInventorySlotContents(index, stack);
index++;
}
}
}
@Override
public PacketIdClient getPacketId() {
return PacketIdClient.RECIPE_TRANSFER_UPDATE;
}
public static class Handler implements IForestryPacketHandlerClient {
@Override
public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException {
BlockPos pos = data.readBlockPos();
NonNullList<ItemStack> craftingInventory = data.readItemStacks();
TileEntity tile = player.world.getTileEntity(pos);
if (tile instanceof TileCarpenter) {
TileCarpenter carpenter = (TileCarpenter) tile;
int index = 0;
for (ItemStack stack : craftingInventory) {
carpenter.getCraftingInventory().setInventorySlotContents(index, stack);
index++;
}
} else if (tile instanceof TileFabricator) {
TileFabricator fabricator = (TileFabricator) tile;
int index = 0;
for (ItemStack stack : craftingInventory) {
fabricator.getCraftingInventory().setInventorySlotContents(index, stack);
index++;
}
}
}
}
}
@@ -12,46 +12,46 @@ package forestry.factory.network.packets;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.ForestryPacket;
import forestry.core.network.IForestryPacketClient;
import forestry.core.network.IForestryPacketHandlerClient;
import forestry.core.network.PacketBufferForestry;
import forestry.core.network.PacketIdClient;
import forestry.core.network.packets.PacketCoordinates;
import forestry.core.proxy.Proxies;
import forestry.factory.recipes.RecipeMemory;
import forestry.factory.tiles.TileWorktable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
public class PacketWorktableMemoryUpdate extends PacketCoordinates implements IForestryPacketClient {
private RecipeMemory recipeMemory;
public PacketWorktableMemoryUpdate() {
}
public class PacketWorktableMemoryUpdate extends ForestryPacket implements IForestryPacketClient {
private final BlockPos pos;
private final RecipeMemory recipeMemory;
public PacketWorktableMemoryUpdate(TileWorktable worktable) {
super(worktable);
this.pos = worktable.getPos();
this.recipeMemory = worktable.getMemory();
}
@Override
protected void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
recipeMemory.writeData(data);
}
@Override
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
if (tile instanceof TileWorktable) {
((TileWorktable) tile).getMemory().readData(data);
}
}
@Override
public PacketIdClient getPacketId() {
return PacketIdClient.WORKTABLE_MEMORY_UPDATE;
}
@Override
protected void writeData(PacketBufferForestry data) throws IOException {
data.writeBlockPos(pos);
recipeMemory.writeData(data);
}
public static class Handler implements IForestryPacketHandlerClient {
@Override
public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException {
BlockPos pos = data.readBlockPos();
TileEntity tile = player.world.getTileEntity(pos);
if (tile instanceof TileWorktable) {
((TileWorktable) tile).getMemory().readData(data);
}
}
}
}
@@ -12,63 +12,62 @@ package forestry.factory.network.packets;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.ForestryPacket;
import forestry.core.network.IForestryPacketHandlerServer;
import forestry.core.network.IForestryPacketServer;
import forestry.core.network.PacketBufferForestry;
import forestry.core.network.PacketIdServer;
import forestry.core.network.packets.PacketCoordinates;
import forestry.core.proxy.Proxies;
import forestry.factory.gui.ContainerWorktable;
import forestry.factory.recipes.MemorizedRecipe;
import forestry.factory.tiles.TileWorktable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
/**
* Used to sync the worktable crafting grid from Client to Server.
*/
public class PacketWorktableRecipeRequest extends PacketCoordinates implements IForestryPacketServer {
private MemorizedRecipe recipe;
public PacketWorktableRecipeRequest() {
}
public class PacketWorktableRecipeRequest extends ForestryPacket implements IForestryPacketServer {
private final BlockPos pos;
private final MemorizedRecipe recipe;
public PacketWorktableRecipeRequest(TileWorktable worktable, MemorizedRecipe recipe) {
super(worktable);
this.pos = worktable.getPos();
this.recipe = recipe;
}
@Override
protected void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeStreamable(recipe);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
recipe = data.readStreamable(MemorizedRecipe.class);
}
@Override
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
TileEntity tile = getTarget(player.worldObj);
if (tile instanceof TileWorktable) {
TileWorktable worktable = (TileWorktable) tile;
worktable.setCurrentRecipe(recipe);
if (player.openContainer instanceof ContainerWorktable) {
ContainerWorktable containerWorktable = (ContainerWorktable) player.openContainer;
containerWorktable.updateCraftMatrix();
}
Proxies.net.sendNetworkPacket(new PacketWorktableRecipeUpdate(worktable), player.worldObj);
}
}
@Override
public PacketIdServer getPacketId() {
return PacketIdServer.WORKTABLE_RECIPE_REQUEST;
}
@Override
protected void writeData(PacketBufferForestry data) throws IOException {
data.writeBlockPos(pos);
recipe.writeData(data);
}
public static class Handler implements IForestryPacketHandlerServer {
@Override
public void onPacketData(PacketBufferForestry data, EntityPlayerMP player) throws IOException {
BlockPos pos = data.readBlockPos();
MemorizedRecipe recipe = new MemorizedRecipe();
recipe.readData(data);
TileEntity tile = player.world.getTileEntity(pos);
if (tile instanceof TileWorktable) {
TileWorktable worktable = (TileWorktable) tile;
worktable.setCurrentRecipe(recipe);
if (player.openContainer instanceof ContainerWorktable) {
ContainerWorktable containerWorktable = (ContainerWorktable) player.openContainer;
containerWorktable.updateCraftMatrix();
}
Proxies.net.sendNetworkPacket(new PacketWorktableRecipeUpdate(worktable), pos, player.world);
}
}
}
}
@@ -12,54 +12,51 @@ package forestry.factory.network.packets;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.ForestryPacket;
import forestry.core.network.IForestryPacketClient;
import forestry.core.network.IForestryPacketHandlerClient;
import forestry.core.network.PacketBufferForestry;
import forestry.core.network.PacketIdClient;
import forestry.core.network.packets.PacketCoordinates;
import forestry.core.proxy.Proxies;
import forestry.factory.recipes.MemorizedRecipe;
import forestry.factory.tiles.TileWorktable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
/**
* Used to sync the worktable crafting result from Server to Client.
*/
public class PacketWorktableRecipeUpdate extends PacketCoordinates implements IForestryPacketClient {
private MemorizedRecipe recipe;
public PacketWorktableRecipeUpdate() {
}
public class PacketWorktableRecipeUpdate extends ForestryPacket implements IForestryPacketClient {
private final BlockPos pos;
private final MemorizedRecipe recipe;
public PacketWorktableRecipeUpdate(TileWorktable worktable) {
super(worktable);
this.pos = worktable.getPos();
this.recipe = worktable.getCurrentRecipe();
}
@Override
protected void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeStreamable(recipe);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
recipe = data.readStreamable(MemorizedRecipe.class);
}
@Override
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
if (tile instanceof TileWorktable) {
((TileWorktable) tile).setCurrentRecipe(recipe);
}
}
@Override
public PacketIdClient getPacketId() {
return PacketIdClient.WORKTABLE_CRAFTING_UPDATE;
}
@Override
protected void writeData(PacketBufferForestry data) {
data.writeBlockPos(pos);
data.writeStreamable(recipe);
}
public static class Handler implements IForestryPacketHandlerClient {
@Override
public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException {
BlockPos pos = data.readBlockPos();
MemorizedRecipe recipe = new MemorizedRecipe();
recipe.readData(data);
TileEntity tile = player.world.getTileEntity(pos);
if (tile instanceof TileWorktable) {
((TileWorktable) tile).setCurrentRecipe(recipe);
}
}
}
}
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.network.packets;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -16,46 +16,39 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
public class BottlerRecipe {
public static BottlerRecipe createFilled(ItemStack filled) {
if (filled == null) {
return null;
}
@Nullable
public static BottlerRecipe createEmptyingRecipe(ItemStack filled) {
ItemStack empty = filled.copy();
empty.stackSize = 1;
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(empty);
empty.setCount(1);
IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(empty);
if (fluidHandler == null) {
return null;
}
FluidStack drained = fluidHandler.drain(Integer.MAX_VALUE, true);
if (drained != null && drained.amount > 0) {
return new BottlerRecipe(empty, drained, filled, false);
return new BottlerRecipe(fluidHandler.getContainer(), drained, filled, false);
}
return null;
}
public static BottlerRecipe createEmpty(Fluid res, ItemStack empty) {
if (res == null || empty == null) {
return null;
}
@Nullable
public static BottlerRecipe createFillingRecipe(Fluid res, ItemStack empty) {
ItemStack filled = empty.copy();
filled.stackSize = 1;
filled.setCount(1);
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(filled);
IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(filled);
if (fluidHandler == null) {
return null;
}
int fillAmount = fluidHandler.fill(new FluidStack(res, Integer.MAX_VALUE), true);
if (fillAmount > 0) {
return new BottlerRecipe(empty, new FluidStack(res, fillAmount), filled, true);
return new BottlerRecipe(empty, new FluidStack(res, fillAmount), fluidHandler.getContainer(), true);
}
return null;
@@ -63,22 +56,21 @@ public class BottlerRecipe {
public final FluidStack fluid;
public final ItemStack inputStack;
@Nullable
public final ItemStack outputStack;
public final boolean fillRecipe;
public BottlerRecipe(ItemStack inputStack, FluidStack fluid, @Nullable ItemStack outputStack, boolean fillRecipe) {
public BottlerRecipe(ItemStack inputStack, FluidStack fluid, ItemStack outputStack, boolean fillRecipe) {
this.fluid = fluid;
this.inputStack = inputStack;
this.outputStack = outputStack;
this.fillRecipe = fillRecipe;
}
public boolean matchEmpty(ItemStack emptyCan, FluidStack resource) {
return emptyCan != null && resource != null && emptyCan.isItemEqual(inputStack) && resource.isFluidEqual(fluid) && fillRecipe;
return emptyCan.isEmpty() && emptyCan.isItemEqual(inputStack) && resource.isFluidEqual(fluid) && fillRecipe;
}
public boolean matchFilled(ItemStack filledCan) {
return outputStack != null && !fillRecipe && outputStack.isItemEqual(filledCan);
return !outputStack.isEmpty() && !fillRecipe && outputStack.isItemEqual(filledCan);
}
}
@@ -12,6 +12,7 @@ package forestry.factory.recipes;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@@ -25,11 +26,12 @@ public class CarpenterRecipe implements ICarpenterRecipe {
private final int packagingTime;
@Nullable
private final FluidStack liquid;
@Nullable
private final ItemStack box;
private final ShapedRecipeCustom internal;
public CarpenterRecipe(int packagingTime, @Nullable FluidStack liquid, @Nullable ItemStack box, ShapedRecipeCustom internal) {
public CarpenterRecipe(int packagingTime, @Nullable FluidStack liquid, ItemStack box, ShapedRecipeCustom internal) {
Preconditions.checkNotNull(box);
Preconditions.checkNotNull(internal);
this.packagingTime = packagingTime;
this.liquid = liquid;
this.box = box;
@@ -42,7 +44,6 @@ public class CarpenterRecipe implements ICarpenterRecipe {
}
@Override
@Nullable
public ItemStack getBox() {
return box;
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -43,12 +44,13 @@ public class CarpenterRecipeManager implements ICarpenterManager {
}
@Override
public void addRecipe(int packagingTime, FluidStack liquid, ItemStack box, ItemStack product, Object materials[]) {
public void addRecipe(int packagingTime, @Nullable FluidStack liquid, ItemStack box, ItemStack product, Object materials[]) {
ICarpenterRecipe recipe = new CarpenterRecipe(packagingTime, liquid, box, ShapedRecipeCustom.createShapedRecipe(product, materials));
addRecipe(recipe);
}
public static ICarpenterRecipe findMatchingRecipe(FluidStack liquid, ItemStack item, IInventory inventorycrafting) {
@Nullable
public static ICarpenterRecipe findMatchingRecipe(@Nullable FluidStack liquid, ItemStack item, IInventory inventorycrafting) {
for (ICarpenterRecipe recipe : recipes) {
if (matches(recipe, liquid, item, inventorycrafting)) {
return recipe;
@@ -57,7 +59,7 @@ public class CarpenterRecipeManager implements ICarpenterManager {
return null;
}
public static boolean matches(ICarpenterRecipe recipe, FluidStack resource, ItemStack item, IInventory inventoryCrafting) {
public static boolean matches(@Nullable ICarpenterRecipe recipe, @Nullable FluidStack resource, ItemStack item, IInventory inventoryCrafting) {
if (recipe == null) {
return false;
}
@@ -70,7 +72,7 @@ public class CarpenterRecipeManager implements ICarpenterManager {
}
ItemStack box = recipe.getBox();
if (box != null && !ItemStackUtil.isCraftingEquivalent(box, item)) {
if (!box.isEmpty() && !ItemStackUtil.isCraftingEquivalent(box, item)) {
return false;
}
@@ -79,7 +81,7 @@ public class CarpenterRecipeManager implements ICarpenterManager {
}
public static boolean isBox(ItemStack resource) {
if (resource == null) {
if (resource.isEmpty()) {
return false;
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
@@ -31,8 +32,9 @@ public class CentrifugeRecipeManager implements ICentrifugeManager {
addRecipe(recipe);
}
@Nullable
public static ICentrifugeRecipe findMatchingRecipe(ItemStack itemStack) {
if (itemStack == null) {
if (itemStack.isEmpty()) {
return null;
}
@@ -10,48 +10,46 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import forestry.api.recipes.IFabricatorRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.recipes.IFabricatorRecipe;
import forestry.core.recipes.ShapedRecipeCustom;
public class FabricatorRecipe implements IFabricatorRecipe {
private final ItemStack plan;
private final FluidStack molten;
private final ShapedRecipeCustom internal;
private final NonNullList<NonNullList<ItemStack>> ingredients;
private final ItemStack result;
public FabricatorRecipe(ItemStack plan, FluidStack molten, ItemStack result, Object[] ingredients) {
this(plan, molten, ShapedRecipeCustom.createShapedRecipe(result, ingredients));
}
public FabricatorRecipe(ItemStack plan, FluidStack molten, ShapedRecipeCustom internal) {
public FabricatorRecipe(ItemStack plan, FluidStack molten, ItemStack result, NonNullList<NonNullList<ItemStack>> ingredients) {
Preconditions.checkNotNull(plan);
Preconditions.checkNotNull(molten);
Preconditions.checkNotNull(result);
Preconditions.checkArgument(!result.isEmpty());
Preconditions.checkNotNull(ingredients);
this.plan = plan;
this.molten = molten;
this.internal = internal;
this.result = result;
this.ingredients = ingredients;
}
@Override
public Object[] getIngredients() {
return internal.getIngredients();
public NonNullList<NonNullList<ItemStack>> getIngredients() {
return ingredients;
}
@Override
public int getWidth() {
return internal.getWidth();
return 3;
}
@Override
public int getHeight() {
return internal.getHeight();
return 3;
}
@Override
@Nullable
public ItemStack getPlan() {
return plan;
}
@@ -63,6 +61,6 @@ public class FabricatorRecipe implements IFabricatorRecipe {
@Override
public ItemStack getRecipeOutput() {
return internal.getRecipeOutput();
return result;
}
}
@@ -10,20 +10,20 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.recipes.IFabricatorManager;
import forestry.api.recipes.IFabricatorRecipe;
import forestry.core.recipes.RecipeUtil;
import forestry.core.recipes.ShapedRecipeCustom;
import forestry.core.utils.ItemStackUtil;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
public class FabricatorRecipeManager implements IFabricatorManager {
@@ -31,15 +31,19 @@ public class FabricatorRecipeManager implements IFabricatorManager {
@Override
public void addRecipe(ItemStack plan, FluidStack molten, ItemStack result, Object[] pattern) {
IFabricatorRecipe recipe = new FabricatorRecipe(plan, molten, ShapedRecipeCustom.createShapedRecipe(result, pattern));
ShapedRecipeCustom patternRecipe = new ShapedRecipeCustom(result, pattern);
NonNullList<NonNullList<ItemStack>> ingredients = patternRecipe.getIngredients();
IFabricatorRecipe recipe = new FabricatorRecipe(plan, molten, result, ingredients);
addRecipe(recipe);
}
@Nullable
public static IFabricatorRecipe findMatchingRecipe(ItemStack plan, IInventory resources) {
ItemStack[][] gridResources = RecipeUtil.getResources(resources);
for (IFabricatorRecipe recipe : recipes) {
if (recipe.getPlan() != null && !ItemStackUtil.isCraftingEquivalent(recipe.getPlan(), plan)) {
if (!recipe.getPlan().isEmpty() && !ItemStackUtil.isCraftingEquivalent(recipe.getPlan(), plan)) {
continue;
}
if (RecipeUtil.matches(recipe.getIngredients(), recipe.getWidth(), recipe.getHeight(), gridResources)) {
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.factory.recipes;
import com.google.common.base.Preconditions;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@@ -23,12 +24,9 @@ public class FabricatorSmeltingRecipe implements IFabricatorSmeltingRecipe {
private final int meltingPoint;
public FabricatorSmeltingRecipe(ItemStack resource, FluidStack molten, int meltingPoint) {
if (resource == null) {
throw new IllegalArgumentException("Resource cannot be null");
}
if (molten == null) {
throw new IllegalArgumentException("Molten cannot be null");
}
Preconditions.checkNotNull(resource);
Preconditions.checkArgument(!resource.isEmpty());
Preconditions.checkNotNull(molten);
this.resource = resource;
this.product = molten;
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -26,8 +27,9 @@ import forestry.core.utils.ItemStackUtil;
public class FabricatorSmeltingRecipeManager implements IFabricatorSmeltingManager {
public static final Set<IFabricatorSmeltingRecipe> recipes = new HashSet<>();
@Nullable
public static IFabricatorSmeltingRecipe findMatchingSmelting(ItemStack resource) {
if (resource == null) {
if (resource.isEmpty()) {
return null;
}
@@ -42,9 +44,6 @@ public class FabricatorSmeltingRecipeManager implements IFabricatorSmeltingManag
@Override
public void addSmelting(ItemStack resource, FluidStack molten, int meltingPoint) {
if (resource == null || molten == null) {
return;
}
addRecipe(new FabricatorSmeltingRecipe(resource, molten, meltingPoint));
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.factory.recipes;
import com.google.common.base.Preconditions;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
@@ -26,21 +27,10 @@ public class FermenterRecipe implements IFermenterRecipe {
private final FluidStack fluidResource;
public FermenterRecipe(ItemStack resource, int fermentationValue, float modifier, Fluid output, FluidStack fluidResource) {
if (resource == null) {
throw new NullPointerException("Fermenter Resource cannot be null!");
}
if (resource.getItem() == null) {
throw new NullPointerException("Fermenter Resource item cannot be null!");
}
if (output == null) {
throw new NullPointerException("Fermenter Output cannot be null!");
}
if (fluidResource == null) {
throw new NullPointerException("Fermenter Liquid cannot be null!");
}
Preconditions.checkNotNull(resource, "Fermenter Resource cannot be null!");
Preconditions.checkArgument(!resource.isEmpty(), "Fermenter Resource item cannot be empty!");
Preconditions.checkNotNull(output, "Fermenter Output cannot be null!");
Preconditions.checkNotNull(fluidResource, "Fermenter Liquid cannot be null!");
this.resource = resource;
this.fermentationValue = fermentationValue;
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -41,6 +42,7 @@ public class FermenterRecipeManager implements IFermenterManager {
addRecipe(resource, fermentationValue, modifier, output, new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME));
}
@Nullable
public static IFermenterRecipe findMatchingRecipe(ItemStack res, FluidStack liqu) {
for (IFermenterRecipe recipe : recipes) {
if (matches(recipe, res, liqu)) {
@@ -57,11 +59,11 @@ public class FermenterRecipeManager implements IFermenterManager {
}
FluidStack fluid = recipe.getFluidResource();
return liqu != null && liqu.isFluidEqual(fluid);
return liqu.isFluidEqual(fluid);
}
public static boolean isResource(ItemStack resource) {
if (resource == null) {
if (resource.isEmpty()) {
return false;
}
@@ -20,10 +20,10 @@ public interface ISqueezerContainerRecipe {
int getProcessingTime();
@Nullable
ItemStack getRemnants();
float getRemnantsChance();
@Nullable
ISqueezerRecipe getSqueezerRecipe(ItemStack filledContainer);
}
@@ -11,26 +11,24 @@
package forestry.factory.recipes;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamable;
import forestry.core.network.PacketBufferForestry;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.factory.inventory.InventoryCraftingForestry;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
public final class MemorizedRecipe implements INbtWritable, INbtReadable, IStreamable {
private final InventoryCraftingForestry craftMatrix = new InventoryCraftingForestry();
private final List<ItemStack> recipeOutputs = new ArrayList<>();
private final NonNullList<ItemStack> recipeOutputs = NonNullList.create();
private int selectedRecipe;
private long lastUsed;
private boolean locked;
@@ -87,7 +85,7 @@ public final class MemorizedRecipe implements INbtWritable, INbtReadable, IStrea
public ItemStack getRecipeOutput() {
if (recipeOutputs.isEmpty()) {
return null;
return ItemStack.EMPTY;
} else {
return recipeOutputs.get(selectedRecipe);
}
@@ -136,7 +134,7 @@ public final class MemorizedRecipe implements INbtWritable, INbtReadable, IStrea
/* IStreamable */
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
public void writeData(PacketBufferForestry data) {
data.writeInventory(craftMatrix);
data.writeBoolean(locked);
data.writeItemStacks(recipeOutputs);
@@ -144,7 +142,7 @@ public final class MemorizedRecipe implements INbtWritable, INbtReadable, IStrea
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
public void readData(PacketBufferForestry data) throws IOException {
data.readInventory(craftMatrix);
locked = data.readBoolean();
data.readItemStacks(recipeOutputs);
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -31,7 +32,7 @@ public class MoistenerRecipeManager implements IMoistenerManager {
}
public static boolean isResource(ItemStack resource) {
if (resource == null) {
if (resource.isEmpty()) {
return false;
}
@@ -44,6 +45,7 @@ public class MoistenerRecipeManager implements IMoistenerManager {
return false;
}
@Nullable
public static IMoistenerRecipe findMatchingRecipe(ItemStack item) {
for (IMoistenerRecipe recipe : recipes) {
if (ItemStackUtil.isCraftingEquivalent(recipe.getResource(), item)) {
@@ -10,13 +10,16 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import forestry.api.core.INbtWritable;
import forestry.core.network.IStreamable;
import forestry.core.network.PacketBufferForestry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemMap;
import net.minecraft.item.ItemStack;
@@ -24,11 +27,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import forestry.api.core.INbtWritable;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamable;
public class RecipeMemory implements INbtWritable, IStreamable {
private static final int capacity = 9;
@@ -46,7 +44,7 @@ public class RecipeMemory implements INbtWritable, IStreamable {
memorizedRecipes = new LinkedList<>();
}
public RecipeMemory(@Nonnull NBTTagCompound nbt) {
public RecipeMemory(NBTTagCompound nbt) {
memorizedRecipes = new LinkedList<>();
if (!nbt.hasKey("RecipeMemory")) {
return;
@@ -61,16 +59,16 @@ public class RecipeMemory implements INbtWritable, IStreamable {
}
}
private static boolean isValid(MemorizedRecipe recipe) {
private static boolean isValid(@Nullable MemorizedRecipe recipe) {
if (recipe == null) {
return false;
}
ItemStack recipeOutput = recipe.getRecipeOutput();
if (recipeOutput == null) {
if (recipeOutput.isEmpty()) {
return false;
}
Item item = recipeOutput.getItem();
return item != null && !memoryBlacklist.contains(item.getClass());
return !memoryBlacklist.contains(item.getClass());
}
public void validate(World world) {
@@ -129,6 +127,7 @@ public class RecipeMemory implements INbtWritable, IStreamable {
memorizedRecipes.set(index, updatedRecipe);
}
@Nullable
private MemorizedRecipe getOldestUnlockedRecipe() {
MemorizedRecipe oldest = null;
for (MemorizedRecipe existing : memorizedRecipes) {
@@ -143,6 +142,7 @@ public class RecipeMemory implements INbtWritable, IStreamable {
return oldest;
}
@Nullable
public MemorizedRecipe getRecipe(int recipeIndex) {
if (recipeIndex < 0 || recipeIndex >= memorizedRecipes.size()) {
return null;
@@ -150,6 +150,7 @@ public class RecipeMemory implements INbtWritable, IStreamable {
return memorizedRecipes.get(recipeIndex);
}
@Nullable
public ItemStack getRecipeDisplayOutput(int recipeIndex) {
MemorizedRecipe recipe = getRecipe(recipeIndex);
if (recipe == null) {
@@ -160,10 +161,7 @@ public class RecipeMemory implements INbtWritable, IStreamable {
public boolean isLocked(int recipeIndex) {
MemorizedRecipe recipe = getRecipe(recipeIndex);
if (recipe == null) {
return false;
}
return recipe.isLocked();
return recipe != null && recipe.isLocked();
}
public void toggleLock(long worldTime, int recipeIndex) {
@@ -173,6 +171,7 @@ public class RecipeMemory implements INbtWritable, IStreamable {
}
}
@Nullable
private MemorizedRecipe getExistingMemorizedRecipe(ItemStack craftingRecipeOutput) {
for (MemorizedRecipe memorizedRecipe : memorizedRecipes) {
if (memorizedRecipe.hasRecipeOutput(craftingRecipeOutput)) {
@@ -198,12 +197,12 @@ public class RecipeMemory implements INbtWritable, IStreamable {
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
public void writeData(PacketBufferForestry data) {
data.writeStreamables(memorizedRecipes);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
public void readData(PacketBufferForestry data) throws IOException {
data.readStreamables(memorizedRecipes, MemorizedRecipe.class);
}
}
@@ -12,9 +12,11 @@ package forestry.factory.recipes;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import forestry.api.recipes.ISqueezerRecipe;
import forestry.core.utils.ItemStackUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
@@ -22,11 +24,14 @@ public class SqueezerContainerRecipe implements ISqueezerContainerRecipe {
private final ItemStack emptyContainer;
private final int processingTime;
@Nullable
private final ItemStack remnants;
private final float remnantsChance;
public SqueezerContainerRecipe(ItemStack emptyContainer, int processingTime, @Nullable ItemStack remnants, float remnantsChance) {
public SqueezerContainerRecipe(ItemStack emptyContainer, int processingTime, ItemStack remnants, float remnantsChance) {
Preconditions.checkNotNull(emptyContainer);
Preconditions.checkArgument(!emptyContainer.isEmpty());
Preconditions.checkNotNull(remnants);
this.emptyContainer = emptyContainer;
this.processingTime = processingTime;
this.remnants = remnants;
@@ -43,7 +48,6 @@ public class SqueezerContainerRecipe implements ISqueezerContainerRecipe {
return processingTime;
}
@Nullable
@Override
public ItemStack getRemnants() {
return remnants;
@@ -55,16 +59,19 @@ public class SqueezerContainerRecipe implements ISqueezerContainerRecipe {
}
@Override
@Nullable
public ISqueezerRecipe getSqueezerRecipe(ItemStack filledContainer) {
if (filledContainer == null) {
if (filledContainer.isEmpty()) {
return null;
}
FluidStack fluidOutput = FluidUtil.getFluidContained(filledContainer);
if (fluidOutput == null) {
return null;
}
ItemStack filledContainerCopy = ItemStackUtil.createSplitStack(filledContainer, 1);
return new SqueezerRecipe(processingTime, new ItemStack[]{filledContainerCopy}, fluidOutput, remnants, remnantsChance);
ItemStack filledContainerCopy = ItemStackUtil.createCopyWithCount(filledContainer, 1);
NonNullList<ItemStack> input = NonNullList.create();
input.add(filledContainerCopy);
return new SqueezerRecipe(processingTime, input, fluidOutput, remnants, remnantsChance);
}
}
@@ -10,10 +10,10 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.recipes.ISqueezerRecipe;
@@ -21,13 +21,17 @@ import forestry.api.recipes.ISqueezerRecipe;
public class SqueezerRecipe implements ISqueezerRecipe {
private final int processingTime;
private final ItemStack[] resources;
private final NonNullList<ItemStack> resources;
private final FluidStack fluidOutput;
@Nullable
private final ItemStack remnants;
private final float remnantsChance;
public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, @Nullable ItemStack remnants, float remnantsChance) {
public SqueezerRecipe(int processingTime, NonNullList<ItemStack> resources, FluidStack fluidOutput, ItemStack remnants, float remnantsChance) {
Preconditions.checkNotNull(resources);
Preconditions.checkArgument(!resources.isEmpty());
Preconditions.checkNotNull(fluidOutput);
Preconditions.checkNotNull(remnants);
this.processingTime = processingTime;
this.resources = resources;
this.fluidOutput = fluidOutput;
@@ -36,12 +40,11 @@ public class SqueezerRecipe implements ISqueezerRecipe {
}
@Override
public ItemStack[] getResources() {
public NonNullList<ItemStack> getResources() {
return resources;
}
@Override
@Nullable
public ItemStack getRemnants() {
return remnants;
}
@@ -17,6 +17,7 @@ import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.recipes.ISqueezerManager;
@@ -31,18 +32,32 @@ public class SqueezerRecipeManager implements ISqueezerManager {
public static final ItemStackMap<ISqueezerContainerRecipe> containerRecipes = new ItemStackMap<>();
@Override
public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid, @Nullable ItemStack remnants, int chance) {
public void addRecipe(int timePerItem, NonNullList<ItemStack> resources, FluidStack liquid, ItemStack remnants, int chance) {
ISqueezerRecipe recipe = new SqueezerRecipe(timePerItem, resources, liquid, remnants, chance / 100.0f);
addRecipe(recipe);
}
@Override
public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid) {
addRecipe(timePerItem, resources, liquid, null, 0);
public void addRecipe(int timePerItem, ItemStack resources, FluidStack liquid, ItemStack remnants, int chance) {
NonNullList<ItemStack> resourcesList = NonNullList.create();
resourcesList.add(resources);
addRecipe(timePerItem, resourcesList, liquid, remnants, chance);
}
@Override
public void addContainerRecipe(int timePerItem, ItemStack emptyContainer, @Nullable ItemStack remnants, float chance) {
public void addRecipe(int timePerItem, NonNullList<ItemStack> resources, FluidStack liquid) {
addRecipe(timePerItem, resources, liquid, ItemStack.EMPTY, 0);
}
@Override
public void addRecipe(int timePerItem, ItemStack resources, FluidStack liquid) {
NonNullList<ItemStack> resourcesList = NonNullList.create();
resourcesList.add(resources);
addRecipe(timePerItem, resourcesList, liquid);
}
@Override
public void addContainerRecipe(int timePerItem, ItemStack emptyContainer, ItemStack remnants, float chance) {
containerRecipes.put(emptyContainer, new SqueezerContainerRecipe(emptyContainer, timePerItem, remnants, chance));
}
@@ -55,7 +70,8 @@ public class SqueezerRecipeManager implements ISqueezerManager {
return containerRecipes.get(new ItemStack(filledContainer.getItem()));
}
public static ISqueezerRecipe findMatchingRecipe(ItemStack[] items) {
@Nullable
public static ISqueezerRecipe findMatchingRecipe(NonNullList<ItemStack> items) {
// Find container recipes
for (ItemStack itemStack : items) {
ISqueezerContainerRecipe containerRecipe = findMatchingContainerRecipe(itemStack);
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.factory.recipes;
import com.google.common.base.Preconditions;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.recipes.IStillRecipe;
@@ -20,13 +21,10 @@ public class StillRecipe implements IStillRecipe {
private final FluidStack output;
public StillRecipe(int timePerUnit, FluidStack input, FluidStack output) {
Preconditions.checkNotNull(input, "Still recipes need an input. Input was null.");
Preconditions.checkNotNull(output, "Still recipes need an output. Output was null.");
this.timePerUnit = timePerUnit;
if (input == null) {
throw new IllegalArgumentException("Still recipes need an input. Input was null.");
}
if (output == null) {
throw new IllegalArgumentException("Still recipes need an output. Output was null.");
}
this.input = input;
this.output = output;
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.factory.recipes;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -32,7 +33,8 @@ public class StillRecipeManager implements IStillManager {
addRecipe(recipe);
}
public static IStillRecipe findMatchingRecipe(FluidStack item) {
@Nullable
public static IStillRecipe findMatchingRecipe(@Nullable FluidStack item) {
if (item == null) {
return null;
}
@@ -44,7 +46,7 @@ public class StillRecipeManager implements IStillManager {
return null;
}
public static boolean matches(IStillRecipe recipe, FluidStack item) {
public static boolean matches(@Nullable IStillRecipe recipe, @Nullable FluidStack item) {
if (recipe == null || item == null) {
return false;
}
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.Rectangle;
import java.util.List;
@@ -61,10 +60,11 @@ import net.minecraft.item.ItemStack;
@JEIPlugin
public class FactoryJeiPlugin extends BlankModPlugin {
@Nullable
public static IJeiHelpers jeiHelpers;
@Override
public void register(@Nonnull IModRegistry registry) {
public void register(IModRegistry registry) {
jeiHelpers = registry.getJeiHelpers();
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
@@ -79,7 +79,7 @@ public class FactoryJeiPlugin extends BlankModPlugin {
new SqueezerRecipeCategory(guiHelper),
new StillRecipeCategory(guiHelper)
);
registry.addRecipeHandlers(
new BottlerRecipeHandler(),
new CarpenterRecipeHandler(),
@@ -101,7 +101,7 @@ public class FactoryJeiPlugin extends BlankModPlugin {
registry.addRecipes(MoistenerRecipeMaker.getMoistenerRecipes());
registry.addRecipes(RainmakerRecipeMaker.getRecipes());
registry.addRecipes(SqueezerRecipeMaker.getSqueezerRecipes());
registry.addRecipes(SqueezerRecipeMaker.getSqueezerContainerRecipes());
registry.addRecipes(SqueezerRecipeMaker.getSqueezerContainerRecipes(registry.getIngredientRegistry()));
registry.addRecipes(StillRecipeMaker.getStillRecipes());
registry.addRecipeClickArea(GuiBottler.class, 107, 33, 26, 22, ForestryRecipeCategoryUid.BOTTLER);
@@ -129,9 +129,9 @@ public class FactoryJeiPlugin extends BlankModPlugin {
registry.addRecipeCategoryCraftingItem(new ItemStack(blocks.worktable), VanillaRecipeCategoryUid.CRAFTING);
IRecipeTransferRegistry transferRegistry = registry.getRecipeTransferRegistry();
transferRegistry.addRecipeTransferHandler(new WorktableRecipeTransferHandler());
transferRegistry.addRecipeTransferHandler(new CarpenterRecipeTransferHandler());
transferRegistry.addRecipeTransferHandler(new FabricatorRecipeTransferHandler());
transferRegistry.addRecipeTransferHandler(new WorktableRecipeTransferHandler(), VanillaRecipeCategoryUid.CRAFTING);
transferRegistry.addRecipeTransferHandler(new CarpenterRecipeTransferHandler(), ForestryRecipeCategoryUid.CARPENTER);
transferRegistry.addRecipeTransferHandler(new FabricatorRecipeTransferHandler(), ForestryRecipeCategoryUid.FABRICATOR);
registry.addAdvancedGuiHandlers(new ForestryAdvancedGuiHandler());
@@ -142,7 +142,7 @@ public class FactoryJeiPlugin extends BlankModPlugin {
}
private static class ForestryAdvancedGuiHandler extends BlankAdvancedGuiHandler<GuiForestry> {
@Nonnull
@Override
public Class<GuiForestry> getGuiContainerClass() {
return GuiForestry.class;
@@ -151,8 +151,7 @@ public class FactoryJeiPlugin extends BlankModPlugin {
@Nullable
@Override
public List<Rectangle> getGuiExtraAreas(GuiForestry guiContainer) {
GuiForestry<?, ?> guiForestry = guiContainer;
return guiForestry.getExtraGuiAreas();
return ((GuiForestry<?, ?>) guiContainer).getExtraGuiAreas();
}
@Nullable
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
@@ -11,7 +10,6 @@ import forestry.factory.inventory.InventoryCraftingForestry;
import forestry.factory.recipes.MemorizedRecipe;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import net.minecraft.entity.player.EntityPlayer;
@@ -23,14 +21,9 @@ class WorktableRecipeTransferHandler implements IRecipeTransferHandler<Container
return ContainerWorktable.class;
}
@Override
public String getRecipeCategoryUid() {
return VanillaRecipeCategoryUid.CRAFTING;
}
@Nullable
@Override
public IRecipeTransferError transferRecipe(@Nonnull ContainerWorktable container, @Nonnull IRecipeLayout recipeLayout, @Nonnull EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
public IRecipeTransferError transferRecipe(ContainerWorktable container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
Map<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredients = recipeLayout.getItemStacks().getGuiIngredients();
InventoryCraftingForestry inventory = new InventoryCraftingForestry(container);
@@ -11,11 +11,6 @@ public class BottlerRecipeHandler implements IRecipeHandler<BottlerRecipeWrapper
return BottlerRecipeWrapper.class;
}
@Override
public String getRecipeCategoryUid() {
return ForestryRecipeCategoryUid.BOTTLER;
}
@Override
public String getRecipeCategoryUid(BottlerRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.BOTTLER;
@@ -3,8 +3,6 @@ package forestry.factory.recipes.jei.bottler;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.ImmutableList;
import forestry.core.config.Constants;
import mezz.jei.api.ingredients.IIngredientRegistry;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
@@ -12,6 +10,8 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
public class BottlerRecipeMaker {
@@ -20,25 +20,35 @@ public class BottlerRecipeMaker {
public static List<BottlerRecipeWrapper> getBottlerRecipes(IIngredientRegistry ingredientRegistry) {
List<BottlerRecipeWrapper> recipes = new ArrayList<>();
for (ItemStack stack : ingredientRegistry.getIngredients(ItemStack.class)) {
if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidHandlerItem fluidHandler = stack.copy().getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
if (fluidHandler != null) {
final boolean canDrain = canDrain(fluidHandler);
final boolean canFill = canFill(fluidHandler);
ImmutableList<ItemStack> ingredients = ingredientRegistry.getIngredients(ItemStack.class);
for (ItemStack ingredient : ingredients) {
if (ingredient.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) {
FluidStack drain;
ItemStack emptyStack = ingredient.copy();
IFluidHandler emptyCapability = emptyStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
drain = emptyCapability.drain(Constants.PROCESSOR_TANK_CAPACITY, true);
if (drain != null) {
if (emptyStack.stackSize == 0) {
emptyStack = null;
if (canDrain) {
FluidStack drainedFluid = fluidHandler.drain(Integer.MAX_VALUE, true);
if (drainedFluid != null) {
ItemStack drained = fluidHandler.getContainer();
recipes.add(new BottlerRecipeWrapper(stack, drainedFluid, drained, false));
}
}
recipes.add(new BottlerRecipeWrapper(ingredient, drain, emptyStack, false));
addFillRecipe(ingredient, drain.getFluid(), recipes);
} else {
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
addFillRecipe(ingredient, fluid, recipes);
if (canFill) {
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
IFluidHandlerItem fillingCapability = stack.copy().getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
if (fillingCapability != null) {
int fill = fillingCapability.fill(new FluidStack(fluid, Integer.MAX_VALUE), true);
if (fill > 0) {
FluidStack filledFluid = new FluidStack(fluid, fill);
ItemStack filled = fluidHandler.getContainer();
recipes.add(new BottlerRecipeWrapper(stack, filledFluid, filled, true));
}
} else {
break;
}
}
}
}
}
@@ -46,13 +56,21 @@ public class BottlerRecipeMaker {
return recipes;
}
private static void addFillRecipe(ItemStack ingredient, Fluid fluid, List<BottlerRecipeWrapper> recipes) {
ItemStack fillStack = ingredient.copy();
IFluidHandler fillCapability = fillStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
int fill = fillCapability.fill(new FluidStack(fluid, Constants.PROCESSOR_TANK_CAPACITY), true);
if (fill > 0) {
FluidStack filledFluid = new FluidStack(fluid, fill);
recipes.add(new BottlerRecipeWrapper(ingredient, filledFluid, fillStack, true));
private static boolean canDrain(IFluidHandler fluidHandler) {
for (IFluidTankProperties properties : fluidHandler.getTankProperties()) {
if (properties.canDrain()) {
return true;
}
}
return false;
}
private static boolean canFill(IFluidHandler fluidHandler) {
for (IFluidTankProperties properties : fluidHandler.getTankProperties()) {
if (properties.canFill()) {
return true;
}
}
return false;
}
}
@@ -1,7 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei.bottler;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,7 +1,6 @@
package forestry.factory.recipes.jei.carpenter;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import forestry.api.recipes.ICarpenterRecipe;
@@ -9,7 +8,6 @@ import forestry.api.recipes.IDescriptiveRecipe;
import forestry.core.recipes.jei.ForestryRecipeCategory;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import forestry.core.render.ForestryResource;
import forestry.factory.recipes.jei.FactoryJeiPlugin;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.ICraftingGridHelper;
import mezz.jei.api.gui.IDrawable;
@@ -19,9 +17,9 @@ import mezz.jei.api.gui.IGuiFluidStackGroup;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IStackHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
@@ -30,70 +28,70 @@ public class CarpenterRecipeCategory extends ForestryRecipeCategory<CarpenterRec
private static final int boxSlot = 0;
private static final int craftOutputSlot = 1;
private static final int craftInputSlot = 2;
private static final int inputTank = 0;
private final static ResourceLocation guiTexture = new ForestryResource("textures/gui/carpenter.png");
@Nonnull
private final ICraftingGridHelper craftingGridHelper;
@Nonnull
private final IDrawableAnimated arrow;
@Nonnull
private final IDrawable tankOverlay;
public CarpenterRecipeCategory(IGuiHelper guiHelper) {
super(guiHelper.createDrawable(guiTexture, 9, 16, 158, 61), "tile.for.carpenter.name");
craftingGridHelper = guiHelper.createCraftingGridHelper(craftInputSlot, craftOutputSlot);
IDrawableStatic arrowDrawable = guiHelper.createDrawable(guiTexture, 176, 59, 4, 17);
this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.BOTTOM, false);
this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58);
}
@Nonnull
@Override
public String getUid() {
return ForestryRecipeCategoryUid.CARPENTER;
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft) {
public void drawExtras(Minecraft minecraft) {
arrow.draw(minecraft, 89, 34);
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull CarpenterRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
public void setRecipe(IRecipeLayout recipeLayout, CarpenterRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
guiItemStacks.init(boxSlot, true, 73, 3);
guiItemStacks.init(craftOutputSlot, false, 70, 34);
for (int y = 0; y < 3; ++y) {
for (int x = 0; x < 3; ++x) {
int index = craftInputSlot + x + y * 3;
guiItemStacks.init(index, true, x * 18, 3 + y * 18);
}
}
guiFluidStacks.init(inputTank, true, 141, 1, 16, 58, 10000, false, tankOverlay);
ICarpenterRecipe recipe = recipeWrapper.getRecipe();
ItemStack box = recipe.getBox();
if (box != null) {
if (!box.isEmpty()) {
guiItemStacks.set(boxSlot, box);
}
List<ItemStack> outputs = ingredients.getOutputs(ItemStack.class);
craftingGridHelper.setOutput(guiItemStacks, outputs);
List<List<ItemStack>> outputs = ingredients.getOutputs(ItemStack.class);
guiItemStacks.set(craftOutputSlot, outputs.get(0));
IDescriptiveRecipe craftingGridRecipe = recipe.getCraftingGridRecipe();
List<Object> inputs = Arrays.asList(craftingGridRecipe.getIngredients());
IStackHelper stackHelper = FactoryJeiPlugin.jeiHelpers.getStackHelper();
List<List<ItemStack>> craftInputs = stackHelper.expandRecipeItemStackInputs(inputs);
craftingGridHelper.setInputStacks(guiItemStacks, craftInputs, craftingGridRecipe.getWidth(), craftingGridRecipe.getHeight());
NonNullList<NonNullList<ItemStack>> inputs = craftingGridRecipe.getIngredients();
List<List<ItemStack>> inputStacks = new ArrayList<>();
for (List<ItemStack> stacks : inputs) {
List<ItemStack> copy = new ArrayList<>();
copy.addAll(stacks);
inputStacks.add(copy);
}
craftingGridHelper.setInputs(guiItemStacks, inputStacks, craftingGridRecipe.getWidth(), craftingGridRecipe.getHeight());
List<List<FluidStack>> fluidInputs = ingredients.getInputs(FluidStack.class);
if (!fluidInputs.isEmpty()) {
@@ -1,7 +1,5 @@
package forestry.factory.recipes.jei.carpenter;
import javax.annotation.Nonnull;
import forestry.api.recipes.ICarpenterRecipe;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
@@ -9,44 +7,29 @@ import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
public class CarpenterRecipeHandler implements IRecipeHandler<CarpenterRecipeWrapper> {
@Nonnull
@Override
public Class<CarpenterRecipeWrapper> getRecipeClass() {
return CarpenterRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid( CarpenterRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.CARPENTER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull CarpenterRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.CARPENTER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull CarpenterRecipeWrapper recipe) {
public IRecipeWrapper getRecipeWrapper( CarpenterRecipeWrapper recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull CarpenterRecipeWrapper wrapper) {
public boolean isRecipeValid( CarpenterRecipeWrapper wrapper) {
ICarpenterRecipe recipe = wrapper.getRecipe();
if (recipe.getPackagingTime() <= 0) {
return false;
}
if (recipe.getCraftingGridRecipe() == null || recipe.getCraftingGridRecipe().getIngredients() == null) {
return false;
}
int inputCount = 0;
for (Object ingredient : recipe.getCraftingGridRecipe().getIngredients()) {
inputCount++;
}
int inputCount = recipe.getCraftingGridRecipe().getIngredients().size();
return inputCount > 0;
}
@@ -3,7 +3,6 @@ package forestry.factory.recipes.jei.carpenter;
import java.util.Map.Entry;
import forestry.core.proxy.Proxies;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import forestry.factory.gui.ContainerCarpenter;
import forestry.factory.network.packets.PacketRecipeTransferRequest;
import mezz.jei.api.gui.IGuiIngredient;
@@ -13,6 +12,7 @@ import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
public class CarpenterRecipeTransferHandler implements IRecipeTransferHandler<ContainerCarpenter> {
@@ -21,24 +21,19 @@ public class CarpenterRecipeTransferHandler implements IRecipeTransferHandler<Co
return ContainerCarpenter.class;
}
@Override
public String getRecipeCategoryUid() {
return ForestryRecipeCategoryUid.CARPENTER;
}
@Override
public IRecipeTransferError transferRecipe(ContainerCarpenter container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
if(doTransfer){
IInventory craftingInventory = container.getCarpenter().getCraftingInventory();
ItemStack[] items = new ItemStack[9];
NonNullList<ItemStack> items = NonNullList.withSize(9, ItemStack.EMPTY);
for(Entry<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredientEntry : recipeLayout.getItemStacks().getGuiIngredients().entrySet()){
IGuiIngredient<ItemStack> guiIngredient = guiIngredientEntry.getValue();
if(guiIngredientEntry != null && guiIngredient.getDisplayedIngredient() != null){
if(guiIngredient != null && guiIngredient.getDisplayedIngredient() != null){
int index = guiIngredientEntry.getKey();
if (index >= 2) {
ItemStack ingredient = guiIngredient.getDisplayedIngredient().copy();
craftingInventory.setInventorySlotContents(index - 2, ingredient);
items[index - 2] = ingredient;
items.set(index - 2, ingredient);
}
}
}
@@ -1,35 +1,38 @@
package forestry.factory.recipes.jei.carpenter;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import forestry.api.recipes.ICarpenterRecipe;
import forestry.api.recipes.IDescriptiveRecipe;
import forestry.core.recipes.jei.ForestryRecipeWrapper;
import forestry.factory.recipes.jei.FactoryJeiPlugin;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IStackHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
public class CarpenterRecipeWrapper extends ForestryRecipeWrapper<ICarpenterRecipe> {
public CarpenterRecipeWrapper(@Nonnull ICarpenterRecipe recipe) {
public CarpenterRecipeWrapper(ICarpenterRecipe recipe) {
super(recipe);
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
public void getIngredients(IIngredients ingredients) {
ICarpenterRecipe recipe = getRecipe();
IDescriptiveRecipe craftingGridRecipe = recipe.getCraftingGridRecipe();
Object[] inputs = craftingGridRecipe.getIngredients();
IStackHelper stackHelper = FactoryJeiPlugin.jeiHelpers.getStackHelper();
NonNullList<NonNullList<ItemStack>> inputs = craftingGridRecipe.getIngredients();
List<List<ItemStack>> inputStacks = new ArrayList<>();
for (List<ItemStack> stacks : inputs) {
List<ItemStack> copy = new ArrayList<>();
copy.addAll(stacks);
inputStacks.add(copy);
}
List<List<ItemStack>> inputStacks = stackHelper.expandRecipeItemStackInputs(Arrays.asList(inputs));
ItemStack box = recipe.getBox();
if (box != null) {
if (!box.isEmpty()) {
inputStacks.add(Collections.singletonList(box));
}
ingredients.setInputLists(ItemStack.class, inputStacks);
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei.carpenter;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei.centrifuge;
import javax.annotation.Nonnull;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@@ -26,44 +25,38 @@ import net.minecraft.util.ResourceLocation;
public class CentrifugeRecipeCategory extends ForestryRecipeCategory<CentrifugeRecipeWrapper> {
private static final int[][] OUTPUTS = new int[][]{{0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1}, {0, 2}, {1, 2}, {2, 2}};
private static final Comparator<Entry<ItemStack, Float>> highestChanceComparator = new Comparator<Entry<ItemStack, Float>>() {
@Override
public int compare(Entry<ItemStack, Float> o1, Entry<ItemStack, Float> o2) {
return o2.getValue().compareTo(o1.getValue());
}
};
private static final Comparator<Entry<ItemStack, Float>> highestChanceComparator = (o1, o2) -> o2.getValue().compareTo(o1.getValue());
private static final int inputSlot = 0;
private static final int outputSlot = 1;
private final static ResourceLocation guiTexture = new ForestryResource("textures/gui/centrifugesocket2.png");
@Nonnull
private final IDrawableAnimated arrow;
public CentrifugeRecipeCategory(IGuiHelper guiHelper) {
super(guiHelper.createDrawable(guiTexture, 11, 18, 154, 54), "tile.for.centrifuge.name");
IDrawableStatic arrowDrawable = guiHelper.createDrawable(guiTexture, 176, 0, 4, 17);
this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 80, IDrawableAnimated.StartDirection.BOTTOM, false);
}
@Nonnull
@Override
public String getUid() {
return ForestryRecipeCategoryUid.CENTRIFUGE;
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft) {
public void drawExtras(Minecraft minecraft) {
arrow.draw(minecraft, 32, 18);
arrow.draw(minecraft, 56, 18);
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull CentrifugeRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
public void setRecipe(IRecipeLayout recipeLayout, CentrifugeRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(inputSlot, true, 4, 18);
List<List<ItemStack>> inputs = ingredients.getInputs(ItemStack.class);
guiItemStacks.set(inputSlot, inputs.get(0));
@@ -73,7 +66,7 @@ public class CentrifugeRecipeCategory extends ForestryRecipeCategory<CentrifugeR
setResults(tooltip, products, guiItemStacks);
guiItemStacks.addTooltipCallback(tooltip);
}
private static void setResults(ForestryTooltipCallback tooltip, Map<ItemStack, Float> outputs, IGuiItemStackGroup guiItemStacks) {
Set<Entry<ItemStack, Float>> entrySet = outputs.entrySet();
if (entrySet.isEmpty()) {
@@ -1,54 +1,37 @@
package forestry.factory.recipes.jei.centrifuge;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import forestry.api.recipes.ICentrifugeRecipe;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
public class CentrifugeRecipeHandler implements IRecipeHandler<CentrifugeRecipeWrapper> {
@Nonnull
@Override
public Class<CentrifugeRecipeWrapper> getRecipeClass() {
return CentrifugeRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid(CentrifugeRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.CENTRIFUGE;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull CentrifugeRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.CENTRIFUGE;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull CentrifugeRecipeWrapper recipe) {
public IRecipeWrapper getRecipeWrapper(CentrifugeRecipeWrapper recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull CentrifugeRecipeWrapper wrapper) {
public boolean isRecipeValid(CentrifugeRecipeWrapper wrapper) {
ICentrifugeRecipe recipe = wrapper.getRecipe();
if (recipe.getProcessingTime() <= 0) {
return false;
}
if (recipe.getInput() == null) {
if (recipe.getInput().isEmpty()) {
return false;
}
int inputCount = 0;
for (ItemStack ingredient : recipe.getAllProducts().keySet()) {
inputCount++;
}
int inputCount = recipe.getAllProducts().keySet().size();
return inputCount > 0;
}
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei.centrifuge;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
@@ -11,13 +10,12 @@ import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.item.ItemStack;
public class CentrifugeRecipeWrapper extends ForestryRecipeWrapper<ICentrifugeRecipe> {
public CentrifugeRecipeWrapper(@Nonnull ICentrifugeRecipe recipe) {
public CentrifugeRecipeWrapper(ICentrifugeRecipe recipe) {
super(recipe);
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
public void getIngredients(IIngredients ingredients) {
ICentrifugeRecipe recipe = getRecipe();
ingredients.setInputs(ItemStack.class, Collections.singletonList(recipe.getInput()));
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei.centrifuge;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei.fabricator;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -29,49 +28,47 @@ public class FabricatorRecipeCategory extends ForestryRecipeCategory<FabricatorR
private static final int smeltingInputSlot = 1;
private static final int craftOutputSlot = 2;
private static final int craftInputSlot = 3;
private static final int inputTank = 0;
private final static ResourceLocation guiTexture = new ForestryResource("textures/gui/fabricator.png");
@Nonnull
private final ICraftingGridHelper craftingGridHelper;
public FabricatorRecipeCategory(IGuiHelper guiHelper) {
super(guiHelper.createDrawable(guiTexture, 20, 16, 136, 54), "tile.for.fabricator.name");
craftingGridHelper = guiHelper.createCraftingGridHelper(craftInputSlot, craftOutputSlot);
}
@Nonnull
@Override
public String getUid() {
return ForestryRecipeCategoryUid.FABRICATOR;
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull FabricatorRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
public void setRecipe(IRecipeLayout recipeLayout, FabricatorRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
guiItemStacks.init(planSlot, true, 118, 0);
guiItemStacks.init(smeltingInputSlot, true, 5, 4);
guiItemStacks.init(craftOutputSlot, false, 118, 36);
for (int y = 0; y < 3; ++y) {
for (int x = 0; x < 3; ++x) {
int index = craftInputSlot + x + y * 3;
guiItemStacks.init(index, true, 46 + x * 18, y * 18);
}
}
guiFluidStacks.init(inputTank, true, 6, 32, 16, 16, 2000, false, null);
IFabricatorRecipe recipe = recipeWrapper.getRecipe();
ItemStack plan = recipe.getPlan();
if (plan != null) {
if (!plan.isEmpty()) {
guiItemStacks.set(planSlot, plan);
}
@@ -84,18 +81,18 @@ public class FabricatorRecipeCategory extends ForestryRecipeCategory<FabricatorR
guiItemStacks.set(smeltingInputSlot, smeltingInput);
}
List<ItemStack> itemOutputs = ingredients.getOutputs(ItemStack.class);
craftingGridHelper.setOutput(guiItemStacks, itemOutputs);
List<List<ItemStack>> itemOutputs = ingredients.getOutputs(ItemStack.class);
guiItemStacks.set(craftOutputSlot, itemOutputs.get(0));
List<List<ItemStack>> itemStackInputs = ingredients.getInputs(ItemStack.class);
craftingGridHelper.setInputStacks(guiItemStacks, itemStackInputs, recipe.getWidth(), recipe.getHeight());
craftingGridHelper.setInputs(guiItemStacks, itemStackInputs, recipe.getWidth(), recipe.getHeight());
List<List<FluidStack>> fluidInputs = ingredients.getInputs(FluidStack.class);
if (!fluidInputs.isEmpty()) {
guiFluidStacks.set(inputTank, fluidInputs.get(0));
}
}
private static Map<Fluid, List<IFabricatorSmeltingRecipe>> getSmeltingInputs() {
Map<Fluid, List<IFabricatorSmeltingRecipe>> smeltingInputs = new HashMap<>();
for (IFabricatorSmeltingRecipe smelting : FabricatorSmeltingRecipeManager.recipes) {
@@ -1,55 +1,30 @@
package forestry.factory.recipes.jei.fabricator;
import javax.annotation.Nonnull;
import forestry.api.recipes.IFabricatorRecipe;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
public class FabricatorRecipeHandler implements IRecipeHandler<FabricatorRecipeWrapper> {
@Nonnull
@Override
public Class<FabricatorRecipeWrapper> getRecipeClass() {
return FabricatorRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid(FabricatorRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.FABRICATOR;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull FabricatorRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.FABRICATOR;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull FabricatorRecipeWrapper recipe) {
public IRecipeWrapper getRecipeWrapper(FabricatorRecipeWrapper recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull FabricatorRecipeWrapper wrapper) {
public boolean isRecipeValid(FabricatorRecipeWrapper wrapper) {
IFabricatorRecipe recipe = wrapper.getRecipe();
if (recipe.getIngredients() == null) {
return false;
}
if (recipe.getLiquid() == null) {
return false;
}
if (recipe.getRecipeOutput() == null) {
return false;
}
int inputCount = 0;
for (Object ingredient : recipe.getIngredients()) {
inputCount++;
}
int inputCount = recipe.getIngredients().size();
return inputCount > 0;
}
@@ -3,7 +3,6 @@ package forestry.factory.recipes.jei.fabricator;
import java.util.Map.Entry;
import forestry.core.proxy.Proxies;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import forestry.factory.gui.ContainerFabricator;
import forestry.factory.network.packets.PacketRecipeTransferRequest;
import mezz.jei.api.gui.IGuiIngredient;
@@ -13,6 +12,7 @@ import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
public class FabricatorRecipeTransferHandler implements IRecipeTransferHandler<ContainerFabricator> {
@@ -21,24 +21,19 @@ public class FabricatorRecipeTransferHandler implements IRecipeTransferHandler<C
return ContainerFabricator.class;
}
@Override
public String getRecipeCategoryUid() {
return ForestryRecipeCategoryUid.FABRICATOR;
}
@Override
public IRecipeTransferError transferRecipe(ContainerFabricator container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
if(doTransfer){
if (doTransfer) {
IInventory craftingInventory = container.getFabricator().getCraftingInventory();
ItemStack[] items = new ItemStack[9];
for(Entry<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredientEntry : recipeLayout.getItemStacks().getGuiIngredients().entrySet()){
NonNullList<ItemStack> items = NonNullList.withSize(9, ItemStack.EMPTY);
for (Entry<Integer, ? extends IGuiIngredient<ItemStack>> guiIngredientEntry : recipeLayout.getItemStacks().getGuiIngredients().entrySet()) {
IGuiIngredient<ItemStack> guiIngredient = guiIngredientEntry.getValue();
int index = guiIngredientEntry.getKey();
if (index >= 3 && guiIngredientEntry != null && guiIngredient.getDisplayedIngredient() != null) {
ItemStack ingredient =guiIngredient.getDisplayedIngredient().copy();
craftingInventory.setInventorySlotContents(index - 3, ingredient);
items[index - 3] = ingredient;
}
if (index >= 3 && guiIngredient.getDisplayedIngredient() != null) {
ItemStack ingredient = guiIngredient.getDisplayedIngredient().copy();
craftingInventory.setInventorySlotContents(index - 3, ingredient);
items.set(index - 3, ingredient);
}
}
Proxies.net.sendToServer(new PacketRecipeTransferRequest(container.getFabricator(), items));
}
@@ -1,32 +1,35 @@
package forestry.factory.recipes.jei.fabricator;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import forestry.api.recipes.IFabricatorRecipe;
import forestry.core.recipes.jei.ForestryRecipeWrapper;
import forestry.factory.recipes.jei.FactoryJeiPlugin;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IStackHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
public class FabricatorRecipeWrapper extends ForestryRecipeWrapper<IFabricatorRecipe> {
public FabricatorRecipeWrapper(@Nonnull IFabricatorRecipe recipe) {
public FabricatorRecipeWrapper(IFabricatorRecipe recipe) {
super(recipe);
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
public void getIngredients(IIngredients ingredients) {
IFabricatorRecipe recipe = getRecipe();
IStackHelper stackHelper = FactoryJeiPlugin.jeiHelpers.getStackHelper();
Object[] itemInputs = recipe.getIngredients();
List<List<ItemStack>> itemStackInputs = stackHelper.expandRecipeItemStackInputs(Arrays.asList(itemInputs));
ingredients.setInputLists(ItemStack.class, itemStackInputs);
NonNullList<NonNullList<ItemStack>> itemInputs = recipe.getIngredients();
List<List<ItemStack>> inputStacks = new ArrayList<>();
for (List<ItemStack> stacks : itemInputs) {
List<ItemStack> copy = new ArrayList<>();
copy.addAll(stacks);
inputStacks.add(copy);
}
ingredients.setInputLists(ItemStack.class, inputStacks);
ingredients.setInputs(FluidStack.class, Collections.singletonList(getRecipe().getLiquid()));
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei.fabricator;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,7 +1,5 @@
package forestry.factory.recipes.jei.fermenter;
import javax.annotation.Nonnull;
import forestry.core.recipes.jei.ForestryRecipeCategory;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import forestry.core.render.ForestryResource;
@@ -20,48 +18,45 @@ public class FermenterRecipeCategory extends ForestryRecipeCategory<FermenterRec
private static final int resourceSlot = 0;
private static final int fuelSlot = 1;
private static final int inputTank = 0;
private static final int outputTank = 1;
private final static ResourceLocation guiTexture = new ForestryResource("textures/gui/fermenter.png");
@Nonnull
private static final ResourceLocation guiTexture = new ForestryResource("textures/gui/fermenter.png");
private final IDrawableAnimated progressBar0;
@Nonnull
private final IDrawableAnimated progressBar1;
@Nonnull
private final IDrawable tankOverlay;
public FermenterRecipeCategory(IGuiHelper guiHelper) {
super(guiHelper.createDrawable(guiTexture, 34, 18, 108, 60), "tile.for.fermenter.name");
IDrawableStatic progressBarDrawable0 = guiHelper.createDrawable(guiTexture, 176, 60, 4, 18);
this.progressBar0 = guiHelper.createAnimatedDrawable(progressBarDrawable0, 40, IDrawableAnimated.StartDirection.BOTTOM, false);
IDrawableStatic progressBarDrawable1 = guiHelper.createDrawable(guiTexture, 176, 78, 4, 18);
this.progressBar1 = guiHelper.createAnimatedDrawable(progressBarDrawable1, 80, IDrawableAnimated.StartDirection.BOTTOM, false);
this.tankOverlay = guiHelper.createDrawable(guiTexture, 192, 0, 16, 58);
}
@Nonnull
@Override
public String getUid() {
return ForestryRecipeCategoryUid.FERMENTER;
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft) {
public void drawExtras(Minecraft minecraft) {
progressBar0.draw(minecraft, 40, 14);
progressBar1.draw(minecraft, 64, 28);
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull FermenterRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
public void setRecipe(IRecipeLayout recipeLayout, FermenterRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
guiItemStacks.init(resourceSlot, true, 50, 4);
guiItemStacks.init(fuelSlot, true, 40, 38);
guiFluidStacks.init(inputTank, true, 1, 1, 16, 58, 3000, false, tankOverlay);
guiFluidStacks.init(outputTank, false, 91, 1, 16, 58, 3000, false, tankOverlay);
@@ -1,55 +1,30 @@
package forestry.factory.recipes.jei.fermenter;
import javax.annotation.Nonnull;
import forestry.api.recipes.IFermenterRecipe;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
public class FermenterRecipeHandler implements IRecipeHandler<FermenterRecipeWrapper> {
@Nonnull
@Override
public Class<FermenterRecipeWrapper> getRecipeClass() {
return FermenterRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid(FermenterRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.FERMENTER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull FermenterRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.FERMENTER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull FermenterRecipeWrapper recipe) {
public IRecipeWrapper getRecipeWrapper(FermenterRecipeWrapper recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull FermenterRecipeWrapper wrapper) {
public boolean isRecipeValid(FermenterRecipeWrapper wrapper) {
IFermenterRecipe recipe = wrapper.getRecipe();
if (recipe.getFermentationValue() <= 0) {
return false;
}
if (recipe.getModifier() <= 0) {
return false;
}
if (recipe.getFluidResource() == null) {
return false;
}
if (recipe.getResource() == null) {
return false;
}
return recipe.getOutput() != null;
return recipe.getFermentationValue() > 0 &&
!(recipe.getModifier() <= 0);
}
}
@@ -19,7 +19,7 @@ public class FermenterRecipeMaker {
public static List<FermenterRecipeWrapper> getFermenterRecipes(IStackHelper stackHelper) {
List<FermenterRecipeWrapper> recipes = new ArrayList<>();
for (IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) {
if (recipe.getResource() != null) {
if (!recipe.getResource().isEmpty()) {
if (recipe.getResource().getItem() instanceof IVariableFermentable) {
for (ItemStack stack : stackHelper.getSubtypes(recipe.getResource())) {
recipes.add(new FermenterRecipeWrapper(recipe, stack));
@@ -28,7 +28,7 @@ public class FermenterRecipeMaker {
recipes.add(new FermenterRecipeWrapper(recipe, recipe.getResource()));
}
} else {
Log.error("Null resource for recipe");
Log.error("Empty resource for recipe");
}
}
return recipes;
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei.fermenter;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -16,17 +15,15 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class FermenterRecipeWrapper extends ForestryRecipeWrapper<IFermenterRecipe> {
@Nonnull
private final ItemStack fermentable;
public FermenterRecipeWrapper(@Nonnull IFermenterRecipe recipe, @Nonnull ItemStack fermentable) {
public FermenterRecipeWrapper(IFermenterRecipe recipe, ItemStack fermentable) {
super(recipe);
this.fermentable = fermentable;
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
public void getIngredients(IIngredients ingredients) {
List<ItemStack> fuelInputs = new ArrayList<>();
for (FermenterFuel fuel : FuelManager.fermenterFuel.values()) {
fuelInputs.add(fuel.getItem());
@@ -48,9 +45,4 @@ public class FermenterRecipeWrapper extends ForestryRecipeWrapper<IFermenterReci
FluidStack fluidOutput = new FluidStack(getRecipe().getOutput(), amount);
ingredients.setOutput(FluidStack.class, fluidOutput);
}
@Nonnull
public ItemStack getFermentable() {
return fermentable;
}
}
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei.fermenter;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,7 +1,5 @@
package forestry.factory.recipes.jei.moistener;
import javax.annotation.Nonnull;
import forestry.core.recipes.jei.ForestryRecipeCategory;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import forestry.core.render.ForestryResource;
@@ -22,50 +20,47 @@ public class MoistenerRecipeCategory extends ForestryRecipeCategory<MoistenerRec
private static final int productSlot = 1;
private static final int fuelItemSlot = 2;
private static final int fuelProductSlot = 3;
private static final int inputTank = 0;
private final static ResourceLocation guiTexture = new ForestryResource("textures/gui/moistener.png");
@Nonnull
private static final ResourceLocation guiTexture = new ForestryResource("textures/gui/moistener.png");
private final IDrawableAnimated arrow;
@Nonnull
private final IDrawableAnimated progressBar;
@Nonnull
private final IDrawable tankOverlay;
public MoistenerRecipeCategory(IGuiHelper guiHelper) {
super(guiHelper.createDrawable(guiTexture, 15, 15, 145, 60), "tile.for.moistener.name");
IDrawableStatic arrowDrawable = guiHelper.createDrawable(guiTexture, 176, 91, 29, 55);
this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 80, IDrawableAnimated.StartDirection.BOTTOM, false);
IDrawableStatic progressBar = guiHelper.createDrawable(guiTexture, 176, 74, 16, 15);
this.progressBar = guiHelper.createAnimatedDrawable(progressBar, 160, IDrawableAnimated.StartDirection.LEFT, false);
this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58);
}
@Nonnull
@Override
public String getUid() {
return ForestryRecipeCategoryUid.MOISTENER;
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft) {
public void drawExtras(Minecraft minecraft) {
arrow.draw(minecraft, 78, 2);
progressBar.draw(minecraft, 109, 22);
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull MoistenerRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
public void setRecipe(IRecipeLayout recipeLayout, MoistenerRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
guiItemStacks.init(resourceSlot, true, 127, 3);
guiItemStacks.init(fuelItemSlot, true, 23, 42);
guiItemStacks.init(productSlot, false, 127, 39);
guiItemStacks.init(fuelProductSlot, false, 89, 21);
guiFluidStacks.init(inputTank, true, 1, 1, 16, 58, 10000, false, tankOverlay);
guiItemStacks.set(ingredients);
@@ -1,7 +1,5 @@
package forestry.factory.recipes.jei.moistener;
import javax.annotation.Nonnull;
import forestry.api.recipes.IMoistenerRecipe;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
@@ -9,44 +7,24 @@ import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
public class MoistenerRecipeHandler implements IRecipeHandler<MoistenerRecipeWrapper> {
@Nonnull
@Override
public Class<MoistenerRecipeWrapper> getRecipeClass() {
return MoistenerRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid( MoistenerRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.MOISTENER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull MoistenerRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.MOISTENER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull MoistenerRecipeWrapper recipe) {
public IRecipeWrapper getRecipeWrapper( MoistenerRecipeWrapper recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull MoistenerRecipeWrapper wrapper) {
public boolean isRecipeValid( MoistenerRecipeWrapper wrapper) {
IMoistenerRecipe recipe = wrapper.getRecipe();
if (recipe.getTimePerItem() <= 0) {
return false;
}
if (recipe.getResource() == null) {
return false;
}
if (recipe.getProduct() == null) {
return false;
}
return wrapper.getFuel() != null || wrapper.getFuel().getItem() != null || wrapper.getFuel().getProduct() != null;
return recipe.getTimePerItem() > 0;
}
}
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei.moistener;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
@@ -13,41 +12,33 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
public class MoistenerRecipeWrapper extends ForestryRecipeWrapper<IMoistenerRecipe> {
@Nonnull
private final MoistenerFuel fuel;
public MoistenerRecipeWrapper(@Nonnull IMoistenerRecipe recipe, @Nonnull MoistenerFuel fuel) {
public MoistenerRecipeWrapper( IMoistenerRecipe recipe, MoistenerFuel fuel) {
super(recipe);
this.fuel = fuel;
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
public void getIngredients( IIngredients ingredients) {
IMoistenerRecipe recipe = getRecipe();
List<ItemStack> itemStackInputs = new ArrayList<>();
itemStackInputs.add(recipe.getResource());
ItemStack fuelItem = fuel.getItem();
if (fuelItem != null) {
itemStackInputs.add(fuelItem);
}
itemStackInputs.add(fuelItem);
ingredients.setInputs(ItemStack.class, itemStackInputs);
List<ItemStack> itemStackOutputs = new ArrayList<>();
itemStackOutputs.add(recipe.getProduct());
ItemStack fuelProduct = fuel.getProduct();
if (fuelProduct != null) {
itemStackOutputs.add(fuelProduct);
}
itemStackOutputs.add(fuelProduct);
ingredients.setOutputs(ItemStack.class, itemStackOutputs);
ingredients.setInput(FluidStack.class, new FluidStack(FluidRegistry.WATER, recipe.getTimePerItem() / 4));
}
@Nonnull
public MoistenerFuel getFuel() {
return fuel;
}
}
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei.moistener;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,7 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,7 +1,5 @@
package forestry.factory.recipes.jei.rainmaker;
import javax.annotation.Nonnull;
import forestry.core.recipes.jei.ForestryRecipeCategory;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import mezz.jei.api.IGuiHelper;
@@ -15,25 +13,24 @@ public class RainmakerRecipeCategory extends ForestryRecipeCategory<RainmakerRec
private static final int SLOT_INPUT_INDEX = 0;
private final IDrawable slot;
public RainmakerRecipeCategory(@Nonnull IGuiHelper guiHelper) {
public RainmakerRecipeCategory(IGuiHelper guiHelper) {
super(guiHelper.createBlankDrawable(150, 30), "tile.for.rainmaker.name");
this.slot = guiHelper.getSlotDrawable();
}
@Nonnull
@Override
public String getUid() {
return ForestryRecipeCategoryUid.RAINMAKER;
}
@Override
public void drawExtras(@Nonnull Minecraft minecraft) {
public void drawExtras(Minecraft minecraft) {
super.drawExtras(minecraft);
slot.draw(minecraft);
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RainmakerRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
public void setRecipe(IRecipeLayout recipeLayout, RainmakerRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(SLOT_INPUT_INDEX, true, 0, 0);
guiItemStacks.set(ingredients);
@@ -1,39 +1,27 @@
package forestry.factory.recipes.jei.rainmaker;
import javax.annotation.Nonnull;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
public class RainmakerRecipeHandler implements IRecipeHandler<RainmakerRecipeWrapper> {
@Nonnull
@Override
public Class<RainmakerRecipeWrapper> getRecipeClass() {
return RainmakerRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid(RainmakerRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.RAINMAKER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull RainmakerRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.RAINMAKER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull RainmakerRecipeWrapper recipe) {
public IRecipeWrapper getRecipeWrapper(RainmakerRecipeWrapper recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull RainmakerRecipeWrapper wrapper) {
public boolean isRecipeValid(RainmakerRecipeWrapper wrapper) {
return true;
}
}
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei.rainmaker;
import javax.annotation.Nonnull;
import java.awt.Color;
import java.util.Collections;
@@ -12,20 +11,19 @@ import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
public class RainmakerRecipeWrapper extends BlankRecipeWrapper {
@Nonnull
private final RainSubstrate substrate;
public RainmakerRecipeWrapper(@Nonnull RainSubstrate substrate) {
public RainmakerRecipeWrapper(RainSubstrate substrate) {
this.substrate = substrate;
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
public void getIngredients(IIngredients ingredients) {
ingredients.setInputs(ItemStack.class, Collections.singletonList(substrate.getItem()));
}
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
minecraft.fontRendererObj.drawString(getEffectString(), 24, 0, Color.darkGray.getRGB());
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei.rainmaker;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,11 +1,9 @@
package forestry.factory.recipes.jei.squeezer;
import javax.annotation.Nonnull;
import forestry.core.recipes.jei.ForestryRecipeWrapper;
public abstract class AbstractSqueezerRecipeWrapper<R> extends ForestryRecipeWrapper<R> {
public AbstractSqueezerRecipeWrapper(@Nonnull R recipe) {
public AbstractSqueezerRecipeWrapper(R recipe) {
super(recipe);
}
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei.squeezer;
import javax.annotation.Nonnull;
import java.util.Collections;
import forestry.factory.recipes.ISqueezerContainerRecipe;
@@ -10,21 +9,19 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
public class SqueezerContainerRecipeWrapper extends AbstractSqueezerRecipeWrapper<ISqueezerContainerRecipe> {
@Nonnull
private final ItemStack filledContainer;
public SqueezerContainerRecipeWrapper(@Nonnull ISqueezerContainerRecipe recipe, @Nonnull ItemStack filledContainer) {
public SqueezerContainerRecipeWrapper(ISqueezerContainerRecipe recipe, ItemStack filledContainer) {
super(recipe);
this.filledContainer = filledContainer;
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
public void getIngredients(IIngredients ingredients) {
ingredients.setInputs(ItemStack.class, Collections.singletonList(filledContainer));
ItemStack remnants = getRecipe().getRemnants();
if (remnants != null) {
if (!remnants.isEmpty()) {
ingredients.setOutput(ItemStack.class, remnants);
}
@@ -1,7 +1,5 @@
package forestry.factory.recipes.jei.squeezer;
import javax.annotation.Nonnull;
import forestry.core.recipes.jei.ForestryRecipeCategory;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import forestry.core.recipes.jei.ForestryTooltipCallback;
@@ -18,41 +16,39 @@ import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
public class SqueezerRecipeCategory extends ForestryRecipeCategory<AbstractSqueezerRecipeWrapper> {
private static final int[][] INPUTS = new int[][]{{0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1}, {0, 2}, {1, 2}, {2, 2}};
private static final int craftOutputSlot = 0;
private static final int craftInputSlot = 1;
private static final int outputTank = 0;
private final static ResourceLocation guiTexture = new ForestryResource("textures/gui/squeezersocket.png");
@Nonnull
private static final ResourceLocation guiTexture = new ForestryResource("textures/gui/squeezersocket.png");
private final IDrawableAnimated arrow;
@Nonnull
private final IDrawable tankOverlay;
public SqueezerRecipeCategory(@Nonnull IGuiHelper guiHelper) {
public SqueezerRecipeCategory(IGuiHelper guiHelper) {
super(guiHelper.createDrawable(guiTexture, 9, 16, 158, 62), "tile.for.squeezer.name");
IDrawableStatic arrowDrawable = guiHelper.createDrawable(guiTexture, 176, 60, 43, 18);
this.arrow = guiHelper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.LEFT, false);
this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58);
}
@Nonnull
@Override
public String getUid() {
return ForestryRecipeCategoryUid.SQUEEZER;
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft) {
public void drawExtras(Minecraft minecraft) {
arrow.draw(minecraft, 67, 25);
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull AbstractSqueezerRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
public void setRecipe(IRecipeLayout recipeLayout, AbstractSqueezerRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
@@ -1,46 +1,33 @@
package forestry.factory.recipes.jei.squeezer;
import javax.annotation.Nonnull;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
public class SqueezerRecipeHandler<R extends AbstractSqueezerRecipeWrapper> implements IRecipeHandler<R> {
@Nonnull
private final Class<R> recipeClass;
public SqueezerRecipeHandler(@Nonnull Class<R> recipeClass) {
public SqueezerRecipeHandler(Class<R> recipeClass) {
this.recipeClass = recipeClass;
}
@Nonnull
@Override
public Class<R> getRecipeClass() {
return recipeClass;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid(R recipe) {
return ForestryRecipeCategoryUid.SQUEEZER;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull R recipe) {
return ForestryRecipeCategoryUid.SQUEEZER;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull R recipe) {
public IRecipeWrapper getRecipeWrapper(R recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull R wrapper) {
public boolean isRecipeValid(R wrapper) {
return true;
}
@@ -3,19 +3,18 @@ package forestry.factory.recipes.jei.squeezer;
import java.util.ArrayList;
import java.util.List;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import forestry.api.recipes.ISqueezerRecipe;
import forestry.api.recipes.RecipeManagers;
import forestry.factory.recipes.ISqueezerContainerRecipe;
import forestry.factory.recipes.SqueezerRecipeManager;
import mezz.jei.api.ingredients.IIngredientRegistry;
import net.minecraft.item.ItemStack;
public class SqueezerRecipeMaker {
private SqueezerRecipeMaker() {
}
public static List<SqueezerRecipeWrapper> getSqueezerRecipes() {
List<SqueezerRecipeWrapper> recipes = new ArrayList<>();
for (ISqueezerRecipe recipe : RecipeManagers.squeezerManager.recipes()) {
@@ -23,16 +22,15 @@ public class SqueezerRecipeMaker {
}
return recipes;
}
public static List<SqueezerContainerRecipeWrapper> getSqueezerContainerRecipes() {
public static List<SqueezerContainerRecipeWrapper> getSqueezerContainerRecipes(IIngredientRegistry ingredientRegistry) {
List<SqueezerContainerRecipeWrapper> recipes = new ArrayList<>();
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
ISqueezerContainerRecipe containerRecipe = SqueezerRecipeManager.findMatchingContainerRecipe(data.filledContainer);
for (ItemStack stack : ingredientRegistry.getIngredients(ItemStack.class)) {
ISqueezerContainerRecipe containerRecipe = SqueezerRecipeManager.findMatchingContainerRecipe(stack);
if (containerRecipe != null) {
recipes.add(new SqueezerContainerRecipeWrapper(containerRecipe, data.filledContainer));
recipes.add(new SqueezerContainerRecipeWrapper(containerRecipe, stack));
}
}
return recipes;
}
}
@@ -1,26 +1,23 @@
package forestry.factory.recipes.jei.squeezer;
import javax.annotation.Nonnull;
import java.util.Arrays;
import forestry.api.recipes.ISqueezerRecipe;
import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
public class SqueezerRecipeWrapper extends AbstractSqueezerRecipeWrapper<ISqueezerRecipe> {
public SqueezerRecipeWrapper(@Nonnull ISqueezerRecipe recipe) {
public SqueezerRecipeWrapper(ISqueezerRecipe recipe) {
super(recipe);
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
ItemStack[] resources = getRecipe().getResources();
ingredients.setInputs(ItemStack.class, Arrays.asList(resources));
public void getIngredients(IIngredients ingredients) {
NonNullList<ItemStack> resources = getRecipe().getResources();
ingredients.setInputs(ItemStack.class, resources);
ItemStack remnants = getRecipe().getRemnants();
if (remnants != null) {
if (!remnants.isEmpty()) {
ingredients.setOutput(ItemStack.class, remnants);
}
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei.squeezer;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,7 +1,5 @@
package forestry.factory.recipes.jei.still;
import javax.annotation.Nonnull;
import forestry.core.recipes.jei.ForestryRecipeCategory;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import forestry.core.render.ForestryResource;
@@ -17,38 +15,34 @@ import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
public class StillRecipeCategory extends ForestryRecipeCategory {
private static final int inputTank = 0;
private static final int outputTank = 1;
private final static ResourceLocation guiTexture = new ForestryResource("textures/gui/still.png");
@Nonnull
private static final ResourceLocation guiTexture = new ForestryResource("textures/gui/still.png");
private final IDrawable tankOverlay;
@Nonnull
private final IDrawableAnimated progressBar;
public StillRecipeCategory(IGuiHelper guiHelper) {
super(guiHelper.createDrawable(guiTexture, 34, 14, 108, 60), "tile.for.still.name");
this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58);
IDrawableStatic progressBarDrawable0 = guiHelper.createDrawable(guiTexture, 176, 74, 4, 18);
this.progressBar = guiHelper.createAnimatedDrawable(progressBarDrawable0, 20, IDrawableAnimated.StartDirection.BOTTOM, false);
}
@Nonnull
@Override
public String getUid() {
return ForestryRecipeCategoryUid.STILL;
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft) {
public void drawExtras(Minecraft minecraft) {
progressBar.draw(minecraft, 50, 3);
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
guiFluidStacks.init(inputTank, true, 1, 1, 16, 58, 10000, false, tankOverlay);
@@ -1,49 +1,27 @@
package forestry.factory.recipes.jei.still;
import javax.annotation.Nonnull;
import forestry.api.recipes.IStillRecipe;
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
public class StillRecipeHandler implements IRecipeHandler<StillRecipeWrapper> {
@Nonnull
@Override
public Class<StillRecipeWrapper> getRecipeClass() {
return StillRecipeWrapper.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid(StillRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.STILL;
}
@Nonnull
@Override
public String getRecipeCategoryUid(@Nonnull StillRecipeWrapper recipe) {
return ForestryRecipeCategoryUid.STILL;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull StillRecipeWrapper recipe) {
public IRecipeWrapper getRecipeWrapper(StillRecipeWrapper recipe) {
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull StillRecipeWrapper wrapper) {
IStillRecipe recipe = wrapper.getRecipe();
if (recipe.getInput() == null) {
return false;
}
if (recipe.getOutput() == null) {
return false;
}
public boolean isRecipeValid(StillRecipeWrapper wrapper) {
return true;
}
}
@@ -1,6 +1,5 @@
package forestry.factory.recipes.jei.still;
import javax.annotation.Nonnull;
import java.util.Collections;
import forestry.api.recipes.IStillRecipe;
@@ -9,13 +8,13 @@ import mezz.jei.api.ingredients.IIngredients;
import net.minecraftforge.fluids.FluidStack;
public class StillRecipeWrapper extends ForestryRecipeWrapper<IStillRecipe> {
public StillRecipeWrapper(@Nonnull IStillRecipe recipe) {
public StillRecipeWrapper(IStillRecipe recipe) {
super(recipe);
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
public void getIngredients(IIngredients ingredients) {
ingredients.setInputs(FluidStack.class, Collections.singletonList(getRecipe().getInput()));
ingredients.setOutput(FluidStack.class, getRecipe().getOutput());
}
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes.jei.still;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package forestry.factory.recipes;
import javax.annotation.ParametersAreNonnullByDefault;
import forestry.core.utils.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.factory.tiles;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.EnumMap;
@@ -20,12 +19,11 @@ import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.FluidHelper.FillStatus;
import forestry.core.fluids.StandardTank;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.watchers.ISlotPickupWatcher;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketBufferForestry;
import forestry.core.render.TankRenderInfo;
import forestry.core.tiles.ILiquidTankTile;
import forestry.core.tiles.TilePowered;
@@ -39,7 +37,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
@@ -57,9 +55,9 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
private final StandardTank resourceTank;
private final TankManager tankManager;
private EnumMap<EnumFacing, Boolean> canDump;
private final EnumMap<EnumFacing, Boolean> canDump;
private boolean dumpingFluid = false;
@Nullable
private BottlerRecipe currentRecipe;
@SideOnly(Side.CLIENT)
public boolean isFillRecipe;
@@ -71,12 +69,12 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
resourceTank = new StandardTank(Constants.PROCESSOR_TANK_CAPACITY);
tankManager = new TankManager(this, resourceTank);
canDump = new EnumMap<>(EnumFacing.class);
}
/* SAVING & LOADING */
@Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
@@ -93,13 +91,13 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
public void writeData(PacketBufferForestry data) {
super.writeData(data);
tankManager.writeData(data);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
public void readData(PacketBufferForestry data) throws IOException {
super.readData(data);
tankManager.readData(data);
}
@@ -111,16 +109,16 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
if (updateOnInterval(20)) {
ItemStack leftProcessingStack = getStackInSlot(InventoryBottler.SLOT_EMPTYING_PROCESSING);
ItemStack rightProcessingStack = getStackInSlot(InventoryBottler.SLOT_FILLING_PROCESSING);
if (leftProcessingStack == null) {
if (leftProcessingStack.isEmpty()) {
ItemStack inputStack = getStackInSlot(InventoryBottler.SLOT_INPUT_FULL_CONTAINER);
if (inputStack != null) {
if (!inputStack.isEmpty()) {
leftProcessingStack = decrStackSize(InventoryBottler.SLOT_INPUT_FULL_CONTAINER, 1);
setInventorySlotContents(InventoryBottler.SLOT_EMPTYING_PROCESSING, leftProcessingStack);
}
}
if (rightProcessingStack == null) {
if (rightProcessingStack.isEmpty()) {
ItemStack inputStack = getStackInSlot(InventoryBottler.SLOT_INPUT_EMPTY_CONTAINER);
if (inputStack != null) {
if (!inputStack.isEmpty()) {
rightProcessingStack = decrStackSize(InventoryBottler.SLOT_INPUT_EMPTY_CONTAINER, 1);
setInventorySlotContents(InventoryBottler.SLOT_FILLING_PROCESSING, rightProcessingStack);
}
@@ -133,13 +131,13 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
}
}
}
private boolean canDump() {
FluidStack fluid = tankManager.getFluid(0);
if (fluid != null) {
if (canDump.isEmpty()) {
for (EnumFacing facing : EnumFacing.VALUES) {
canDump.put(facing, FluidHelper.canAcceptFluid(worldObj, pos.offset(facing), facing.getOpposite(), fluid));
canDump.put(facing, FluidHelper.canAcceptFluid(world, pos.offset(facing), facing.getOpposite(), fluid));
}
}
@@ -154,9 +152,9 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
private boolean dumpFluid() {
if (!resourceTank.isEmpty()) {
for(EnumFacing facing : EnumFacing.VALUES){
if(canDump.get(facing)){
IFluidHandler fluidDestination = FluidUtil.getFluidHandler(worldObj, pos.offset(facing), facing.getOpposite());
for (EnumFacing facing : EnumFacing.VALUES) {
if (canDump.get(facing)) {
IFluidHandler fluidDestination = FluidUtil.getFluidHandler(world, pos.offset(facing), facing.getOpposite());
if (fluidDestination != null) {
if (FluidUtil.tryFluidTransfer(fluidDestination, tankManager, Fluid.BUCKET_VOLUME / 20, true) != null) {
return true;
@@ -171,35 +169,40 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
@Override
public boolean workCycle() {
FluidHelper.FillStatus status;
if(currentRecipe.fillRecipe){
status = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_FILLING_PROCESSING, InventoryBottler.SLOT_OUTPUT_FULL_CONTAINER, currentRecipe.fluid.getFluid(), true);
}else{
status = FluidHelper.drainContainers(tankManager, this, InventoryBottler.SLOT_EMPTYING_PROCESSING, InventoryBottler.SLOT_OUTPUT_EMPTY_CONTAINER, true);
if (currentRecipe != null) {
if (currentRecipe.fillRecipe) {
status = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_FILLING_PROCESSING, InventoryBottler.SLOT_OUTPUT_FULL_CONTAINER, currentRecipe.fluid.getFluid(), true);
} else {
status = FluidHelper.drainContainers(tankManager, this, InventoryBottler.SLOT_EMPTYING_PROCESSING, InventoryBottler.SLOT_OUTPUT_EMPTY_CONTAINER, true);
}
} else {
return true;
}
if(status == FluidHelper.FillStatus.SUCCESS){
if (status == FluidHelper.FillStatus.SUCCESS) {
currentRecipe = null;
return true;
}
return false;
}
@Override
public void onNeighborTileChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) {
public void onNeighborTileChange(World world, BlockPos pos, BlockPos neighbor) {
super.onNeighborTileChange(world, pos, neighbor);
canDump.clear();
}
private void checkFillRecipe(){
private void checkFillRecipe() {
ItemStack emptyCan = getStackInSlot(InventoryBottler.SLOT_FILLING_PROCESSING);
if(emptyCan != null){
if (!emptyCan.isEmpty()) {
FluidStack resource = resourceTank.getFluid();
if (resource == null) {
return;
}
//Fill Container
if (currentRecipe == null || !currentRecipe.matchEmpty(emptyCan, resource)) {
currentRecipe = BottlerRecipe.createEmpty(resource.getFluid(), emptyCan);
currentRecipe = BottlerRecipe.createFillingRecipe(resource.getFluid(), emptyCan);
if (currentRecipe != null) {
float viscosityMultiplier = resource.getFluid().getViscosity(resource) / 1000.0f;
viscosityMultiplier = (viscosityMultiplier - 1f) / 20f + 1f; // scale down the effect
@@ -214,13 +217,13 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
}
}
}
private void checkEmptyRecipe(){
private void checkEmptyRecipe() {
ItemStack filledCan = getStackInSlot(InventoryBottler.SLOT_EMPTYING_PROCESSING);
if(filledCan != null){
if (!filledCan.isEmpty()) {
//Empty Container
if (currentRecipe == null || !currentRecipe.matchFilled(filledCan) && !currentRecipe.fillRecipe) {
currentRecipe = BottlerRecipe.createFilled(filledCan);
currentRecipe = BottlerRecipe.createEmptyingRecipe(filledCan);
if (currentRecipe != null) {
FluidStack resource = currentRecipe.fluid;
float viscosityMultiplier = resource.getFluid().getViscosity(resource) / 1000.0f;
@@ -236,47 +239,47 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
}
}
}
@Override
public void onPickupFromSlot(int slotIndex, EntityPlayer player) {
if(slotIndex == InventoryBottler.SLOT_EMPTYING_PROCESSING){
if(currentRecipe != null && !currentRecipe.fillRecipe){
public void onTake(int slotIndex, EntityPlayer player) {
if (slotIndex == InventoryBottler.SLOT_EMPTYING_PROCESSING) {
if (currentRecipe != null && !currentRecipe.fillRecipe) {
currentRecipe = null;
setTicksPerWorkCycle(0);
}
}else if(slotIndex == InventoryBottler.SLOT_FILLING_PROCESSING){
if(currentRecipe != null && currentRecipe.fillRecipe){
} else if (slotIndex == InventoryBottler.SLOT_FILLING_PROCESSING) {
if (currentRecipe != null && currentRecipe.fillRecipe) {
currentRecipe = null;
setTicksPerWorkCycle(0);
}
}
}
@Override
public void readGuiData(DataInputStreamForestry data) throws IOException {
super.readGuiData(data);
isFillRecipe = data.readBoolean();
}
@Override
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
public void writeGuiData(PacketBufferForestry data) {
super.writeGuiData(data);
if(currentRecipe == null){
if (currentRecipe == null) {
data.writeBoolean(false);
}else{
} else {
data.writeBoolean(currentRecipe.fillRecipe);
}
}
@Override
public void readGuiData(PacketBufferForestry data) throws IOException {
super.readGuiData(data);
isFillRecipe = data.readBoolean();
}
@Override
public boolean hasResourcesMin(float percentage) {
IInventoryAdapter inventory = getInternalInventory();
ItemStack emptyCan = inventory.getStackInSlot(InventoryBottler.SLOT_FILLING_PROCESSING);
if (emptyCan == null) {
if (emptyCan.isEmpty()) {
return false;
}
return (float) emptyCan.stackSize / (float) emptyCan.getMaxStackSize() > percentage;
return (float) emptyCan.getCount() / (float) emptyCan.getMaxStackSize() > percentage;
}
@Override
@@ -285,37 +288,37 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
FluidHelper.FillStatus fillStatus;
IErrorLogic errorLogic = getErrorLogic();
errorLogic.clearErrors();
checkEmptyRecipe();
if (currentRecipe != null) {
IFluidTankProperties properties = tankManager.getTankProperties()[0];
if(properties != null){
if (properties != null) {
emptyStatus = FluidHelper.drainContainers(tankManager, this, InventoryBottler.SLOT_EMPTYING_PROCESSING, InventoryBottler.SLOT_OUTPUT_EMPTY_CONTAINER, false);
}else{
} else {
emptyStatus = FillStatus.SUCCESS;
}
}else{
} else {
emptyStatus = null;
}
if(emptyStatus == null || emptyStatus != FillStatus.SUCCESS){
if (emptyStatus == null || emptyStatus != FillStatus.SUCCESS) {
checkFillRecipe();
if (currentRecipe == null) {
return false;
}else{
} else {
fillStatus = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_FILLING_PROCESSING, InventoryBottler.SLOT_OUTPUT_FULL_CONTAINER, currentRecipe.fluid.getFluid(), false);
}
}else{
} else {
return true;
}
if(fillStatus == FillStatus.SUCCESS){
if (fillStatus == FillStatus.SUCCESS) {
return true;
}
errorLogic.setCondition(fillStatus == FluidHelper.FillStatus.NO_FLUID, EnumErrorCode.NO_RESOURCE_LIQUID);
errorLogic.setCondition(fillStatus == FluidHelper.FillStatus.NO_SPACE, EnumErrorCode.NO_SPACE_INVENTORY);
errorLogic.setCondition(emptyStatus == FluidHelper.FillStatus.NO_SPACE_FLUID, EnumErrorCode.NO_SPACE_TANK);
if(emptyStatus == FillStatus.INVALID_INPUT || fillStatus == FillStatus.INVALID_INPUT || errorLogic.hasErrors()){
if (emptyStatus == FillStatus.INVALID_INPUT || fillStatus == FillStatus.INVALID_INPUT || errorLogic.hasErrors()) {
currentRecipe = null;
return false;
}
@@ -328,20 +331,20 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
}
/* ILIQUIDCONTAINER */
@Nonnull
@Override
public TankManager getTankManager() {
return tankManager;
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}
@Nonnull
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
}
@@ -10,33 +10,19 @@
******************************************************************************/
package forestry.factory.tiles;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import forestry.api.core.IErrorLogic;
import forestry.api.recipes.ICarpenterRecipe;
import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
import forestry.core.fluids.FilteredTank;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.core.inventory.wrappers.InventoryMapper;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketBufferForestry;
import forestry.core.render.TankRenderInfo;
import forestry.core.tiles.IItemStackDisplay;
import forestry.core.tiles.ILiquidTankTile;
@@ -47,6 +33,17 @@ import forestry.factory.gui.GuiCarpenter;
import forestry.factory.inventory.InventoryCarpenter;
import forestry.factory.inventory.InventoryGhostCrafting;
import forestry.factory.recipes.CarpenterRecipeManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
public class TileCarpenter extends TilePowered implements ISidedInventory, ILiquidTankTile, IItemStackDisplay {
private static final int TICKS_PER_RECIPE_TIME = 1;
@@ -55,7 +52,7 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
private final FilteredTank resourceTank;
private final TankManager tankManager;
private final InventoryAdapterTile craftingInventory;
private final InventoryAdapterTile craftingInventory;
private final InventoryCraftResult craftPreviewInventory;
@Nullable
@@ -78,7 +75,7 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
}
/* LOADING & SAVING */
@Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
@@ -96,19 +93,19 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
public void writeData(PacketBufferForestry data) {
super.writeData(data);
tankManager.writeData(data);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
public void readData(PacketBufferForestry data) throws IOException {
super.readData(data);
tankManager.readData(data);
}
public void checkRecipe() {
if (worldObj.isRemote) {
if (world.isRemote) {
return;
}
@@ -123,7 +120,7 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
ItemStack craftingResult = currentRecipe.getCraftingGridRecipe().getRecipeOutput();
craftPreviewInventory.setInventorySlotContents(0, craftingResult);
} else {
craftPreviewInventory.setInventorySlotContents(0, null);
craftPreviewInventory.setInventorySlotContents(0, ItemStack.EMPTY);
}
}
}
@@ -146,9 +143,10 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
return false;
}
ItemStack pendingProduct = currentRecipe.getCraftingGridRecipe().getRecipeOutput();
InventoryUtil.tryAddStack(this, pendingProduct, InventoryCarpenter.SLOT_PRODUCT, InventoryCarpenter.SLOT_PRODUCT_COUNT, true);
if (currentRecipe != null) {
ItemStack pendingProduct = currentRecipe.getCraftingGridRecipe().getRecipeOutput();
InventoryUtil.tryAddStack(this, pendingProduct, InventoryCarpenter.SLOT_PRODUCT, InventoryCarpenter.SLOT_PRODUCT_COUNT, true);
}
return true;
}
@@ -160,7 +158,7 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
FluidStack fluid = currentRecipe.getFluidResource();
if (fluid != null) {
FluidStack drained = resourceTank.drainInternal(fluid, false);
if (!FluidHelper.areFluidStacksEqual(drained, fluid)) {
if (!drained.isFluidStackIdentical(fluid)) {
return false;
}
if (doRemove) {
@@ -176,9 +174,9 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
return true;
}
if (currentRecipe.getBox() != null) {
if (!currentRecipe.getBox().isEmpty()) {
ItemStack box = getStackInSlot(InventoryCarpenter.SLOT_BOX);
if (box == null || box.stackSize == 0) {
if (box.isEmpty()) {
return false;
}
if (doRemove) {
@@ -186,7 +184,7 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
}
}
ItemStack[] craftingSets = InventoryUtil.getStacks(craftingInventory, InventoryGhostCrafting.SLOT_CRAFTING_1, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
NonNullList<ItemStack> craftingSets = InventoryUtil.getStacks(craftingInventory, InventoryGhostCrafting.SLOT_CRAFTING_1, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
IInventory inventory = new InventoryMapper(getInternalInventory(), InventoryCarpenter.SLOT_INVENTORY_1, InventoryCarpenter.SLOT_INVENTORY_COUNT);
return InventoryUtil.removeSets(inventory, 1, craftingSets, null, true, true, false, doRemove);
}
@@ -241,20 +239,20 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
craftPreviewInventory.setInventorySlotContents(0, itemStack);
}
@Nonnull
@Override
public TankManager getTankManager() {
return tankManager;
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}
@Nonnull
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
}
@@ -10,18 +10,11 @@
******************************************************************************/
package forestry.factory.tiles;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Collection;
import java.util.Stack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitBoard;
@@ -33,8 +26,7 @@ import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketBufferForestry;
import forestry.core.tiles.IItemStackDisplay;
import forestry.core.tiles.TilePowered;
import forestry.core.utils.InventoryUtil;
@@ -42,6 +34,13 @@ import forestry.factory.gui.ContainerCentrifuge;
import forestry.factory.gui.GuiCentrifuge;
import forestry.factory.inventory.InventoryCentrifuge;
import forestry.factory.recipes.CentrifugeRecipeManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class TileCentrifuge extends TilePowered implements ISocketable, ISidedInventory, IItemStackDisplay {
private static final int TICKS_PER_RECIPE_TIME = 1;
@@ -50,7 +49,7 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
private final InventoryCraftResult craftPreviewInventory;
@Nullable
private ICentrifugeRecipe currentRecipe;
private final Stack<ItemStack> pendingProducts = new Stack<>();
@@ -62,7 +61,7 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
}
/* LOADING & SAVING */
@Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
@@ -90,12 +89,12 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
NBTTagList nbttaglist = nbttagcompound.getTagList("PendingProducts", 10);
for (int i = 0; i < nbttaglist.tagCount(); i++) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
pendingProducts.add(ItemStack.loadItemStackFromNBT(nbttagcompound1));
pendingProducts.add(new ItemStack(nbttagcompound1));
}
sockets.readFromNBT(nbttagcompound);
ItemStack chip = sockets.getStackInSlot(0);
if (chip != null) {
if (!chip.isEmpty()) {
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(chip);
if (chipset != null) {
chipset.onLoad(this);
@@ -104,13 +103,13 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
}
@Override
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
public void writeGuiData(PacketBufferForestry data) {
super.writeGuiData(data);
sockets.writeData(data);
}
@Override
public void readGuiData(DataInputStreamForestry data) throws IOException {
public void readGuiData(PacketBufferForestry data) throws IOException {
super.readGuiData(data);
sockets.readData(data);
}
@@ -122,7 +121,7 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
}
if (!pendingProducts.isEmpty()) {
craftPreviewInventory.setInventorySlotContents(0, null);
craftPreviewInventory.setInventorySlotContents(0, ItemStack.EMPTY);
return false;
}
@@ -131,14 +130,14 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
}
// We are done, add products to queue
Collection<ItemStack> products = currentRecipe.getProducts(worldObj.rand);
Collection<ItemStack> products = currentRecipe.getProducts(world.rand);
pendingProducts.addAll(products);
//Add Item to preview slot.
ItemStack previewStack = getInternalInventory().getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).copy();
previewStack.stackSize=1;
previewStack.setCount(1);
craftPreviewInventory.setInventorySlotContents(0, previewStack);
getInternalInventory().decrStackSize(InventoryCentrifuge.SLOT_RESOURCE, 1);
return true;
}
@@ -168,8 +167,8 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
if (added) {
pendingProducts.pop();
if(pendingProducts.isEmpty()){
craftPreviewInventory.setInventorySlotContents(0, null);
if (pendingProducts.isEmpty()) {
craftPreviewInventory.setInventorySlotContents(0, ItemStack.EMPTY);
}
}
@@ -180,21 +179,21 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
@Override
public boolean hasResourcesMin(float percentage) {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE) == null) {
if (inventory.getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).isEmpty()) {
return false;
}
return (float) inventory.getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).stackSize / (float) inventory.getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).getMaxStackSize() > percentage;
return (float) inventory.getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).getCount() / (float) inventory.getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).getMaxStackSize() > percentage;
}
@Override
public boolean hasWork() {
if(!pendingProducts.isEmpty()){
if (!pendingProducts.isEmpty()) {
return true;
}
checkRecipe();
boolean hasResource = getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE) != null;
boolean hasResource = !getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).isEmpty();
IErrorLogic errorLogic = getErrorLogic();
errorLogic.setCondition(!hasResource, EnumErrorCode.NO_RESOURCE);
@@ -227,12 +226,12 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
@Override
public void setSocket(int slot, ItemStack stack) {
if (stack != null && !ChipsetManager.circuitRegistry.isChipset(stack)) {
if (!stack.isEmpty() && !ChipsetManager.circuitRegistry.isChipset(stack)) {
return;
}
// Dispose correctly of old chipsets
if (sockets.getStackInSlot(slot) != null) {
if (!sockets.getStackInSlot(slot).isEmpty()) {
if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) {
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(sockets.getStackInSlot(slot));
if (chipset != null) {
@@ -242,7 +241,7 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
}
sockets.setInventorySlotContents(slot, stack);
if (stack == null) {
if (stack.isEmpty()) {
return;
}
@@ -266,7 +265,7 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
public Object getContainer(EntityPlayer player, int data) {
return new ContainerCentrifuge(player.inventory, this);
}
public IInventory getCraftPreviewInventory() {
return craftPreviewInventory;
}
@@ -10,41 +10,23 @@
******************************************************************************/
package forestry.factory.tiles;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import forestry.api.core.IErrorLogic;
import forestry.api.recipes.IFabricatorRecipe;
import forestry.api.recipes.IFabricatorSmeltingRecipe;
import forestry.core.errors.EnumErrorCode;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.FilteredTank;
import forestry.core.fluids.Fluids;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.inventory.InventoryAdapterTile;
import forestry.core.inventory.watchers.ISlotPickupWatcher;
import forestry.core.inventory.wrappers.InventoryMapper;
import forestry.core.items.ICraftingPlan;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketBufferForestry;
import forestry.core.tiles.ILiquidTankTile;
import forestry.core.tiles.TilePowered;
import forestry.core.utils.InventoryUtil;
@@ -54,6 +36,20 @@ import forestry.factory.inventory.InventoryFabricator;
import forestry.factory.inventory.InventoryGhostCrafting;
import forestry.factory.recipes.FabricatorRecipeManager;
import forestry.factory.recipes.FabricatorSmeltingRecipeManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
public class TileFabricator extends TilePowered implements ISlotPickupWatcher, ILiquidTankTile, ISidedInventory {
private static final int MAX_HEAT = 5000;
@@ -76,7 +72,7 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
}
/* SAVING & LOADING */
@Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
@@ -97,13 +93,13 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
public void writeData(PacketBufferForestry data) {
super.writeData(data);
tankManager.writeData(data);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
public void readData(PacketBufferForestry data) throws IOException {
super.readData(data);
tankManager.readData(data);
}
@@ -135,7 +131,7 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
IInventoryAdapter inventory = getInternalInventory();
ItemStack smeltResource = inventory.getStackInSlot(InventoryFabricator.SLOT_METAL);
if (smeltResource == null) {
if (smeltResource.isEmpty()) {
return;
}
@@ -164,12 +160,13 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
return true;
}
@Nullable
private IFabricatorRecipe getRecipe() {
IInventoryAdapter inventory = getInternalInventory();
ItemStack plan = inventory.getStackInSlot(InventoryFabricator.SLOT_PLAN);
FluidStack liquid = moltenTank.getFluid();
IFabricatorRecipe recipe = FabricatorRecipeManager.findMatchingRecipe(plan, craftingInventory);
if (liquid != null && !liquid.containsFluid(recipe.getLiquid())) {
if (liquid != null && recipe != null && !liquid.containsFluid(recipe.getLiquid())) {
return null;
}
return recipe;
@@ -179,7 +176,7 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
IFabricatorRecipe myRecipe = getRecipe();
if (myRecipe == null) {
return null;
return ItemStack.EMPTY;
}
return myRecipe.getRecipeOutput().copy();
@@ -187,7 +184,7 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
/* ISlotPickupWatcher */
@Override
public void onPickupFromSlot(int slotIndex, EntityPlayer player) {
public void onTake(int slotIndex, EntityPlayer player) {
if (slotIndex == InventoryFabricator.SLOT_RESULT) {
decrStackSize(InventoryFabricator.SLOT_RESULT, 1);
}
@@ -195,49 +192,36 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
private void craftResult() {
IFabricatorRecipe myRecipe = getRecipe();
if (myRecipe == null) {
return;
}
ItemStack craftResult = getResult();
if (myRecipe != null && !craftResult.isEmpty() && getStackInSlot(InventoryFabricator.SLOT_RESULT).isEmpty()) {
FluidStack liquid = myRecipe.getLiquid();
ItemStack result = getResult();
if (result == null) {
return;
}
// Remove resources
NonNullList<ItemStack> crafting = InventoryUtil.getStacks(craftingInventory, InventoryGhostCrafting.SLOT_CRAFTING_1, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
if (removeFromInventory(crafting, false)) {
FluidStack drained = moltenTank.drainInternal(liquid, false);
if (drained.isFluidStackIdentical(liquid)) {
removeFromInventory(crafting, true);
moltenTank.drain(liquid.amount, true);
if (getStackInSlot(InventoryFabricator.SLOT_RESULT) != null) {
return;
}
// Damage plan
if (!getStackInSlot(InventoryFabricator.SLOT_PLAN).isEmpty()) {
Item planItem = getStackInSlot(InventoryFabricator.SLOT_PLAN).getItem();
if (planItem instanceof ICraftingPlan) {
ItemStack planUsed = ((ICraftingPlan) planItem).planUsed(getStackInSlot(InventoryFabricator.SLOT_PLAN), craftResult);
setInventorySlotContents(InventoryFabricator.SLOT_PLAN, planUsed);
}
}
FluidStack liquid = myRecipe.getLiquid();
// Remove resources
ItemStack[] crafting = InventoryUtil.getStacks(craftingInventory, InventoryGhostCrafting.SLOT_CRAFTING_1, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
if (!removeFromInventory(crafting, null, false)) {
return;
}
FluidStack drained = moltenTank.drainInternal(liquid, false);
if (!FluidHelper.areFluidStacksEqual(drained, liquid)) {
return;
}
removeFromInventory(crafting, null, true);
moltenTank.drain(liquid.amount, true);
// Damage plan
if (getStackInSlot(InventoryFabricator.SLOT_PLAN) != null) {
Item planItem = getStackInSlot(InventoryFabricator.SLOT_PLAN).getItem();
if (planItem instanceof ICraftingPlan) {
setInventorySlotContents(InventoryFabricator.SLOT_PLAN, ((ICraftingPlan) planItem).planUsed(getStackInSlot(InventoryFabricator.SLOT_PLAN), result));
setInventorySlotContents(InventoryFabricator.SLOT_RESULT, craftResult);
}
}
}
setInventorySlotContents(InventoryFabricator.SLOT_RESULT, result);
}
private boolean removeFromInventory(ItemStack[] set, EntityPlayer player, boolean doRemove) {
private boolean removeFromInventory(NonNullList<ItemStack> set, boolean doRemove) {
IInventory inventory = new InventoryMapper(this, InventoryFabricator.SLOT_INVENTORY_1, InventoryFabricator.SLOT_INVENTORY_COUNT);
return InventoryUtil.removeSets(inventory, 1, set, player, true, true, false, doRemove);
return InventoryUtil.removeSets(inventory, 1, set, null, true, true, false, doRemove);
}
@Override
@@ -249,11 +233,11 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
ItemStack plan = getStackInSlot(InventoryFabricator.SLOT_PLAN);
IFabricatorRecipe recipe = FabricatorRecipeManager.findMatchingRecipe(plan, craftingInventory);
if (recipe != null) {
ItemStack[] crafting = InventoryUtil.getStacks(craftingInventory, InventoryGhostCrafting.SLOT_CRAFTING_1, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
hasResources = removeFromInventory(crafting, null, false);
NonNullList<ItemStack> crafting = InventoryUtil.getStacks(craftingInventory, InventoryGhostCrafting.SLOT_CRAFTING_1, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
hasResources = removeFromInventory(crafting, false);
FluidStack toDrain = recipe.getLiquid();
FluidStack drained = moltenTank.drainInternal(toDrain, false);
hasLiquidResources = FluidHelper.areFluidStacksEqual(drained, toDrain);
hasLiquidResources = drained.isFluidStackIdentical(toDrain);
} else {
hasRecipe = false;
}
@@ -271,7 +255,7 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
}
private int getMeltingPoint() {
if (this.getStackInSlot(InventoryFabricator.SLOT_METAL) != null) {
if (!this.getStackInSlot(InventoryFabricator.SLOT_METAL).isEmpty()) {
IFabricatorSmeltingRecipe smelt = FabricatorSmeltingRecipeManager.findMatchingSmelting(this.getStackInSlot(InventoryFabricator.SLOT_METAL));
if (smelt != null) {
return smelt.getMeltingPoint();
@@ -314,20 +298,19 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
return craftingInventory;
}
@Nonnull
@Override
public TankManager getTankManager() {
return tankManager;
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}
@Nonnull
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
@Nullable
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
}
Loaded 100 of 1145 files, more files were not shown because too many files have changed in this diff. Show more