Compiles for 1.9! Very buggy, some things are missing.

This commit is contained in:
mezz committed 2016-05-05 01:11:21 -07:00
1 parent 5d74c1254b
commit 7bf554b024
135 files changed
+1710 -1919

No files matched your search

@@ -26,7 +26,6 @@ import forestry.api.circuits.ICircuitSocketType;
import forestry.api.core.IErrorLogic;
import forestry.core.circuits.ISocketable;
import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
@@ -36,10 +35,8 @@ import forestry.core.tiles.TileEngine;
import forestry.energy.gui.ContainerEngineElectric;
import forestry.energy.gui.GuiEngineElectric;
import forestry.energy.inventory.InventoryEngineElectric;
import forestry.plugins.compat.PluginIC2;
import ic2.api.energy.prefab.BasicSink;
// TODO: IC2 for 1.9
public class TileEngineElectric extends TileEngine implements ISocketable, IInventory, IStreamableGui {
protected static class EuConfig {
@@ -57,16 +54,16 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
private final EuConfig euConfig = new EuConfig();
private BasicSink ic2EnergySink;
// private BasicSink ic2EnergySink;
public TileEngineElectric() {
super("engine.tin", Constants.ENGINE_ELECTRIC_HEAT_MAX, 100000);
setInternalInventory(new InventoryEngineElectric(this));
if (PluginIC2.instance.isAvailable()) {
ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3);
}
// if (PluginIC2.instance.isAvailable()) {
// ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3);
// }
}
// / SAVING / LOADING
@@ -74,9 +71,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
if (ic2EnergySink != null) {
ic2EnergySink.readFromNBT(nbttagcompound);
}
// if (ic2EnergySink != null) {
// ic2EnergySink.readFromNBT(nbttagcompound);
// }
sockets.readFromNBT(nbttagcompound);
ItemStack chip = sockets.getStackInSlot(0);
@@ -92,26 +89,26 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
if (ic2EnergySink != null) {
ic2EnergySink.writeToNBT(nbttagcompound);
}
// if (ic2EnergySink != null) {
// ic2EnergySink.writeToNBT(nbttagcompound);
// }
sockets.writeToNBT(nbttagcompound);
}
@Override
public void onChunkUnload() {
if (ic2EnergySink != null) {
ic2EnergySink.onChunkUnload();
}
// if (ic2EnergySink != null) {
// ic2EnergySink.onChunkUnload();
// }
super.onChunkUnload();
}
@Override
public void invalidate() {
if (ic2EnergySink != null) {
ic2EnergySink.invalidate();
}
// if (ic2EnergySink != null) {
// ic2EnergySink.invalidate();
// }
super.invalidate();
}
@@ -159,11 +156,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
IErrorLogic errorLogic = getErrorLogic();
// No work to be done if IC2 is unavailable.
if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) {
return;
}
ic2EnergySink.update();
// if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) {
// return;
// }
//
// ic2EnergySink.update();
super.updateServerSide();
@@ -180,8 +177,8 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
return;
}
boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle);
errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL);
// boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle);
// errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL);
}
@Override
@@ -193,10 +190,10 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
return;
}
if (ic2EnergySink.useEnergy(euConfig.euForCycle)) {
currentOutput = euConfig.rfPerCycle;
energyManager.generateEnergy(euConfig.rfPerCycle);
}
// if (ic2EnergySink.useEnergy(euConfig.euForCycle)) {
// currentOutput = euConfig.rfPerCycle;
// energyManager.generateEnergy(euConfig.rfPerCycle);
// }
}
@@ -205,22 +202,23 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
return;
}
ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3);
// ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3);
}
// / STATE INFORMATION
@Override
protected boolean isBurning() {
return mayBurn() && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle);
// TODO: IC2 for 1.9
return mayBurn();// && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle);
}
public int getStorageScaled(int i) {
if (ic2EnergySink == null) {
return 0;
}
return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity());
}
// public int getStorageScaled(int i) {
// if (ic2EnergySink == null) {
// return 0;
// }
//
// return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity());
// }
// / SMP GUI
@Override
@@ -229,11 +227,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
data.writeVarInt(heat);
sockets.writeData(data);
energyManager.writeData(data);
final boolean hasIc2EnergySink = (ic2EnergySink != null);
data.writeBoolean(hasIc2EnergySink);
if (hasIc2EnergySink) {
data.writeVarInt((int) ic2EnergySink.getEnergyStored());
}
// final boolean hasIc2EnergySink = (ic2EnergySink != null);
// data.writeBoolean(hasIc2EnergySink);
// if (hasIc2EnergySink) {
// data.writeVarInt((int) ic2EnergySink.getEnergyStored());
// }
}
@Override
@@ -242,11 +240,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
heat = data.readVarInt();
sockets.readData(data);
energyManager.readData(data);
final boolean hasIc2EnergySink = data.readBoolean();
if (hasIc2EnergySink) {
final int energyStored = data.readVarInt();
ic2EnergySink.setEnergyStored(energyStored);
}
// final boolean hasIc2EnergySink = data.readBoolean();
// if (hasIc2EnergySink) {
// final int energyStored = data.readVarInt();
// ic2EnergySink.setEnergyStored(energyStored);
// }
}
@Override
@@ -265,9 +263,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
euConfig.rfPerCycle += rfChange;
euConfig.euStorage += storageChange;
if (ic2EnergySink != null) {
ic2EnergySink.setCapacity(euConfig.euStorage);
}
// if (ic2EnergySink != null) {
// ic2EnergySink.setCapacity(euConfig.euStorage);
// }
}
/* ISocketable */