Fixed #471 - Gutter not searching all possible gutters for fluid flow in
This commit is contained in:
parent
cf6d3cdb30
commit
fc5af14ff0
1 changed files with 365 additions and 326 deletions
|
@ -1,35 +1,5 @@
|
|||
package resonantinduction.archaic.fluid.gutter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.common.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 org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.archaic.fluid.grate.TileGrate;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction.RecipeType;
|
||||
import resonantinduction.core.fluid.TilePressureNode;
|
||||
import resonantinduction.core.grid.fluid.FluidPressureNode;
|
||||
import resonantinduction.core.grid.fluid.IPressureNodeProvider;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.api.recipe.MachineRecipes;
|
||||
import calclavia.api.recipe.RecipeResource;
|
||||
import calclavia.lib.content.module.TileRender;
|
||||
|
@ -41,368 +11,437 @@ import calclavia.lib.utility.WorldUtility;
|
|||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import resonantinduction.archaic.fluid.grate.TileGrate;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction.RecipeType;
|
||||
import resonantinduction.core.fluid.TilePressureNode;
|
||||
import resonantinduction.core.grid.fluid.FluidPressureNode;
|
||||
import resonantinduction.core.grid.fluid.IPressureNodeProvider;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
||||
/** The gutter, used for fluid transfer.
|
||||
*
|
||||
* @author Calclavia */
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The gutter, used for fluid transfer.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
public class TileGutter extends TilePressureNode
|
||||
{
|
||||
public TileGutter()
|
||||
{
|
||||
super(Material.rock);
|
||||
textureName = "material_wood_surface";
|
||||
isOpaqueCube = false;
|
||||
normalRender = false;
|
||||
bounds = new Cuboid(0, 0, 0, 1, 0.99, 1);
|
||||
public TileGutter()
|
||||
{
|
||||
super(Material.rock);
|
||||
textureName = "material_wood_surface";
|
||||
isOpaqueCube = false;
|
||||
normalRender = false;
|
||||
bounds = new Cuboid(0, 0, 0, 1, 0.99, 1);
|
||||
|
||||
node = new FluidGravityNode(this)
|
||||
{
|
||||
@Override
|
||||
public void doRecache()
|
||||
{
|
||||
connections.clear();
|
||||
byte previousConnections = renderSides;
|
||||
renderSides = 0;
|
||||
node = new FluidGravityNode(this)
|
||||
{
|
||||
@Override
|
||||
public void doRecache()
|
||||
{
|
||||
connections.clear();
|
||||
byte previousConnections = renderSides;
|
||||
renderSides = 0;
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = position().translate(dir).getTileEntity(world());
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = position().translate(dir).getTileEntity(world());
|
||||
|
||||
if (tile instanceof IFluidHandler)
|
||||
{
|
||||
if (tile instanceof IPressureNodeProvider)
|
||||
{
|
||||
FluidPressureNode check = ((IPressureNodeProvider) tile).getNode(FluidPressureNode.class, dir.getOpposite());
|
||||
if (tile instanceof IFluidHandler)
|
||||
{
|
||||
if (tile instanceof IPressureNodeProvider)
|
||||
{
|
||||
FluidPressureNode check = ((IPressureNodeProvider) tile).getNode(FluidPressureNode.class, dir.getOpposite());
|
||||
|
||||
if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this))
|
||||
{
|
||||
connections.put(check, dir);
|
||||
if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this))
|
||||
{
|
||||
connections.put(check, dir);
|
||||
|
||||
if (tile instanceof TileGutter)
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, dir, true);
|
||||
if (tile instanceof TileGutter)
|
||||
{
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, dir, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
connections.put(tile, dir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
connections.put(tile, dir);
|
||||
|
||||
if (tile instanceof TileGrate)
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, dir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tile instanceof TileGrate)
|
||||
{
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, dir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Only send packet updates if visuallyConnected changed. */
|
||||
if (previousConnections != renderSides)
|
||||
{
|
||||
sendRenderUpdate();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/** Only send packet updates if visuallyConnected changed. */
|
||||
if (previousConnections != renderSides)
|
||||
{
|
||||
sendRenderUpdate();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
if (!this.world().isRemote && this.ticks % 5 == 0)
|
||||
{
|
||||
/** Drain block above if it is a fluid. */
|
||||
Vector3 drainPos = new Vector3(this).translate(0, 1, 0);
|
||||
FluidStack drain = FluidUtility.drainBlock(worldObj, drainPos, false);
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (drain != null)
|
||||
{
|
||||
if (fill(ForgeDirection.UP, drain, false) >= drain.amount)
|
||||
{
|
||||
fill(ForgeDirection.UP, drain, true);
|
||||
FluidUtility.drainBlock(worldObj, drainPos, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.world().isRemote && this.ticks % 20 == 0)
|
||||
{
|
||||
/** Drain block above if it is a fluid. */
|
||||
Vector3 drainPos = position().translate(0, 1, 0);
|
||||
FluidStack drain = FluidUtility.drainBlock(worldObj, drainPos, false);
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid> getCollisionBoxes()
|
||||
{
|
||||
List<Cuboid> list = new ArrayList<Cuboid>();
|
||||
if (drain != null)
|
||||
{
|
||||
ArrayList<IFluidTank> tanks = new ArrayList<IFluidTank>();
|
||||
|
||||
float thickness = 0.1F;
|
||||
synchronized (node.getGrid().getNodes())
|
||||
{
|
||||
for (Object check : node.getGrid().getNodes())
|
||||
{
|
||||
if (check instanceof FluidPressureNode)
|
||||
{
|
||||
if (((FluidPressureNode) check).parent instanceof TileGutter)
|
||||
{
|
||||
tanks.add(((FluidPressureNode) check).parent.getPressureTank());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.DOWN))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, thickness, 1.0F));
|
||||
}
|
||||
if (FluidUtility.fillAllTanks(tanks, drain, false) >= drain.amount)
|
||||
{
|
||||
FluidUtility.fillAllTanks(tanks, drain, true);
|
||||
FluidUtility.drainBlock(worldObj, drainPos, true);
|
||||
|
||||
synchronized (node.getGrid().getNodes())
|
||||
{
|
||||
for (Object check : node.getGrid().getNodes())
|
||||
{
|
||||
if (check instanceof FluidPressureNode)
|
||||
{
|
||||
((FluidPressureNode) check).parent.onFluidChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.WEST))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 0.0F, thickness, 1.0F, 1.0F));
|
||||
}
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.NORTH))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, thickness));
|
||||
}
|
||||
@Override
|
||||
public Iterable<Cuboid> getCollisionBoxes()
|
||||
{
|
||||
List<Cuboid> list = new ArrayList<Cuboid>();
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.EAST))
|
||||
{
|
||||
list.add(new Cuboid(1.0F - thickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F));
|
||||
}
|
||||
float thickness = 0.1F;
|
||||
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.SOUTH))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 1.0F - thickness, 1.0F, 1.0F, 1.0F));
|
||||
}
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.DOWN))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, thickness, 1.0F));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.WEST))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 0.0F, thickness, 1.0F, 1.0F));
|
||||
}
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.NORTH))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, thickness));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(Entity entity)
|
||||
{
|
||||
if (getInternalTank().getFluidAmount() > 0)
|
||||
{
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
int pressure = node.getPressure(dir);
|
||||
Vector3 position = position().translate(dir);
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.EAST))
|
||||
{
|
||||
list.add(new Cuboid(1.0F - thickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F));
|
||||
}
|
||||
|
||||
TileEntity checkTile = position.getTileEntity(world());
|
||||
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.SOUTH))
|
||||
{
|
||||
list.add(new Cuboid(0.0F, 0.0F, 1.0F - thickness, 1.0F, 1.0F, 1.0F));
|
||||
}
|
||||
|
||||
if (checkTile instanceof TileGutter)
|
||||
{
|
||||
int deltaPressure = pressure - ((TileGutter) checkTile).node.getPressure(dir.getOpposite());
|
||||
return list;
|
||||
}
|
||||
|
||||
entity.motionX += 0.01 * dir.offsetX * deltaPressure;
|
||||
entity.motionY += 0.01 * dir.offsetY * deltaPressure;
|
||||
entity.motionZ += 0.01 * dir.offsetZ * deltaPressure;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void collide(Entity entity)
|
||||
{
|
||||
if (getInternalTank().getFluidAmount() > 0)
|
||||
{
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
int pressure = node.getPressure(dir);
|
||||
Vector3 position = position().translate(dir);
|
||||
|
||||
if (getInternalTank().getFluid().getFluid().getTemperature() >= 373)
|
||||
{
|
||||
entity.setFire(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.extinguish();
|
||||
}
|
||||
}
|
||||
TileEntity checkTile = position.getTileEntity(world());
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
entity.noClip = true;
|
||||
}
|
||||
}
|
||||
if (checkTile instanceof TileGutter)
|
||||
{
|
||||
int deltaPressure = pressure - ((TileGutter) checkTile).node.getPressure(dir.getOpposite());
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, int side, Vector3 vector3)
|
||||
{
|
||||
if (player.getCurrentEquippedItem() != null)
|
||||
{
|
||||
/** Manually wash dust into refined dust. */
|
||||
ItemStack itemStack = player.getCurrentEquippedItem();
|
||||
entity.motionX += 0.01 * dir.offsetX * deltaPressure;
|
||||
entity.motionY += 0.01 * dir.offsetY * deltaPressure;
|
||||
entity.motionZ += 0.01 * dir.offsetZ * deltaPressure;
|
||||
}
|
||||
}
|
||||
|
||||
RecipeResource[] outputs = MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER.name(), itemStack);
|
||||
if (getInternalTank().getFluid().getFluid().getTemperature() >= 373)
|
||||
{
|
||||
entity.setFire(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.extinguish();
|
||||
}
|
||||
}
|
||||
|
||||
if (outputs.length > 0)
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
int drainAmount = 50 + world().rand.nextInt(50);
|
||||
FluidStack drain = drain(ForgeDirection.UP, drainAmount, false);
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
entity.noClip = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (drain != null && drain.amount > 0 && world().rand.nextFloat() > 0.9)
|
||||
{
|
||||
if (world().rand.nextFloat() > 0.1)
|
||||
for (RecipeResource res : outputs)
|
||||
InventoryUtility.dropItemStack(world(), new Vector3(player), res.getItemStack().copy(), 0);
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, int side, Vector3 vector3)
|
||||
{
|
||||
if (player.getCurrentEquippedItem() != null)
|
||||
{
|
||||
/** Manually wash dust into refined dust. */
|
||||
ItemStack itemStack = player.getCurrentEquippedItem();
|
||||
|
||||
itemStack.stackSize--;
|
||||
RecipeResource[] outputs = MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER.name(), itemStack);
|
||||
|
||||
if (itemStack.stackSize <= 0)
|
||||
itemStack = null;
|
||||
if (outputs.length > 0)
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
int drainAmount = 50 + world().rand.nextInt(50);
|
||||
FluidStack drain = drain(ForgeDirection.UP, drainAmount, false);
|
||||
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, itemStack);
|
||||
}
|
||||
if (drain != null && drain.amount > 0 && world().rand.nextFloat() > 0.9)
|
||||
{
|
||||
if (world().rand.nextFloat() > 0.1)
|
||||
{
|
||||
for (RecipeResource res : outputs)
|
||||
{
|
||||
InventoryUtility.dropItemStack(world(), new Vector3(player), res.getItemStack().copy(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
drain(ForgeDirection.UP, drainAmount, true);
|
||||
itemStack.stackSize--;
|
||||
|
||||
world().playSoundEffect(x() + 0.5, y() + 0.5, z() + 0.5, "liquid.water", 0.5f, 1);
|
||||
}
|
||||
if (itemStack.stackSize <= 0)
|
||||
{
|
||||
itemStack = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, itemStack);
|
||||
}
|
||||
|
||||
if (!world().isRemote)
|
||||
{
|
||||
ArrayList<IFluidTank> tanks = new ArrayList<IFluidTank>();
|
||||
drain(ForgeDirection.UP, drainAmount, true);
|
||||
|
||||
synchronized (node.getGrid().getNodes())
|
||||
{
|
||||
for (Object check : node.getGrid().getNodes())
|
||||
if (check instanceof FluidPressureNode)
|
||||
if (((FluidPressureNode) check).parent instanceof TileGutter)
|
||||
tanks.add(((FluidPressureNode) check).parent.getPressureTank());
|
||||
}
|
||||
world().playSoundEffect(x() + 0.5, y() + 0.5, z() + 0.5, "liquid.water", 0.5f, 1);
|
||||
}
|
||||
|
||||
if (FluidUtility.playerActivatedFluidItem(tanks, player, side))
|
||||
{
|
||||
synchronized (node.getGrid().getNodes())
|
||||
{
|
||||
for (Object check : node.getGrid().getNodes())
|
||||
{
|
||||
if (check instanceof FluidPressureNode)
|
||||
{
|
||||
((FluidPressureNode) check).parent.onFluidChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!world().isRemote)
|
||||
{
|
||||
ArrayList<IFluidTank> tanks = new ArrayList<IFluidTank>();
|
||||
|
||||
return false;
|
||||
synchronized (node.getGrid().getNodes())
|
||||
{
|
||||
for (Object check : node.getGrid().getNodes())
|
||||
{
|
||||
if (check instanceof FluidPressureNode)
|
||||
{
|
||||
if (((FluidPressureNode) check).parent instanceof TileGutter)
|
||||
{
|
||||
tanks.add(((FluidPressureNode) check).parent.getPressureTank());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (FluidUtility.playerActivatedFluidItem(tanks, player, side))
|
||||
{
|
||||
synchronized (node.getGrid().getNodes())
|
||||
{
|
||||
for (Object check : node.getGrid().getNodes())
|
||||
{
|
||||
if (check instanceof FluidPressureNode)
|
||||
{
|
||||
((FluidPressureNode) check).parent.onFluidChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFillRain()
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
fill(ForgeDirection.UP, new FluidStack(FluidRegistry.WATER, 10), true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (!resource.getFluid().isGaseous())
|
||||
{
|
||||
return super.fill(from, resource, doFill);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return from != ForgeDirection.UP && !fluid.isGaseous();
|
||||
}
|
||||
@Override
|
||||
public void onFillRain()
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
fill(ForgeDirection.UP, new FluidStack(FluidRegistry.WATER, 10), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return from != ForgeDirection.UP && !fluid.isGaseous();
|
||||
}
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (!resource.getFluid().isGaseous())
|
||||
{
|
||||
return super.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
protected TileRender newRenderer()
|
||||
{
|
||||
return new TileRender()
|
||||
{
|
||||
public final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "gutter.tcn");
|
||||
public final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "gutter.png");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStatic(RenderBlocks renderer, Vector3 position)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return from != ForgeDirection.UP && !fluid.isGaseous();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5);
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return from != ForgeDirection.UP && !fluid.isGaseous();
|
||||
}
|
||||
|
||||
FluidStack liquid = getInternalTank().getFluid();
|
||||
int capacity = getInternalTank().getCapacity();
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
protected TileRender newRenderer()
|
||||
{
|
||||
return new TileRender()
|
||||
{
|
||||
public final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "gutter.tcn");
|
||||
public final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "gutter.png");
|
||||
|
||||
render(0, renderSides);
|
||||
@Override
|
||||
public boolean renderStatic(RenderBlocks renderer, Vector3 position)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (world() != null)
|
||||
{
|
||||
FluidTank tank = getInternalTank();
|
||||
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
|
||||
@Override
|
||||
public boolean renderDynamic(Vector3 position, boolean isItem, float frame)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5);
|
||||
|
||||
if (percentageFilled > 0.1)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(0.990, 0.99, 0.990);
|
||||
FluidStack liquid = getInternalTank().getFluid();
|
||||
int capacity = getInternalTank().getCapacity();
|
||||
|
||||
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, world(), position(), ForgeDirection.SOUTH, ForgeDirection.EAST);
|
||||
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, world(), position(), ForgeDirection.NORTH, ForgeDirection.EAST);
|
||||
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, world(), position(), ForgeDirection.SOUTH, ForgeDirection.WEST);
|
||||
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, world(), position(), ForgeDirection.NORTH, ForgeDirection.WEST);
|
||||
render(0, renderSides);
|
||||
|
||||
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
if (world() != null)
|
||||
{
|
||||
FluidTank tank = getInternalTank();
|
||||
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
return true;
|
||||
}
|
||||
if (percentageFilled > 0.1)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(0.990, 0.99, 0.990);
|
||||
|
||||
@Override
|
||||
public boolean renderItem(ItemStack itemStack)
|
||||
{
|
||||
GL11.glTranslated(0.5, 0.5, 0.5);
|
||||
render(itemStack.getItemDamage(), Byte.parseByte("001100", 2));
|
||||
return true;
|
||||
}
|
||||
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, world(), position(), ForgeDirection.SOUTH, ForgeDirection.EAST);
|
||||
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, world(), position(), ForgeDirection.NORTH, ForgeDirection.EAST);
|
||||
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, world(), position(), ForgeDirection.SOUTH, ForgeDirection.WEST);
|
||||
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, world(), position(), ForgeDirection.NORTH, ForgeDirection.WEST);
|
||||
|
||||
public void render(int meta, byte sides)
|
||||
{
|
||||
RenderUtility.bind(TEXTURE);
|
||||
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
double thickness = 0.055;
|
||||
double height = 0.5;
|
||||
GL11.glPopMatrix();
|
||||
return true;
|
||||
}
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
RenderUtility.rotateBlockBasedOnDirection(dir);
|
||||
@Override
|
||||
public boolean renderItem(ItemStack itemStack)
|
||||
{
|
||||
GL11.glTranslated(0.5, 0.5, 0.5);
|
||||
render(itemStack.getItemDamage(), Byte.parseByte("001100", 2));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (WorldUtility.isEnabledSide(sides, ForgeDirection.DOWN))
|
||||
{
|
||||
GL11.glTranslatef(0, -0.075f, 0);
|
||||
GL11.glScalef(1, 1.15f, 1);
|
||||
}
|
||||
public void render(int meta, byte sides)
|
||||
{
|
||||
RenderUtility.bind(TEXTURE);
|
||||
|
||||
if (!WorldUtility.isEnabledSide(sides, dir))
|
||||
{
|
||||
/** Render sides */
|
||||
MODEL.renderOnly("left");
|
||||
}
|
||||
double thickness = 0.055;
|
||||
double height = 0.5;
|
||||
|
||||
if (!WorldUtility.isEnabledSide(sides, dir) || !WorldUtility.isEnabledSide(sides, dir.getRotation(ForgeDirection.UP)))
|
||||
{
|
||||
/** Render strips */
|
||||
MODEL.renderOnly("backCornerL");
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
RenderUtility.rotateBlockBasedOnDirection(dir);
|
||||
|
||||
if (!WorldUtility.isEnabledSide(sides, ForgeDirection.DOWN))
|
||||
{
|
||||
MODEL.renderOnly("base");
|
||||
}
|
||||
if (WorldUtility.isEnabledSide(sides, ForgeDirection.DOWN))
|
||||
{
|
||||
GL11.glTranslatef(0, -0.075f, 0);
|
||||
GL11.glScalef(1, 1.15f, 1);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
if (!WorldUtility.isEnabledSide(sides, dir))
|
||||
{
|
||||
/** Render sides */
|
||||
MODEL.renderOnly("left");
|
||||
}
|
||||
|
||||
if (!WorldUtility.isEnabledSide(sides, dir) || !WorldUtility.isEnabledSide(sides, dir.getRotation(ForgeDirection.UP)))
|
||||
{
|
||||
/** Render strips */
|
||||
MODEL.renderOnly("backCornerL");
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
if (!WorldUtility.isEnabledSide(sides, ForgeDirection.DOWN))
|
||||
{
|
||||
MODEL.renderOnly("base");
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue