mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 20:42:35 +00:00
Readd Ic2 Integration
This commit is contained in:
1 parent
5b2b0bfc95
commit
834e3ed55a
24 files changed
+1690
-1623
No files matched your search
@@ -29,6 +29,7 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.MigrationHelper;
|
||||
import forestry.core.worldgen.WorldGenerator;
|
||||
import forestry.plugins.PluginManager;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -55,8 +56,8 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
acceptedMinecraftVersions = "[1.11]",
|
||||
dependencies = "required-after:forge@[13.20.0.2270,);"
|
||||
+ "after:JEI@[4.3.0,);")
|
||||
// + "after:" + PluginIC2.modId + ";")
|
||||
+ "after:JEI@[4.3.0,);"
|
||||
+ "after:" + PluginIC2.modId + ";")
|
||||
public class Forestry {
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
|
||||
@@ -74,6 +74,32 @@ public abstract class ItemStackUtil {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The registry name of the block as {@link ResourceLocation}
|
||||
*/
|
||||
@Nullable
|
||||
public static String getBlockNameFromRegistryAsString(Block block) {
|
||||
IForgeRegistry<Block> itemRegistry = ForgeRegistries.BLOCKS;
|
||||
if (itemRegistry.containsValue(block)) {
|
||||
return itemRegistry.getKey(block).toString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The registry name of the block as {@link ResourceLocation}
|
||||
*/
|
||||
@Nullable
|
||||
public static ResourceLocation getBlockNameFromRegistry(Block block) {
|
||||
IForgeRegistry<Block> itemRegistry = ForgeRegistries.BLOCKS;
|
||||
if (itemRegistry.containsValue(block)) {
|
||||
return itemRegistry.getKey(block);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The registry name of the item as {@link String}
|
||||
|
||||
@@ -20,14 +20,16 @@ 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(createEngineProperties(TileEnginePeat.class, "peat", "/engine_copper")),
|
||||
BIOGAS(createEngineProperties(TileEngineBiogas.class, "biogas", "/engine_bronze")),
|
||||
CLOCKWORK(createEngineProperties(TileEngineClockwork.class, "clockwork", "/engine_clock"));
|
||||
// ELECTRICAL(createEngineProperties(TileEngineElectric.class, "electrical", "/engine_tin")),
|
||||
// GENERATOR(createMachineProperties(TileEuGenerator.class, "generator", "/generator"));
|
||||
CLOCKWORK(createEngineProperties(TileEngineClockwork.class, "clockwork", "/engine_clock")),
|
||||
ELECTRICAL(createEngineProperties(TileEngineElectric.class, "electrical", "/engine_tin")),
|
||||
GENERATOR(createMachineProperties(TileEuGenerator.class, "generator", "/generator"));
|
||||
|
||||
public static final BlockTypeEngine[] VALUES = values();
|
||||
|
||||
|
||||
@@ -1,20 +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 CircuitElectricBoost extends CircuitElectricChange {
|
||||
//
|
||||
// public CircuitElectricBoost(String uid, int eu, int rf) {
|
||||
// super(uid);
|
||||
// this.configureChange(eu, rf);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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 eu, int rf) {
|
||||
super(uid);
|
||||
this.configureChange(eu, rf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +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) {
|
||||
// super(uid);
|
||||
// }
|
||||
//
|
||||
// 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) {
|
||||
// }
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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) {
|
||||
super(uid);
|
||||
}
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
///*******************************************************************************
|
||||
// * 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);
|
||||
// this.configureChange(-2, -10);
|
||||
// }
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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);
|
||||
this.configureChange(-2, -10);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +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 CircuitElectricEfficiency extends CircuitElectricChange {
|
||||
//
|
||||
// public CircuitElectricEfficiency(String uid) {
|
||||
// super(uid);
|
||||
// this.configureChange(-1, 0);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http:www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.energy.circuits;
|
||||
|
||||
public class CircuitElectricEfficiency extends CircuitElectricChange {
|
||||
|
||||
public CircuitElectricEfficiency(String uid) {
|
||||
super(uid);
|
||||
this.configureChange(-1, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +1,36 @@
|
||||
///*******************************************************************************
|
||||
// * 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 detectAndSendChanges() {
|
||||
// super.detectAndSendChanges();
|
||||
// PacketGuiUpdate packet = new PacketGuiUpdate(tile);
|
||||
// sendPacketToListeners(packet);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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 detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(tile);
|
||||
sendPacketToListeners(packet);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +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.gui;
|
||||
//
|
||||
//import net.minecraft.entity.player.InventoryPlayer;
|
||||
//import forestry.core.gui.ContainerLiquidTanks;
|
||||
//import forestry.core.gui.slots.SlotLiquidIn;
|
||||
//import forestry.core.network.packets.PacketGuiUpdate;
|
||||
//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 SlotLiquidIn(tile, InventoryGenerator.SLOT_CAN, 22, 38));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void detectAndSendChanges() {
|
||||
// super.detectAndSendChanges();
|
||||
// PacketGuiUpdate packet = new PacketGuiUpdate(tile);
|
||||
// sendPacketToListeners(packet);
|
||||
// }
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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.ContainerLiquidTanks;
|
||||
import forestry.core.gui.slots.SlotLiquidIn;
|
||||
import forestry.core.network.packets.PacketGuiUpdate;
|
||||
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 SlotLiquidIn(tile, InventoryGenerator.SLOT_CAN, 22, 38));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(tile);
|
||||
sendPacketToListeners(packet);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +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);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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 = tile;
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +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 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);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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> {
|
||||
|
||||
private final TileEuGenerator tile;
|
||||
|
||||
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));
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
int progress = tile.getStoredScaled(49);
|
||||
if (progress > 0) {
|
||||
drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addLedgers() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +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;
|
||||
// }
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +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.FluidStack;
|
||||
//import net.minecraftforge.fluids.FluidUtil;
|
||||
//
|
||||
//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) {
|
||||
// FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
// return tile.getTankManager().canFillFluidType(fluid);
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
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) {
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return tile.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,310 +1,316 @@
|
||||
///*******************************************************************************
|
||||
// * 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 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;
|
||||
//import net.minecraft.entity.player.EntityPlayer;
|
||||
//import net.minecraft.inventory.IInventory;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.nbt.NBTTagCompound;
|
||||
//
|
||||
//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, 4);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // / 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
// nbttagcompound = super.writeToNBT(nbttagcompound);
|
||||
//
|
||||
// if (ic2EnergySink != null) {
|
||||
// ic2EnergySink.writeToNBT(nbttagcompound);
|
||||
// }
|
||||
// sockets.writeToNBT(nbttagcompound);
|
||||
// return 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.getEnergyStored() / (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(PacketBufferForestry data) {
|
||||
// super.writeGuiData(data);
|
||||
// sockets.writeData(data);
|
||||
// final boolean hasIc2EnergySink = (ic2EnergySink != null);
|
||||
// data.writeBoolean(hasIc2EnergySink);
|
||||
// if (hasIc2EnergySink) {
|
||||
// data.writeVarInt((int) ic2EnergySink.getEnergyStored());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void readGuiData(PacketBufferForestry data) throws IOException {
|
||||
// super.readGuiData(data);
|
||||
// sockets.readData(data);
|
||||
// final boolean hasIc2EnergySink = data.readBoolean();
|
||||
// if (hasIc2EnergySink) {
|
||||
// final int energyStored = data.readVarInt();
|
||||
// ic2EnergySink.setEnergyStored(energyStored);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // / 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);
|
||||
// }
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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 javax.annotation.Nonnull;
|
||||
|
||||
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.IStreamableGui;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
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;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
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, 4);
|
||||
}
|
||||
}
|
||||
|
||||
// / 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound = super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySink != null) {
|
||||
ic2EnergySink.writeToNBT(nbttagcompound);
|
||||
}
|
||||
sockets.writeToNBT(nbttagcompound);
|
||||
return 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.getEnergyStored() / (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(PacketBufferForestry data) {
|
||||
super.writeGuiData(data);
|
||||
sockets.writeData(data);
|
||||
final boolean hasIc2EnergySink = (ic2EnergySink != null);
|
||||
data.writeBoolean(hasIc2EnergySink);
|
||||
if (hasIc2EnergySink) {
|
||||
data.writeVarInt((int) ic2EnergySink.getEnergyStored());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(PacketBufferForestry data) throws IOException {
|
||||
super.readGuiData(data);
|
||||
sockets.readData(data);
|
||||
final boolean hasIc2EnergySink = data.readBoolean();
|
||||
if (hasIc2EnergySink) {
|
||||
final int energyStored = data.readVarInt();
|
||||
ic2EnergySink.setEnergyStored(energyStored);
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public GuiContainer getGui(EntityPlayer player, int data) {
|
||||
return new GuiEngineElectric(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerEngineElectric(player.inventory, this);
|
||||
}
|
||||
}
|
||||
@@ -1,234 +1,238 @@
|
||||
///*******************************************************************************
|
||||
// * 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 javax.annotation.Nullable;
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//import net.minecraft.entity.player.EntityPlayer;
|
||||
//import net.minecraft.inventory.ISidedInventory;
|
||||
//import net.minecraft.nbt.NBTTagCompound;
|
||||
//import net.minecraft.util.EnumFacing;
|
||||
//
|
||||
//import net.minecraftforge.common.capabilities.Capability;
|
||||
//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;
|
||||
//import forestry.core.fluids.ITankManager;
|
||||
//import forestry.core.fluids.TankManager;
|
||||
//import forestry.core.fluids.FilteredTank;
|
||||
//import forestry.core.network.DataInputStreamForestry;
|
||||
//import forestry.core.network.DataOutputStreamForestry;
|
||||
//import forestry.core.network.IStreamableGui;
|
||||
//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, IRenderableTile, IStreamableGui {
|
||||
// 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);
|
||||
// resourceTank.setFilters(FuelManager.generatorFuel.keySet());
|
||||
//
|
||||
// tankManager = new TankManager(this, resourceTank);
|
||||
//
|
||||
// if (PluginIC2.instance.isAvailable()) {
|
||||
// ic2EnergySource = new BasicSource(this, maxEnergy, 1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
// nbttagcompound = super.writeToNBT(nbttagcompound);
|
||||
//
|
||||
// if (ic2EnergySource != null) {
|
||||
// ic2EnergySource.writeToNBT(nbttagcompound);
|
||||
// }
|
||||
//
|
||||
// tankManager.writeToNBT(nbttagcompound);
|
||||
// return nbttagcompound;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
// super.readFromNBT(nbttagcompound);
|
||||
//
|
||||
// if (ic2EnergySource != null) {
|
||||
// ic2EnergySource.readFromNBT(nbttagcompound);
|
||||
// }
|
||||
//
|
||||
// tankManager.readFromNBT(nbttagcompound);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void writeData(PacketBufferForestry data) {
|
||||
// super.writeData(data);
|
||||
// tankManager.writeData(data);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void readData(PacketBufferForestry 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.canDrainFluidType(fuel.getFuelConsumed()) && ic2EnergySource.getFreeCapacity() >= fuel.getEu()) {
|
||||
// ic2EnergySource.addEnergy(fuel.getEu());
|
||||
// this.tickCount++;
|
||||
//
|
||||
// if (tickCount >= fuel.getRate()) {
|
||||
// tickCount = 0;
|
||||
// resourceTank.drain(fuel.getFuelConsumed().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;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void writeGuiData(PacketBufferForestry data) {
|
||||
// if (ic2EnergySource != null) {
|
||||
// data.writeDouble(ic2EnergySource.getEnergyStored());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void readGuiData(PacketBufferForestry data) throws IOException {
|
||||
// if (ic2EnergySource != null) {
|
||||
// ic2EnergySource.setEnergyStored(data.readDouble());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @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);
|
||||
// }
|
||||
//
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public ITankManager getTankManager() {
|
||||
// return tankManager;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
// if (super.hasCapability(capability, facing)) {
|
||||
// return true;
|
||||
// }
|
||||
// return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
// }
|
||||
//
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
// if (super.hasCapability(capability, facing)) {
|
||||
// return super.getCapability(capability, facing);
|
||||
// }
|
||||
// if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
// return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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 javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
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.ITankManager;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.FilteredTank;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
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, IRenderableTile, IStreamableGui {
|
||||
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);
|
||||
resourceTank.setFilters(FuelManager.generatorFuel.keySet());
|
||||
|
||||
tankManager = new TankManager(this, resourceTank);
|
||||
|
||||
if (PluginIC2.instance.isAvailable()) {
|
||||
ic2EnergySource = new BasicSource(this, maxEnergy, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound = super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
tankManager.writeToNBT(nbttagcompound);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
tankManager.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(PacketBufferForestry data) {
|
||||
super.writeData(data);
|
||||
tankManager.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(PacketBufferForestry 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.canDrainFluidType(fuel.getFuelConsumed()) && ic2EnergySource.getFreeCapacity() >= fuel.getEu()) {
|
||||
ic2EnergySource.addEnergy(fuel.getEu());
|
||||
this.tickCount++;
|
||||
|
||||
if (tickCount >= fuel.getRate()) {
|
||||
tickCount = 0;
|
||||
resourceTank.drain(fuel.getFuelConsumed().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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(PacketBufferForestry data) {
|
||||
if (ic2EnergySource != null) {
|
||||
data.writeDouble(ic2EnergySource.getEnergyStored());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(PacketBufferForestry data) throws IOException {
|
||||
if (ic2EnergySource != null) {
|
||||
ic2EnergySource.setEnergyStored(data.readDouble());
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public GuiContainer getGui(EntityPlayer player, int data) {
|
||||
return new GuiGenerator(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerGenerator(player.inventory, this);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,9 @@ public final class FarmRegistry implements IFarmRegistry {
|
||||
|
||||
@Override
|
||||
public void registerFertilizer(ItemStack itemStack, int value) {
|
||||
if(itemStack == null || itemStack.isEmpty()){
|
||||
return;
|
||||
}
|
||||
fertilizers.put(itemStack, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,82 +1,87 @@
|
||||
//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.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<ItemStack> 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<ItemStack> getCropDrops(TileEntity tileEntity) {
|
||||
// if (isIC2Crop(tileEntity)) {
|
||||
// ICropTile crop = (ICropTile) tileEntity;
|
||||
// return crop.performHarvest();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
package forestry.farming.logic;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
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 NonNullList<ItemStack> 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 NonNullList<ItemStack> getCropDrops(TileEntity tileEntity) {
|
||||
if (isIC2Crop(tileEntity)) {
|
||||
ICropTile crop = (ICropTile) tileEntity;
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
drops.addAll(crop.performHarvest());
|
||||
return drops;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,94 +1,97 @@
|
||||
///*******************************************************************************
|
||||
// * 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 javax.annotation.Nullable;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Collection;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import com.google.common.base.Optional;
|
||||
//import com.google.common.collect.ImmutableCollection;
|
||||
//import forestry.core.config.Constants;
|
||||
//import forestry.core.network.packets.PacketFXSignal;
|
||||
//import forestry.core.proxy.Proxies;
|
||||
//import forestry.core.utils.ItemStackUtil;
|
||||
//import forestry.plugins.compat.PluginIC2;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.block.properties.IProperty;
|
||||
//import net.minecraft.block.state.IBlockState;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.world.World;
|
||||
//
|
||||
//public class CropRubber extends CropDestroy {
|
||||
//
|
||||
// public CropRubber(World world, IBlockState blockState, BlockPos position) {
|
||||
// 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 <T extends Comparable<T>> IBlockState getReplantState(IBlockState sappyState) {
|
||||
// if (hasRubberToHarvest(sappyState)) {
|
||||
// for (Map.Entry<IProperty<?>, Comparable<?>> wetPropertyEntry : sappyState.getProperties().entrySet()) {
|
||||
// String valueWetString = wetPropertyEntry.getValue().toString();
|
||||
// String valueDryString = valueWetString.replace("wet", "dry");
|
||||
// IProperty<?> property = wetPropertyEntry.getKey();
|
||||
//
|
||||
// IBlockState baseState = sappyState.getBlock().getBlockState().getBaseState();
|
||||
// IBlockState dryState = getStateWithValue(baseState, property, valueDryString);
|
||||
// if (dryState != null) {
|
||||
// return dryState;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return sappyState.getBlock().getDefaultState();
|
||||
// }
|
||||
//
|
||||
// public static boolean hasRubberToHarvest(IBlockState blockState) {
|
||||
// Block block = blockState.getBlock();
|
||||
// if (ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
|
||||
// ImmutableCollection<Comparable<?>> propertyValues = blockState.getProperties().values();
|
||||
// for (Comparable<?> propertyValue : propertyValues) {
|
||||
// if (propertyValue.toString().contains("wet")) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// private static <T extends Comparable<T>> IBlockState getStateWithValue(IBlockState baseState, IProperty<T> property, String valueString) {
|
||||
// Optional<T> value = property.parseValue(valueString);
|
||||
// if (value.isPresent()) {
|
||||
// return baseState.withProperty(property, value.get());
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected Collection<ItemStack> harvestBlock(World world, BlockPos pos) {
|
||||
// Collection<ItemStack> harvested = new ArrayList<>();
|
||||
// harvested.add(PluginIC2.resin.copy());
|
||||
//
|
||||
// PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
|
||||
// Proxies.net.sendNetworkPacket(packet, world);
|
||||
//
|
||||
// world.setBlockState(pos, replantState, Constants.FLAG_BLOCK_SYNC);
|
||||
// return harvested;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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 javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.network.PacketHandler;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CropRubber extends CropDestroy {
|
||||
|
||||
public CropRubber(World world, IBlockState blockState, BlockPos position) {
|
||||
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 <T extends Comparable<T>> IBlockState getReplantState(IBlockState sappyState) {
|
||||
if (hasRubberToHarvest(sappyState)) {
|
||||
for (Map.Entry<IProperty<?>, Comparable<?>> wetPropertyEntry : sappyState.getProperties().entrySet()) {
|
||||
String valueWetString = wetPropertyEntry.getValue().toString();
|
||||
String valueDryString = valueWetString.replace("wet", "dry");
|
||||
IProperty<?> property = wetPropertyEntry.getKey();
|
||||
|
||||
IBlockState baseState = sappyState.getBlock().getBlockState().getBaseState();
|
||||
IBlockState dryState = getStateWithValue(baseState, property, valueDryString);
|
||||
if (dryState != null) {
|
||||
return dryState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sappyState.getBlock().getDefaultState();
|
||||
}
|
||||
|
||||
public static boolean hasRubberToHarvest(IBlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
if (ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
|
||||
ImmutableCollection<Comparable<?>> propertyValues = blockState.getProperties().values();
|
||||
for (Comparable<?> propertyValue : propertyValues) {
|
||||
if (propertyValue.toString().contains("wet")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static <T extends Comparable<T>> IBlockState getStateWithValue(IBlockState baseState, IProperty<T> property, String valueString) {
|
||||
Optional<T> value = property.parseValue(valueString);
|
||||
if (value.isPresent()) {
|
||||
return baseState.withProperty(property, value.get());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NonNullList<ItemStack> harvestBlock(World world, BlockPos pos) {
|
||||
NonNullList<ItemStack> harvested = NonNullList.create();
|
||||
harvested.add(PluginIC2.resin.copy());
|
||||
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
|
||||
NetworkUtil.sendNetworkPacket(packet, pos, world);
|
||||
|
||||
world.setBlockState(pos, replantState, Constants.FLAG_BLOCK_SYNC);
|
||||
return harvested;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,132 +1,133 @@
|
||||
///*******************************************************************************
|
||||
// * 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.Collection;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//import java.util.Stack;
|
||||
//
|
||||
//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.plugins.compat.PluginIC2;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.block.state.IBlockState;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.world.World;
|
||||
//
|
||||
//public class FarmLogicRubber extends FarmLogic {
|
||||
//
|
||||
// private boolean active = true;
|
||||
//
|
||||
// public FarmLogicRubber() {
|
||||
// if (PluginIC2.rubberWood == null || PluginIC2.resin == null) {
|
||||
// Log.warning("Failed to init a farm logic {} since IC2 rubber wood or resin were not found", getClass().getName());
|
||||
// active = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack getIconItemStack() {
|
||||
// return PluginIC2.resin;
|
||||
// }
|
||||
//
|
||||
// @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(World world, IFarmHousing farmHousing) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// private final Map<BlockPos, Integer> lastExtents = new HashMap<>();
|
||||
//
|
||||
// @Override
|
||||
// public Collection<ICrop> harvest(World world, BlockPos pos, FarmDirection direction, int extent) {
|
||||
// if (!active) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (!lastExtents.containsKey(pos)) {
|
||||
// lastExtents.put(pos, 0);
|
||||
// }
|
||||
//
|
||||
// int lastExtent = lastExtents.get(pos);
|
||||
// if (lastExtent > extent) {
|
||||
// lastExtent = 0;
|
||||
// }
|
||||
//
|
||||
// BlockPos position = translateWithOffset(pos.up(), direction, lastExtent);
|
||||
// Collection<ICrop> crops = getHarvestBlocks(world, position);
|
||||
// lastExtent++;
|
||||
// lastExtents.put(pos, lastExtent);
|
||||
//
|
||||
// return crops;
|
||||
// }
|
||||
//
|
||||
// private Collection<ICrop> getHarvestBlocks(World world, BlockPos position) {
|
||||
// Stack<ICrop> crops = new Stack<>();
|
||||
//
|
||||
// for (int j = 0; j < 10; j++) {
|
||||
// BlockPos candidate = position.add(0, j, 0);
|
||||
//
|
||||
// IBlockState blockState = world.getBlockState(candidate);
|
||||
// Block block = blockState.getBlock();
|
||||
// if (!ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// if (CropRubber.hasRubberToHarvest(blockState)) {
|
||||
// crops.push(new CropRubber(world, blockState, candidate));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return crops;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
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.plugins.compat.PluginIC2;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class FarmLogicRubber extends FarmLogic {
|
||||
|
||||
private boolean active = true;
|
||||
|
||||
public FarmLogicRubber() {
|
||||
if (PluginIC2.rubberWood == null || PluginIC2.resin == null) {
|
||||
Log.warning("Failed to init a farm logic {} since IC2 rubber wood or resin were not found", getClass().getName());
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return PluginIC2.resin;
|
||||
}
|
||||
|
||||
@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 NonNullList<ItemStack> collect(World world, IFarmHousing farmHousing) {
|
||||
return NonNullList.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private final Map<BlockPos, Integer> lastExtents = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Collection<ICrop> harvest(World world, BlockPos pos, FarmDirection direction, int extent) {
|
||||
if (!active) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!lastExtents.containsKey(pos)) {
|
||||
lastExtents.put(pos, 0);
|
||||
}
|
||||
|
||||
int lastExtent = lastExtents.get(pos);
|
||||
if (lastExtent > extent) {
|
||||
lastExtent = 0;
|
||||
}
|
||||
|
||||
BlockPos position = translateWithOffset(pos.up(), direction, lastExtent);
|
||||
Collection<ICrop> crops = getHarvestBlocks(world, position);
|
||||
lastExtent++;
|
||||
lastExtents.put(pos, lastExtent);
|
||||
|
||||
return crops;
|
||||
}
|
||||
|
||||
private Collection<ICrop> getHarvestBlocks(World world, BlockPos position) {
|
||||
Stack<ICrop> crops = new Stack<>();
|
||||
|
||||
for (int j = 0; j < 10; j++) {
|
||||
BlockPos candidate = position.add(0, j, 0);
|
||||
|
||||
IBlockState blockState = world.getBlockState(candidate);
|
||||
Block block = blockState.getBlock();
|
||||
if (!ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (CropRubber.hasRubberToHarvest(blockState)) {
|
||||
crops.push(new CropRubber(world, blockState, candidate));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return crops;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +1,85 @@
|
||||
//package forestry.farming.logic;
|
||||
//
|
||||
//import javax.annotation.Nullable;
|
||||
//
|
||||
//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;
|
||||
// }
|
||||
//}
|
||||
package forestry.farming.logic;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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.getStorageNutrients() <= 100) {
|
||||
crop.setStorageNutrients(crop.getStorageNutrients() + 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;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
//package forestry.plugins.compat;
|
||||
//
|
||||
//import forestry.core.blocks.BlockBase;
|
||||
//import forestry.core.blocks.BlockRegistry;
|
||||
//import forestry.core.items.ItemBlockForestry;
|
||||
//import forestry.energy.blocks.BlockEngine;
|
||||
//import forestry.energy.blocks.BlockTypeEngine;
|
||||
//
|
||||
//public class BlockRegistryIC2 extends BlockRegistry {
|
||||
// public final BlockBase electricalEngine;
|
||||
// public final BlockEngine generator;
|
||||
//
|
||||
// public BlockRegistryIC2() {
|
||||
// electricalEngine = new BlockEngine(BlockTypeEngine.ELECTRICAL);
|
||||
// registerBlock(electricalEngine, new ItemBlockForestry<>(electricalEngine), "engine_electrical");
|
||||
//
|
||||
// generator = new BlockEngine(BlockTypeEngine.GENERATOR);
|
||||
// registerBlock(generator, new ItemBlockForestry<>(generator), "engine_generator");
|
||||
// }
|
||||
//}
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import forestry.core.blocks.BlockBase;
|
||||
import forestry.core.blocks.BlockRegistry;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import forestry.energy.blocks.BlockEngine;
|
||||
import forestry.energy.blocks.BlockTypeEngine;
|
||||
|
||||
public class BlockRegistryIC2 extends BlockRegistry {
|
||||
public final BlockBase electricalEngine;
|
||||
public final BlockEngine generator;
|
||||
|
||||
public BlockRegistryIC2() {
|
||||
electricalEngine = new BlockEngine(BlockTypeEngine.ELECTRICAL);
|
||||
registerBlock(electricalEngine, new ItemBlockForestry<>(electricalEngine), "engine_electrical");
|
||||
|
||||
generator = new BlockEngine(BlockTypeEngine.GENERATOR);
|
||||
registerBlock(generator, new ItemBlockForestry<>(generator), "engine_generator");
|
||||
}
|
||||
}
|
||||
@@ -1,313 +1,321 @@
|
||||
///*******************************************************************************
|
||||
// * 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 java.util.Set;
|
||||
//
|
||||
//import com.google.common.collect.ImmutableMap;
|
||||
//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.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.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;
|
||||
//import net.minecraft.init.Blocks;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraftforge.fluids.Fluid;
|
||||
//import net.minecraftforge.fluids.FluidRegistry;
|
||||
//import net.minecraftforge.fml.common.Optional;
|
||||
//import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
//
|
||||
//@ForestryPlugin(pluginID = ForestryPluginUids.INDUSTRIALCRAFT2, 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 BlockRegistryIC2 blocks;
|
||||
//
|
||||
// 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();
|
||||
//
|
||||
// // 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);
|
||||
//
|
||||
// Farmables.fertilizers.put(IC2Items.getItem("crop_res", "fertilizer"), 250);
|
||||
// }
|
||||
//
|
||||
// @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", 7, 20);
|
||||
// Circuit.energyElectricBoost2 = new CircuitElectricBoost("electric.boost.2", 15, 40);
|
||||
//
|
||||
// blocks.electricalEngine.init();
|
||||
// blocks.generator.init();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void postInit() {
|
||||
// super.postInit();
|
||||
//
|
||||
// if (BackpackManager.backpackInterface == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (resin != null) {
|
||||
// BackpackManager.backpackInterface.addItemToForestryBackpack(BackpackManager.FORESTER_UID, resin);
|
||||
// }
|
||||
// if (rubber != null) {
|
||||
// BackpackManager.backpackInterface.addItemToForestryBackpack(BackpackManager.FORESTER_UID, rubber);
|
||||
// }
|
||||
// if (rubberSapling != null) {
|
||||
// BackpackManager.backpackInterface.addItemToForestryBackpack(BackpackManager.FORESTER_UID, rubberSapling);
|
||||
// }
|
||||
// ItemStack rubberLeaves = IC2Items.getItem("leaves");
|
||||
// if (rubberLeaves != null) {
|
||||
// BackpackManager.backpackInterface.addItemToForestryBackpack(BackpackManager.FORESTER_UID, 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)) {
|
||||
// Fluid biogas = FluidRegistry.getFluid("ic2biogas");
|
||||
// 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, 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();
|
||||
// }
|
||||
//}
|
||||
/*******************************************************************************
|
||||
* 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 java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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.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.circuits.Circuits;
|
||||
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.core.utils.OreDictUtil;
|
||||
import forestry.energy.PluginEnergy;
|
||||
import forestry.energy.blocks.BlockRegistryEnergy;
|
||||
import forestry.energy.circuits.CircuitElectricBoost;
|
||||
import forestry.energy.circuits.CircuitElectricChoke;
|
||||
import forestry.energy.circuits.CircuitElectricEfficiency;
|
||||
import forestry.farming.FarmRegistry;
|
||||
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.Recipes;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.INDUSTRIALCRAFT2, 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 static ItemStack fertilizer;
|
||||
|
||||
public BlockRegistryIC2 blocks;
|
||||
|
||||
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();
|
||||
|
||||
// rubber chain
|
||||
rubberWood = IC2Items.getItem("rubber_wood");
|
||||
resin = IC2Items.getItem("misc_resource", "resin");
|
||||
rubberSapling = IC2Items.getItem("sapling");
|
||||
rubber = IC2Items.getItem("crafting", "rubber");
|
||||
fertilizer = IC2Items.getItem("crop_res","fertilizer");
|
||||
|
||||
Circuits.farmRubberManual = new CircuitFarmLogic("manualRubber", new FarmLogicRubber());
|
||||
|
||||
ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE);
|
||||
ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin);
|
||||
|
||||
if(fertilizer != null){
|
||||
FarmRegistry.getInstance().registerFertilizer(fertilizer, 250);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = PluginIC2.modId)
|
||||
public void doInit() {
|
||||
super.doInit();
|
||||
|
||||
// Remove some items from the recycler
|
||||
if (Recipes.recyclerBlacklist != null) {
|
||||
ItemRegistryApiculture beeItems = PluginApiculture.getItems();
|
||||
if (beeItems != null) {
|
||||
Recipes.recyclerBlacklist.add(Recipes.inputFactory.forStack(new ItemStack(beeItems.beeQueenGE)));
|
||||
Recipes.recyclerBlacklist.add(Recipes.inputFactory.forStack(new ItemStack(beeItems.beePrincessGE)));
|
||||
}
|
||||
} else {
|
||||
Log.error("IC2 Recipes.recyclerBlacklist not found.");
|
||||
}
|
||||
|
||||
Circuits.energyElectricChoke1 = new CircuitElectricChoke("electric.choke.1");
|
||||
Circuits.energyElectricEfficiency1 = new CircuitElectricEfficiency("electric.efficiency.1");
|
||||
Circuits.energyElectricBoost1 = new CircuitElectricBoost("electric.boost.1", 7, 20);
|
||||
Circuits.energyElectricBoost2 = new CircuitElectricBoost("electric.boost.2", 15, 40);
|
||||
|
||||
blocks.electricalEngine.init();
|
||||
blocks.generator.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
super.postInit();
|
||||
|
||||
if (BackpackManager.backpackInterface == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (resin != null) {
|
||||
BackpackManager.backpackInterface.addItemToForestryBackpack(BackpackManager.FORESTER_UID, resin);
|
||||
}
|
||||
if (rubber != null) {
|
||||
BackpackManager.backpackInterface.addItemToForestryBackpack(BackpackManager.FORESTER_UID, rubber);
|
||||
}
|
||||
if (rubberSapling != null) {
|
||||
BackpackManager.backpackInterface.addItemToForestryBackpack(BackpackManager.FORESTER_UID, rubberSapling);
|
||||
}
|
||||
ItemStack rubberLeaves = IC2Items.getItem("leaves");
|
||||
if (rubberLeaves != null) {
|
||||
BackpackManager.backpackInterface.addItemToForestryBackpack(BackpackManager.FORESTER_UID, 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) {
|
||||
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), coreItems.tubes.get(EnumElectronTube.RUBBER, 4),
|
||||
new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', "itemRubber"});
|
||||
}
|
||||
|
||||
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.getItems();
|
||||
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.getBlockNameFromRegistryAsString(ItemStackUtil.getBlock(rubberSapling));
|
||||
if(saplingName != null){
|
||||
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)) {
|
||||
Fluid biogas = FluidRegistry.getFluid("ic2biogas");
|
||||
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, 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.getBlocks().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), Circuits.energyElectricChoke1);
|
||||
ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuits.energyElectricBoost1);
|
||||
ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuits.energyElectricBoost2);
|
||||
ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.IRON, 1), Circuits.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), Circuits.farmRubberManual);
|
||||
}
|
||||
|
||||
FarmRegistry.getInstance().registerFarmables("farmOrchard", 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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user