Attempt to get energy to flow
This commit is contained in:
parent
2421259bbd
commit
aa8a2b9726
6 changed files with 45 additions and 32 deletions
|
@ -126,13 +126,6 @@ public class BlockAdvancedFurnace extends BlockFurnace
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int newID)
|
||||
{
|
||||
super.onNeighborBlockChange(world, x, y, z, newID);
|
||||
((TileEntityAdvancedFurnace) world.getBlockTileEntity(x, y, z)).checkProduce();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.ResonantInduction;
|
||||
import universalelectricity.api.CompatibilityModule;
|
||||
import universalelectricity.api.UniversalClass;
|
||||
import universalelectricity.api.electricity.IVoltage;
|
||||
import universalelectricity.api.energy.IConductor;
|
||||
|
@ -22,8 +23,6 @@ import calclavia.lib.tile.EnergyStorage;
|
|||
public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEnergyInterface, IVoltage
|
||||
{
|
||||
private static final float WATTAGE = 5;
|
||||
private boolean doProduce = false;
|
||||
private boolean init = true;
|
||||
|
||||
private EnergyStorage energy = new EnergyStorage(ResonantInduction.FURNACE_WATTAGE * 5);
|
||||
|
||||
|
@ -63,6 +62,8 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEne
|
|||
if (this.furnaceBurnTime > 0)
|
||||
{
|
||||
this.energy.receiveEnergy(ResonantInduction.FURNACE_WATTAGE / 20, true);
|
||||
|
||||
this.produce();
|
||||
}
|
||||
|
||||
if (doBlockStateUpdate != this.furnaceBurnTime > 0)
|
||||
|
@ -133,23 +134,16 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEne
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the furnace should produce power.
|
||||
*/
|
||||
public void checkProduce()
|
||||
private void produce()
|
||||
{
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
||||
|
||||
if (tileEntity instanceof IConductor)
|
||||
if (this.energy.getEnergy() > 0)
|
||||
{
|
||||
this.doProduce = true;
|
||||
return;
|
||||
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
||||
this.energy.extractEnergy(CompatibilityModule.receiveEnergy(tileEntity, direction.getOpposite(), this.energy.extractEnergy(this.energy.getEnergy(), false), true), true);
|
||||
}
|
||||
}
|
||||
|
||||
this.doProduce = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -201,7 +201,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
|||
|
||||
updateInternalConnections();
|
||||
|
||||
//if (updateOpenConnections())
|
||||
// if (updateOpenConnections())
|
||||
{
|
||||
updateExternalConnections();
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
|||
{
|
||||
int absDir = Rotation.rotateSide(side, r);
|
||||
TMultiPart facePart = tile().partMap(absDir);
|
||||
if (facePart != null && (!(facePart instanceof FlatWire) || !canConnect((FlatWire) facePart)))
|
||||
if (facePart != null && (!(facePart instanceof FlatWire) || !canConnectTo((FlatWire) facePart)))
|
||||
return false;
|
||||
|
||||
if (tile().partMap(PartMap.edgeBetween(side, absDir)) != null)
|
||||
|
@ -581,7 +581,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
|||
else
|
||||
{
|
||||
TileEntity tileEntity = world().getBlockTileEntity(pos.x, pos.y, pos.z);
|
||||
return this.canConnect(tileEntity);
|
||||
return this.canConnectTo(tileEntity);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -635,7 +635,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
|||
|
||||
public boolean connectCorner(IAdvancedConductor wire, int r)
|
||||
{
|
||||
if (canConnect(wire) && maskOpen(r))
|
||||
if (canConnectTo(wire) && maskOpen(r))
|
||||
{
|
||||
int oldConn = connMap;
|
||||
connMap |= 0x1 << r;
|
||||
|
@ -651,7 +651,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
|||
|
||||
public boolean connectStraight(IAdvancedConductor wire, int r)
|
||||
{
|
||||
if (canConnect(wire) && maskOpen(r))
|
||||
if (canConnectTo(wire) && maskOpen(r))
|
||||
{
|
||||
int oldConn = connMap;
|
||||
connMap |= 0x10 << r;
|
||||
|
@ -664,7 +664,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
|||
|
||||
public boolean connectInternal(IAdvancedConductor wire, int r)
|
||||
{
|
||||
if (canConnect(wire))
|
||||
if (canConnectTo(wire))
|
||||
{
|
||||
int oldConn = connMap;
|
||||
connMap |= 0x100 << r;
|
||||
|
|
|
@ -74,16 +74,25 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
|
|||
}
|
||||
|
||||
/**
|
||||
* Can externally connect?
|
||||
* EXTERNAL USE
|
||||
* Can this wire be connected by another block?
|
||||
*/
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
Vector3 connectPos = new Vector3(tile()).modifyPositionFromSide(direction);
|
||||
TileEntity connectTile = connectPos.getTileEntity(world());
|
||||
return CompatibilityModule.canConnect(connectTile, direction.getOpposite());
|
||||
|
||||
if (connectTile instanceof IConductor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return CompatibilityModule.isHandler(connectTile);
|
||||
}
|
||||
|
||||
public abstract boolean canConnectTo(Object obj);
|
||||
|
||||
/**
|
||||
* Recalculates all the netwirk connections
|
||||
*/
|
||||
|
@ -104,6 +113,4 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean canConnect(Object obj);
|
||||
}
|
||||
|
|
|
@ -31,9 +31,11 @@ public abstract class PartWireBase extends PartConductor
|
|||
public boolean isInsulated = false;
|
||||
|
||||
/**
|
||||
* Can connect with this conductor?
|
||||
* INTERNAL USE.
|
||||
* Can this conductor connect with an external object?
|
||||
*/
|
||||
public boolean canConnect(Object obj)
|
||||
@Override
|
||||
public boolean canConnectTo(Object obj)
|
||||
{
|
||||
if (obj instanceof IAdvancedConductor)
|
||||
{
|
||||
|
|
|
@ -74,12 +74,29 @@ public class TraitConductor extends TileMultipart implements IConductor
|
|||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
for (IConductor conductor : this.interfaces)
|
||||
{
|
||||
if (conductor.canConnect(direction))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||
{
|
||||
TMultiPart part = this.partMap(from.ordinal());
|
||||
|
||||
if (this.interfaces.contains(part) && part instanceof IConductor)
|
||||
{
|
||||
//((IConductor) part).onReceiveEnergy(from, receive, doReceive);
|
||||
|
||||
System.out.println("RECEIVING");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue