fixed Debug load and source blocks
This was honestly very stupid why it wasn't working. It all came down the a method called getOutputdirections. Honestly why did this stupid enumset stuff return when its a bad way to track connections. It makes rotation more complex, and can connect is good enough to handle both. Any complex connection mojo should be handled by the update tick or custom mod method rather then by default be there.
This commit is contained in:
parent
244e822678
commit
07e2a7511a
5 changed files with 79 additions and 43 deletions
|
@ -51,17 +51,19 @@ public abstract class TileEntityElectrical extends TileEntityAdvanced implements
|
|||
|
||||
/**
|
||||
* Produces UE power towards a specific direction.
|
||||
*
|
||||
*
|
||||
* @param outputDirection - The output direction.
|
||||
*/
|
||||
public void produceUE(ForgeDirection outputDirection)
|
||||
{
|
||||
System.out.println("Outputing to side " +outputDirection.toString());
|
||||
if (!this.worldObj.isRemote && outputDirection != null && outputDirection != ForgeDirection.UNKNOWN)
|
||||
{
|
||||
float provide = this.getProvide(outputDirection);
|
||||
|
||||
if (provide > 0)
|
||||
{
|
||||
System.out.println("Outputing " +provide +"W");
|
||||
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection);
|
||||
IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(outputTile, outputDirection);
|
||||
|
||||
|
@ -71,6 +73,7 @@ public abstract class TileEntityElectrical extends TileEntityAdvanced implements
|
|||
|
||||
if (powerRequest.getWatts() > 0)
|
||||
{
|
||||
System.out.println("Request " +powerRequest +"W");
|
||||
ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(this.getEnergyStored(), this.getVoltage()), ElectricityPack.getFromWatts(provide, this.getVoltage()));
|
||||
float rejectedPower = outputNetwork.produce(sendPack, this);
|
||||
this.provideElectricity(sendPack.getWatts() - rejectedPower, true);
|
||||
|
@ -82,7 +85,7 @@ public abstract class TileEntityElectrical extends TileEntityAdvanced implements
|
|||
|
||||
/**
|
||||
* The electrical input direction.
|
||||
*
|
||||
*
|
||||
* @return The direction that electricity is entered into the tile. Return null for no input. By
|
||||
* default you can accept power from all sides.
|
||||
*/
|
||||
|
@ -93,7 +96,7 @@ public abstract class TileEntityElectrical extends TileEntityAdvanced implements
|
|||
|
||||
/**
|
||||
* The electrical output direction.
|
||||
*
|
||||
*
|
||||
* @return The direction that electricity is output from the tile. Return null for no output. By
|
||||
* default it will return an empty EnumSet.
|
||||
*/
|
||||
|
|
|
@ -1,13 +1,32 @@
|
|||
package dark.common.debug;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.block.IElectrical;
|
||||
import universalelectricity.compatibility.TileEntityUniversalElectrical;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
|
||||
public class TileEntityInfLoad extends TileEntity implements IElectrical
|
||||
public class TileEntityInfLoad extends TileEntityUniversalElectrical
|
||||
{
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.ticks % 1000 == 0)
|
||||
{
|
||||
this.setEnergyStored(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
|
@ -15,28 +34,11 @@ public class TileEntityInfLoad extends TileEntity implements IElectrical
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
|
||||
{
|
||||
if(receive != null)
|
||||
{
|
||||
System.out.println("Burning off "+receive.getWatts()+" watts of energy");
|
||||
}
|
||||
return this.canConnect(from) && receive != null ? receive.getWatts() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRequest(ForgeDirection direction)
|
||||
{
|
||||
//TODO add config options to change this for testing
|
||||
return Integer.MAX_VALUE;
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,4 +53,10 @@ public class TileEntityInfLoad extends TileEntity implements IElectrical
|
|||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxEnergyStored()
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package dark.common.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.compatibility.TileEntityUniversalElectrical;
|
||||
import universalelectricity.core.block.IElectrical;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
|
||||
public class TileEntityInfSupply extends TileEntityUniversalElectrical implements IElectrical
|
||||
public class TileEntityInfSupply extends TileEntityUniversalElectrical
|
||||
{
|
||||
|
||||
@Override
|
||||
|
@ -15,28 +16,38 @@ public class TileEntityInfSupply extends TileEntityUniversalElectrical implement
|
|||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
System.out.println("Inf power supply cycle " + this.ticks);
|
||||
//System.out.println("Inf power supply cycle " + this.ticks);
|
||||
this.produce();
|
||||
if (this.ticks % 10 == 0)
|
||||
{
|
||||
this.setEnergyStored(this.getEnergyStored() + (this.getProvide(ForgeDirection.UNKNOWN) * 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getOutputDirections()
|
||||
{
|
||||
return EnumSet.allOf(ForgeDirection.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
|
||||
{
|
||||
return this.canConnect(from) ? request : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProvide(ForgeDirection direction)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return Integer.MAX_VALUE;
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,12 +62,6 @@ public class TileEntityInfSupply extends TileEntityUniversalElectrical implement
|
|||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnergyStored()
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRequest(ForgeDirection direction)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,18 @@ import universalelectricity.compatibility.TileEntityUniversalConductor;
|
|||
|
||||
public class TileEntityWire extends TileEntityUniversalConductor
|
||||
{
|
||||
int updateTick = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
if (this.ticks % 1 + updateTick == 0)
|
||||
{
|
||||
this.updateTick = this.worldObj.rand.nextInt(200);
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getResistance()
|
||||
|
@ -17,4 +29,10 @@ public class TileEntityWire extends TileEntityUniversalConductor
|
|||
return 10000f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -145,17 +145,19 @@ public class ItemTools extends ItemBasic
|
|||
}
|
||||
if (tileEntity instanceof IElectricalStorage)
|
||||
{
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(" EnergyStored> %1$.2fW of %1$.2fW max", ((IElectricalStorage) tileEntity).getEnergyStored(), ((IElectricalStorage) tileEntity).getMaxEnergyStored())));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(" EnergyStored> %1$.2fW of %2$.2fW max", ((IElectricalStorage) tileEntity).getEnergyStored(), ((IElectricalStorage) tileEntity).getMaxEnergyStored())));
|
||||
out = true;
|
||||
}
|
||||
if (tileEntity instanceof IConductor)
|
||||
{
|
||||
out = true;
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(" Resistance> %1$.2fW | AmpMax> %1$.2fW", ((IConductor) tileEntity).getResistance(), ((IConductor) tileEntity).getCurrentCapacity())));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(" Resistance> %1$.2fW | AmpMax> %2$.2fW", ((IConductor) tileEntity).getResistance(), ((IConductor) tileEntity).getCurrentCapacity())));
|
||||
|
||||
if (((IConductor) tileEntity).getNetwork() != null)
|
||||
{
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(" Network>WattRequired> %1$.2fW | TotalResistance> %1$.2fW", (((IConductor) tileEntity).getNetwork().getRequest() != null ? ((IConductor) tileEntity).getNetwork().getRequest().getWatts() : 0), ((IConductor) tileEntity).getNetwork().getTotalResistance())));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(" Network>" + ((IConductor) tileEntity).getNetwork().toString()));
|
||||
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(String.format(" Network>WattRequired> %1$.2fW | TotalResistance> %2$.2fW", (((IConductor) tileEntity).getNetwork().getRequest() != null ? ((IConductor) tileEntity).getNetwork().getRequest().getWatts() : 0), ((IConductor) tileEntity).getNetwork().getTotalResistance())));
|
||||
}
|
||||
}
|
||||
if (!out)
|
||||
|
|
Loading…
Reference in a new issue