Fixed several errors caused by changes in UE api
This commit is contained in:
parent
a7ebb5de9a
commit
c99988e462
40 changed files with 169 additions and 411 deletions
|
@ -10,13 +10,13 @@ import net.minecraft.nbt.NBTTagCompound
|
|||
import net.minecraft.util.{ChatComponentText, IIcon}
|
||||
import net.minecraft.world.IBlockAccess
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.{Fluid, FluidContainerRegistry, FluidRegistry, FluidStack, FluidTankInfo}
|
||||
import net.minecraftforge.fluids.{Fluid, FluidContainerRegistry, FluidRegistry, FluidStack}
|
||||
import resonant.api.IRotatable
|
||||
import resonant.lib.config.Config
|
||||
import resonant.lib.utility.FluidUtility
|
||||
import resonantinduction.archaic.fluid.grate.TileGrate._
|
||||
import resonantinduction.core.Reference
|
||||
import resonantinduction.core.grid.fluid.pressure.{FluidPressureNode, TilePressureNode}
|
||||
import resonantinduction.core.prefab.node.TilePressureNode
|
||||
import universalelectricity.core.transform.vector.Vector3
|
||||
|
||||
object TileGrate {
|
||||
|
@ -48,19 +48,10 @@ object TileGrate {
|
|||
class TileGrate extends TilePressureNode( Material.rock ) with IRotatable {
|
||||
|
||||
private var gratePath : GratePathfinder = _
|
||||
|
||||
private var fillOver : Boolean = true
|
||||
|
||||
isOpaqueCube = false
|
||||
|
||||
normalRender = true
|
||||
|
||||
//rotationMask = java.lang.Byte.parseByte( "111111", 2 )
|
||||
|
||||
tankNode = new FluidPressureNode( this )
|
||||
|
||||
tankNode.maxFlowRate = getPressureTank.getCapacity
|
||||
|
||||
override def getIcon( world : IBlockAccess, side : Int ) : IIcon = {
|
||||
if ( side == getDirection.ordinal() ) iconFront else iconSide
|
||||
}
|
||||
|
@ -96,8 +87,6 @@ class TileGrate extends TilePressureNode( Material.rock ) with IRotatable {
|
|||
nbt.setBoolean( "fillOver", fillOver )
|
||||
}
|
||||
|
||||
override def getTankInfo( from : ForgeDirection ) : Array[ FluidTankInfo ] = Array( getPressureTank.getInfo )
|
||||
|
||||
override def canFill( from : ForgeDirection, fluid : Fluid ) : Boolean = getDirection != from
|
||||
|
||||
override def canDrain( from : ForgeDirection, fluid : Fluid ) : Boolean = getDirection != from
|
||||
|
@ -106,22 +95,22 @@ class TileGrate extends TilePressureNode( Material.rock ) with IRotatable {
|
|||
super.update()
|
||||
if ( !world.isRemote ) {
|
||||
if ( ticks % 10 == 0 ) {
|
||||
val pressure = tankNode.getPressure( getDirection )
|
||||
val pressure = getPressure( getDirection )
|
||||
val blockEffect = Math.abs( pressure * grateEffectMultiplier ).toInt
|
||||
getPressureTank.setCapacity( Math.max( blockEffect * FluidContainerRegistry.BUCKET_VOLUME * grateDrainSpeedMultiplier,
|
||||
setCapacity( Math.max( blockEffect * FluidContainerRegistry.BUCKET_VOLUME * grateDrainSpeedMultiplier,
|
||||
FluidContainerRegistry.BUCKET_VOLUME ).toInt )
|
||||
if ( pressure > 0 ) {
|
||||
if ( getPressureTank.getFluidAmount >= FluidContainerRegistry.BUCKET_VOLUME ) {
|
||||
if ( getFluidAmount >= FluidContainerRegistry.BUCKET_VOLUME ) {
|
||||
if ( gratePath == null ) {
|
||||
gratePath = new GratePathfinder( true )
|
||||
gratePath.startFill( new Vector3( this ), getPressureTank.getFluid.getFluid.getID )
|
||||
gratePath.startFill( new Vector3( this ), getTank().getFluid.getFluid.getID )
|
||||
}
|
||||
val filledInWorld = gratePath.tryFill( getPressureTank.getFluidAmount, blockEffect )
|
||||
getPressureTank.drain( filledInWorld, true )
|
||||
val filledInWorld = gratePath.tryFill( getFluidAmount, blockEffect )
|
||||
getTank().drain( filledInWorld, true )
|
||||
}
|
||||
}
|
||||
else if ( pressure < 0 ) {
|
||||
val maxDrain = getPressureTank.getCapacity - getPressureTank.getFluidAmount
|
||||
val maxDrain = getTank().getCapacity - getFluidAmount
|
||||
if ( maxDrain > 0 ) {
|
||||
if ( gratePath == null ) {
|
||||
gratePath = new GratePathfinder( false )
|
||||
|
@ -130,7 +119,7 @@ class TileGrate extends TilePressureNode( Material.rock ) with IRotatable {
|
|||
}
|
||||
}
|
||||
if ( gratePath != null && gratePath.tryPopulateDrainMap( blockEffect ) ) {
|
||||
getPressureTank.fill( gratePath.tryDrain( maxDrain, true ), true )
|
||||
getTank().fill( gratePath.tryDrain( maxDrain, true ), true )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +127,7 @@ class TileGrate extends TilePressureNode( Material.rock ) with IRotatable {
|
|||
}
|
||||
}
|
||||
|
||||
override def fill( from : ForgeDirection, resource : FluidStack, doFill : Boolean ) : Int = getPressureTank.fill( resource, doFill )
|
||||
override def fill( from : ForgeDirection, resource : FluidStack, doFill : Boolean ) : Int = getTank().fill( resource, doFill )
|
||||
|
||||
override def drain( from : ForgeDirection, resource : FluidStack, doDrain : Boolean ) : FluidStack = {
|
||||
if ( resource != null ) {
|
||||
|
@ -148,7 +137,7 @@ class TileGrate extends TilePressureNode( Material.rock ) with IRotatable {
|
|||
}
|
||||
|
||||
override def drain( from : ForgeDirection, maxDrain : Int, doDrain : Boolean ) : FluidStack = {
|
||||
getPressureTank.drain( maxDrain, doDrain )
|
||||
getTank().drain( maxDrain, doDrain )
|
||||
}
|
||||
|
||||
def resetPath() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package resonantinduction.archaic.fluid.gutter;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonantinduction.core.grid.fluid.TileTankNode;
|
||||
import resonantinduction.core.grid.fluid.pressure.FluidPressureNode;
|
||||
import resonantinduction.core.prefab.node.NodePressure;
|
||||
import resonantinduction.core.prefab.node.TileTankNode;
|
||||
|
||||
public class FluidGravityNode extends FluidPressureNode
|
||||
public class FluidGravityNode extends NodePressure
|
||||
{
|
||||
public FluidGravityNode(TileTankNode parent)
|
||||
{
|
||||
|
@ -22,10 +22,4 @@ public class FluidGravityNode extends FluidPressureNode
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -29,12 +24,10 @@ import resonant.lib.render.RenderUtility;
|
|||
import resonant.lib.utility.FluidUtility;
|
||||
import resonant.lib.utility.WorldUtility;
|
||||
import resonant.lib.utility.inventory.InventoryUtility;
|
||||
import resonantinduction.archaic.fluid.grate.TileGrate;
|
||||
import resonantinduction.core.RecipeType;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.grid.fluid.TileTankNode;
|
||||
import resonantinduction.core.grid.fluid.pressure.FluidPressureNode;
|
||||
import resonantinduction.core.grid.fluid.pressure.TilePressureNode;
|
||||
import resonantinduction.core.prefab.node.TilePressureNode;
|
||||
import resonantinduction.core.prefab.node.TileTankNode;
|
||||
import universalelectricity.core.transform.region.Cuboid;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -59,94 +52,6 @@ public class TileGutter extends TilePressureNode
|
|||
isOpaqueCube(false);
|
||||
normalRender(false);
|
||||
bounds(new Cuboid(0, 0, 0, 1, 0.99, 1));
|
||||
|
||||
tankNode_$eq(new FluidGravityNode(this) {
|
||||
@Override
|
||||
public void doRecache() {
|
||||
connections().clear();
|
||||
byte previousConnections = renderSides();
|
||||
renderSides_$eq((byte)0);
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
TileEntity tile = position().add(dir).getTileEntity(world());
|
||||
|
||||
if (tile instanceof IFluidHandler) {
|
||||
if (tile instanceof TileTankNode) {
|
||||
FluidPressureNode check = (FluidPressureNode) ((TileTankNode) tile).getNode(FluidPressureNode.class, dir.getOpposite());
|
||||
|
||||
if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this)) {
|
||||
connections().put(check, dir);
|
||||
|
||||
if (tile instanceof TileGutter) {
|
||||
renderSides_$eq(WorldUtility.setEnableSide(renderSides(), dir, true));
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
connections().put(tile, dir);
|
||||
|
||||
if (tile instanceof TileGrate) {
|
||||
renderSides_$eq(WorldUtility.setEnableSide(renderSides(), dir, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Only send packet updates if visuallyConnected changed. */
|
||||
if (previousConnections != renderSides()) {
|
||||
sendRenderUpdate();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
super.update();
|
||||
|
||||
if (!this.world().isRemote && this.ticks() % 20 == 0)
|
||||
{
|
||||
/** Drain block above if it is a fluid. */
|
||||
Vector3 drainPos = position().add(0, 1, 0);
|
||||
FluidStack drain = FluidUtility.drainBlock(worldObj, drainPos, false);
|
||||
|
||||
if (drain != null)
|
||||
{
|
||||
ArrayList<IFluidTank> tanks = new ArrayList<IFluidTank>();
|
||||
|
||||
synchronized (tankNode().getGrid().getNodes())
|
||||
{
|
||||
for (Object check : tankNode().getGrid().getNodes())
|
||||
{
|
||||
if (check instanceof FluidPressureNode)
|
||||
{
|
||||
if (((FluidPressureNode) check).getParent() instanceof TileGutter)
|
||||
{
|
||||
//tanks.add(((FluidPressureNode) check).getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FluidUtility.fillAllTanks(tanks, drain, false) >= drain.amount)
|
||||
{
|
||||
FluidUtility.fillAllTanks(tanks, drain, true);
|
||||
FluidUtility.drainBlock(worldObj, drainPos, true);
|
||||
|
||||
synchronized (tankNode().getGrid().getNodes())
|
||||
{
|
||||
for (Object check : tankNode().getGrid().getNodes())
|
||||
{
|
||||
if (check instanceof FluidPressureNode)
|
||||
{
|
||||
//((FluidPressureNode) check).getParent().onFluidChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -191,14 +96,14 @@ public class TileGutter extends TilePressureNode
|
|||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
int pressure = tankNode().getPressure(dir);
|
||||
int pressure = getPressure(dir);
|
||||
Vector3 position = position().add(dir);
|
||||
|
||||
TileEntity checkTile = position.getTileEntity(world());
|
||||
|
||||
if (checkTile instanceof TileGutter)
|
||||
{
|
||||
int deltaPressure = pressure - ((TileGutter) checkTile).tankNode().getPressure(dir.getOpposite());
|
||||
int deltaPressure = pressure - ((TileGutter) checkTile).getPressure(dir.getOpposite());
|
||||
|
||||
entity.motionX += 0.01 * dir.offsetX * deltaPressure;
|
||||
entity.motionY += 0.01 * dir.offsetY * deltaPressure;
|
||||
|
@ -326,7 +231,7 @@ public class TileGutter extends TilePressureNode
|
|||
|
||||
if (world() != null)
|
||||
{
|
||||
FluidTank tank = getTank();
|
||||
IFluidTank tank = getTank();
|
||||
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
|
||||
|
||||
if (percentageFilled > 0.1)
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.nbt.NBTTagCompound
|
|||
import net.minecraft.world.IBlockAccess
|
||||
import net.minecraftforge.client.IItemRenderer
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.{FluidContainerRegistry, FluidStack, FluidTank}
|
||||
import net.minecraftforge.fluids.{IFluidTank, FluidContainerRegistry, FluidStack, FluidTank}
|
||||
import org.lwjgl.opengl.GL11
|
||||
import resonant.api.IRemovable.ISneakPickup
|
||||
import resonant.content.prefab.scala.render.ISimpleItemRenderer
|
||||
|
@ -19,7 +19,7 @@ import resonant.lib.utility.FluidUtility
|
|||
import resonant.lib.utility.render.RenderBlockUtility
|
||||
import resonantinduction.archaic.ArchaicBlocks
|
||||
import resonantinduction.core.Reference
|
||||
import resonantinduction.core.grid.fluid.TileTankNode
|
||||
import resonantinduction.core.prefab.node.TileTankNode
|
||||
import universalelectricity.core.transform.vector.Vector3
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,7 @@ class TileTank extends TileTankNode(Material.iron) with ISneakPickup {
|
|||
isOpaqueCube(false)
|
||||
normalRender(false)
|
||||
itemBlock(classOf[ItemBlockTank])
|
||||
this.tank.setCapacity(16 * FluidContainerRegistry.BUCKET_VOLUME)
|
||||
setCapacity(16 * FluidContainerRegistry.BUCKET_VOLUME)
|
||||
|
||||
override def shouldSideBeRendered(access: IBlockAccess, x: Int, y: Int, z: Int, side: Int): Boolean = {
|
||||
return access.getBlock(x, y, z) ne getBlockType
|
||||
|
@ -113,7 +113,7 @@ class TileTank extends TileTankNode(Material.iron) with ISneakPickup {
|
|||
GL11.glPushMatrix
|
||||
if (!fluid.getFluid.isGaseous) {
|
||||
GL11.glScaled(0.99, 0.99, 0.99)
|
||||
val tank: FluidTank = getTank
|
||||
val tank: IFluidTank = getTank
|
||||
val percentageFilled: Double = tank.getFluidAmount.asInstanceOf[Double] / tank.getCapacity.asInstanceOf[Double]
|
||||
val ySouthEast: Double = FluidUtility.getAveragePercentageFilledForSides(classOf[TileTank], percentageFilled, world, new Vector3(this), ForgeDirection.SOUTH, ForgeDirection.EAST)
|
||||
val yNorthEast: Double = FluidUtility.getAveragePercentageFilledForSides(classOf[TileTank], percentageFilled, world, new Vector3(this), ForgeDirection.NORTH, ForgeDirection.EAST)
|
||||
|
|
|
@ -2,6 +2,7 @@ package resonantinduction.archaic.waila;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import resonantinduction.archaic.fluid.tank.TileTank;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
@ -22,7 +23,7 @@ public class WailaFluidTank implements IWailaDataProvider
|
|||
TileEntity tile = accessor.getTileEntity();
|
||||
if (tile instanceof TileTank)
|
||||
{
|
||||
FluidTank tank = ((TileTank) tile).getTank();
|
||||
IFluidTank tank = ((TileTank) tile).getTank();
|
||||
if (tank != null && tank.getFluid() != null)
|
||||
{
|
||||
currenttip.add(LanguageUtility.getLocal("info.waila.tank.fluid") + " " + tank.getFluid().getFluid().getLocalizedName());
|
||||
|
|
|
@ -2,6 +2,7 @@ package resonantinduction.atomic.machine.accelerator;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonant.lib.gui.GuiContainerBase;
|
||||
import universalelectricity.api.UnitDisplay;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
|
@ -50,7 +51,7 @@ public class GuiAccelerator extends GuiContainerBase
|
|||
this.fontRendererObj.drawString("Antimatter: " + this.tileEntity.antimatter + " mg", 8, 80, 4210752);
|
||||
this.fontRendererObj.drawString("Status:", 8, 90, 4210752);
|
||||
this.fontRendererObj.drawString(status, 8, 100, 4210752);
|
||||
this.fontRendererObj.drawString("Buffer: " + this.tileEntity.electricNode().getEnergy() + "/" + new UnitDisplay(UnitDisplay.Unit.JOULES, this.tileEntity.electricNode().getEnergyCapacity(),true ), 8, 110,
|
||||
this.fontRendererObj.drawString("Buffer: " + this.tileEntity.electricNode().getEnergy(ForgeDirection.UNKNOWN) + "/" + new UnitDisplay(UnitDisplay.Unit.JOULES, this.tileEntity.electricNode().getEnergyCapacity(ForgeDirection.UNKNOWN),true ), 8, 110,
|
||||
4210752);
|
||||
this.fontRendererObj.drawString("Facing: " + this.tileEntity.getDirection().getOpposite(), 100, 123, 4210752);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class TileAccelerator extends TileElectricInventory implements IElectroma
|
|||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
clientEnergy = electricNode().energy().getEnergy();
|
||||
clientEnergy = energy().getEnergy();
|
||||
velocity = 0;
|
||||
|
||||
// Calculate accelerated particle velocity if it is spawned.
|
||||
|
@ -116,7 +116,7 @@ public class TileAccelerator extends TileElectricInventory implements IElectroma
|
|||
// Check if redstone signal is currently being applied.
|
||||
if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))
|
||||
{
|
||||
if (electricNode().energy().checkExtract())
|
||||
if (energy().checkExtract())
|
||||
{
|
||||
if (entityParticle == null)
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ public class TileAccelerator extends TileElectricInventory implements IElectroma
|
|||
}
|
||||
}
|
||||
|
||||
electricNode().energy().extractEnergy();
|
||||
energy().extractEnergy();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@ package resonantinduction.atomic.machine.boiler;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonant.lib.gui.GuiContainerBase;
|
||||
import universalelectricity.api.UnitDisplay;
|
||||
|
||||
|
@ -23,7 +24,7 @@ public class GuiNuclearBoiler extends GuiContainerBase
|
|||
this.fontRendererObj.drawString("Boiler", 52, 6, 4210752);
|
||||
|
||||
this.renderUniversalDisplay(8, 112, TileNuclearBoiler.DIAN * 20, mouseX, mouseY, UnitDisplay.Unit.WATT);
|
||||
this.renderUniversalDisplay(110, 112, tileEntity.electricNode().voltage(), mouseX, mouseY, UnitDisplay.Unit.VOLTAGE);
|
||||
this.renderUniversalDisplay(110, 112, tileEntity.electricNode().getVoltage(ForgeDirection.UNKNOWN), mouseX, mouseY, UnitDisplay.Unit.VOLTAGE);
|
||||
|
||||
this.fontRendererObj.drawString("The nuclear boiler can boil", 8, 75, 4210752);
|
||||
this.fontRendererObj.drawString("yellow cake into uranium", 8, 85, 4210752);
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TileNuclearBoiler extends TileElectricInventory implements IPacketR
|
|||
public TileNuclearBoiler()
|
||||
{
|
||||
super(Material.iron);
|
||||
electricNode().energy().setCapacity(DIAN * 2);
|
||||
energy().setCapacity(DIAN * 2);
|
||||
this.setSizeInventory(4);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class TileNuclearBoiler extends TileElectricInventory implements IPacketR
|
|||
{
|
||||
this.discharge(getStackInSlot(0));
|
||||
|
||||
if (electricNode().energy().extractEnergy(DIAN, false) >= TileNuclearBoiler.DIAN)
|
||||
if (energy().extractEnergy(DIAN, false) >= TileNuclearBoiler.DIAN)
|
||||
{
|
||||
if (this.timer == 0)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ public class TileNuclearBoiler extends TileElectricInventory implements IPacketR
|
|||
this.timer = 0;
|
||||
}
|
||||
|
||||
electricNode().energy().extractEnergy(DIAN, true);
|
||||
energy().extractEnergy(DIAN, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -2,6 +2,7 @@ package resonantinduction.atomic.machine.centrifuge;
|
|||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonant.lib.gui.GuiContainerBase;
|
||||
import universalelectricity.api.UnitDisplay;
|
||||
|
||||
|
@ -39,7 +40,7 @@ public class GuiCentrifuge extends GuiContainerBase
|
|||
this.fontRendererObj.drawString("Status: " + displayText, 70, 50, 4210752);
|
||||
|
||||
this.renderUniversalDisplay(8, 112, TileCentrifuge.DIAN * 20, mouseX, mouseY, UnitDisplay.Unit.WATT);
|
||||
this.renderUniversalDisplay(100, 112, this.tileEntity.electricNode().getVoltage(), mouseX, mouseY, UnitDisplay.Unit.VOLTAGE);
|
||||
this.renderUniversalDisplay(100, 112, this.tileEntity.electricNode().getVoltage(ForgeDirection.UNKNOWN), mouseX, mouseY, UnitDisplay.Unit.VOLTAGE);
|
||||
|
||||
this.fontRendererObj.drawString("The centrifuge spins", 8, 75, 4210752);
|
||||
this.fontRendererObj.drawString("uranium hexafluoride gas into", 8, 85, 4210752);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class TileCentrifuge extends TileElectricInventory implements IPacketRece
|
|||
super(Material.iron);
|
||||
isOpaqueCube(true);
|
||||
normalRender(false);
|
||||
electricNode().energy().setCapacity(DIAN * 2);
|
||||
energy().setCapacity(DIAN * 2);
|
||||
setSizeInventory(4);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class TileCentrifuge extends TileElectricInventory implements IPacketRece
|
|||
{
|
||||
this.discharge(getStackInSlot(0));
|
||||
|
||||
if (electricNode().energy().extractEnergy(TileCentrifuge.DIAN, false) >= DIAN)
|
||||
if (energy().extractEnergy(TileCentrifuge.DIAN, false) >= DIAN)
|
||||
{
|
||||
if (this.timer == 0)
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ public class TileCentrifuge extends TileElectricInventory implements IPacketRece
|
|||
this.timer = 0;
|
||||
}
|
||||
|
||||
electricNode().energy().extractEnergy(DIAN, true);
|
||||
energy().extractEnergy(DIAN, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -2,6 +2,7 @@ package resonantinduction.atomic.machine.extractor;
|
|||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonant.lib.gui.GuiContainerBase;
|
||||
import universalelectricity.api.UnitDisplay;
|
||||
|
||||
|
@ -22,7 +23,7 @@ public class GuiChemicalExtractor extends GuiContainerBase
|
|||
this.fontRendererObj.drawString("Chemical Extractor", 45, 6, 4210752);
|
||||
|
||||
this.renderUniversalDisplay(8, 112, TileChemicalExtractor.ENERGY * 20, mouseX, mouseY, UnitDisplay.Unit.WATT);
|
||||
this.renderUniversalDisplay(100, 112, this.tileEntity.electricNode().getVoltage(), mouseX, mouseY, UnitDisplay.Unit.VOLTAGE);
|
||||
this.renderUniversalDisplay(100, 112, this.tileEntity.electricNode().getVoltage(ForgeDirection.UNKNOWN), mouseX, mouseY, UnitDisplay.Unit.VOLTAGE);
|
||||
|
||||
this.fontRendererObj.drawString("The extractor can extract", 8, 75, 4210752);
|
||||
this.fontRendererObj.drawString("uranium, deuterium and tritium.", 8, 85, 4210752);
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TileChemicalExtractor extends TileProcess implements IFluidHandler
|
|||
public TileChemicalExtractor()
|
||||
{
|
||||
super(Material.iron);
|
||||
electricNode().energy().setCapacity(ENERGY * 2);
|
||||
energy().setCapacity(ENERGY * 2);
|
||||
this.setSizeInventory(7);
|
||||
this.isOpaqueCube(true);
|
||||
this.normalRender(false);
|
||||
|
@ -73,7 +73,7 @@ public class TileChemicalExtractor extends TileProcess implements IFluidHandler
|
|||
{
|
||||
discharge(getStackInSlot(0));
|
||||
|
||||
if (electricNode().energy().checkExtract(ENERGY))
|
||||
if (energy().checkExtract(ENERGY))
|
||||
{
|
||||
if (time == 0)
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ public class TileChemicalExtractor extends TileProcess implements IFluidHandler
|
|||
}
|
||||
}
|
||||
|
||||
electricNode().energy().extractEnergy(ENERGY, true);
|
||||
energy().extractEnergy(ENERGY, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ public class FulminationHandler
|
|||
|
||||
long energy = (long) Math.min(maxEnergyPerGenerator, maxEnergyPerGenerator / (juLi / evt.iExplosion.getRadius()));
|
||||
energy = (long) Math.max((1 - density) * energy, 0);
|
||||
tileEntity.electricNode().energy().receiveEnergy(energy, true);
|
||||
tileEntity.energy().receiveEnergy(energy, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class TileFulmination extends TileElectric
|
|||
public TileFulmination()
|
||||
{
|
||||
super(Material.iron);
|
||||
electricNode().energy().setCapacity(DIAN * 2);
|
||||
energy().setCapacity(DIAN * 2);
|
||||
this.blockHardness(10);
|
||||
this.blockResistance(25000);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class TileFulmination extends TileElectric
|
|||
{
|
||||
super.update();
|
||||
// Slowly lose energy.
|
||||
electricNode().energy().extractEnergy(10, true);
|
||||
energy().extractEnergy(10, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,8 +49,8 @@ public class TilePlasmaHeater extends TileElectric implements IPacketReceiver, I
|
|||
public TilePlasmaHeater()
|
||||
{
|
||||
super(Material.iron);
|
||||
electricNode().energy().setCapacity(joules);
|
||||
electricNode().energy().setMaxTransfer(joules / 20);
|
||||
energy().setCapacity(joules);
|
||||
energy().setMaxTransfer(joules / 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,11 +58,11 @@ public class TilePlasmaHeater extends TileElectric implements IPacketReceiver, I
|
|||
{
|
||||
super.update();
|
||||
|
||||
rotation += electricNode().energy().getEnergy() / 10000f;
|
||||
rotation += energy().getEnergy() / 10000f;
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (electricNode().energy().checkExtract())
|
||||
if (energy().checkExtract())
|
||||
{
|
||||
// Creates plasma if there is enough Deuterium, Tritium AND Plasma output is not full.
|
||||
if (tankInputDeuterium.getFluidAmount() >= plasmaHeatAmount &&
|
||||
|
@ -72,7 +72,7 @@ public class TilePlasmaHeater extends TileElectric implements IPacketReceiver, I
|
|||
tankInputDeuterium.drain(plasmaHeatAmount, true);
|
||||
tankInputTritium.drain(plasmaHeatAmount, true);
|
||||
tankOutput.fill(new FluidStack(AtomicContent.FLUID_PLASMA(), tankOutput.getCapacity()), true);
|
||||
electricNode().energy().extractEnergy();
|
||||
energy().extractEnergy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ public class TilePlasmaHeater extends TileElectric implements IPacketReceiver, I
|
|||
@Override
|
||||
public float addInformation(HashMap<String, Integer> map, EntityPlayer player)
|
||||
{
|
||||
if (electricNode().energy() != null)
|
||||
if (energy() != null)
|
||||
{
|
||||
map.put(LanguageUtility.getLocal("tooltip.energy") + ": " + new UnitDisplay(UnitDisplay.Unit.JOULES, electricNode().energy().getEnergy()), 0xFFFFFF);
|
||||
map.put(LanguageUtility.getLocal("tooltip.energy") + ": " + new UnitDisplay(UnitDisplay.Unit.JOULES, energy().getEnergy()), 0xFFFFFF);
|
||||
}
|
||||
|
||||
if (tankInputDeuterium.getFluidAmount() > 0)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package resonantinduction.atomic.machine.quantum;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonantinduction.atomic.Atomic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -48,7 +49,7 @@ public class GuiQuantumAssembler extends GuiContainerBase
|
|||
}
|
||||
|
||||
this.fontRendererObj.drawString(displayText, 9, this.ySize - 106, 4210752);
|
||||
this.renderUniversalDisplay(100, this.ySize - 94, this.tileEntity.electricNode().voltage(), mouseX, mouseY, UnitDisplay.Unit.VOLTAGE);
|
||||
this.renderUniversalDisplay(100, this.ySize - 94, this.tileEntity.electricNode().getVoltage(ForgeDirection.UNKNOWN), mouseX, mouseY, UnitDisplay.Unit.VOLTAGE);
|
||||
this.renderUniversalDisplay(8, this.ySize - 95, tileEntity.MAX_TIME, mouseX, mouseY, UnitDisplay.Unit.WATT);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ public class TileQuantumAssembler extends TileElectricInventory implements IPack
|
|||
{
|
||||
super(Material.iron);
|
||||
setSizeInventory(7);
|
||||
electricNode().energy().setCapacity(ENERGY);
|
||||
electricNode().energy().setMaxTransfer(ENERGY / 10);
|
||||
energy().setCapacity(ENERGY);
|
||||
energy().setMaxTransfer(ENERGY / 10);
|
||||
isOpaqueCube(false);
|
||||
normalRender(false);
|
||||
customItemRender(true);
|
||||
|
@ -68,7 +68,7 @@ public class TileQuantumAssembler extends TileElectricInventory implements IPack
|
|||
{
|
||||
if (this.canProcess())
|
||||
{
|
||||
if (electricNode().energy().checkExtract())
|
||||
if (energy().checkExtract())
|
||||
{
|
||||
if (this.time == 0)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ public class TileQuantumAssembler extends TileElectricInventory implements IPack
|
|||
{
|
||||
this.time = 0;
|
||||
}
|
||||
electricNode().energy().extractEnergy(ENERGY, true);
|
||||
energy().extractEnergy(ENERGY, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
package resonantinduction.core.grid.fluid.distribution
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids._
|
||||
import resonantinduction.core.grid.fluid.TileTankNode
|
||||
import universalelectricity.core.grid.{GridTicking, UpdateTicker}
|
||||
|
||||
/**
|
||||
* Used for multiblock tanks to distribute fluid.
|
||||
*
|
||||
* @author DarkCow, Calclavia
|
||||
*/
|
||||
abstract class FluidDistributionGrid extends GridTicking[TankNode](classOf[TankNode]) with IFluidHandler
|
||||
{
|
||||
val tank = new FluidTank(0)
|
||||
var needsUpdate = false
|
||||
|
||||
override def canUpdate: Boolean =
|
||||
{
|
||||
return needsUpdate && getNodes().size > 0
|
||||
}
|
||||
|
||||
override def continueUpdate: Boolean =
|
||||
{
|
||||
return canUpdate
|
||||
}
|
||||
|
||||
override def reconstruct()
|
||||
{
|
||||
tank.setCapacity(0)
|
||||
tank.setFluid(null)
|
||||
super.reconstruct()
|
||||
needsUpdate = true
|
||||
UpdateTicker.addUpdater(this)
|
||||
}
|
||||
|
||||
override def reconstructNode(node: TankNode)
|
||||
{
|
||||
val connectorTank: FluidTank = node.getParent.asInstanceOf[TileTankNode].getTank
|
||||
|
||||
if (connectorTank != null)
|
||||
{
|
||||
tank.setCapacity(tank.getCapacity + connectorTank.getCapacity)
|
||||
if (connectorTank.getFluid != null)
|
||||
{
|
||||
if (tank.getFluid == null)
|
||||
{
|
||||
tank.setFluid(connectorTank.getFluid.copy)
|
||||
}
|
||||
else if (tank.getFluid.isFluidEqual(connectorTank.getFluid))
|
||||
{
|
||||
tank.getFluid.amount += connectorTank.getFluidAmount
|
||||
}
|
||||
else if (tank.getFluid != null)
|
||||
{
|
||||
//TODO: Mix fluid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean): Int =
|
||||
{
|
||||
val fill: Int = tank.fill(resource.copy, doFill)
|
||||
if (fill > 0)
|
||||
{
|
||||
needsUpdate = true
|
||||
UpdateTicker.addUpdater(this)
|
||||
}
|
||||
return fill
|
||||
}
|
||||
|
||||
override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
if (resource != null && resource.isFluidEqual(tank.getFluid))
|
||||
{
|
||||
val drain: FluidStack = tank.drain(resource.amount, doDrain)
|
||||
needsUpdate = true
|
||||
UpdateTicker.addUpdater(this)
|
||||
return drain
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override def drain(from: ForgeDirection, resource: Int, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
val drain: FluidStack = tank.drain(resource, doDrain)
|
||||
needsUpdate = true
|
||||
UpdateTicker.addUpdater(this)
|
||||
return drain
|
||||
}
|
||||
|
||||
override def canFill(from: ForgeDirection, fluid: Fluid) = true
|
||||
|
||||
override def canDrain(from: ForgeDirection, fluid: Fluid) = true
|
||||
|
||||
override def getTankInfo(from: ForgeDirection) = Array[FluidTankInfo](tank.getInfo)
|
||||
|
||||
override def toString: String =
|
||||
{
|
||||
return super.toString + " Volume: " + this.tank.getFluidAmount
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package resonantinduction.core.grid.fluid.distribution
|
||||
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.fluids.FluidStack
|
||||
import resonant.lib.utility.FluidUtility
|
||||
import resonantinduction.core.grid.fluid.TileTankNode
|
||||
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.collection.mutable
|
||||
|
||||
/** Network that handles connected tanks
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
class TankGrid extends FluidDistributionGrid
|
||||
{
|
||||
needsUpdate = true
|
||||
|
||||
override def update(deltaTime: Double)
|
||||
{
|
||||
val networkTankFluid = tank.getFluid
|
||||
|
||||
if (getNodes.size > 0)
|
||||
{
|
||||
var totalFluid = if (networkTankFluid != null) networkTankFluid.amount else 0
|
||||
|
||||
/**
|
||||
* Creates a priority queue with tanks in the bottom as highest priority.
|
||||
*/
|
||||
val heightPriorityQueue = new mutable.PriorityQueue[TileTankNode]()(new Ordering[TileTankNode]
|
||||
{
|
||||
def compare(a: TileTankNode, b: TileTankNode): Int =
|
||||
{
|
||||
if (networkTankFluid != null && networkTankFluid.getFluid.isGaseous) return 0
|
||||
return b.asInstanceOf[TileEntity].yCoord - a.asInstanceOf[TileEntity].yCoord
|
||||
}
|
||||
})
|
||||
|
||||
heightPriorityQueue ++= (getNodes() map (_.getParent.asInstanceOf[TileTankNode]))
|
||||
|
||||
var didChange = false
|
||||
|
||||
while (!heightPriorityQueue.isEmpty)
|
||||
{
|
||||
val distributeNode = heightPriorityQueue.dequeue()
|
||||
val yCoord = distributeNode.yCoord
|
||||
val connectorCount = heightPriorityQueue count (_.yCoord == yCoord)
|
||||
|
||||
if (totalFluid <= 0)
|
||||
{
|
||||
distributeNode.getTank.setFluid(null)
|
||||
distributeNode.onFluidChanged
|
||||
}
|
||||
else
|
||||
{
|
||||
val fluidPer: Int = totalFluid / connectorCount
|
||||
val deltaFluidAmount: Int = fluidPer - distributeNode.getTank.getFluidAmount
|
||||
val current: Int = distributeNode.getTank.getFluidAmount
|
||||
|
||||
if (deltaFluidAmount > 0)
|
||||
{
|
||||
val filled: Int = distributeNode.getTank.fill(FluidUtility.getStack(networkTankFluid, deltaFluidAmount), false)
|
||||
distributeNode.getTank.fill(FluidUtility.getStack(networkTankFluid, deltaFluidAmount / 10), true)
|
||||
totalFluid -= current + filled
|
||||
}
|
||||
else
|
||||
{
|
||||
val drain: FluidStack = distributeNode.getTank.drain(Math.abs(deltaFluidAmount), false)
|
||||
distributeNode.getTank.drain(Math.abs(deltaFluidAmount / 10), true)
|
||||
if (drain != null) totalFluid -= current - drain.amount
|
||||
}
|
||||
|
||||
if (deltaFluidAmount != 0) didChange = true
|
||||
distributeNode.onFluidChanged
|
||||
}
|
||||
}
|
||||
|
||||
if (!didChange) needsUpdate = false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,12 +2,13 @@ package resonantinduction.core.interfaces;
|
|||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.api.core.grid.INode;
|
||||
import universalelectricity.api.core.grid.IUpdate;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
|
||||
/** Applied to any node that will act as a resonantinduction.mechanical object in the network
|
||||
*
|
||||
* @author Darkguardsman */
|
||||
public interface IMechanicalNode extends INode
|
||||
public interface IMechanicalNode extends INode, IUpdate
|
||||
{
|
||||
/** Gets the radius of the gear in meters. Used to calculate torque and gear ratio */
|
||||
public double getRadius();
|
||||
|
|
|
@ -10,8 +10,8 @@ import net.minecraftforge.fluids.FluidTank;
|
|||
*/
|
||||
public class LimitedTank extends FluidTank
|
||||
{
|
||||
protected int maxInput;
|
||||
protected int maxOutput;
|
||||
public int maxInput;
|
||||
public int maxOutput;
|
||||
|
||||
public LimitedTank(int capacity)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.core.grid;
|
||||
package resonantinduction.core.prefab;
|
||||
|
||||
import codechicken.multipart.PartMap;
|
||||
import codechicken.multipart.TMultiPart;
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.core.grid
|
||||
package resonantinduction.core.prefab.node
|
||||
|
||||
import codechicken.multipart.TMultiPart
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
|
@ -19,16 +19,16 @@ abstract class MultipartNode(parent: INodeProvider) extends NodeConnector(parent
|
|||
|
||||
override def x: Double =
|
||||
{
|
||||
return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).x else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).xCoord else null
|
||||
return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).x else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).xCoord else 0
|
||||
}
|
||||
|
||||
override def y: Double =
|
||||
{
|
||||
return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).y else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).yCoord else null
|
||||
return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).y else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).yCoord else 0
|
||||
}
|
||||
|
||||
override def z: Double =
|
||||
{
|
||||
return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).z else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).zCoord else null
|
||||
return if (parent.isInstanceOf[TMultiPart]) (parent.asInstanceOf[TMultiPart]).z else if (parent.isInstanceOf[TileEntity]) (parent.asInstanceOf[TileEntity]).zCoord else 0
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ import universalelectricity.core.grid.node.NodeConnector;
|
|||
*/
|
||||
public class NodeTank extends NodeConnector implements IFluidTank, IFluidHandler, ISave, IPacketIDReceiver
|
||||
{
|
||||
FluidTank tank;
|
||||
LimitedTank tank;
|
||||
static final int PACKET_DESCRIPTION = 100, PACKET_TANK = 101;
|
||||
|
||||
public NodeTank(INodeProvider parent)
|
||||
|
@ -164,4 +164,19 @@ public class NodeTank extends NodeConnector implements IFluidTank, IFluidHandler
|
|||
save(tag);
|
||||
ResonantEngine.instance.packetHandler.sendToAllAround(new PacketTile((int)x(), (int)y(), (int)z(), tag), this, 64);
|
||||
}
|
||||
|
||||
public void setCapacity(int capacity)
|
||||
{
|
||||
tank.setCapacity(capacity);
|
||||
}
|
||||
|
||||
public int maxInput()
|
||||
{
|
||||
return tank.maxInput;
|
||||
}
|
||||
|
||||
public int maxOutput()
|
||||
{
|
||||
return tank.maxOutput;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package resonantinduction.core.prefab.node;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Created by robert on 8/15/2014.
|
||||
*/
|
||||
public class TilePressureNode extends TileTankNode
|
||||
{
|
||||
public TilePressureNode(Material material)
|
||||
{
|
||||
super(material);
|
||||
tankNode_$eq(new NodePressure(this));
|
||||
}
|
||||
|
||||
public NodePressure getPressureNode()
|
||||
{
|
||||
return (NodePressure) tankNode();
|
||||
}
|
||||
|
||||
public int getPressure(ForgeDirection direction)
|
||||
{
|
||||
return getPressureNode().getPressure(direction);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.core.grid.fluid
|
||||
package resonantinduction.core.prefab.node
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils
|
||||
import io.netty.buffer.ByteBuf
|
||||
|
@ -10,7 +10,6 @@ import net.minecraftforge.fluids._
|
|||
import resonant.content.prefab.java.TileAdvanced
|
||||
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
||||
import resonant.lib.network.handle.{IPacketIDReceiver, TPacketIDSender}
|
||||
import resonantinduction.core.prefab.node.NodeTank
|
||||
import universalelectricity.api.core.grid.{INode, INodeProvider}
|
||||
|
||||
/**
|
||||
|
@ -114,4 +113,11 @@ class TileTankNode(material: Material) extends TileAdvanced(material) with INode
|
|||
tankNode.deconstruct()
|
||||
super.invalidate()
|
||||
}
|
||||
|
||||
def setCapacity(capacity: Int)
|
||||
{
|
||||
tankNode.setCapacity(capacity)
|
||||
}
|
||||
|
||||
def getFluidAmount : Int = tankNode.getFluidAmount
|
||||
}
|
|
@ -12,6 +12,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.api.core.grid.IConnector;
|
||||
import universalelectricity.api.core.grid.INode;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
|
@ -159,9 +160,9 @@ public abstract class PartFramedConnection<M extends Enum> extends PartColorable
|
|||
{
|
||||
boolean notPrevented = !isConnectionPrevented(tile, side);
|
||||
|
||||
if (getConnector(tile) != null)
|
||||
if (getConnector(tile) instanceof IConnector)
|
||||
{
|
||||
notPrevented &= getConnector(tile).canConnect(side.getOpposite(), this);
|
||||
notPrevented &= ((IConnector)getConnector(tile)).canConnect(side.getOpposite(), this);
|
||||
}
|
||||
|
||||
return notPrevented;
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.item.Item
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.{IIcon, MovingObjectPosition}
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import universalelectricity.api.core.grid.{INode, INodeProvider}
|
||||
import universalelectricity.api.core.grid.{ISave, INode, INodeProvider}
|
||||
|
||||
object PartFramedNode {
|
||||
def connectionMapContainsSide(connections: Byte, side: ForgeDirection): Boolean = {
|
||||
|
@ -180,12 +180,14 @@ abstract class PartFramedNode[M](insulationType: Item) extends PartColorableMate
|
|||
|
||||
override def save(nbt: NBTTagCompound) {
|
||||
super.save(nbt)
|
||||
node.save(nbt)
|
||||
if(node.isInstanceOf[ISave])
|
||||
node.asInstanceOf[ISave].save(nbt)
|
||||
}
|
||||
|
||||
override def load(nbt: NBTTagCompound) {
|
||||
super.load(nbt)
|
||||
node.load(nbt)
|
||||
if(node.isInstanceOf[ISave])
|
||||
node.asInstanceOf[ISave].load(nbt)
|
||||
}
|
||||
|
||||
override def toString: String = {
|
||||
|
|
|
@ -55,7 +55,7 @@ public class TileBattery extends TileEnergyDistribution implements IPacketReceiv
|
|||
@Override
|
||||
public void read(ByteBuf data, EntityPlayer player, PacketType type)
|
||||
{
|
||||
this.electricNode().energy().setEnergy(data.readLong());
|
||||
this.energy().setEnergy(data.readLong());
|
||||
this.ioMap_$eq(data.readShort());
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class TileMotor extends TileElectric(Material.iron) with IRotatable {
|
|||
|
||||
def receiveMechanical {
|
||||
val power: Double = mech_node.getEnergy
|
||||
val receive: Double = electricNode.addEnergy(power, true)
|
||||
val receive: Double = electricNode.addEnergy(ForgeDirection.UNKNOWN, power, true)
|
||||
if (receive > 0) {
|
||||
val percentageUsed: Double = receive / power
|
||||
mech_node.apply(this, -mech_node.getTorque * percentageUsed, -mech_node.getAngularSpeed * percentageUsed)
|
||||
|
@ -59,7 +59,7 @@ class TileMotor extends TileElectric(Material.iron) with IRotatable {
|
|||
}
|
||||
|
||||
def produceMechanical {
|
||||
val extract: Double = electricNode.removeEnergy(electricNode.getEnergy, false)
|
||||
val extract: Double = electricNode.removeEnergy(ForgeDirection.UNKNOWN, electricNode.getEnergy(ForgeDirection.UNKNOWN), false)
|
||||
if (extract > 0) {
|
||||
val torqueRatio: Long = ((gearRatio + 1) / 2.2d * (extract)).asInstanceOf[Long]
|
||||
if (torqueRatio > 0) {
|
||||
|
@ -72,7 +72,7 @@ class TileMotor extends TileElectric(Material.iron) with IRotatable {
|
|||
val currentVelo: Double = Math.abs(mech_node.getAngularSpeed)
|
||||
if (currentVelo != 0) setAngularVelocity = Math.min(+setAngularVelocity, maxAngularVelocity) * (mech_node.getAngularSpeed / currentVelo)
|
||||
mech_node.apply(this, setTorque - mech_node.getTorque, setAngularVelocity - mech_node.getAngularSpeed)
|
||||
electricNode.removeEnergy(Math.abs(setTorque * setAngularVelocity).asInstanceOf[Long], true)
|
||||
electricNode.removeEnergy(ForgeDirection.UNKNOWN, Math.abs(setTorque * setAngularVelocity).asInstanceOf[Long], true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package resonantinduction.electrical.generator
|
|||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.client.renderer.texture.IIconRegister
|
||||
import net.minecraft.util.IIcon
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.content.spatial.block.SpatialBlock
|
||||
import resonantinduction.core.Reference
|
||||
import resonantinduction.core.Settings
|
||||
|
@ -13,7 +14,7 @@ import universalelectricity.core.transform.region.Cuboid
|
|||
|
||||
class TileSolarPanel extends TileEnergyDistribution(Material.iron) {
|
||||
|
||||
electricNode.energy.setCapacity(Settings.SOLAR_ENERGY * 20)
|
||||
energy.setCapacity(Settings.SOLAR_ENERGY * 20)
|
||||
ioMap_$eq(728.asInstanceOf[Short])
|
||||
setTextureName("solarPanel_top")
|
||||
bounds(new Cuboid(0, 0, 0, 1, 0.3f, 1))
|
||||
|
@ -41,7 +42,7 @@ class TileSolarPanel extends TileEnergyDistribution(Material.iron) {
|
|||
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky) {
|
||||
if (this.worldObj.isDaytime) {
|
||||
if (!(this.worldObj.isThundering || this.worldObj.isRaining)) {
|
||||
this.electricNode.addEnergy(Settings.SOLAR_ENERGY, true)
|
||||
this.electricNode.addEnergy(ForgeDirection.UNKNOWN, Settings.SOLAR_ENERGY, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class TileThermopile extends TileElectric(Material.rock) {
|
|||
}
|
||||
val multiplier: Int = (3 - Math.abs(heatSources - coolingSources))
|
||||
if (multiplier > 0 && coolingSources > 0 && heatSources > 0) {
|
||||
electricNode.addEnergy(15 * multiplier, true)
|
||||
electricNode.addEnergy(ForgeDirection.UNKNOWN, 15 * multiplier, true)
|
||||
if (({
|
||||
usingTicks += 1; usingTicks
|
||||
}) >= MAX_USE_TICKS) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import resonant.lib.network.discriminator.PacketType;
|
|||
import resonant.lib.network.handle.IPacketReceiver;
|
||||
import resonant.lib.utility.WrenchUtility;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.grid.fluid.pressure.FluidPressureNode;
|
||||
import resonantinduction.core.interfaces.IMechanicalNode;
|
||||
import resonantinduction.core.prefab.part.PartFace;
|
||||
import resonantinduction.electrical.Electrical;
|
||||
|
|
|
@ -17,9 +17,6 @@ class ElectricTransformerNode(parent: INodeProvider) extends NodeElectric(parent
|
|||
var otherNode : ElectricTransformerNode = null
|
||||
var step : Int = 2
|
||||
|
||||
//Default constructor
|
||||
setResistance(0)
|
||||
|
||||
def this(parent: INodeProvider, side: ForgeDirection, in : Boolean) =
|
||||
{
|
||||
this(parent)
|
||||
|
@ -27,13 +24,13 @@ class ElectricTransformerNode(parent: INodeProvider) extends NodeElectric(parent
|
|||
input = in
|
||||
}
|
||||
|
||||
override def getVoltage: Double =
|
||||
def getVoltage: Double =
|
||||
{
|
||||
if(!input)
|
||||
{
|
||||
return otherNode.getVoltage * step
|
||||
}
|
||||
return voltage
|
||||
return 120
|
||||
}
|
||||
|
||||
override def canConnect(from: ForgeDirection, source: AnyRef): Boolean =
|
||||
|
@ -41,7 +38,7 @@ class ElectricTransformerNode(parent: INodeProvider) extends NodeElectric(parent
|
|||
return source.isInstanceOf[INodeProvider] && from == connectionDirection
|
||||
}
|
||||
|
||||
override def addEnergy(wattage: Double, doAdd: Boolean): Double =
|
||||
override def addEnergy(dir: ForgeDirection, wattage: Double, doAdd: Boolean): Double =
|
||||
{
|
||||
if(input)
|
||||
{
|
||||
|
@ -61,7 +58,7 @@ class ElectricTransformerNode(parent: INodeProvider) extends NodeElectric(parent
|
|||
}
|
||||
|
||||
|
||||
override def removeEnergy(wattage: Double, doRemove: Boolean) : Double =
|
||||
override def removeEnergy(dir: ForgeDirection, wattage: Double, doRemove: Boolean) : Double =
|
||||
{
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class MultipartMechanical implements IPartFactory
|
|||
MultiPartRegistry.registerParts(this, PART_TYPES);
|
||||
//MultipartGenerator.registerPassThroughInterface("resonantinduction.core.grid.fluid.IPressureNodeProvider");
|
||||
// TODO: Move to UE
|
||||
MultipartGenerator.registerTrait("resonant.api.grid.INodeProvider", "resonantinduction.core.grid.TraitNodeProvider");
|
||||
MultipartGenerator.registerTrait("resonant.api.grid.INodeProvider", "resonantinduction.core.prefab.TraitNodeProvider");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -218,7 +218,17 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
prev_angle = renderAngle;
|
||||
}
|
||||
|
||||
protected void onUpdate()
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void onUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -331,7 +341,7 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
getConnections().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void recache()
|
||||
{
|
||||
synchronized (this)
|
||||
|
|
|
@ -52,9 +52,6 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial> implements TSlott
|
|||
public void setMaterial(EnumPipeMaterial material)
|
||||
{
|
||||
super.setMaterial(material);
|
||||
((PipePressureNode)getNode()).setMaxFlowRate(getMaterial().maxFlowRate);
|
||||
((PipePressureNode)getNode()).setMaxPressure(getMaterial().maxPressure);
|
||||
tank.setCapacity(((PipePressureNode)getNode()).maxFlowRate());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -198,8 +195,6 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial> implements TSlott
|
|||
{
|
||||
super.load(nbt);
|
||||
tank.readFromNBT(nbt);
|
||||
((PipePressureNode)getNode()).setMaxFlowRate(getMaterial().maxFlowRate);
|
||||
((PipePressureNode)getNode()).setMaxPressure(getMaterial().maxPressure);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonant.lib.utility.WorldUtility;
|
||||
import resonantinduction.core.grid.fluid.pressure.FluidPressureNode;
|
||||
import resonantinduction.core.prefab.node.NodePressure;
|
||||
import resonantinduction.core.prefab.part.PartColorableMaterial;
|
||||
import universalelectricity.api.core.grid.INode;
|
||||
import universalelectricity.api.core.grid.INodeProvider;
|
||||
|
@ -12,7 +12,7 @@ import universalelectricity.api.core.grid.INodeProvider;
|
|||
/** Pressure node for the pipe
|
||||
*
|
||||
* @author Calclavia, Darkguardsman */
|
||||
public class PipePressureNode extends FluidPressureNode
|
||||
public class PipePressureNode extends NodePressure
|
||||
{
|
||||
public PipePressureNode(PartPipe parent)
|
||||
{
|
||||
|
@ -24,10 +24,10 @@ public class PipePressureNode extends FluidPressureNode
|
|||
return (PartPipe) this.getParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void doRecache()
|
||||
{
|
||||
connections().clear();
|
||||
connections.clear();
|
||||
|
||||
if (world() != null)
|
||||
{
|
||||
|
@ -46,23 +46,23 @@ public class PipePressureNode extends FluidPressureNode
|
|||
INode check = null;
|
||||
try
|
||||
{
|
||||
check = ((INodeProvider) tile).getNode(FluidPressureNode.class, dir.getOpposite());
|
||||
check = ((INodeProvider) tile).getNode(NodePressure.class, dir.getOpposite());
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
check = null;
|
||||
}
|
||||
|
||||
if (check != null && check instanceof FluidPressureNode && canConnect(dir, check) && ((FluidPressureNode) check).canConnect(dir.getOpposite(), this))
|
||||
if (check != null && check instanceof NodePressure && canConnect(dir, check) && ((NodePressure) check).canConnect(dir.getOpposite(), this))
|
||||
{
|
||||
pipe().currentConnections_$eq(WorldUtility.setEnableSide(pipe().currentConnections(), dir, true));
|
||||
connections().put((resonantinduction.core.grid.fluid.distribution.TankNode) check, dir);
|
||||
connections.put(check, dir);
|
||||
}
|
||||
}
|
||||
else if (canConnect(dir, tile))
|
||||
{
|
||||
pipe().currentConnections_$eq(WorldUtility.setEnableSide(pipe().currentConnections(), dir, true));
|
||||
connections().put((IFluidHandler) tile, dir);
|
||||
connections.put(tile, dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,9 +80,9 @@ public class PipePressureNode extends FluidPressureNode
|
|||
{
|
||||
if (!pipe().isBlockedOnSide(from))
|
||||
{
|
||||
if (source instanceof FluidPressureNode)
|
||||
if (source instanceof NodePressure)
|
||||
{
|
||||
FluidPressureNode otherNode = (FluidPressureNode) source;
|
||||
NodePressure otherNode = (NodePressure) source;
|
||||
|
||||
if (otherNode.getParent() instanceof PartPipe)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package resonantinduction.mechanical.fluid.transport;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import resonantinduction.core.prefab.node.NodePressure;
|
||||
import resonantinduction.mechanical.energy.grid.TileMechanical;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -9,13 +10,12 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonant.api.IRotatable;
|
||||
import resonantinduction.core.grid.fluid.pressure.FluidPressureNode;
|
||||
import universalelectricity.api.core.grid.INode;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
|
||||
public class TilePump extends TileMechanical implements IRotatable, IFluidHandler
|
||||
{
|
||||
private final FluidPressureNode pressureNode;
|
||||
private final NodePressure pressureNode;
|
||||
|
||||
public TilePump()
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ public class TilePump extends TileMechanical implements IRotatable, IFluidHandle
|
|||
isOpaqueCube(false);
|
||||
customItemRender(true);
|
||||
setTextureName("material_steel");
|
||||
pressureNode = new FluidPressureNode(this)
|
||||
pressureNode = new NodePressure(this)
|
||||
{
|
||||
@Override
|
||||
public int getPressure(ForgeDirection dir)
|
||||
|
@ -45,12 +45,6 @@ public class TilePump extends TileMechanical implements IRotatable, IFluidHandle
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate()
|
||||
{
|
||||
return (int) Math.abs(mechanicalNode.getAngularSpeed() * 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection from, Object source)
|
||||
{
|
||||
|
@ -88,7 +82,7 @@ public class TilePump extends TileMechanical implements IRotatable, IFluidHandle
|
|||
|
||||
if (tileIn instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack drain = ((IFluidHandler) tileIn).drain(getDirection(), pressureNode.getMaxFlowRate(), false);
|
||||
FluidStack drain = ((IFluidHandler) tileIn).drain(getDirection(), pressureNode.maxOutput(), false);
|
||||
|
||||
if (drain != null)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue