mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-17 10:55:06 +00:00
Close #1144 add IC2 compatibility back
This commit is contained in:
1 parent
04173d6bcf
commit
08d543b2ef
24 files changed
+1694
-7
No files matched your search
@@ -31,7 +31,9 @@ import forestry.core.tiles.TileAnalyzer;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
import forestry.core.tiles.TileNaturalistChest;
|
||||
import forestry.energy.tiles.TileEngineBiogas;
|
||||
import forestry.energy.tiles.TileEngineElectric;
|
||||
import forestry.energy.tiles.TileEnginePeat;
|
||||
import forestry.energy.tiles.TileEuGenerator;
|
||||
import forestry.factory.tiles.TileBottler;
|
||||
import forestry.factory.tiles.TileCarpenter;
|
||||
import forestry.factory.tiles.TileCentrifuge;
|
||||
@@ -87,7 +89,9 @@ public class GuiIdRegistry {
|
||||
TileGreenhouse.class,
|
||||
|
||||
TileEngineBiogas.class,
|
||||
TileEngineElectric.class,
|
||||
TileEnginePeat.class,
|
||||
TileEuGenerator.class,
|
||||
|
||||
TileMailbox.class,
|
||||
TileStampCollector.class,
|
||||
|
||||
@@ -16,26 +16,42 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
|
||||
import forestry.core.blocks.IBlockTypeTesr;
|
||||
import forestry.core.blocks.IMachinePropertiesTesr;
|
||||
import forestry.core.blocks.MachinePropertiesTesr;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileBase;
|
||||
import forestry.core.tiles.TileEngine;
|
||||
import forestry.energy.PluginEnergy;
|
||||
import forestry.energy.tiles.TileEngineBiogas;
|
||||
import forestry.energy.tiles.TileEngineClockwork;
|
||||
import forestry.energy.tiles.TileEngineElectric;
|
||||
import forestry.energy.tiles.TileEnginePeat;
|
||||
import forestry.energy.tiles.TileEuGenerator;
|
||||
|
||||
public enum BlockTypeEngine implements IBlockTypeTesr {
|
||||
PEAT(0, TileEnginePeat.class, "peat", "/engine_copper_"),
|
||||
BIOGAS(1, TileEngineBiogas.class, "biogas", "/engine_bronze_"),
|
||||
CLOCKWORK(2, TileEngineClockwork.class, "clockwork", "/engine_clock_");
|
||||
PEAT(createEngineProperties(0, TileEnginePeat.class, "peat", "/engine_copper_")),
|
||||
BIOGAS(createEngineProperties(1, TileEngineBiogas.class, "biogas", "/engine_bronze_")),
|
||||
CLOCKWORK(createEngineProperties(2, TileEngineClockwork.class, "clockwork", "/engine_clock_")),
|
||||
ELECTRICAL(createEngineProperties(3, TileEngineElectric.class, "electrical", "/engine_tin_")),
|
||||
GENERATOR(createMachineProperties(4, TileEuGenerator.class, "generator", "/generator_"));
|
||||
|
||||
public static final BlockTypeEngine[] VALUES = values();
|
||||
|
||||
@Nonnull
|
||||
private final IMachinePropertiesTesr<?> machineProperties;
|
||||
|
||||
BlockTypeEngine(int meta, @Nonnull Class<? extends TileEngine> teClass, @Nonnull String name, @Nonnull String textureName) {
|
||||
BlockTypeEngine(@Nonnull IMachinePropertiesTesr<?> machineProperties) {
|
||||
this.machineProperties = machineProperties;
|
||||
}
|
||||
|
||||
protected static IMachinePropertiesTesr<?> createEngineProperties(int meta, @Nonnull Class<? extends TileEngine> teClass, @Nonnull String name, @Nonnull String textureName) {
|
||||
TileEntitySpecialRenderer<TileEngine> renderer = PluginEnergy.proxy.getRenderDefaultEngine(Constants.TEXTURE_PATH_BLOCKS + textureName);
|
||||
this.machineProperties = new MachinePropertiesEngine<>(meta, teClass, name, renderer);
|
||||
return new MachinePropertiesEngine<>(meta, teClass, name, renderer);
|
||||
}
|
||||
|
||||
protected static IMachinePropertiesTesr<?> createMachineProperties(int meta, @Nonnull Class<? extends TileBase> teClass, @Nonnull String name, @Nonnull String textureName) {
|
||||
TileEntitySpecialRenderer<TileBase> renderer = Proxies.render.getRenderDefaultMachine(Constants.TEXTURE_PATH_BLOCKS + textureName);
|
||||
return new MachinePropertiesTesr<>(meta, teClass, name, renderer);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.circuits;
|
||||
|
||||
public class CircuitElectricBoost extends CircuitElectricChange {
|
||||
|
||||
public CircuitElectricBoost(String uid, int limit, int eu, int rf) {
|
||||
super(uid, false);
|
||||
this.setLimit(limit);
|
||||
this.configureChange(eu, rf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.circuits;
|
||||
|
||||
import forestry.core.circuits.Circuit;
|
||||
import forestry.energy.tiles.TileEngineElectric;
|
||||
|
||||
public abstract class CircuitElectricChange extends Circuit {
|
||||
|
||||
private int euChange = 7;
|
||||
private int rfChange = 20;
|
||||
|
||||
protected CircuitElectricChange(String uid, boolean requiresDiscovery) {
|
||||
super(uid, requiresDiscovery);
|
||||
}
|
||||
|
||||
protected void configureChange(int euChange, int rfChange) {
|
||||
this.euChange = euChange;
|
||||
this.rfChange = rfChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCircuitable(Object tile) {
|
||||
return tile instanceof TileEngineElectric;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInsertion(int slot, Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileEngineElectric engine = (TileEngineElectric) tile;
|
||||
engine.changeEnergyConfig(euChange, rfChange, 2 * euChange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad(int slot, Object tile) {
|
||||
onInsertion(slot, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoval(int slot, Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileEngineElectric engine = (TileEngineElectric) tile;
|
||||
engine.changeEnergyConfig(-euChange, -rfChange, -(2 * euChange));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(int slot, Object tile) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.circuits;
|
||||
|
||||
public class CircuitElectricChoke extends CircuitElectricChange {
|
||||
|
||||
public CircuitElectricChoke(String uid) {
|
||||
super(uid, false);
|
||||
this.configureChange(-2, -10);
|
||||
this.setLimit(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.circuits;
|
||||
|
||||
public class CircuitElectricEfficiency extends CircuitElectricChange {
|
||||
|
||||
public CircuitElectricEfficiency(String uid) {
|
||||
super(uid, false);
|
||||
this.setLimit(1);
|
||||
this.configureChange(-1, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.gui.ContainerSocketed;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.network.packets.PacketGuiUpdate;
|
||||
import forestry.energy.inventory.InventoryEngineElectric;
|
||||
import forestry.energy.tiles.TileEngineElectric;
|
||||
|
||||
public class ContainerEngineElectric extends ContainerSocketed<TileEngineElectric> {
|
||||
|
||||
public ContainerEngineElectric(InventoryPlayer player, TileEngineElectric tile) {
|
||||
super(tile, player, 8, 84);
|
||||
|
||||
this.addSlotToContainer(new SlotFiltered(tile, InventoryEngineElectric.SLOT_BATTERY, 84, 53));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
if (tile != null) {
|
||||
tile.getGUINetworkData(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (tile != null) {
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(tile);
|
||||
sendPacketToCrafters(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.energy.inventory.InventoryGenerator;
|
||||
import forestry.energy.tiles.TileEuGenerator;
|
||||
|
||||
public class ContainerGenerator extends ContainerLiquidTanks<TileEuGenerator> {
|
||||
|
||||
public ContainerGenerator(InventoryPlayer player, TileEuGenerator tile) {
|
||||
super(tile, player, 8, 84);
|
||||
|
||||
this.addSlotToContainer(new SlotFiltered(tile, InventoryGenerator.SLOT_CAN, 22, 38));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int messageId, int data) {
|
||||
super.updateProgressBar(messageId, data);
|
||||
|
||||
tile.getGUINetworkData(messageId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (Object crafter : crafters) {
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.gui;
|
||||
|
||||
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;
|
||||
|
||||
public class GuiEngineElectric extends GuiEngine<ContainerEngineElectric, TileEngineElectric> {
|
||||
|
||||
public GuiEngineElectric(InventoryPlayer inventory, TileEngineElectric tile) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/electricalengine.png", new ContainerEngineElectric(inventory, tile), tile);
|
||||
widgetManager.add(new SocketWidget(this.widgetManager, 30, 40, tile, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
TileEngineElectric engine = inventory;
|
||||
int storageHeight = engine.getStorageScaled(46);
|
||||
int storageMaxHeight = engine.getStorageScaled(100);
|
||||
EnumTankLevel rated = EnumTankLevel.rateTankLevel(storageMaxHeight);
|
||||
|
||||
drawHealthMeter(guiLeft + 74, guiTop + 25, storageHeight, rated);
|
||||
}
|
||||
|
||||
private void drawHealthMeter(int x, int y, int height, EnumTankLevel rated) {
|
||||
int i = 176 + rated.getLevelScaled(16);
|
||||
int k = 0;
|
||||
|
||||
this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
|
||||
}
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.energy.tiles.TileEuGenerator;
|
||||
|
||||
public class GuiGenerator extends GuiForestryTitled<ContainerGenerator, TileEuGenerator> {
|
||||
|
||||
public GuiGenerator(InventoryPlayer inventory, TileEuGenerator tile) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/generator.png", new ContainerGenerator(inventory, tile), tile);
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 49, 17, 0));
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.energy.tiles.TileEngineElectric;
|
||||
|
||||
import ic2.api.item.ElectricItem;
|
||||
|
||||
public class InventoryEngineElectric extends InventoryAdapterTile<TileEngineElectric> {
|
||||
public static final short SLOT_BATTERY = 0;
|
||||
|
||||
public InventoryEngineElectric(TileEngineElectric engineTin) {
|
||||
super(engineTin, 1, "electrical");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_BATTERY) {
|
||||
return ElectricItem.manager.getCharge(itemStack) > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.energy.tiles.TileEuGenerator;
|
||||
|
||||
public class InventoryGenerator extends InventoryAdapterTile<TileEuGenerator> {
|
||||
public static final short SLOT_CAN = 0;
|
||||
|
||||
public InventoryGenerator(TileEuGenerator generator) {
|
||||
super(generator, 1, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.CircuitSocketType;
|
||||
import forestry.api.circuits.ICircuitBoard;
|
||||
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;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.tiles.TemperatureState;
|
||||
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;
|
||||
|
||||
public class TileEngineElectric extends TileEngine implements ISocketable, IInventory, IStreamableGui {
|
||||
protected static class EuConfig {
|
||||
|
||||
public int euForCycle;
|
||||
public int rfPerCycle;
|
||||
public int euStorage;
|
||||
|
||||
public EuConfig() {
|
||||
this.euForCycle = Constants.ENGINE_TIN_EU_FOR_CYCLE;
|
||||
this.rfPerCycle = Constants.ENGINE_TIN_ENERGY_PER_CYCLE;
|
||||
this.euStorage = Constants.ENGINE_TIN_MAX_EU_STORED;
|
||||
}
|
||||
}
|
||||
|
||||
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
|
||||
private final EuConfig euConfig = new EuConfig();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// / SAVING / LOADING
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.readFromNBT(nbttagcompound);
|
||||
}
|
||||
sockets.readFromNBT(nbttagcompound);
|
||||
|
||||
ItemStack chip = sockets.getStackInSlot(0);
|
||||
if (chip != null) {
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(chip);
|
||||
if (chipset != null) {
|
||||
chipset.onLoad(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.writeToNBT(nbttagcompound);
|
||||
}
|
||||
sockets.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.onChunkUnload();
|
||||
}
|
||||
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.invalidate();
|
||||
}
|
||||
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
// / HEAT MANAGEMENT
|
||||
@Override
|
||||
public int dissipateHeat() {
|
||||
if (heat <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int loss = 0;
|
||||
|
||||
if (!isBurning() || !isRedstoneActivated()) {
|
||||
loss += 1;
|
||||
}
|
||||
|
||||
TemperatureState tempState = getTemperatureState();
|
||||
if (tempState == TemperatureState.OVERHEATING || tempState == TemperatureState.OPERATING_TEMPERATURE) {
|
||||
loss += 1;
|
||||
}
|
||||
|
||||
heat -= loss;
|
||||
return loss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int generateHeat() {
|
||||
|
||||
int gain = 0;
|
||||
if (isRedstoneActivated() && isBurning()) {
|
||||
gain++;
|
||||
if (((double) energyManager.getTotalEnergyStored() / (double) energyManager.getMaxEnergyStored()) > 0.5) {
|
||||
gain++;
|
||||
}
|
||||
}
|
||||
|
||||
addHeat(gain);
|
||||
return gain;
|
||||
}
|
||||
|
||||
// / WORK
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
// No work to be done if IC2 is unavailable.
|
||||
if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ic2EnergySink.update();
|
||||
|
||||
super.updateServerSide();
|
||||
|
||||
if (forceCooldown) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getStackInSlot(InventoryEngineElectric.SLOT_BATTERY) != null) {
|
||||
replenishFromBattery(InventoryEngineElectric.SLOT_BATTERY);
|
||||
}
|
||||
|
||||
// Updating of gui delayed to prevent it from going crazy
|
||||
if (!updateOnInterval(80)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle);
|
||||
errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void burn() {
|
||||
|
||||
currentOutput = 0;
|
||||
|
||||
if (!isRedstoneActivated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ic2EnergySink.useEnergy(euConfig.euForCycle)) {
|
||||
currentOutput = euConfig.rfPerCycle;
|
||||
energyManager.generateEnergy(euConfig.rfPerCycle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void replenishFromBattery(int slot) {
|
||||
if (!isRedstoneActivated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3);
|
||||
}
|
||||
|
||||
// / STATE INFORMATION
|
||||
@Override
|
||||
protected boolean isBurning() {
|
||||
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());
|
||||
}
|
||||
|
||||
// / SMP GUI
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeVarInt(currentOutput);
|
||||
data.writeVarInt(heat);
|
||||
sockets.writeData(data);
|
||||
energyManager.writeData(data);
|
||||
final boolean hasIc2EnergySink = (ic2EnergySink != null);
|
||||
data.writeBoolean(hasIc2EnergySink);
|
||||
if (hasIc2EnergySink) {
|
||||
data.writeVarInt((int) ic2EnergySink.getEnergyStored());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
currentOutput = data.readVarInt();
|
||||
heat = data.readVarInt();
|
||||
sockets.readData(data);
|
||||
energyManager.readData(data);
|
||||
final boolean hasIc2EnergySink = data.readBoolean();
|
||||
if (hasIc2EnergySink) {
|
||||
final int energyStored = data.readVarInt();
|
||||
ic2EnergySink.setEnergyStored(energyStored);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
// handled by IStreamableGui
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGUINetworkData(Container containerEngine, ICrafting iCrafting) {
|
||||
// handled by IStreamableGui
|
||||
}
|
||||
|
||||
// / ENERGY CONFIG CHANGE
|
||||
public void changeEnergyConfig(int euChange, int rfChange, int storageChange) {
|
||||
euConfig.euForCycle += euChange;
|
||||
euConfig.rfPerCycle += rfChange;
|
||||
euConfig.euStorage += storageChange;
|
||||
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.setCapacity(euConfig.euStorage);
|
||||
}
|
||||
}
|
||||
|
||||
/* ISocketable */
|
||||
@Override
|
||||
public int getSocketCount() {
|
||||
return sockets.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSocket(int slot) {
|
||||
return sockets.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSocket(int slot, ItemStack stack) {
|
||||
|
||||
if (stack != null && !ChipsetManager.circuitRegistry.isChipset(stack)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Dispose correctly of old chipsets
|
||||
if (sockets.getStackInSlot(slot) != null) {
|
||||
if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) {
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(sockets.getStackInSlot(slot));
|
||||
if (chipset != null) {
|
||||
chipset.onRemoval(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sockets.setInventorySlotContents(slot, stack);
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(stack);
|
||||
if (chipset != null) {
|
||||
chipset.onInsertion(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICircuitSocketType getSocketType() {
|
||||
return CircuitSocketType.ELECTRIC_ENGINE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
return new GuiEngineElectric(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerEngineElectric(player.inventory, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
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;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.render.TankRenderInfo;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
import forestry.core.tiles.IRenderableTile;
|
||||
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;
|
||||
|
||||
public class TileEuGenerator extends TileBase implements ISidedInventory, ILiquidTankTile, IFluidHandler, IRenderableTile {
|
||||
private static final int maxEnergy = 30000;
|
||||
|
||||
private final TankManager tankManager;
|
||||
private final FilteredTank resourceTank;
|
||||
|
||||
private int tickCount = 0;
|
||||
|
||||
private BasicSource ic2EnergySource;
|
||||
|
||||
public TileEuGenerator() {
|
||||
super("generator");
|
||||
|
||||
setInternalInventory(new InventoryGenerator(this));
|
||||
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet());
|
||||
tankManager = new TankManager(this, resourceTank);
|
||||
|
||||
if (PluginIC2.instance.isAvailable()) {
|
||||
ic2EnergySource = new BasicSource(this, maxEnergy, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
tankManager.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
tankManager.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.onChunkUnload();
|
||||
}
|
||||
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.invalidate();
|
||||
}
|
||||
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
if (updateOnInterval(20)) {
|
||||
FluidHelper.drainContainers(tankManager, this, InventoryGenerator.SLOT_CAN);
|
||||
}
|
||||
|
||||
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.canDrain(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);
|
||||
}
|
||||
|
||||
public boolean isWorking() {
|
||||
return resourceTank.getFluidAmount() > 0;
|
||||
}
|
||||
|
||||
public int getResourceScaled(int i) {
|
||||
return (resourceTank.getFluidAmount() * i) / Constants.PROCESSOR_TANK_CAPACITY;
|
||||
}
|
||||
|
||||
public int getStoredScaled(int i) {
|
||||
if (ic2EnergySource == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankRenderInfo getResourceTankInfo() {
|
||||
return new TankRenderInfo(resourceTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankRenderInfo getProductTankInfo() {
|
||||
return TankRenderInfo.EMPTY;
|
||||
}
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
if (i == 0) {
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.setEnergyStored(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
if (ic2EnergySource != null) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored());
|
||||
}
|
||||
}
|
||||
|
||||
/* ILiquidTankTile */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
return new GuiGenerator(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerGenerator(player.inventory, this);
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,16 @@ public class PluginFactory extends BlankForestryPlugin {
|
||||
FuelManager.rainSubstrate.put(iodineCharge, new RainSubstrate(iodineCharge, Constants.RAINMAKER_RAIN_DURATION_IODINE, 0.01f));
|
||||
FuelManager.rainSubstrate.put(dissipationCharge, new RainSubstrate(dissipationCharge, 0.075f));
|
||||
|
||||
blocks.factoryTESR.addDefinitions(BlockTypeFactoryTesr.VALUES);
|
||||
blocks.factoryTESR.addDefinitions(
|
||||
BlockTypeFactoryTesr.BOTTLER,
|
||||
BlockTypeFactoryTesr.CARPENTER,
|
||||
BlockTypeFactoryTesr.CENTRIFUGE,
|
||||
BlockTypeFactoryTesr.FERMENTER,
|
||||
BlockTypeFactoryTesr.MOISTENER,
|
||||
BlockTypeFactoryTesr.SQUEEZER,
|
||||
BlockTypeFactoryTesr.STILL,
|
||||
BlockTypeFactoryTesr.RAINMAKER
|
||||
);
|
||||
blocks.factoryPlain.addDefinitions(BlockTypeFactoryPlain.VALUES);
|
||||
|
||||
ICircuitLayout layoutMachineUpgrade = new CircuitLayout("machine.upgrade", CircuitSocketType.MACHINE);
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
import ic2.api.crops.ICropTile;
|
||||
|
||||
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<ItemStack> 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<ItemStack> getCropDrops(TileEntity tileEntity) {
|
||||
if (isIC2Crop(tileEntity)) {
|
||||
ICropTile crop = (ICropTile) tileEntity;
|
||||
return crop.performHarvest();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
public class CropRubber extends CropBlock {
|
||||
|
||||
public CropRubber(World world, Block block, int meta, Vect position) {
|
||||
super(world, block, meta, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
Collection<ItemStack> harvested = new ArrayList<>();
|
||||
harvested.add(PluginIC2.resin.copy());
|
||||
Proxies.common.addBlockDestroyEffects(world, pos, block.getStateFromMeta(0));
|
||||
world.setBlockState(pos, block.getStateFromMeta(meta + 6), Constants.FLAG_BLOCK_SYNCH);
|
||||
return harvested;
|
||||
}
|
||||
|
||||
}
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.core.utils.vect.VectUtil;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
public class FarmLogicRubber extends FarmLogic {
|
||||
|
||||
private boolean inActive;
|
||||
|
||||
public FarmLogicRubber(IFarmHousing housing) {
|
||||
super(housing);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem() {
|
||||
if (!inActive) {
|
||||
return PluginIC2.resin.getItem();
|
||||
} else {
|
||||
return Items.gunpowder;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Rubber Plantation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFertilizerConsumption() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaterConsumption(float hydrationModifier) {
|
||||
return (int) (5 * hydrationModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedResource(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedGermling(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedWindfall(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> collect() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private final HashMap<Vect, Integer> lastExtents = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent) {
|
||||
if (inActive) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Vect start = new Vect(pos);
|
||||
if (!lastExtents.containsKey(start)) {
|
||||
lastExtents.put(start, 0);
|
||||
}
|
||||
|
||||
int lastExtent = lastExtents.get(start);
|
||||
if (lastExtent > extent) {
|
||||
lastExtent = 0;
|
||||
}
|
||||
|
||||
Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent);
|
||||
Collection<ICrop> crops = getHarvestBlocks(position);
|
||||
lastExtent++;
|
||||
lastExtents.put(start, lastExtent);
|
||||
|
||||
return crops;
|
||||
}
|
||||
|
||||
private Collection<ICrop> getHarvestBlocks(Vect position) {
|
||||
|
||||
Set<Vect> seen = new HashSet<>();
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
|
||||
World world = getWorld();
|
||||
|
||||
// Determine what type we want to harvest.
|
||||
Block block = VectUtil.getBlock(world, position);
|
||||
if (!ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
|
||||
return crops;
|
||||
}
|
||||
|
||||
int meta = VectUtil.getBlockMeta(world, position);
|
||||
if (meta >= 2 && meta <= 5) {
|
||||
crops.push(new CropRubber(getWorld(), block, meta, position));
|
||||
}
|
||||
|
||||
ArrayList<Vect> candidates = processHarvestBlock(crops, seen, position);
|
||||
ArrayList<Vect> temp = new ArrayList<>();
|
||||
while (!candidates.isEmpty() && crops.size() < 100) {
|
||||
for (Vect candidate : candidates) {
|
||||
temp.addAll(processHarvestBlock(crops, seen, candidate));
|
||||
}
|
||||
candidates.clear();
|
||||
candidates.addAll(temp);
|
||||
temp.clear();
|
||||
}
|
||||
|
||||
return crops;
|
||||
}
|
||||
|
||||
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect position) {
|
||||
World world = getWorld();
|
||||
|
||||
ArrayList<Vect> candidates = new ArrayList<>();
|
||||
|
||||
// Get additional candidates to return
|
||||
for (int j = 0; j < 2; j++) {
|
||||
Vect candidate = new Vect(position.getX(), position.getY() + j, position.getZ());
|
||||
if (candidate.equals(position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// See whether the given position has already been processed
|
||||
if (seen.contains(candidate)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = VectUtil.getBlock(world, candidate);
|
||||
if (ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
|
||||
int meta = VectUtil.getBlockMeta(world, candidate);
|
||||
if (meta >= 2 && meta <= 5) {
|
||||
crops.push(new CropRubber(world, block, meta, candidate));
|
||||
}
|
||||
candidates.add(candidate);
|
||||
seen.add(candidate);
|
||||
}
|
||||
}
|
||||
|
||||
return candidates;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
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;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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 net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
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.BlockSoil;
|
||||
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;
|
||||
|
||||
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";
|
||||
public static PluginIC2 instance;
|
||||
|
||||
private static ItemStack rubberSapling;
|
||||
private static ItemStack rubber;
|
||||
public static ItemStack rubberWood;
|
||||
public static ItemStack resin;
|
||||
|
||||
public PluginIC2() {
|
||||
if (PluginIC2.instance == null) {
|
||||
PluginIC2.instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(PluginIC2.modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailMessage() {
|
||||
return "IndustrialCraft2 not found";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<String> getDependencyUids() {
|
||||
Set<String> dependencyUids = super.getDependencyUids();
|
||||
dependencyUids.add(ForestryPluginUids.FARMING);
|
||||
dependencyUids.add(ForestryPluginUids.FACTORY);
|
||||
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);
|
||||
}
|
||||
|
||||
@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, "cratedResin");
|
||||
}
|
||||
|
||||
if (rubber != null) {
|
||||
crateRegistry.registerCrate(rubber, "cratedRubber");
|
||||
}
|
||||
|
||||
ItemStack scrap = IC2Items.getItem("crafting", "scrap");
|
||||
if (scrap != null) {
|
||||
crateRegistry.registerCrate(scrap, "cratedScrap");
|
||||
}
|
||||
|
||||
ItemStack uuMatter = IC2Items.getItem("misc_resource", "matter");
|
||||
if (uuMatter != null) {
|
||||
crateRegistry.registerCrate(uuMatter, "cratedUUM");
|
||||
}
|
||||
|
||||
ItemStack silver = IC2Items.getItem("ingot", "silver");
|
||||
if (silver != null) {
|
||||
crateRegistry.registerCrateUsingOreDict(silver, "cratedSilver");
|
||||
}
|
||||
|
||||
ItemStack brass = IC2Items.getItem("ingot", "bronze");
|
||||
if (brass != null) {
|
||||
crateRegistry.registerCrateUsingOreDict(brass, "cratedBrass");
|
||||
}
|
||||
}
|
||||
|
||||
@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.getItemNameFromRegistryAsSting(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(BlockSoil.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user