Rewrote tank distribution network
This commit is contained in:
parent
6dcdd50437
commit
a353e01840
34 changed files with 805 additions and 1054 deletions
|
@ -12,7 +12,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.prefab.fluid.BlockFluidNetwork;
|
||||
import resonantinduction.core.fluid.BlockFluidNetwork;
|
||||
import resonantinduction.core.render.RIBlockRenderingHandler;
|
||||
import universalelectricity.api.UniversalElectricity;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
@ -112,7 +112,7 @@ public class BlockGutter extends BlockFluidNetwork
|
|||
|
||||
if (checkTile instanceof TileGutter)
|
||||
{
|
||||
int deltaPressure =pressure- ((TileGutter) checkTile).getPressure(null) ;
|
||||
int deltaPressure = pressure - ((TileGutter) checkTile).getPressure(null);
|
||||
|
||||
entity.motionX += 0.01 * dir.offsetX * deltaPressure;
|
||||
entity.motionY += 0.01 * dir.offsetY * deltaPressure;
|
||||
|
|
|
@ -8,13 +8,17 @@ import net.minecraftforge.client.model.AdvancedModelLoader;
|
|||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.archaic.fluid.tank.TileTank;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.render.RenderFluidHelper;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.render.FluidRenderUtility;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import calclavia.lib.render.item.ISimpleItemRenderer;
|
||||
import calclavia.lib.utility.FluidUtility;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -77,27 +81,19 @@ public class RenderGutter extends TileEntitySpecialRenderer implements ISimpleIt
|
|||
|
||||
render(0, renderSides);
|
||||
|
||||
if (liquid != null && liquid.amount > 0)
|
||||
if (tileEntity.worldObj != null)
|
||||
{
|
||||
float percentage = Math.min((float) liquid.amount / (float) capacity, 1);
|
||||
int[] displayList = RenderFluidHelper.getFluidDisplayLists(liquid, tile.worldObj, false);
|
||||
bindTexture(RenderFluidHelper.getFluidSheet(liquid));
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glScaled(0.99, 0.99, 0.99);
|
||||
FluidTank tank = ((TileGutter) tileEntity).getInternalTank();
|
||||
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
|
||||
|
||||
float xScale = WorldUtility.isEnabledSide(renderSides, ForgeDirection.EAST) || WorldUtility.isEnabledSide(renderSides, ForgeDirection.WEST) ? 1.01f : 0.8f;
|
||||
float zScale = WorldUtility.isEnabledSide(renderSides, ForgeDirection.NORTH) || WorldUtility.isEnabledSide(renderSides, ForgeDirection.SOUTH) ? 1.01f : 0.8f;
|
||||
GL11.glTranslatef(-xScale / 2, -0.45f, -zScale / 2);
|
||||
GL11.glScalef(xScale, 0.9f, zScale);
|
||||
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
|
||||
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
|
||||
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.WEST);
|
||||
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.WEST);
|
||||
|
||||
GL11.glCallList(displayList[(int) (percentage * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,35 +1,29 @@
|
|||
package resonantinduction.archaic.fluid.gutter;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidNetwork;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidPipe;
|
||||
import resonantinduction.core.prefab.fluid.PipeNetwork;
|
||||
import resonantinduction.core.prefab.fluid.TileFluidNetwork;
|
||||
import resonantinduction.core.fluid.IPressurizedNode;
|
||||
import resonantinduction.core.fluid.TilePressurizedNode;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
|
||||
/** @author Darkguardsman */
|
||||
public class TileGutter extends TileFluidNetwork implements IFluidPipe
|
||||
/**
|
||||
* The gutter, used for fluid transfer.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
||||
{
|
||||
public TileGutter()
|
||||
{
|
||||
getInternalTank().setCapacity(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
//TODO: Packet before doing.
|
||||
|
||||
// TODO: Packet before doing.
|
||||
if (!this.worldObj.isRemote)
|
||||
sendTankUpdate();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,55 +34,17 @@ public class TileGutter extends TileFluidNetwork implements IFluidPipe
|
|||
if (tileEntity instanceof TileGutter)
|
||||
{
|
||||
getNetwork().merge(((TileGutter) tileEntity).getNetwork());
|
||||
setRenderSide(side, true);
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
else if (tileEntity instanceof IFluidHandler)
|
||||
{
|
||||
setRenderSide(side, true);
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFlow()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null)
|
||||
{
|
||||
this.network = new PipeNetwork();
|
||||
this.network.addConnector(this);
|
||||
}
|
||||
|
||||
return this.network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(IFluidNetwork network)
|
||||
{
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
tank.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
tank.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPressure(ForgeDirection dir)
|
||||
{
|
||||
|
@ -100,47 +56,12 @@ public class TileGutter extends TileFluidNetwork implements IFluidPipe
|
|||
return pressure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPressure(int amount)
|
||||
{
|
||||
pressure = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (!resource.getFluid().isGaseous())
|
||||
{
|
||||
int fill = getInternalTank().fill(resource, doFill);
|
||||
onFluidChanged();
|
||||
return fill;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
FluidStack drain = getInternalTank().drain(resource.amount, doDrain);
|
||||
onFluidChanged();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
FluidStack drain = getInternalTank().drain(maxDrain, doDrain);
|
||||
onFluidChanged();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
|
@ -152,10 +73,4 @@ public class TileGutter extends TileFluidNetwork implements IFluidPipe
|
|||
{
|
||||
return from != ForgeDirection.UP && !fluid.isGaseous();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] { getInternalTank().getInfo() };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.prefab.fluid.BlockFluidNetwork;
|
||||
import resonantinduction.core.fluid.BlockFluidNetwork;
|
||||
import resonantinduction.core.render.RIBlockRenderingHandler;
|
||||
import resonantinduction.mechanical.fluid.pipe.ItemBlockFluidContainer;
|
||||
import universalelectricity.api.UniversalElectricity;
|
|
@ -0,0 +1,109 @@
|
|||
package resonantinduction.archaic.fluid.tank;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.archaic.Archaic;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.render.FluidRenderUtility;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import calclavia.lib.render.item.ISimpleItemRenderer;
|
||||
import calclavia.lib.utility.FluidUtility;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderTank extends TileEntitySpecialRenderer implements ISimpleItemRenderer
|
||||
{
|
||||
public static final RenderTank INSTANCE = new RenderTank();
|
||||
private final TileTank tileTank = new TileTank();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
this.renderTank(tileEntity, x, y, z, tileEntity instanceof TileTank ? ((TileTank) tileEntity).getInternalTank().getFluid() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryItem(ItemStack itemStack)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, -0.1, 0);
|
||||
|
||||
FluidStack fluid = null;
|
||||
|
||||
if (itemStack.getTagCompound() != null && itemStack.getTagCompound().hasKey("fluid"))
|
||||
{
|
||||
fluid = FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluid"));
|
||||
}
|
||||
|
||||
renderTank(tileTank, 0, 0, 0, fluid);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
public void renderTank(TileEntity tileEntity, double x, double y, double z, FluidStack fluid)
|
||||
{
|
||||
if (tileEntity instanceof TileTank)
|
||||
{
|
||||
byte renderSides = ((TileTank) tileEntity).renderSides;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
RenderUtility.renderBlockWithConnectedTextures(renderSides, Archaic.blockTank, null, ResonantInduction.blockMachinePart, null);
|
||||
|
||||
if (tileEntity.worldObj != null)
|
||||
{
|
||||
GL11.glScaled(0.99, 0.99, 0.99);
|
||||
FluidTank tank = ((TileTank) tileEntity).getInternalTank();
|
||||
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
|
||||
|
||||
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
|
||||
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
|
||||
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.WEST);
|
||||
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.WEST);
|
||||
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fluid != null)
|
||||
{
|
||||
int capacity = tileEntity instanceof TileTank ? ((TileTank) tileEntity).getInternalTank().getCapacity() : fluid.amount;
|
||||
double filledPercentage = (double) fluid.amount / (double) capacity;
|
||||
double renderPercentage = fluid.getFluid().isGaseous() ? 1 : filledPercentage;
|
||||
int[] displayList = FluidRenderUtility.getFluidDisplayLists(fluid, tileEntity.worldObj, false);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
Color color = new Color(fluid.getFluid().getColor());
|
||||
RenderUtility.enableBlending();
|
||||
GL11.glColor4d(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, fluid.getFluid().isGaseous() ? filledPercentage : 1);
|
||||
|
||||
RenderUtility.bind(FluidRenderUtility.getFluidSheet(fluid));
|
||||
// Prevent Z-fighting
|
||||
GL11.glTranslatef((float) x, (float) y + 0.001f, (float) z);
|
||||
GL11.glCallList(displayList[(int) (renderPercentage * (FluidRenderUtility.DISPLAY_STAGES - 1))]);
|
||||
RenderUtility.disableBlending();
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package resonantinduction.archaic.fluid.tank;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import resonantinduction.core.fluid.FluidDistributionetwork;
|
||||
import resonantinduction.core.fluid.IFluidDistribution;
|
||||
import calclavia.lib.utility.FluidUtility;
|
||||
|
||||
/**
|
||||
* Network that handles connected tanks
|
||||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public class TankNetwork extends FluidDistributionetwork
|
||||
{
|
||||
public TankNetwork()
|
||||
{
|
||||
super();
|
||||
animateDistribution = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
// if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||
// distributeConnectors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distributeConnectors()
|
||||
{
|
||||
int animateRate = 0;
|
||||
|
||||
FluidStack totalFluid = getTank().getFluid();
|
||||
int lowestY = 255, highestY = 0;
|
||||
|
||||
if (totalFluid == null || totalFluid.getFluid().isGaseous())
|
||||
{
|
||||
super.distributeConnectors();
|
||||
}
|
||||
else if (getConnectors().size() > 0)
|
||||
{
|
||||
FluidStack distributeFluid = totalFluid.copy();
|
||||
HashMap<Integer, Integer> heightCount = new HashMap<Integer, Integer>();
|
||||
PriorityQueue<IFluidDistribution> heightPriorityQueue = new PriorityQueue<IFluidDistribution>(1024, new Comparator()
|
||||
{
|
||||
@Override
|
||||
public int compare(Object a, Object b)
|
||||
{
|
||||
TileEntity wa = (TileEntity) a;
|
||||
TileEntity wb = (TileEntity) b;
|
||||
return wa.yCoord - wb.yCoord;
|
||||
}
|
||||
});
|
||||
|
||||
for (IFluidDistribution connector : this.getConnectors())
|
||||
{
|
||||
if (connector instanceof TileEntity)
|
||||
{
|
||||
int yCoord = ((TileEntity) connector).yCoord;
|
||||
|
||||
if (yCoord < lowestY)
|
||||
{
|
||||
lowestY = yCoord;
|
||||
}
|
||||
|
||||
if (yCoord > highestY)
|
||||
{
|
||||
highestY = yCoord;
|
||||
}
|
||||
|
||||
heightPriorityQueue.add(connector);
|
||||
heightCount.put(yCoord, heightCount.containsKey(yCoord) ? heightCount.get(yCoord) + 1 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
boolean didChange = false;
|
||||
//System.out.println("TANK UPDATE " + distributeFluid.amount);
|
||||
while (!heightPriorityQueue.isEmpty())
|
||||
{
|
||||
IFluidDistribution distributeNode = heightPriorityQueue.poll();
|
||||
int yCoord = ((TileEntity) distributeNode).yCoord;
|
||||
int connectorCount = heightCount.get(yCoord);
|
||||
|
||||
if (distributeFluid == null || distributeFluid.amount <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
int fluidPer = (distributeFluid.amount / connectorCount) + (distributeFluid.amount % connectorCount);
|
||||
int deltaFluidAmount = (fluidPer - distributeNode.getInternalTank().getFluidAmount()) / 10;
|
||||
|
||||
distributeNode.getInternalTank().setFluid(FluidUtility.getStack(distributeFluid, fluidPer));
|
||||
|
||||
/*
|
||||
* System.out.println(connectorCount + " : " + fluidPer);
|
||||
|
||||
if (deltaFluidAmount > 0)
|
||||
{
|
||||
distributeNode.getInternalTank().fill(FluidUtility.getStack(distributeFluid, deltaFluidAmount), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: This causes quite a lot of issues.
|
||||
FluidStack drained = distributeNode.getInternalTank().drain(Math.abs(deltaFluidAmount), true);
|
||||
}*/
|
||||
|
||||
distributeFluid.amount -= distributeNode.getInternalTank().getFluidAmount();
|
||||
|
||||
if (deltaFluidAmount != 0)
|
||||
didChange = true;
|
||||
|
||||
if (connectorCount > 1)
|
||||
connectorCount--;
|
||||
|
||||
heightCount.put(yCoord, connectorCount);
|
||||
distributeNode.onFluidChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankNetwork newInstance()
|
||||
{
|
||||
return new TankNetwork();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package resonantinduction.archaic.fluid.tank;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import resonantinduction.api.mechanical.fluid.IPressure;
|
||||
import resonantinduction.core.fluid.FluidDistributionetwork;
|
||||
import resonantinduction.core.fluid.IFluidDistribution;
|
||||
import resonantinduction.core.fluid.TileFluidDistribution;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
|
||||
public class TileTank extends TileFluidDistribution implements IPressure
|
||||
{
|
||||
public static final int VOLUME = 16;
|
||||
|
||||
public TileTank()
|
||||
{
|
||||
this.getInternalTank().setCapacity(VOLUME * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
getNetwork().distributeConnectors();
|
||||
sendTankUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidDistributionetwork getNetwork()
|
||||
{
|
||||
if (this.network == null)
|
||||
{
|
||||
this.network = new TankNetwork();
|
||||
this.network.addConnector(this);
|
||||
}
|
||||
return this.network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(FluidDistributionetwork network)
|
||||
{
|
||||
if (network instanceof TankNetwork)
|
||||
{
|
||||
this.network = network;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (tileEntity instanceof TileTank)
|
||||
{
|
||||
getNetwork().merge(((IFluidDistribution) tileEntity).getNetwork());
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPressure(int amount)
|
||||
{
|
||||
pressure = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPressure(ForgeDirection dir)
|
||||
{
|
||||
return (getInternalTank().getCapacity() - getInternalTank().getFluidAmount()) / 10;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package resonantinduction.archaic.fluid.tank;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.archaic.Archaic;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.render.RenderFluidHelper;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import calclavia.lib.render.item.ISimpleItemRenderer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderTank extends TileEntitySpecialRenderer implements ISimpleItemRenderer
|
||||
{
|
||||
public static final RenderTank INSTANCE = new RenderTank();
|
||||
private final TileTank tileTank = new TileTank();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
this.renderTank(tileEntity, x, y, z, tileEntity instanceof TileTank ? ((TileTank) tileEntity).getInternalTank().getFluid() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryItem(ItemStack itemStack)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, -0.1, 0);
|
||||
|
||||
FluidStack fluid = null;
|
||||
|
||||
if (itemStack.getTagCompound() != null && itemStack.getTagCompound().hasKey("fluid"))
|
||||
{
|
||||
fluid = FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluid"));
|
||||
}
|
||||
|
||||
renderTank(tileTank, 0, 0, 0, fluid);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
public void renderTank(TileEntity tileEntity, double x, double y, double z, FluidStack fluid)
|
||||
{
|
||||
if (tileEntity instanceof TileTank)
|
||||
{
|
||||
byte renderSides = ((TileTank) tileEntity).renderSides;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
RenderUtility.renderBlockWithConnectedTextures(renderSides, Archaic.blockTank, null, ResonantInduction.blockMachinePart, null);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (fluid != null)
|
||||
{
|
||||
int capacity = tileEntity instanceof TileTank ? ((TileTank) tileEntity).getInternalTank().getCapacity() : fluid.amount;
|
||||
double filledPercentage = (double) fluid.amount / (double) capacity;
|
||||
double renderPercentage = fluid.getFluid().isGaseous() ? 1 : filledPercentage;
|
||||
int[] displayList = RenderFluidHelper.getFluidDisplayLists(fluid, tileEntity.worldObj, false);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
Color color = new Color(fluid.getFluid().getColor());
|
||||
RenderUtility.enableBlending();
|
||||
GL11.glColor4d(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, fluid.getFluid().isGaseous() ? filledPercentage : 1);
|
||||
|
||||
RenderUtility.bind(RenderFluidHelper.getFluidSheet(fluid));
|
||||
// Prevent Z-fighting
|
||||
GL11.glTranslatef((float) x, (float) y + 0.001f, (float) z);
|
||||
GL11.glCallList(displayList[(int) (renderPercentage * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
||||
RenderUtility.disableBlending();
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package resonantinduction.archaic.fluid.tank;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidConnector;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidNetwork;
|
||||
import resonantinduction.core.prefab.fluid.FluidNetwork;
|
||||
|
||||
/**
|
||||
* Network that handles connected tanks
|
||||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public class TankNetwork extends FluidNetwork
|
||||
{
|
||||
@Override
|
||||
public void distributeConnectors()
|
||||
{
|
||||
FluidStack fillStack = this.getTank().getFluid();
|
||||
int lowestY = 255, highestY = 0;
|
||||
|
||||
if (fillStack == null || fillStack.getFluid().isGaseous())
|
||||
{
|
||||
super.distributeConnectors();
|
||||
}
|
||||
else if (this.getConnectors().size() > 0)
|
||||
{
|
||||
fillStack = fillStack.copy();
|
||||
|
||||
for (IFluidConnector connector : this.getConnectors())
|
||||
{
|
||||
connector.getInternalTank().setFluid(null);
|
||||
connector.onFluidChanged();
|
||||
|
||||
if (connector instanceof TileEntity && ((TileEntity) connector).yCoord < lowestY)
|
||||
{
|
||||
lowestY = ((TileEntity) connector).yCoord;
|
||||
}
|
||||
if (connector instanceof TileEntity && ((TileEntity) connector).yCoord > highestY)
|
||||
{
|
||||
highestY = ((TileEntity) connector).yCoord;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Add path finder to prevent filling when tanks are only connected at the top
|
||||
for (int y = lowestY; y <= highestY; y++)
|
||||
{
|
||||
Set<IFluidConnector> parts = new LinkedHashSet<IFluidConnector>();
|
||||
|
||||
for (IFluidConnector part : this.getConnectors())
|
||||
{
|
||||
if (part instanceof IFluidConnector && ((TileEntity) part).yCoord == y)
|
||||
{
|
||||
parts.add(part);
|
||||
}
|
||||
}
|
||||
if (!parts.isEmpty())
|
||||
{
|
||||
this.fillTankSet(fillStack, parts);
|
||||
}
|
||||
|
||||
if (fillStack == null || fillStack.amount <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidNetwork newInstance()
|
||||
{
|
||||
return new TankNetwork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package resonantinduction.archaic.fluid.tank;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidConnector;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidNetwork;
|
||||
import resonantinduction.core.prefab.fluid.TileFluidNetwork;
|
||||
|
||||
public class TileTank extends TileFluidNetwork
|
||||
{
|
||||
public static final int VOLUME = 16;
|
||||
|
||||
public TileTank()
|
||||
{
|
||||
this.getInternalTank().setCapacity(VOLUME * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null)
|
||||
{
|
||||
this.network = new TankNetwork();
|
||||
this.network.addConnector(this);
|
||||
}
|
||||
return this.network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(IFluidNetwork network)
|
||||
{
|
||||
if (network instanceof TankNetwork)
|
||||
{
|
||||
this.network = network;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (tileEntity instanceof TileTank)
|
||||
{
|
||||
getNetwork().merge(((IFluidConnector) tileEntity).getNetwork());
|
||||
this.setRenderSide(side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFlow()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@ public class MultipartMechanical implements IPartFactory
|
|||
public MultipartMechanical()
|
||||
{
|
||||
MultiPartRegistry.registerParts(this, PART_TYPES);
|
||||
MultipartGenerator.registerPassThroughInterface("resonantinduction.api.mechanical.fluid.IFluidPipe");
|
||||
MultipartGenerator.registerPassThroughInterface("resonantinduction.core.fluid.IPressurizedNode");
|
||||
MultipartGenerator.registerPassThroughInterface("resonantinduction.api.mechanical.fluid.IPressure");
|
||||
MultipartGenerator.registerTrait("resonantinduction.api.mechanical.IMechanical", "resonantinduction.mechanical.trait.TraitMechanical");
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import resonantinduction.core.prefab.fluid.TileFluidNetwork;
|
||||
import resonantinduction.core.fluid.TileFluidDistribution;
|
||||
|
||||
/**
|
||||
* Enum to hold info about each pipe material. Values are by default and some can change with pipe
|
||||
|
@ -114,9 +114,9 @@ public enum EnumPipeMaterial
|
|||
int meta = world.getBlockMetadata(x, y, z);
|
||||
TileEntity ent = world.getBlockTileEntity(x, y, z);
|
||||
meta *= spacing;
|
||||
if (ent instanceof TileFluidNetwork)
|
||||
if (ent instanceof TileFluidDistribution)
|
||||
{
|
||||
meta += ((TileFluidNetwork) ent).getSubID();
|
||||
meta += ((TileFluidDistribution) ent).getSubID();
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
import resonantinduction.archaic.Archaic;
|
||||
import resonantinduction.archaic.fluid.tank.TileTank;
|
||||
import resonantinduction.core.prefab.fluid.TileFluidNetwork;
|
||||
import resonantinduction.core.fluid.TileFluidDistribution;
|
||||
import universalelectricity.api.energy.UnitDisplay;
|
||||
import universalelectricity.api.energy.UnitDisplay.Unit;
|
||||
import universalelectricity.api.energy.UnitDisplay.UnitPrefix;
|
||||
|
@ -122,12 +122,12 @@ public class ItemBlockFluidContainer extends ItemBlock
|
|||
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, (metadata / EnumPipeMaterial.spacing)))
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileFluidNetwork)
|
||||
if (tile instanceof TileFluidDistribution)
|
||||
{
|
||||
((TileFluidNetwork) tile).setSubID(stack.getItemDamage());
|
||||
((TileFluidDistribution) tile).setSubID(stack.getItemDamage());
|
||||
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
|
||||
{
|
||||
((TileFluidNetwork) tile).fill(ForgeDirection.UNKNOWN, FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("fluid")), true);
|
||||
((TileFluidDistribution) tile).fill(ForgeDirection.UNKNOWN, FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("fluid")), true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -11,10 +11,9 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidNetwork;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidPipe;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.prefab.fluid.PipeNetwork;
|
||||
import resonantinduction.core.fluid.IPressurizedNode;
|
||||
import resonantinduction.core.fluid.PressureNetwork;
|
||||
import resonantinduction.core.prefab.part.PartFramedConnection;
|
||||
import resonantinduction.mechanical.Mechanical;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
|
@ -29,7 +28,7 @@ import codechicken.multipart.TileMultipart;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe, IFluidNetwork> implements IFluidPipe, TSlottedPart, JNormalOcclusion, IHollowConnect
|
||||
public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IPressurizedNode, PressureNetwork> implements IPressurizedNode, TSlottedPart, JNormalOcclusion, IHollowConnect
|
||||
{
|
||||
protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
private int pressure;
|
||||
|
@ -107,11 +106,11 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe,
|
|||
|
||||
/** Fluid network methods. */
|
||||
@Override
|
||||
public IFluidNetwork getNetwork()
|
||||
public PressureNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null)
|
||||
{
|
||||
this.network = new PipeNetwork();
|
||||
this.network = new PressureNetwork();
|
||||
this.network.addConnector(this);
|
||||
}
|
||||
|
||||
|
@ -216,11 +215,11 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe,
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IFluidPipe getConnector(TileEntity tile)
|
||||
protected IPressurizedNode getConnector(TileEntity tile)
|
||||
{
|
||||
if (tile instanceof IFluidPipe)
|
||||
if (((IFluidPipe) tile).getInstance(ForgeDirection.UNKNOWN) instanceof IFluidPipe)
|
||||
return (IFluidPipe) ((IFluidPipe) tile).getInstance(ForgeDirection.UNKNOWN);
|
||||
if (tile instanceof IPressurizedNode)
|
||||
if (((IPressurizedNode) tile).getInstance(ForgeDirection.UNKNOWN) instanceof IPressurizedNode)
|
||||
return (IPressurizedNode) ((IPressurizedNode) tile).getInstance(ForgeDirection.UNKNOWN);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.lwjgl.opengl.GL11;
|
|||
import codechicken.lib.colour.Colour;
|
||||
import codechicken.lib.colour.ColourARGB;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.render.RenderFluidHelper;
|
||||
import calclavia.lib.render.FluidRenderUtility;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import calclavia.lib.render.item.ISimpleItemRenderer;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
|
@ -56,8 +56,8 @@ public class RenderPipe implements ISimpleItemRenderer
|
|||
if (fluid != null && fluid.amount > 0)
|
||||
{
|
||||
float percentage = (float) fluid.amount / (float) capacity;
|
||||
int[] displayList = RenderFluidHelper.getFluidDisplayLists(fluid, part.world(), false);
|
||||
RenderUtility.bind(RenderFluidHelper.getFluidSheet(fluid));
|
||||
int[] displayList = FluidRenderUtility.getFluidDisplayLists(fluid, part.world(), false);
|
||||
RenderUtility.bind(FluidRenderUtility.getFluidSheet(fluid));
|
||||
Color color = new Color(fluid.getFluid().getColor());
|
||||
GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, fluid.getFluid().isGaseous() ? 0.5f : 1);
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class RenderPipe implements ISimpleItemRenderer
|
|||
GL11.glTranslatef((float) x + 0.35f, (float) y + 0.35f, (float) z + 0.35f);
|
||||
GL11.glScalef(0.3f, 0.3f, 0.3f);
|
||||
|
||||
GL11.glCallList(displayList[(int) (percentage * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
||||
GL11.glCallList(displayList[(int) (percentage * (FluidRenderUtility.DISPLAY_STAGES - 1))]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
|
@ -110,7 +110,7 @@ public class RenderPipe implements ISimpleItemRenderer
|
|||
}
|
||||
|
||||
GL11.glScalef(0.3f, 0.3f, 0.3f);
|
||||
GL11.glCallList(displayList[(int) (percentage * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
||||
GL11.glCallList(displayList[(int) (percentage * (FluidRenderUtility.DISPLAY_STAGES - 1))]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
|
|
|
@ -6,8 +6,8 @@ import net.minecraftforge.fluids.Fluid;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidPipe;
|
||||
import resonantinduction.api.mechanical.fluid.IPressure;
|
||||
import resonantinduction.core.fluid.IPressurizedNode;
|
||||
import resonantinduction.mechanical.energy.network.TileMechanical;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.prefab.tile.IRotatable;
|
||||
|
@ -28,7 +28,7 @@ public class TilePump extends TileMechanical implements IFluidHandler, IRotatabl
|
|||
*/
|
||||
TileEntity tileIn = new Vector3(this).translate(getDirection().getOpposite()).getTileEntity(this.worldObj);
|
||||
|
||||
if (tileIn instanceof IFluidHandler && !(tileIn instanceof IFluidPipe))
|
||||
if (tileIn instanceof IFluidHandler && !(tileIn instanceof IPressurizedNode))
|
||||
{
|
||||
int flowRate = (int) (((double) getPower() / (double) maximumPower) * 500);
|
||||
FluidStack drain = ((IFluidHandler) tileIn).drain(getDirection(), flowRate, false);
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
package resonantinduction.api.mechanical.fluid;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import universalelectricity.api.net.INodeNetwork;
|
||||
|
||||
/**
|
||||
* Interface version of the fluid network.
|
||||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public interface IFluidNetwork extends INodeNetwork<IFluidNetwork, IFluidConnector, IFluidHandler>
|
||||
{
|
||||
/** Called to build the network when something changes such as addition of a pipe */
|
||||
@Override
|
||||
void reconstruct();
|
||||
|
||||
/**
|
||||
* Called to add fluid into the network
|
||||
*
|
||||
* @param source - part that is receiving the fluid for the network
|
||||
* @param from - direction of this connection
|
||||
* @param resource - fluid stack that is being filled into the network
|
||||
* @param doFill - true causes the action to be taken, false simulates the action
|
||||
* @return amount of fluid filled into the network
|
||||
*/
|
||||
int fill(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doFill);
|
||||
|
||||
/**
|
||||
* Called to remove fluid from a network, not supported by all networks
|
||||
*
|
||||
* @param source - part that is receiving the fluid for the network
|
||||
* @param from - direction of this connection
|
||||
* @param resource - fluid stack that is being filled into the network
|
||||
* @param doDrain - true causes the action to be taken, false simulates the action
|
||||
* @return FluidStack that contains the fluid drained from the network
|
||||
*/
|
||||
FluidStack drain(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doDrain);
|
||||
|
||||
/**
|
||||
* Called to remove fluid from a network, not supported by all networks
|
||||
*
|
||||
* @param source - part that is receiving the fluid for the network
|
||||
* @param from - direction of this connection
|
||||
* @param resource - fluid stack that is being filled into the network
|
||||
* @param doDrain - true causes the action to be taken, false simulates the action
|
||||
* @return FluidStack that contains the fluid drained from the network
|
||||
*/
|
||||
FluidStack drain(IFluidConnector source, ForgeDirection from, int resource, boolean doDrain);
|
||||
|
||||
/** Fluid tank that represents the entire network */
|
||||
FluidTank getTank();
|
||||
|
||||
/** Information about the network's tank */
|
||||
FluidTankInfo[] getTankInfo();
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package resonantinduction.api.mechanical.fluid;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Applied to tiles that work with pressure for there inputs
|
||||
*
|
||||
* @author DarkGaurdsman
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IPressureInput extends IPressure
|
||||
{
|
||||
public int getPressureIn(ForgeDirection side);
|
||||
|
||||
public void onWrongPressure(ForgeDirection side, int pressure);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package resonantinduction.api.mechanical.fluid;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Applied to tiles that are a source of pressure in a fluid network
|
||||
*
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IPressureOutput
|
||||
{
|
||||
public int getPressureOut(ForgeDirection side);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package resonantinduction.core.fluid;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import calclavia.lib.prefab.block.BlockTile;
|
||||
|
||||
/** @author Calclavia */
|
||||
public abstract class BlockFluidNetwork extends BlockTile
|
||||
{
|
||||
public BlockFluidNetwork(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileFluidDistribution)
|
||||
{
|
||||
((TileFluidDistribution) tile).refresh();
|
||||
((TileFluidDistribution) tile).getNetwork().reconstruct();
|
||||
}
|
||||
|
||||
if (tile instanceof TilePressurizedNode)
|
||||
{
|
||||
((TilePressurizedNode) tile).refresh();
|
||||
((TilePressurizedNode) tile).getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int par5)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileFluidDistribution)
|
||||
{
|
||||
((TileFluidDistribution) tile).refresh();
|
||||
((TileFluidDistribution) tile).getNetwork().reconstruct();
|
||||
}
|
||||
|
||||
if (tile instanceof TilePressurizedNode)
|
||||
{
|
||||
((TilePressurizedNode) tile).refresh();
|
||||
((TilePressurizedNode) tile).getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.core.prefab.fluid;
|
||||
package resonantinduction.core.fluid;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.core.prefab.fluid;
|
||||
package resonantinduction.core.fluid;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -7,34 +7,31 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidConnector;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidNetwork;
|
||||
import universalelectricity.api.net.IUpdate;
|
||||
import universalelectricity.core.net.NetworkTickHandler;
|
||||
import universalelectricity.core.net.NodeNetwork;
|
||||
import calclavia.lib.utility.FluidUtility;
|
||||
|
||||
/**
|
||||
* The fluid network.
|
||||
* The fluid network for instantaneous equal distribution between all nodes. Used for tanks.
|
||||
*
|
||||
* @author DarkCow, Calclavia
|
||||
*
|
||||
*/
|
||||
public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConnector, IFluidHandler> implements IFluidNetwork, IUpdate
|
||||
public abstract class FluidDistributionetwork extends NodeNetwork<FluidDistributionetwork, IFluidDistribution, IFluidHandler> implements IUpdate
|
||||
{
|
||||
protected FluidTank tank = new FluidTank(0);
|
||||
protected final FluidTankInfo[] tankInfo = new FluidTankInfo[1];
|
||||
|
||||
// TODO: Make animated distribution to create a smooth flow transition.
|
||||
public boolean animateDistribution = false;
|
||||
|
||||
public FluidNetwork()
|
||||
public FluidDistributionetwork()
|
||||
{
|
||||
super(IFluidConnector.class);
|
||||
super(IFluidDistribution.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConnector(IFluidConnector connector)
|
||||
public void addConnector(IFluidDistribution connector)
|
||||
{
|
||||
super.addConnector(connector);
|
||||
NetworkTickHandler.addNetwork(this);
|
||||
|
@ -64,9 +61,9 @@ public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConn
|
|||
}
|
||||
|
||||
@Override
|
||||
public void reconstructConnector(IFluidConnector connector)
|
||||
public void reconstructConnector(IFluidDistribution connector)
|
||||
{
|
||||
if (connector.getNetwork() instanceof IFluidNetwork)
|
||||
if (connector.getNetwork() instanceof FluidDistributionetwork)
|
||||
connector.setNetwork(this);
|
||||
|
||||
FluidTank tank = connector.getInternalTank();
|
||||
|
@ -104,8 +101,7 @@ public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConn
|
|||
NetworkTickHandler.addNetwork(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
public int fill(IFluidDistribution source, ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
int prev = this.getTank().getFluidAmount();
|
||||
int fill = this.getTank().fill(resource, doFill);
|
||||
|
@ -118,10 +114,9 @@ public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConn
|
|||
return fill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
public FluidStack drain(IFluidDistribution source, ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if (resource != null && resource.isFluidEqual(this.getTank().getFluid()))
|
||||
if (resource != null && resource.isFluidEqual(getTank().getFluid()))
|
||||
{
|
||||
FluidStack before = this.getTank().getFluid();
|
||||
FluidStack drain = this.getTank().drain(resource.amount, doDrain);
|
||||
|
@ -136,12 +131,11 @@ public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConn
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(IFluidConnector source, ForgeDirection from, int resource, boolean doDrain)
|
||||
public FluidStack drain(IFluidDistribution source, ForgeDirection from, int resource, boolean doDrain)
|
||||
{
|
||||
if (this.getTank().getFluid() != null)
|
||||
if (getTank().getFluid() != null)
|
||||
{
|
||||
return this.drain(source, from, FluidUtility.getStack(this.getTank().getFluid(), resource), doDrain);
|
||||
return this.drain(source, from, FluidUtility.getStack(getTank().getFluid(), resource), doDrain);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -152,26 +146,26 @@ public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConn
|
|||
this.fillTankSet(stack != null ? stack.copy() : null, this.getConnectors());
|
||||
}
|
||||
|
||||
public void fillTankSet(FluidStack stack, Set<IFluidConnector> connectors)
|
||||
public void fillTankSet(FluidStack stack, Set<IFluidDistribution> connectors)
|
||||
{
|
||||
int parts = connectors.size();
|
||||
for (IFluidConnector part : connectors)
|
||||
int connectorCount = connectors.size();
|
||||
|
||||
for (IFluidDistribution part : connectors)
|
||||
{
|
||||
part.getInternalTank().setFluid(null);
|
||||
if (stack != null)
|
||||
{
|
||||
int fillPer = (stack.amount / parts) + (stack.amount % parts);
|
||||
int fillPer = (stack.amount / connectorCount) + (stack.amount % connectorCount);
|
||||
stack.amount -= part.getInternalTank().fill(FluidUtility.getStack(stack, fillPer), true);
|
||||
|
||||
if (parts > 1)
|
||||
parts--;
|
||||
if (connectorCount > 1)
|
||||
connectorCount--;
|
||||
}
|
||||
|
||||
part.onFluidChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank getTank()
|
||||
{
|
||||
if (this.tank == null)
|
||||
|
@ -181,13 +175,11 @@ public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConn
|
|||
return this.tank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getConnectorClass()
|
||||
{
|
||||
return IFluidConnector.class;
|
||||
return IFluidDistribution.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo()
|
||||
{
|
||||
return tankInfo;
|
||||
|
@ -196,6 +188,6 @@ public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConn
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() + " Vol:" + this.tank.getFluidAmount();
|
||||
return super.toString() + " Volume: " + this.tank.getFluidAmount();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.api.mechanical.fluid;
|
||||
package resonantinduction.core.fluid;
|
||||
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
@ -10,12 +10,10 @@ import universalelectricity.api.net.IConnector;
|
|||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public interface IFluidConnector extends IConnector<IFluidNetwork>, IFluidHandler
|
||||
public interface IFluidDistribution extends IConnector<FluidDistributionetwork>, IFluidHandler
|
||||
{
|
||||
/** FluidTank that the network will have access to fill or drain */
|
||||
public FluidTank getInternalTank();
|
||||
|
||||
public void onFluidChanged();
|
||||
|
||||
public boolean canFlow();
|
||||
}
|
|
@ -1,13 +1,16 @@
|
|||
package resonantinduction.api.mechanical.fluid;
|
||||
package resonantinduction.core.fluid;
|
||||
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.api.mechanical.fluid.IPressure;
|
||||
import universalelectricity.api.net.IConnector;
|
||||
|
||||
/**
|
||||
* Applied to tiles that are pipes and support pressure
|
||||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public interface IFluidPipe extends IFluidConnector, IPressure
|
||||
public interface IPressurizedNode extends IConnector<PressureNetwork>, IFluidHandler, IPressure
|
||||
{
|
||||
public FluidTank getInternalTank();
|
||||
|
|
@ -1,35 +1,35 @@
|
|||
package resonantinduction.core.prefab.fluid;
|
||||
package resonantinduction.core.fluid;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidConnector;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidNetwork;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidPipe;
|
||||
import resonantinduction.api.mechanical.fluid.IPressure;
|
||||
import resonantinduction.archaic.fluid.gutter.TileGutter;
|
||||
import universalelectricity.api.net.IUpdate;
|
||||
import universalelectricity.core.net.NetworkTickHandler;
|
||||
import universalelectricity.core.net.NodeNetwork;
|
||||
|
||||
/**
|
||||
* The network for pipe fluid transfer. getNodes() is NOT used.
|
||||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public class PipeNetwork extends FluidNetwork
|
||||
public class PressureNetwork extends NodeNetwork<PressureNetwork, IPressurizedNode, IFluidHandler> implements IUpdate
|
||||
{
|
||||
public PressureNetwork()
|
||||
{
|
||||
super(IPressurizedNode.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
for (IFluidConnector connector : getConnectors())
|
||||
for (IPressurizedNode connector : getConnectors())
|
||||
{
|
||||
if (connector instanceof IFluidPipe)
|
||||
{
|
||||
calculatePressure((IFluidPipe) connector);
|
||||
distribute((IFluidPipe) connector);
|
||||
}
|
||||
|
||||
calculatePressure((IPressurizedNode) connector);
|
||||
distribute((IPressurizedNode) connector);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class PipeNetwork extends FluidNetwork
|
|||
/**
|
||||
* Calculate pressure in this pipe.
|
||||
*/
|
||||
public void calculatePressure(IFluidPipe sourcePipe)
|
||||
public void calculatePressure(IPressurizedNode sourcePipe)
|
||||
{
|
||||
int totalPressure = 0;
|
||||
int findCount = 0;
|
||||
|
@ -91,7 +91,7 @@ public class PipeNetwork extends FluidNetwork
|
|||
/**
|
||||
* Distribute fluid in this pipe based on pressure.
|
||||
*/
|
||||
public void distribute(IFluidPipe sourcePipe)
|
||||
public void distribute(IPressurizedNode sourcePipe)
|
||||
{
|
||||
Object[] connections = sourcePipe.getConnections();
|
||||
|
||||
|
@ -99,9 +99,9 @@ public class PipeNetwork extends FluidNetwork
|
|||
{
|
||||
Object obj = connections[i];
|
||||
|
||||
if (obj instanceof IFluidPipe)
|
||||
if (obj instanceof IPressurizedNode)
|
||||
{
|
||||
IFluidPipe otherPipe = (IFluidPipe) obj;
|
||||
IPressurizedNode otherPipe = (IPressurizedNode) obj;
|
||||
|
||||
/**
|
||||
* Move fluid from higher pressure to lower. In this case, move from tankA to tankB.
|
||||
|
@ -176,44 +176,26 @@ public class PipeNetwork extends FluidNetwork
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(IFluidConnector source, ForgeDirection from, int resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getConnectorClass()
|
||||
{
|
||||
return IFluidPipe.class;
|
||||
return IPressurizedNode.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidNetwork newInstance()
|
||||
public PressureNetwork newInstance()
|
||||
{
|
||||
return new PipeNetwork();
|
||||
return new PressureNetwork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reconstructConnector(IFluidConnector connector)
|
||||
public void reconstructConnector(IPressurizedNode connector)
|
||||
{
|
||||
connector.setNetwork(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distributeConnectors()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reconstructTankInfo()
|
||||
public void reconstruct()
|
||||
{
|
||||
NetworkTickHandler.addNetwork(this);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.core.prefab.fluid;
|
||||
package resonantinduction.core.fluid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,19 +10,17 @@ import net.minecraft.util.AxisAlignedBB;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import resonantinduction.api.IInformation;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidConnector;
|
||||
import resonantinduction.api.mechanical.fluid.IFluidNetwork;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.network.IPacketReceiverWithID;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.TileAdvanced;
|
||||
import calclavia.lib.utility.FluidUtility;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
|
@ -34,7 +32,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public abstract class TileFluidNetwork extends TileAdvanced implements IFluidConnector, IPacketReceiverWithID, IInformation
|
||||
public abstract class TileFluidDistribution extends TileAdvanced implements IFluidDistribution, IPacketReceiverWithID, IInformation
|
||||
{
|
||||
protected int pressure;
|
||||
|
||||
|
@ -46,7 +44,7 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
|
|||
protected FluidStack prevStack = null;
|
||||
|
||||
/** Network used to link all parts together */
|
||||
protected IFluidNetwork network;
|
||||
protected FluidDistributionetwork network;
|
||||
|
||||
public static final int PACKET_DESCRIPTION = 0;
|
||||
public static final int PACKET_RENDER = 1;
|
||||
|
@ -73,19 +71,19 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
|
|||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return this.getNetwork().fill(this, from, resource, doFill);
|
||||
return getNetwork().fill(this, from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, resource, doDrain);
|
||||
return getNetwork().drain(this, from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, maxDrain, doDrain);
|
||||
return getNetwork().drain(this, from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,7 +101,7 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
|
|||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return this.getNetwork().getTankInfo();
|
||||
return new FluidTankInfo[] { getInternalTank().getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,54 +143,21 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
|
|||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (tileEntity instanceof IFluidConnector)
|
||||
if (tileEntity instanceof IFluidDistribution)
|
||||
{
|
||||
this.getNetwork().merge(((IFluidConnector) tileEntity).getNetwork());
|
||||
this.setRenderSide(side, true);
|
||||
this.getNetwork().merge(((IFluidDistribution) tileEntity).getNetwork());
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRenderSide(ForgeDirection direction, boolean doRender)
|
||||
{
|
||||
if (doRender)
|
||||
{
|
||||
renderSides = (byte) (renderSides | (1 << direction.ordinal()));
|
||||
}
|
||||
else
|
||||
{
|
||||
renderSides = (byte) (renderSides & ~(1 << direction.ordinal()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canRenderSide(ForgeDirection direction)
|
||||
{
|
||||
return (renderSides & (1 << direction.ordinal())) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.colorID = nbt.getInteger("subID");
|
||||
if (nbt.hasKey("stored"))
|
||||
{
|
||||
NBTTagCompound tag = nbt.getCompoundTag("stored");
|
||||
String name = tag.getString("LiquidName");
|
||||
int amount = nbt.getInteger("Amount");
|
||||
Fluid fluid = FluidRegistry.getFluid(name);
|
||||
if (fluid != null)
|
||||
{
|
||||
FluidStack liquid = new FluidStack(fluid, amount);
|
||||
this.getInternalTank().setFluid(liquid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getInternalTank().readFromNBT(nbt.getCompoundTag("FluidTank"));
|
||||
}
|
||||
getInternalTank().readFromNBT(nbt.getCompoundTag("FluidTank"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -312,7 +277,7 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
|
|||
}
|
||||
|
||||
@Override
|
||||
public IFluidConnector getInstance(ForgeDirection from)
|
||||
public IFluidDistribution getInstance(ForgeDirection from)
|
||||
{
|
||||
return this;
|
||||
}
|
|
@ -0,0 +1,309 @@
|
|||
package resonantinduction.core.fluid;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.network.IPacketReceiverWithID;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.TileAdvanced;
|
||||
import calclavia.lib.utility.FluidUtility;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A prefab class for tiles that use the fluid network.
|
||||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public abstract class TilePressurizedNode extends TileAdvanced implements IPressurizedNode, IPacketReceiverWithID
|
||||
{
|
||||
protected int pressure;
|
||||
|
||||
protected FluidTank tank;
|
||||
protected Object[] connectedBlocks = new Object[6];
|
||||
protected int colorID = 0;
|
||||
|
||||
/** Copy of the tank's content last time it updated */
|
||||
protected FluidStack prevStack = null;
|
||||
|
||||
/** Network used to link all parts together */
|
||||
protected PressureNetwork network;
|
||||
|
||||
public static final int PACKET_DESCRIPTION = 0;
|
||||
public static final int PACKET_RENDER = 1;
|
||||
public static final int PACKET_TANK = 2;
|
||||
|
||||
/** Bitmask that handles connections for the renderer **/
|
||||
public byte renderSides = 0;
|
||||
|
||||
public TilePressurizedNode()
|
||||
{
|
||||
getInternalTank().setCapacity(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate()
|
||||
{
|
||||
super.initiate();
|
||||
refresh();
|
||||
getNetwork().reconstruct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
this.getNetwork().split(this);
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPressure(int amount)
|
||||
{
|
||||
pressure = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (!resource.getFluid().isGaseous())
|
||||
{
|
||||
int fill = getInternalTank().fill(resource, doFill);
|
||||
onFluidChanged();
|
||||
return fill;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
FluidStack drain = getInternalTank().drain(resource.amount, doDrain);
|
||||
onFluidChanged();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
FluidStack drain = getInternalTank().drain(maxDrain, doDrain);
|
||||
onFluidChanged();
|
||||
return drain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] { getInternalTank().getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getConnections()
|
||||
{
|
||||
return connectedBlocks;
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
if (this.worldObj != null && !this.worldObj.isRemote)
|
||||
{
|
||||
byte previousConnections = renderSides;
|
||||
connectedBlocks = new Object[6];
|
||||
renderSides = 0;
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
this.validateConnectionSide(new Vector3(this).translate(dir).getTileEntity(worldObj), dir);
|
||||
}
|
||||
|
||||
/** Only send packet updates if visuallyConnected changed. */
|
||||
if (previousConnections != renderSides)
|
||||
{
|
||||
sendRenderUpdate();
|
||||
getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to make sure the connection is valid to the tileEntity
|
||||
*
|
||||
* @param tileEntity - the tileEntity being checked
|
||||
* @param side - side the connection is too
|
||||
*/
|
||||
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (tileEntity instanceof IFluidDistribution)
|
||||
{
|
||||
this.getNetwork().merge(((IPressurizedNode) tileEntity).getNetwork());
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.colorID = nbt.getInteger("subID");
|
||||
getInternalTank().readFromNBT(nbt.getCompoundTag("FluidTank"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("subID", this.colorID);
|
||||
nbt.setCompoundTag("FluidTank", this.getInternalTank().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
if (id == PACKET_DESCRIPTION)
|
||||
{
|
||||
this.colorID = data.readInt();
|
||||
this.renderSides = data.readByte();
|
||||
this.tank = new FluidTank(data.readInt());
|
||||
this.getInternalTank().readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
return true;
|
||||
}
|
||||
else if (id == PACKET_RENDER)
|
||||
{
|
||||
this.colorID = data.readInt();
|
||||
this.renderSides = data.readByte();
|
||||
return true;
|
||||
}
|
||||
else if (id == PACKET_TANK)
|
||||
{
|
||||
tank = new FluidTank(data.readInt()).readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
pressure = data.readInt();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_DESCRIPTION, this, this.colorID, this.renderSides, this.getInternalTank().getCapacity(), this.getInternalTank().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
public void sendRenderUpdate()
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_RENDER, this, this.colorID, this.renderSides));
|
||||
}
|
||||
|
||||
public void sendTankUpdate()
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_TANK, this, getInternalTank().getCapacity(), getInternalTank().writeToNBT(new NBTTagCompound()), pressure), this.worldObj, new Vector3(this), 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidChanged()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!FluidUtility.matchExact(prevStack, this.getInternalTank().getFluid()))
|
||||
{
|
||||
sendTankUpdate();
|
||||
}
|
||||
|
||||
prevStack = tank.getFluid();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1);
|
||||
}
|
||||
|
||||
public int getSubID()
|
||||
{
|
||||
return this.colorID;
|
||||
}
|
||||
|
||||
public void setSubID(int id)
|
||||
{
|
||||
this.colorID = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank getInternalTank()
|
||||
{
|
||||
if (this.tank == null)
|
||||
{
|
||||
this.tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
return this.tank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPressurizedNode getInstance(ForgeDirection from)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFlow()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PressureNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null)
|
||||
{
|
||||
this.network = new PressureNetwork();
|
||||
this.network.addConnector(this);
|
||||
}
|
||||
|
||||
return this.network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(PressureNetwork network)
|
||||
{
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ import net.minecraftforge.event.ForgeSubscribe;
|
|||
import net.minecraftforge.fluids.BlockFluidFinite;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.prefab.fluid.FluidColored;
|
||||
import resonantinduction.core.fluid.FluidColored;
|
||||
import resonantinduction.core.resource.ResourceGenerator;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
package resonantinduction.core.prefab.fluid;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import calclavia.lib.prefab.block.BlockTile;
|
||||
|
||||
/** @author Calclavia */
|
||||
public abstract class BlockFluidNetwork extends BlockTile
|
||||
{
|
||||
public BlockFluidNetwork(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileFluidNetwork)
|
||||
{
|
||||
((TileFluidNetwork) tile).refresh();
|
||||
((TileFluidNetwork) tile).getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int par5)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileFluidNetwork)
|
||||
{
|
||||
((TileFluidNetwork) tile).refresh();
|
||||
((TileFluidNetwork) tile).getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package resonantinduction.core.render;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EntityFakeBlock extends Entity
|
||||
{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon texture;
|
||||
public float shadowSize = 0;
|
||||
public float rotationX = 0;
|
||||
public float rotationY = 0;
|
||||
public float rotationZ = 0;
|
||||
public double iSize, jSize, kSize;
|
||||
private int brightness = -1;
|
||||
|
||||
public EntityFakeBlock(World world)
|
||||
{
|
||||
super(world);
|
||||
preventEntitySpawning = false;
|
||||
noClip = true;
|
||||
isImmuneToFire = true;
|
||||
}
|
||||
|
||||
public EntityFakeBlock(World world, double xPos, double yPos, double zPos)
|
||||
{
|
||||
super(world);
|
||||
setPositionAndRotation(xPos, yPos, zPos, 0, 0);
|
||||
}
|
||||
|
||||
public EntityFakeBlock(World world, double i, double j, double k, double iSize, double jSize, double kSize)
|
||||
{
|
||||
this(world);
|
||||
this.iSize = iSize;
|
||||
this.jSize = jSize;
|
||||
this.kSize = kSize;
|
||||
setPositionAndRotation(i, j, k, 0, 0);
|
||||
this.motionX = 0.0;
|
||||
this.motionY = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double d, double d1, double d2)
|
||||
{
|
||||
super.setPosition(d, d1, d2);
|
||||
boundingBox.minX = posX;
|
||||
boundingBox.minY = posY;
|
||||
boundingBox.minZ = posZ;
|
||||
|
||||
boundingBox.maxX = posX + iSize;
|
||||
boundingBox.maxY = posY + jSize;
|
||||
boundingBox.maxZ = posZ + kSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveEntity(double d, double d1, double d2)
|
||||
{
|
||||
setPosition(posX + d, posY + d1, posZ + d2);
|
||||
}
|
||||
|
||||
public void setBrightness(int brightness)
|
||||
{
|
||||
this.brightness = brightness;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound data)
|
||||
{
|
||||
iSize = data.getDouble("iSize");
|
||||
jSize = data.getDouble("jSize");
|
||||
kSize = data.getDouble("kSize");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound data)
|
||||
{
|
||||
data.setDouble("iSize", iSize);
|
||||
data.setDouble("jSize", jSize);
|
||||
data.setDouble("kSize", kSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightnessForRender(float par1)
|
||||
{
|
||||
return brightness > 0 ? brightness : super.getBrightnessForRender(par1);
|
||||
}
|
||||
}
|
|
@ -1,193 +0,0 @@
|
|||
package resonantinduction.core.render;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
||||
public class RenderBlockEntity extends Render
|
||||
{
|
||||
|
||||
public static RenderBlockEntity INSTANCE = new RenderBlockEntity();
|
||||
|
||||
private RenderBlockEntity()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double i, double j, double k, float f, float f1)
|
||||
{
|
||||
doRenderBlock((EntityFakeBlock) entity, i, j, k);
|
||||
}
|
||||
|
||||
public void doRenderBlock(EntityFakeBlock entity, double i, double j, double k)
|
||||
{
|
||||
if (entity.isDead)
|
||||
return;
|
||||
|
||||
shadowSize = entity.shadowSize;
|
||||
World world = entity.worldObj;
|
||||
BlockRenderInfo util = new BlockRenderInfo();
|
||||
util.texture = entity.texture;
|
||||
this.bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
for (int iBase = 0; iBase < entity.iSize; ++iBase)
|
||||
{
|
||||
for (int jBase = 0; jBase < entity.jSize; ++jBase)
|
||||
{
|
||||
for (int kBase = 0; kBase < entity.kSize; ++kBase)
|
||||
{
|
||||
|
||||
util.min = new Vector3();
|
||||
util.max = new Vector3();
|
||||
|
||||
double remainX = entity.iSize - iBase;
|
||||
double remainY = entity.jSize - jBase;
|
||||
double remainZ = entity.kSize - kBase;
|
||||
|
||||
util.max.x = (remainX > 1.0 ? 1.0 : remainX);
|
||||
util.max.y = (remainY > 1.0 ? 1.0 : remainY);
|
||||
util.max.z = (remainZ > 1.0 ? 1.0 : remainZ);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) i, (float) j, (float) k);
|
||||
GL11.glRotatef(entity.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(entity.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(entity.rotationZ, 0, 0, 1);
|
||||
GL11.glTranslatef(iBase, jBase, kBase);
|
||||
|
||||
int lightX, lightY, lightZ;
|
||||
|
||||
lightX = (int) (Math.floor(entity.posX) + iBase);
|
||||
lightY = (int) (Math.floor(entity.posY) + jBase);
|
||||
lightZ = (int) (Math.floor(entity.posZ) + kBase);
|
||||
|
||||
GL11.glDisable(2896 /* GL_LIGHTING */);
|
||||
renderBlock(util, world, lightX, lightY, lightZ, false, true);
|
||||
GL11.glEnable(2896 /* GL_LIGHTING */);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderBlock(BlockRenderInfo block, IBlockAccess blockAccess, int x, int y, int z, boolean doLight, boolean doTessellating)
|
||||
{
|
||||
float f = 0.5F;
|
||||
float f1 = 1.0F;
|
||||
float f2 = 0.8F;
|
||||
float f3 = 0.6F;
|
||||
|
||||
renderBlocks.renderMaxX = block.max.x;
|
||||
renderBlocks.renderMinX = block.min.x;
|
||||
|
||||
renderBlocks.renderMaxY = block.max.y;
|
||||
renderBlocks.renderMinY = block.min.y;
|
||||
|
||||
renderBlocks.renderMaxZ = block.max.z;
|
||||
renderBlocks.renderMinZ = block.min.z;
|
||||
|
||||
renderBlocks.enableAO = false;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
if (doTessellating)
|
||||
{
|
||||
tessellator.startDrawingQuads();
|
||||
}
|
||||
|
||||
float f4 = 0, f5 = 0;
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f4 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f * f5, f * f5, f * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5));
|
||||
|
||||
if (doTessellating)
|
||||
{
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package resonantinduction.core.render;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderFluidHelper
|
||||
{
|
||||
|
||||
private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
|
||||
|
||||
private static Map<Fluid, int[]> flowingRenderCache = new HashMap<Fluid, int[]>();
|
||||
private static Map<Fluid, int[]> stillRenderCache = new HashMap<Fluid, int[]>();
|
||||
|
||||
public static final int DISPLAY_STAGES = 100;
|
||||
|
||||
private static final BlockRenderInfo liquidBlock = new BlockRenderInfo();
|
||||
|
||||
public static ResourceLocation getFluidSheet(FluidStack liquid)
|
||||
{
|
||||
return BLOCK_TEXTURE;
|
||||
}
|
||||
|
||||
public static Icon getFluidTexture(Fluid fluid, boolean flowing)
|
||||
{
|
||||
if (fluid == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Icon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
|
||||
if (icon == null)
|
||||
{
|
||||
icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
public static void setColorForFluidStack(FluidStack fluidstack)
|
||||
{
|
||||
if (fluidstack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int color = fluidstack.getFluid().getColor(fluidstack);
|
||||
float red = (color >> 16 & 255) / 255.0F;
|
||||
float green = (color >> 8 & 255) / 255.0F;
|
||||
float blue = (color & 255) / 255.0F;
|
||||
GL11.glColor4f(red, green, blue, 1);
|
||||
}
|
||||
|
||||
public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing)
|
||||
{
|
||||
if (fluidStack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
|
||||
int[] diplayLists = cache.get(fluid);
|
||||
if (diplayLists != null)
|
||||
{
|
||||
return diplayLists;
|
||||
}
|
||||
|
||||
diplayLists = new int[DISPLAY_STAGES];
|
||||
|
||||
if (fluid.getBlockID() > 0)
|
||||
{
|
||||
liquidBlock.baseBlock = Block.blocksList[fluid.getBlockID()];
|
||||
liquidBlock.texture = getFluidTexture(fluidStack.getFluid(), flowing);
|
||||
}
|
||||
else
|
||||
{
|
||||
liquidBlock.baseBlock = Block.waterStill;
|
||||
liquidBlock.texture = getFluidTexture(fluidStack.getFluid(), flowing);
|
||||
}
|
||||
|
||||
cache.put(fluid, diplayLists);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
|
||||
for (int s = 0; s < DISPLAY_STAGES; ++s)
|
||||
{
|
||||
diplayLists[s] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(diplayLists[s], 4864 /* GL_COMPILE */);
|
||||
|
||||
liquidBlock.min.x = 0.01f;
|
||||
liquidBlock.min.y = 0;
|
||||
liquidBlock.min.z = 0.01f;
|
||||
|
||||
liquidBlock.max.x = 0.99f;
|
||||
liquidBlock.max.y = (float) s / (float) DISPLAY_STAGES;
|
||||
liquidBlock.max.z = 0.99f;
|
||||
|
||||
RenderBlockEntity.INSTANCE.renderBlock(liquidBlock, world, 0, 0, 0, false, true);
|
||||
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
return diplayLists;
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ import resonantinduction.api.recipe.OreDetectionBlackList;
|
|||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.Settings;
|
||||
import resonantinduction.core.prefab.fluid.FluidColored;
|
||||
import resonantinduction.core.fluid.FluidColored;
|
||||
import resonantinduction.core.resource.fluid.BlockFluidMaterial;
|
||||
import resonantinduction.core.resource.fluid.BlockFluidMixture;
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
|
|
Loading…
Reference in a new issue