diff --git a/build.gradle b/build.gradle index 1d9706664..6aef1ab53 100755 --- a/build.gradle +++ b/build.gradle @@ -67,8 +67,7 @@ repositories { dependencies { deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}" -// deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api" -// runtime "net.industrial-craft:industrialcraft-2:${ic2_version}:dev" + deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api" } configurations { diff --git a/gradle.properties b/gradle.properties index 59cd29c8d..5324fc312 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,7 @@ forgeversion=12.17.0.1950 mcp_mappings=snapshot_20160525 jei_version=3.4.0.+ +ic2_version=2.5.5-ex19 version_major=5 version_minor=0 diff --git a/src/main/java/forestry/energy/gui/GuiEngineElectric.java b/src/main/java/forestry/energy/gui/GuiEngineElectric.java index 810e59ee6..9e5cdaef8 100644 --- a/src/main/java/forestry/energy/gui/GuiEngineElectric.java +++ b/src/main/java/forestry/energy/gui/GuiEngineElectric.java @@ -14,9 +14,9 @@ import net.minecraft.entity.player.InventoryPlayer; import forestry.core.config.Constants; import forestry.core.gui.widgets.SocketWidget; +import forestry.core.render.EnumTankLevel; import forestry.energy.tiles.TileEngineElectric; -// TODO: IC2 for 1.9 public class GuiEngineElectric extends GuiEngine { public GuiEngineElectric(InventoryPlayer inventory, TileEngineElectric tile) { @@ -24,23 +24,23 @@ public class GuiEngineElectric extends GuiEngine { public GuiGenerator(InventoryPlayer inventory, TileEuGenerator tile) { @@ -25,14 +24,14 @@ public class GuiGenerator extends GuiForestryTitled 0) { -// drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18); -// } -// } + @Override + protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); + + int progress = inventory.getStoredScaled(49); + if (progress > 0) { + drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18); + } + } } diff --git a/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java b/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java index a6514eff2..8af78b513 100644 --- a/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java +++ b/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java @@ -15,7 +15,8 @@ import net.minecraft.item.ItemStack; import forestry.core.inventory.InventoryAdapterTile; import forestry.energy.tiles.TileEngineElectric; -// TODO: IC2 for 1.9 +import ic2.api.item.ElectricItem; + public class InventoryEngineElectric extends InventoryAdapterTile { public static final short SLOT_BATTERY = 0; @@ -25,9 +26,9 @@ public class InventoryEngineElectric extends InventoryAdapterTile 0; -// } + if (slotIndex == SLOT_BATTERY) { + return ElectricItem.manager.getCharge(itemStack) > 0; + } return false; } } diff --git a/src/main/java/forestry/energy/tiles/TileEngineElectric.java b/src/main/java/forestry/energy/tiles/TileEngineElectric.java index 62826ee7f..5b5c07d17 100644 --- a/src/main/java/forestry/energy/tiles/TileEngineElectric.java +++ b/src/main/java/forestry/energy/tiles/TileEngineElectric.java @@ -27,6 +27,7 @@ import forestry.api.circuits.ICircuitSocketType; import forestry.api.core.IErrorLogic; import forestry.core.circuits.ISocketable; import forestry.core.config.Constants; +import forestry.core.errors.EnumErrorCode; import forestry.core.inventory.InventoryAdapter; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; @@ -36,8 +37,10 @@ import forestry.core.tiles.TileEngine; import forestry.energy.gui.ContainerEngineElectric; import forestry.energy.gui.GuiEngineElectric; import forestry.energy.inventory.InventoryEngineElectric; +import forestry.plugins.compat.PluginIC2; + +import ic2.api.energy.prefab.BasicSink; -// TODO: IC2 for 1.9 public class TileEngineElectric extends TileEngine implements ISocketable, IInventory, IStreamableGui { protected static class EuConfig { @@ -55,16 +58,16 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets"); private final EuConfig euConfig = new EuConfig(); -// private BasicSink ic2EnergySink; + private BasicSink ic2EnergySink; public TileEngineElectric() { super("engine.tin", Constants.ENGINE_ELECTRIC_HEAT_MAX, 100000); setInternalInventory(new InventoryEngineElectric(this)); -// if (PluginIC2.instance.isAvailable()) { -// ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3); -// } + if (PluginIC2.instance.isAvailable()) { + ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3); + } } // / SAVING / LOADING @@ -72,9 +75,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); -// if (ic2EnergySink != null) { -// ic2EnergySink.readFromNBT(nbttagcompound); -// } + if (ic2EnergySink != null) { + ic2EnergySink.readFromNBT(nbttagcompound); + } sockets.readFromNBT(nbttagcompound); ItemStack chip = sockets.getStackInSlot(0); @@ -91,27 +94,27 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound = super.writeToNBT(nbttagcompound); -// if (ic2EnergySink != null) { -// ic2EnergySink.writeToNBT(nbttagcompound); -// } + if (ic2EnergySink != null) { + ic2EnergySink.writeToNBT(nbttagcompound); + } sockets.writeToNBT(nbttagcompound); return nbttagcompound; } @Override public void onChunkUnload() { -// if (ic2EnergySink != null) { -// ic2EnergySink.onChunkUnload(); -// } + if (ic2EnergySink != null) { + ic2EnergySink.onChunkUnload(); + } super.onChunkUnload(); } @Override public void invalidate() { -// if (ic2EnergySink != null) { -// ic2EnergySink.invalidate(); -// } + if (ic2EnergySink != null) { + ic2EnergySink.invalidate(); + } super.invalidate(); } @@ -159,11 +162,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve IErrorLogic errorLogic = getErrorLogic(); // No work to be done if IC2 is unavailable. -// if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) { -// return; -// } -// -// ic2EnergySink.update(); + if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) { + return; + } + + ic2EnergySink.update(); super.updateServerSide(); @@ -180,8 +183,8 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve return; } -// boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle); -// errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL); + boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle); + errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL); } @Override @@ -193,10 +196,10 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve return; } -// if (ic2EnergySink.useEnergy(euConfig.euForCycle)) { -// currentOutput = euConfig.rfPerCycle; -// energyManager.generateEnergy(euConfig.rfPerCycle); -// } + if (ic2EnergySink.useEnergy(euConfig.euForCycle)) { + currentOutput = euConfig.rfPerCycle; + energyManager.generateEnergy(euConfig.rfPerCycle); + } } @@ -205,23 +208,22 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve return; } -// ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3); + ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3); } // / STATE INFORMATION @Override protected boolean isBurning() { - // TODO: IC2 for 1.9 - return mayBurn();// && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle); + return mayBurn() && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle); } -// public int getStorageScaled(int i) { -// if (ic2EnergySink == null) { -// return 0; -// } -// -// return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity()); -// } + public int getStorageScaled(int i) { + if (ic2EnergySink == null) { + return 0; + } + + return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity()); + } // / SMP GUI @Override @@ -230,11 +232,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve data.writeVarInt(heat); sockets.writeData(data); energyManager.writeData(data); -// final boolean hasIc2EnergySink = (ic2EnergySink != null); -// data.writeBoolean(hasIc2EnergySink); -// if (hasIc2EnergySink) { -// data.writeVarInt((int) ic2EnergySink.getEnergyStored()); -// } + final boolean hasIc2EnergySink = (ic2EnergySink != null); + data.writeBoolean(hasIc2EnergySink); + if (hasIc2EnergySink) { + data.writeVarInt((int) ic2EnergySink.getEnergyStored()); + } } @Override @@ -243,11 +245,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve heat = data.readVarInt(); sockets.readData(data); energyManager.readData(data); -// final boolean hasIc2EnergySink = data.readBoolean(); -// if (hasIc2EnergySink) { -// final int energyStored = data.readVarInt(); -// ic2EnergySink.setEnergyStored(energyStored); -// } + final boolean hasIc2EnergySink = data.readBoolean(); + if (hasIc2EnergySink) { + final int energyStored = data.readVarInt(); + ic2EnergySink.setEnergyStored(energyStored); + } } @Override @@ -266,9 +268,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve euConfig.rfPerCycle += rfChange; euConfig.euStorage += storageChange; -// if (ic2EnergySink != null) { -// ic2EnergySink.setCapacity(euConfig.euStorage); -// } + if (ic2EnergySink != null) { + ic2EnergySink.setCapacity(euConfig.euStorage); + } } /* ISocketable */ diff --git a/src/main/java/forestry/energy/tiles/TileEuGenerator.java b/src/main/java/forestry/energy/tiles/TileEuGenerator.java index 74ebb380a..d83781c29 100644 --- a/src/main/java/forestry/energy/tiles/TileEuGenerator.java +++ b/src/main/java/forestry/energy/tiles/TileEuGenerator.java @@ -25,6 +25,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import forestry.api.core.IErrorLogic; import forestry.api.fuels.FuelManager; +import forestry.api.fuels.GeneratorFuel; import forestry.core.config.Constants; import forestry.core.errors.EnumErrorCode; import forestry.core.fluids.FluidHelper; @@ -40,8 +41,10 @@ import forestry.core.tiles.TileBase; import forestry.energy.gui.ContainerGenerator; import forestry.energy.gui.GuiGenerator; import forestry.energy.inventory.InventoryGenerator; +import forestry.plugins.compat.PluginIC2; + +import ic2.api.energy.prefab.BasicSource; -// TODO: IC2 for 1.9 public class TileEuGenerator extends TileBase implements ISidedInventory, ILiquidTankTile, IRenderableTile { private static final int maxEnergy = 30000; @@ -50,7 +53,7 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui private int tickCount = 0; -// private BasicSource ic2EnergySource; + private BasicSource ic2EnergySource; public TileEuGenerator() { super("generator"); @@ -62,9 +65,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui tankManager = new TankManager(this, resourceTank); -// if (PluginIC2.instance.isAvailable()) { -// ic2EnergySource = new BasicSource(this, maxEnergy, 1); -// } + if (PluginIC2.instance.isAvailable()) { + ic2EnergySource = new BasicSource(this, maxEnergy, 1); + } } @Nonnull @@ -72,9 +75,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound = super.writeToNBT(nbttagcompound); -// if (ic2EnergySource != null) { -// ic2EnergySource.writeToNBT(nbttagcompound); -// } + if (ic2EnergySource != null) { + ic2EnergySource.writeToNBT(nbttagcompound); + } tankManager.writeToNBT(nbttagcompound); return nbttagcompound; @@ -84,9 +87,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); -// if (ic2EnergySource != null) { -// ic2EnergySource.readFromNBT(nbttagcompound); -// } + if (ic2EnergySource != null) { + ic2EnergySource.readFromNBT(nbttagcompound); + } tankManager.readFromNBT(nbttagcompound); } @@ -105,18 +108,18 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui @Override public void onChunkUnload() { -// if (ic2EnergySource != null) { -// ic2EnergySource.onChunkUnload(); -// } + if (ic2EnergySource != null) { + ic2EnergySource.onChunkUnload(); + } super.onChunkUnload(); } @Override public void invalidate() { -// if (ic2EnergySource != null) { -// ic2EnergySource.invalidate(); -// } + if (ic2EnergySource != null) { + ic2EnergySource.invalidate(); + } super.invalidate(); } @@ -130,25 +133,25 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui IErrorLogic errorLogic = getErrorLogic(); // No work to be done if IC2 is unavailable. -// if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) { -// return; -// } -// -// ic2EnergySource.update(); -// -// if (resourceTank.getFluidAmount() > 0) { -// GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid()); -// if (resourceTank.canDrainFluidType(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) { -// ic2EnergySource.addEnergy(fuel.eu); -// this.tickCount++; -// -// if (tickCount >= fuel.rate) { -// tickCount = 0; -// resourceTank.drain(fuel.fuelConsumed.amount, true); -// } -// } -// -// } + if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) { + return; + } + + ic2EnergySource.update(); + + if (resourceTank.getFluidAmount() > 0) { + GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid()); + if (resourceTank.canDrainFluidType(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) { + ic2EnergySource.addEnergy(fuel.eu); + this.tickCount++; + + if (tickCount >= fuel.rate) { + tickCount = 0; + resourceTank.drain(fuel.fuelConsumed.amount, true); + } + } + + } boolean hasFuel = resourceTank.getFluidAmount() > 0; errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL); @@ -162,13 +165,13 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui return (resourceTank.getFluidAmount() * i) / Constants.PROCESSOR_TANK_CAPACITY; } -// public int getStoredScaled(int i) { -// if (ic2EnergySource == null) { -// return 0; -// } -// -// return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy; -// } + public int getStoredScaled(int i) { + if (ic2EnergySource == null) { + return 0; + } + + return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy; + } @Override public TankRenderInfo getResourceTankInfo() { @@ -183,16 +186,16 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui /* SMP GUI */ public void getGUINetworkData(int i, int j) { if (i == 0) { -// if (ic2EnergySource != null) { -// ic2EnergySource.setEnergyStored(j); -// } + if (ic2EnergySource != null) { + ic2EnergySource.setEnergyStored(j); + } } } public void sendGUINetworkData(Container container, IContainerListener iCrafting) { -// if (ic2EnergySource != null) { -// iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored()); -// } + if (ic2EnergySource != null) { + iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored()); + } } @Override diff --git a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java b/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java index dc49ceb35..4c7ea4889 100644 --- a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java +++ b/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java @@ -1,68 +1,83 @@ package forestry.farming.logic; -// TODO: IC2 for 1.9 -public class CropBasicIC2Crop {//extends Crop { -// private final TileEntity tileEntity; -// -// public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) { -// super(world, position); -// this.tileEntity = tileEntity; -// } -// -// @Override -// protected boolean isCrop(Vect pos) { -// return canHarvestCrop(this.tileEntity); -// } -// -// @Override -// protected Collection harvestBlock(Vect pos) { -// return getCropDrops(this.tileEntity); -// } -// -// /** -// * Check if there is an instance of ICropTile. -// * @param tileEntity tile entity to be checked. -// * @return true if there is an IC2 crop and false otherwise. -// */ -// @Optional.Method(modid = PluginIC2.modId) -// public static boolean isIC2Crop(TileEntity tileEntity) { -// if (tileEntity instanceof ICropTile) { -// return true; -// } -// return false; -// } -// -// /** -// * Check if an IC2 crop is ready to be harvested. -// * @param tileEntity tile entity to be checked. -// * @return true if crop size is optimal for harvest and false otherwise. -// */ -// @Optional.Method(modid = PluginIC2.modId) -// public static boolean canHarvestCrop(TileEntity tileEntity) { -// if (isIC2Crop(tileEntity)) { -// ICropTile crop = (ICropTile) tileEntity; -// if (crop.getCrop() == null) { -// return false; -// } -// if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) { -// return true; -// } -// } -// return false; -// } -// -// /** -// * This function takes care of everything related to the harvesting of the -// * crop meaning it will calculate the drops and also do setSizeAfterHarvest(). -// * @param tileEntity tile entity to be checked. -// * @return list containing the drops. -// */ -// @Optional.Method(modid = PluginIC2.modId) -// private static List getCropDrops(TileEntity tileEntity) { -// if (isIC2Crop(tileEntity)) { -// ICropTile crop = (ICropTile) tileEntity; -// return crop.performHarvest(); -// } -// return null; -// } +import javax.annotation.Nonnull; + +import java.util.Collection; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import net.minecraftforge.fml.common.Optional; + +import forestry.plugins.compat.PluginIC2; + +import ic2.api.crops.ICropTile; + +public class CropBasicIC2Crop extends Crop { + private final TileEntity tileEntity; + + public CropBasicIC2Crop(@Nonnull World world, @Nonnull TileEntity tileEntity, @Nonnull BlockPos position) { + super(world, position); + this.tileEntity = tileEntity; + } + + @Override + protected boolean isCrop(World world, BlockPos pos) { + return canHarvestCrop(this.tileEntity); + } + + @Override + protected Collection harvestBlock(World world, BlockPos pos) { + return getCropDrops(this.tileEntity); + } + + /** + * Check if there is an instance of ICropTile. + * @param tileEntity tile entity to be checked. + * @return true if there is an IC2 crop and false otherwise. + */ + @Optional.Method(modid = PluginIC2.modId) + public static boolean isIC2Crop(TileEntity tileEntity) { + if (tileEntity instanceof ICropTile) { + return true; + } + return false; + } + + /** + * Check if an IC2 crop is ready to be harvested. + * @param tileEntity tile entity to be checked. + * @return true if crop size is optimal for harvest and false otherwise. + */ + @Optional.Method(modid = PluginIC2.modId) + public static boolean canHarvestCrop(TileEntity tileEntity) { + if (isIC2Crop(tileEntity)) { + ICropTile crop = (ICropTile) tileEntity; + if (crop.getCrop() == null) { + return false; + } + if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) { + return true; + } + } + return false; + } + + /** + * This function takes care of everything related to the harvesting of the + * crop meaning it will calculate the drops and also do setSizeAfterHarvest(). + * @param tileEntity tile entity to be checked. + * @return list containing the drops. + */ + @Optional.Method(modid = PluginIC2.modId) + private static List getCropDrops(TileEntity tileEntity) { + if (isIC2Crop(tileEntity)) { + ICropTile crop = (ICropTile) tileEntity; + return crop.performHarvest(); + } + return null; + } } diff --git a/src/main/java/forestry/farming/logic/CropRubber.java b/src/main/java/forestry/farming/logic/CropRubber.java index 585caaa2a..a29688870 100755 --- a/src/main/java/forestry/farming/logic/CropRubber.java +++ b/src/main/java/forestry/farming/logic/CropRubber.java @@ -13,6 +13,7 @@ package forestry.farming.logic; import java.util.ArrayList; import java.util.Collection; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -26,8 +27,17 @@ import forestry.plugins.compat.PluginIC2; public class CropRubber extends CropDestroy { public CropRubber(World world, IBlockState blockState, BlockPos position) { - //TODO IC2 for 1.9: check that this is setting the right state for replanting. - super(world, blockState, position, blockState.getBlock().getDefaultState()); + super(world, blockState, position, getReplantState(blockState)); + } + + /** + * Convert a "wet" rubber log blockstate into the dry version. + * Total hack since we don't have access to the blockstates. + */ + private static IBlockState getReplantState(IBlockState sappyState) { + Block block = sappyState.getBlock(); + int sappyMeta = block.getMetaFromState(sappyState); + return block.getStateFromMeta(sappyMeta - 4); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 936b79f79..108c6d5f4 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -39,25 +39,34 @@ import forestry.plugins.compat.PluginIC2; public class FarmLogicRubber extends FarmLogic { - private boolean inActive; + private boolean active = true; public FarmLogicRubber() { if (PluginIC2.rubberWood == null || PluginIC2.resin == null) { Log.warning("Failed to init a farm logic %s since IC2 was not found", getClass().getName()); - inActive = true; + active = false; } } @Override @SideOnly(Side.CLIENT) public Item getItem() { - if (!inActive) { + if (active) { return PluginIC2.resin.getItem(); } else { return Items.GUNPOWDER; } } + @Override + public int getMetadata() { + if (active) { + return PluginIC2.resin.getMetadata(); + } else { + return super.getMetadata(); + } + } + @Override public String getName() { return "Rubber Plantation"; @@ -102,7 +111,7 @@ public class FarmLogicRubber extends FarmLogic { @Override public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { - if (inActive) { + if (!active) { return null; } @@ -135,7 +144,7 @@ public class FarmLogicRubber extends FarmLogic { } int meta = block.getMetaFromState(blockState); - if (meta >= 2 && meta <= 5) { + if (meta >= 7 && meta <= 10) { crops.push(new CropDestroy(world, blockState, position, null)); } @@ -172,7 +181,7 @@ public class FarmLogicRubber extends FarmLogic { Block block = blockState.getBlock(); if (ItemStackUtil.equals(block, PluginIC2.rubberWood)) { int meta = block.getMetaFromState(blockState); - if (meta >= 2 && meta <= 5) { + if (meta >= 7 && meta <= 10) { crops.push(new CropRubber(world, blockState, candidate)); } candidates.add(candidate); diff --git a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java b/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java index 9b127901e..8700f63da 100644 --- a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java +++ b/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java @@ -1,68 +1,85 @@ package forestry.farming.logic; -// TODO: IC2 for 1.9 -public class FarmableBasicIC2Crop {//implements IFarmable { +import javax.annotation.Nullable; -// /** -// * Perform some of the actions of the crop-matron. -// */ -// @Optional.Method(modid = PluginIC2.modId) -// public static void babysitCrop(TileEntity tileEntity) { -// if (CropBasicIC2Crop.isIC2Crop(tileEntity)) { -// ICropTile crop = (ICropTile) tileEntity; -// /* -// This part might be unbalanced until a custom farm logic is added and makes use of weed-ex. -// if (crop.getCrop() != null) { -// if (crop.getCrop().isWeed(crop)) { -// crop.reset(); -// } -// }*/ -// if (crop.getStorageWater() <= 200) { -// crop.setStorageWater(200); -// } -// if (crop.getStorageNutrient() <= 100) { -// crop.setStorageNutrient(crop.getStorageNutrient() + 100); -// } -// } -// } -// -// @Override -// public boolean isSaplingAt(World world, BlockPos pos) { -// TileEntity crop = world.getTileEntity(pos); -// if (CropBasicIC2Crop.isIC2Crop(crop)) { -// babysitCrop(crop); -// return true; -// } -// return false; -// } -// -// @Override -// public ICrop getCropAt(World world, BlockPos pos) { -// TileEntity crop = world.getTileEntity(pos); -// if (crop == null) { -// return null; -// } -// if (!CropBasicIC2Crop.isIC2Crop(crop)) { -// return null; -// } -// if (!CropBasicIC2Crop.canHarvestCrop(crop)) { -// return null; -// } -// return new CropBasicIC2Crop(world, crop, new Vect(pos)); -// } -// -// @Override -// public boolean isGermling(ItemStack itemstack) { -// return false; -// } -// -// @Override -// public boolean isWindfall(ItemStack itemstack) { -// return false; -// } -// -// @Override -// public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { -// return false; -// } +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import net.minecraftforge.fml.common.Optional; + +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmable; +import forestry.plugins.compat.PluginIC2; + +import ic2.api.crops.ICropTile; + +public class FarmableBasicIC2Crop implements IFarmable { + + /** + * Perform some of the actions of the crop-matron. + */ + @Optional.Method(modid = PluginIC2.modId) + public static void babysitCrop(TileEntity tileEntity) { + if (CropBasicIC2Crop.isIC2Crop(tileEntity)) { + ICropTile crop = (ICropTile) tileEntity; + /* + This part might be unbalanced until a custom farm logic is added and makes use of weed-ex. + if (crop.getCrop() != null) { + if (crop.getCrop().isWeed(crop)) { + crop.reset(); + } + }*/ + if (crop.getStorageWater() <= 200) { + crop.setStorageWater(200); + } + if (crop.getStorageNutrient() <= 100) { + crop.setStorageNutrient(crop.getStorageNutrient() + 100); + } + } + } + + @Override + public boolean isSaplingAt(World world, BlockPos pos) { + TileEntity crop = world.getTileEntity(pos); + if (CropBasicIC2Crop.isIC2Crop(crop)) { + babysitCrop(crop); + return true; + } + return false; + } + + @Nullable + @Override + public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) { + TileEntity crop = world.getTileEntity(pos); + if (crop == null) { + return null; + } + if (!CropBasicIC2Crop.isIC2Crop(crop)) { + return null; + } + if (!CropBasicIC2Crop.canHarvestCrop(crop)) { + return null; + } + return new CropBasicIC2Crop(world, crop, pos); + } + + @Override + public boolean isGermling(ItemStack itemstack) { + return false; + } + + @Override + public boolean isWindfall(ItemStack itemstack) { + return false; + } + + @Override + public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { + return false; + } } diff --git a/src/main/java/forestry/plugins/compat/PluginIC2.java b/src/main/java/forestry/plugins/compat/PluginIC2.java index ef892fb20..aaa2424a7 100644 --- a/src/main/java/forestry/plugins/compat/PluginIC2.java +++ b/src/main/java/forestry/plugins/compat/PluginIC2.java @@ -10,18 +10,63 @@ ******************************************************************************/ package forestry.plugins.compat; +import com.google.common.collect.ImmutableMap; + import javax.annotation.Nonnull; import java.util.Set; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.common.Optional; +import net.minecraftforge.fml.common.event.FMLInterModComms; + +import forestry.api.circuits.ChipsetManager; +import forestry.api.circuits.CircuitSocketType; +import forestry.api.circuits.ICircuitLayout; +import forestry.api.core.ForestryAPI; +import forestry.api.farming.Farmables; +import forestry.api.fuels.EngineBronzeFuel; +import forestry.api.fuels.FuelManager; +import forestry.api.recipes.RecipeManagers; +import forestry.api.storage.BackpackManager; +import forestry.api.storage.IBackpackDefinition; +import forestry.api.storage.ICrateRegistry; +import forestry.api.storage.StorageManager; +import forestry.apiculture.PluginApiculture; +import forestry.apiculture.items.EnumPropolis; +import forestry.apiculture.items.ItemRegistryApiculture; +import forestry.core.PluginCore; +import forestry.core.blocks.BlockBogEarth; +import forestry.core.circuits.Circuit; +import forestry.core.circuits.CircuitLayout; import forestry.core.config.Constants; +import forestry.core.fluids.Fluids; +import forestry.core.items.EnumElectronTube; +import forestry.core.items.ItemRegistryCore; +import forestry.core.recipes.RecipeUtil; +import forestry.core.utils.ItemStackUtil; +import forestry.core.utils.Log; import forestry.core.utils.ModUtil; +import forestry.energy.PluginEnergy; +import forestry.energy.blocks.BlockRegistryEnergy; +import forestry.energy.blocks.BlockTypeEngine; +import forestry.energy.circuits.CircuitElectricBoost; +import forestry.energy.circuits.CircuitElectricChoke; +import forestry.energy.circuits.CircuitElectricEfficiency; +import forestry.farming.circuits.CircuitFarmLogic; +import forestry.farming.logic.FarmLogicRubber; +import forestry.farming.logic.FarmableBasicIC2Crop; import forestry.plugins.BlankForestryPlugin; import forestry.plugins.ForestryPlugin; import forestry.plugins.ForestryPluginUids; -// TODO: IC2 for 1.9 +import ic2.api.item.IC2Items; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.Recipes; + @ForestryPlugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.ic2.description") public class PluginIC2 extends BlankForestryPlugin { public static final String modId = "IC2"; @@ -59,223 +104,217 @@ public class PluginIC2 extends BlankForestryPlugin { return dependencyUids; } -// @Override -// @Optional.Method(modid = PluginIC2.modId) -// public void preInit() { -// super.preInit(); -// -// BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; -// if (energyBlocks != null) { -// energyBlocks.engine.addDefinitions(BlockTypeEngine.ELECTRICAL); -// energyBlocks.engine.addDefinitions(BlockTypeEngine.GENERATOR); -// } -// -// // rubber chain -// rubberWood = IC2Items.getItem("rubber_wood"); -// resin = IC2Items.getItem("misc_resource", "resin"); -// rubberSapling = IC2Items.getItem("sapling"); -// rubber = IC2Items.getItem("crafting", "rubber"); -// -// Circuit.farmRubberManual = new CircuitFarmLogic("manualRubber", FarmLogicRubber.class); -// -// ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE); -// ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin); -// } -// -// @Override -// @Optional.Method(modid = PluginIC2.modId) -// public void doInit() { -// super.doInit(); -// -// // Remove some items from the recycler -// if (Recipes.recyclerBlacklist != null) { -// ItemRegistryApiculture beeItems = PluginApiculture.items; -// if (beeItems != null) { -// Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beeQueenGE))); -// Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beePrincessGE))); -// } -// } else { -// Log.error("IC2 Recipes.recyclerBlacklist not found."); -// } -// -// Circuit.energyElectricChoke1 = new CircuitElectricChoke("electric.choke.1"); -// Circuit.energyElectricEfficiency1 = new CircuitElectricEfficiency("electric.efficiency.1"); -// Circuit.energyElectricBoost1 = new CircuitElectricBoost("electric.boost.1", 2, 7, 20); -// Circuit.energyElectricBoost2 = new CircuitElectricBoost("electric.boost.2", 2, 15, 40); - // - // blocks.electricalEngine.init(); - // blocks.generator.init(); -// } -// -// @Override -// public void postInit() { -// super.postInit(); -// -// if (BackpackManager.backpackInterface == null) { -// return; -// } -// -// IBackpackDefinition forester = BackpackManager.backpackInterface.getBackpack(BackpackManager.FORESTER_UID); -// -// if (resin != null) { -// forester.addValidItem(resin); -// } -// if (rubber != null) { -// forester.addValidItem(rubber); -// } -// if (rubberSapling != null) { -// forester.addValidItem(rubberSapling); -// } -// ItemStack rubberLeaves = IC2Items.getItem("leaves"); -// if (rubberLeaves != null) { -// forester.addValidItem(rubberLeaves); -// } -// } -// -// @Override -// public void registerCrates() { -// ICrateRegistry crateRegistry = StorageManager.crateRegistry; -// if (crateRegistry == null) { -// return; -// } -// -// if (resin != null) { -// crateRegistry.registerCrate(resin); -// } -// -// if (rubber != null) { -// crateRegistry.registerCrate(rubber); -// } -// -// ItemStack scrap = IC2Items.getItem("crafting", "scrap"); -// if (scrap != null) { -// crateRegistry.registerCrate(scrap); -// } -// -// ItemStack uuMatter = IC2Items.getItem("misc_resource", "matter"); -// if (uuMatter != null) { -// crateRegistry.registerCrate(uuMatter); -// } -// -// ItemStack silver = IC2Items.getItem("ingot", "silver"); -// if (silver != null) { -// crateRegistry.registerCrateUsingOreDict(silver); -// } -// -// ItemStack brass = IC2Items.getItem("ingot", "bronze"); -// if (brass != null) { -// crateRegistry.registerCrateUsingOreDict(brass); -// } -// } -// -// @Override -// @Optional.Method(modid = PluginIC2.modId) -// public void registerRecipes() { -// ItemRegistryCore coreItems = PluginCore.items; -// -// if (rubber != null) { -// for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) { -// RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), coreItems.tubes.get(EnumElectronTube.RUBBER, 4), -// new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', rubberOreDict}); -// } -// } -// -// ItemStack plantBall = IC2Items.getItem("crafting", "plant_ball"); -// if (plantBall != null) { -// RecipeUtil.addFermenterRecipes(plantBall, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); -// } -// -// ItemStack bioChaff = IC2Items.getItem("crafting", "bio_chaff"); -// if (bioChaff != null) { -// RecipeUtil.addFermenterRecipes(bioChaff, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); -// } -// -// ItemRegistryApiculture beeItems = PluginApiculture.items; -// if (beeItems != null) { -// if (resin != null) { -// RecipeManagers.centrifugeManager.addRecipe(20, beeItems.propolis.get(EnumPropolis.NORMAL, 1), ImmutableMap.of(resin, 1.0f)); -// } else { -// Log.info("Missing IC2 resin, skipping centrifuge recipe for propolis to resin."); -// } -// } -// -// if (rubberSapling != null) { -// RecipeUtil.addFermenterRecipes(rubberSapling, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); -// } else { -// Log.info("Missing IC2 rubber sapling, skipping fermenter recipe for converting rubber sapling to biomass."); -// } -// -// if (rubberSapling != null && resin != null) { -// String saplingName = ItemStackUtil.getBlockNameFromRegistryAsSting(ItemStackUtil.getBlock(rubberSapling)); -// String resinName = ItemStackUtil.getItemNameFromRegistryAsString(resin.getItem()); -// String imc = String.format("farmArboreal@%s.%s.%s.%s", -// saplingName, rubberSapling.getItemDamage(), -// resinName, resin.getItemDamage()); -// Log.trace("Sending IMC '%s'.", imc); -// FMLInterModComms.sendMessage(Constants.MOD_ID, "add-farmable-sapling", imc); -// } -// -// -// if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ENERGY)) { -// FluidStack biogas = FluidRegistry.getFluidStack("ic2biogas", 1000); -// if (biogas != null) { -// int burnDuration = Math.round(Constants.ENGINE_CYCLE_DURATION_BIOMASS * ForestryAPI.activeMode.getFloatSetting("fuel.biomass.biogas")); -// EngineBronzeFuel bronzeFuel = new EngineBronzeFuel(Fluids.BIOMASS.getFluid(), Constants.ENGINE_FUEL_VALUE_BIOMASS, burnDuration, 1); -// FuelManager.bronzeEngineFuel.put(biogas.getFluid(), bronzeFuel); -// } -// } -// -// ItemStack waterCell = IC2Items.getItem("fluid_cell", "water"); -// if (waterCell != null) { -// int bogEarthOutputCan = ForestryAPI.activeMode.getIntegerSetting("recipe.output.bogearth.can"); -// if (bogEarthOutputCan > 0) { - // ItemStack bogEarthCan = PluginCore.blocks.soil.get(BlockBogEarth.SoilType.BOG_EARTH, bogEarthOutputCan); -// RecipeUtil.addRecipe(bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', waterCell, 'Y', "sand"); -// } -// } -// -// ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout("forestry.engine.tin"); -// -// // / Solder Manager -// ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuit.energyElectricChoke1); -// ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuit.energyElectricBoost1); -// ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuit.energyElectricBoost2); -// ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.IRON, 1), Circuit.energyElectricEfficiency1); -// -// if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) { -// if (resin != null && rubberWood != null) { -// ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual"); -// ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.RUBBER, 1), Circuit.farmRubberManual); -// } -// -// Farmables.farmables.get("farmOrchard").add(new FarmableBasicIC2Crop()); -// } -// -// -// BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; -// if (energyBlocks != null) { -// RecipeUtil.addRecipe(energyBlocks.engine.get(BlockTypeEngine.GENERATOR), -// "X#X", -// "XYX", -// "X#X", -// '#', "blockGlass", -// 'X', "ingotGold", -// 'Y', coreItems.sturdyCasing); -// -// RecipeUtil.addRecipe(energyBlocks.engine.get(BlockTypeEngine.ELECTRICAL), -// "###", -// " X ", -// "YVY", -// '#', "ingotTin", -// 'X', "blockGlass", -// 'Y', "gearTin", -// 'V', Blocks.PISTON); -// } - // } - // - // @Override - // public void registerItemsAndBlocks() { - // super.registerItemsAndBlocks(); - // blocks = new BlockRegistryIC2(); -// } + @Override + @Optional.Method(modid = PluginIC2.modId) + public void preInit() { + super.preInit(); + + // rubber chain + rubberWood = IC2Items.getItem("rubber_wood"); + resin = IC2Items.getItem("misc_resource", "resin"); + rubberSapling = IC2Items.getItem("sapling"); + rubber = IC2Items.getItem("crafting", "rubber"); + + Circuit.farmRubberManual = new CircuitFarmLogic("manualRubber", new FarmLogicRubber()); + + ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE); + ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin); + } + + @Override + @Optional.Method(modid = PluginIC2.modId) + public void doInit() { + super.doInit(); + + // Remove some items from the recycler + if (Recipes.recyclerBlacklist != null) { + ItemRegistryApiculture beeItems = PluginApiculture.items; + if (beeItems != null) { + Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beeQueenGE))); + Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beePrincessGE))); + } + } else { + Log.error("IC2 Recipes.recyclerBlacklist not found."); + } + + Circuit.energyElectricChoke1 = new CircuitElectricChoke("electric.choke.1"); + Circuit.energyElectricEfficiency1 = new CircuitElectricEfficiency("electric.efficiency.1"); + Circuit.energyElectricBoost1 = new CircuitElectricBoost("electric.boost.1", 2, 7, 20); + Circuit.energyElectricBoost2 = new CircuitElectricBoost("electric.boost.2", 2, 15, 40); + + blocks.electricalEngine.init(); + blocks.generator.init(); + } + + @Override + public void postInit() { + super.postInit(); + + if (BackpackManager.backpackInterface == null) { + return; + } + + IBackpackDefinition forester = BackpackManager.backpackInterface.getBackpack(BackpackManager.FORESTER_UID); + + if (resin != null) { + forester.addValidItem(resin); + } + if (rubber != null) { + forester.addValidItem(rubber); + } + if (rubberSapling != null) { + forester.addValidItem(rubberSapling); + } + ItemStack rubberLeaves = IC2Items.getItem("leaves"); + if (rubberLeaves != null) { + forester.addValidItem(rubberLeaves); + } + } + + @Override + public void registerCrates() { + ICrateRegistry crateRegistry = StorageManager.crateRegistry; + if (crateRegistry == null) { + return; + } + + if (resin != null) { + crateRegistry.registerCrate(resin); + } + + if (rubber != null) { + crateRegistry.registerCrate(rubber); + } + + ItemStack scrap = IC2Items.getItem("crafting", "scrap"); + if (scrap != null) { + crateRegistry.registerCrate(scrap); + } + + ItemStack uuMatter = IC2Items.getItem("misc_resource", "matter"); + if (uuMatter != null) { + crateRegistry.registerCrate(uuMatter); + } + + ItemStack silver = IC2Items.getItem("ingot", "silver"); + if (silver != null) { + crateRegistry.registerCrate(silver); + } + + ItemStack brass = IC2Items.getItem("ingot", "bronze"); + if (brass != null) { + crateRegistry.registerCrate(brass); + } + } + + @Override + @Optional.Method(modid = PluginIC2.modId) + public void registerRecipes() { + ItemRegistryCore coreItems = PluginCore.items; + + if (rubber != null) { + for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) { + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), coreItems.tubes.get(EnumElectronTube.RUBBER, 4), + new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', rubberOreDict}); + } + } + + ItemStack plantBall = IC2Items.getItem("crafting", "plant_ball"); + if (plantBall != null) { + RecipeUtil.addFermenterRecipes(plantBall, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); + } + + ItemStack bioChaff = IC2Items.getItem("crafting", "bio_chaff"); + if (bioChaff != null) { + RecipeUtil.addFermenterRecipes(bioChaff, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); + } + + ItemRegistryApiculture beeItems = PluginApiculture.items; + if (beeItems != null) { + if (resin != null) { + RecipeManagers.centrifugeManager.addRecipe(20, beeItems.propolis.get(EnumPropolis.NORMAL, 1), ImmutableMap.of(resin, 1.0f)); + } else { + Log.info("Missing IC2 resin, skipping centrifuge recipe for propolis to resin."); + } + } + + if (rubberSapling != null) { + RecipeUtil.addFermenterRecipes(rubberSapling, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); + } else { + Log.info("Missing IC2 rubber sapling, skipping fermenter recipe for converting rubber sapling to biomass."); + } + + if (rubberSapling != null && resin != null) { + String saplingName = ItemStackUtil.getBlockNameFromRegistryAsSting(ItemStackUtil.getBlock(rubberSapling)); + String resinName = ItemStackUtil.getItemNameFromRegistryAsString(resin.getItem()); + String imc = String.format("farmArboreal@%s.%s.%s.%s", + saplingName, rubberSapling.getItemDamage(), + resinName, resin.getItemDamage()); + Log.trace("Sending IMC '%s'.", imc); + FMLInterModComms.sendMessage(Constants.MOD_ID, "add-farmable-sapling", imc); + } + + + if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ENERGY)) { + FluidStack biogas = FluidRegistry.getFluidStack("ic2biogas", 1000); + if (biogas != null) { + int burnDuration = Math.round(Constants.ENGINE_CYCLE_DURATION_BIOMASS * ForestryAPI.activeMode.getFloatSetting("fuel.biomass.biogas")); + EngineBronzeFuel bronzeFuel = new EngineBronzeFuel(Fluids.BIOMASS.getFluid(), Constants.ENGINE_FUEL_VALUE_BIOMASS, burnDuration, 1); + FuelManager.bronzeEngineFuel.put(biogas.getFluid(), bronzeFuel); + } + } + + ItemStack waterCell = IC2Items.getItem("fluid_cell", "water"); + if (waterCell != null) { + int bogEarthOutputCan = ForestryAPI.activeMode.getIntegerSetting("recipe.output.bogearth.can"); + if (bogEarthOutputCan > 0) { + ItemStack bogEarthCan = PluginCore.blocks.bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, bogEarthOutputCan); + RecipeUtil.addRecipe(bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', waterCell, 'Y', "sand"); + } + } + + ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout("forestry.engine.tin"); + + // / Solder Manager + ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuit.energyElectricChoke1); + ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuit.energyElectricBoost1); + ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuit.energyElectricBoost2); + ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.IRON, 1), Circuit.energyElectricEfficiency1); + + if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) { + if (resin != null && rubberWood != null) { + ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual"); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.RUBBER, 1), Circuit.farmRubberManual); + } + + Farmables.farmables.get("farmOrchard").add(new FarmableBasicIC2Crop()); + } + + + BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; + if (energyBlocks != null) { + RecipeUtil.addRecipe(blocks.generator, + "X#X", + "XYX", + "X#X", + '#', "blockGlass", + 'X', "ingotGold", + 'Y', coreItems.sturdyCasing); + + RecipeUtil.addRecipe(blocks.electricalEngine, + "###", + " X ", + "YVY", + '#', "ingotTin", + 'X', "blockGlass", + 'Y', "gearTin", + 'V', Blocks.PISTON); + } + } + + @Override + public void registerItemsAndBlocks() { + super.registerItemsAndBlocks(); + blocks = new BlockRegistryIC2(); + } }