Finished initial gutter
This commit is contained in:
parent
1442b683c7
commit
7ba79db7d7
4 changed files with 145 additions and 67 deletions
|
@ -3,10 +3,10 @@ package resonantinduction.archaic.gutter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.DamageSource;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
@ -15,6 +15,8 @@ import resonantinduction.core.Reference;
|
||||||
import resonantinduction.core.prefab.fluid.BlockFluidNetwork;
|
import resonantinduction.core.prefab.fluid.BlockFluidNetwork;
|
||||||
import resonantinduction.core.render.RIBlockRenderingHandler;
|
import resonantinduction.core.render.RIBlockRenderingHandler;
|
||||||
import universalelectricity.api.UniversalElectricity;
|
import universalelectricity.api.UniversalElectricity;
|
||||||
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
import calclavia.lib.render.RenderUtility;
|
||||||
import calclavia.lib.utility.FluidUtility;
|
import calclavia.lib.utility.FluidUtility;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -33,20 +35,45 @@ public class BlockGutter extends BlockFluidNetwork
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCollisionBoxesToList(World par1World, int x, int y, int z, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity entity)
|
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity)
|
||||||
{
|
{
|
||||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F);
|
float thickness = 0.1F;
|
||||||
super.addCollisionBoxesToList(par1World, x, y, z, par5AxisAlignedBB, par6List, entity);
|
|
||||||
float thickness = 0.125F;
|
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, thickness, 1.0F, 1.0F);
|
|
||||||
super.addCollisionBoxesToList(par1World, x, y, z, par5AxisAlignedBB, par6List, entity);
|
if (tile instanceof TileGutter)
|
||||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, thickness);
|
{
|
||||||
super.addCollisionBoxesToList(par1World, x, y, z, par5AxisAlignedBB, par6List, entity);
|
byte renderSides = ((TileGutter) tile).renderSides;
|
||||||
this.setBlockBounds(1.0F - thickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
super.addCollisionBoxesToList(par1World, x, y, z, par5AxisAlignedBB, par6List, entity);
|
if (!RenderUtility.canRenderSide(renderSides, ForgeDirection.DOWN))
|
||||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - thickness, 1.0F, 1.0F, 1.0F);
|
{
|
||||||
super.addCollisionBoxesToList(par1World, x, y, z, par5AxisAlignedBB, par6List, entity);
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, thickness, 1.0F);
|
||||||
this.setBlockBoundsForItemRender();
|
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RenderUtility.canRenderSide(renderSides, ForgeDirection.WEST))
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, thickness, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||||
|
}
|
||||||
|
if (!RenderUtility.canRenderSide(renderSides, ForgeDirection.NORTH))
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, thickness);
|
||||||
|
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||||
|
}
|
||||||
|
if (!RenderUtility.canRenderSide(renderSides, ForgeDirection.EAST))
|
||||||
|
{
|
||||||
|
this.setBlockBounds(1.0F - thickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||||
|
}
|
||||||
|
if (!RenderUtility.canRenderSide(renderSides, ForgeDirection.SOUTH))
|
||||||
|
{
|
||||||
|
this.setBlockBounds(0.0F, 0.0F, 1.0F - thickness, 1.0F, 1.0F, 1.0F);
|
||||||
|
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setBlockBounds(0.0F, 0.0F, 0.0F, 1, 0.99f, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockBoundsForItemRender()
|
public void setBlockBoundsForItemRender()
|
||||||
|
@ -61,14 +88,44 @@ public class BlockGutter extends BlockFluidNetwork
|
||||||
|
|
||||||
if (!world.isRemote && tile instanceof TileGutter)
|
if (!world.isRemote && tile instanceof TileGutter)
|
||||||
{
|
{
|
||||||
((TileGutter) tile).fill(ForgeDirection.UNKNOWN, new FluidStack(FluidRegistry.WATER, 10), true);
|
((TileGutter) tile).fill(ForgeDirection.UNKNOWN, new FluidStack(FluidRegistry.WATER, 1), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity entity)
|
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||||
{
|
{
|
||||||
entity.attackEntityFrom(DamageSource.cactus, 1.0F);
|
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (tile instanceof TileGutter)
|
||||||
|
{
|
||||||
|
if (((TileGutter) tile).getInternalTank().getFluidAmount() > 0)
|
||||||
|
{
|
||||||
|
int pressure = ((TileGutter) tile).getPressure(null);
|
||||||
|
|
||||||
|
for (int i = 2; i < 6; i++)
|
||||||
|
{
|
||||||
|
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||||
|
Vector3 position = new Vector3(x, y, z).translate(dir);
|
||||||
|
|
||||||
|
TileEntity checkTile = position.getTileEntity(world);
|
||||||
|
|
||||||
|
if (checkTile instanceof TileGutter)
|
||||||
|
{
|
||||||
|
int deltaPressure = ((TileGutter) checkTile).getPressure(null) - pressure;
|
||||||
|
|
||||||
|
entity.motionX += 0.01 * dir.offsetX * deltaPressure;
|
||||||
|
entity.motionY += 0.01 * dir.offsetY * deltaPressure;
|
||||||
|
entity.motionZ += 0.01 * dir.offsetZ * deltaPressure;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity instanceof EntityItem)
|
||||||
|
{
|
||||||
|
entity.noClip = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,23 @@ public class RenderGutter extends TileEntitySpecialRenderer implements ISimpleIt
|
||||||
public static void render(int meta, byte sides)
|
public static void render(int meta, byte sides)
|
||||||
{
|
{
|
||||||
RenderUtility.bind(TEXTURE);
|
RenderUtility.bind(TEXTURE);
|
||||||
MODEL.renderAll();
|
|
||||||
|
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||||
|
{
|
||||||
|
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN)
|
||||||
|
{
|
||||||
|
if (!RenderUtility.canRenderSide(sides, dir))
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
RenderUtility.rotateBlockBasedOnDirection(dir);
|
||||||
|
MODEL.renderOnly("left", "backCornerL", "frontCornerL");
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RenderUtility.canRenderSide(sides, ForgeDirection.DOWN))
|
||||||
|
MODEL.renderOnly("base");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,6 +60,8 @@ public class RenderGutter extends TileEntitySpecialRenderer implements ISimpleIt
|
||||||
int capacity = tile.getInternalTank().getCapacity();
|
int capacity = tile.getInternalTank().getCapacity();
|
||||||
byte renderSides = (tile instanceof TileGutter ? tile.renderSides : (byte) 0);
|
byte renderSides = (tile instanceof TileGutter ? tile.renderSides : (byte) 0);
|
||||||
|
|
||||||
|
render(0, renderSides);
|
||||||
|
|
||||||
if (liquid != null && liquid.amount > 0)
|
if (liquid != null && liquid.amount > 0)
|
||||||
{
|
{
|
||||||
float percentage = (float) liquid.amount / (float) capacity;
|
float percentage = (float) liquid.amount / (float) capacity;
|
||||||
|
@ -57,51 +75,17 @@ public class RenderGutter extends TileEntitySpecialRenderer implements ISimpleIt
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
GL11.glTranslatef((float) 0F, (float) 0F, (float) 0.3F);
|
float xScale = RenderUtility.canRenderSide(renderSides, ForgeDirection.EAST) || RenderUtility.canRenderSide(renderSides, ForgeDirection.WEST) ? 1.01f : 0.8f;
|
||||||
GL11.glScalef(0.4F, 0.4F, 0.4F);
|
float zScale = RenderUtility.canRenderSide(renderSides, ForgeDirection.NORTH) || RenderUtility.canRenderSide(renderSides, ForgeDirection.SOUTH) ? 1.01f : 0.8f;
|
||||||
|
GL11.glTranslatef(-xScale / 2, -0.45f, -zScale / 2);
|
||||||
|
GL11.glScalef(xScale, 0.9f, zScale);
|
||||||
|
|
||||||
GL11.glCallList(displayList[(int) (percentage * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
GL11.glCallList(displayList[(int) (percentage * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
||||||
|
|
||||||
GL11.glPopAttrib();
|
GL11.glPopAttrib();
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
|
||||||
{
|
|
||||||
if (RenderUtility.canRenderSide(renderSides, direction) && direction != ForgeDirection.UP && direction != ForgeDirection.DOWN)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
switch (direction.ordinal())
|
|
||||||
{
|
|
||||||
case 4:
|
|
||||||
GL11.glTranslatef((float) x + 0F, (float) y + 0.1F, (float) z + 0.3F);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
GL11.glTranslatef((float) x + 0.7F, (float) y + 0.1F, (float) z + 0.3F);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.1F, (float) z + 0F);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.1F, (float) z + 0.7F);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
GL11.glScalef(0.3F, 0.4F, 0.4F);
|
|
||||||
|
|
||||||
GL11.glCallList(displayList[(int) (percentage * (RenderFluidHelper.DISPLAY_STAGES - 1))]);
|
|
||||||
|
|
||||||
GL11.glPopAttrib();
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render(0, renderSides);
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +94,7 @@ public class RenderGutter extends TileEntitySpecialRenderer implements ISimpleIt
|
||||||
{
|
{
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslated(0.5, 0.5, 0.5);
|
GL11.glTranslated(0.5, 0.5, 0.5);
|
||||||
render(itemStack.getItemDamage(), Byte.parseByte("000011", 2));
|
render(itemStack.getItemDamage(), Byte.parseByte("001100", 2));
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
@ -17,8 +18,6 @@ import calclavia.lib.utility.WrenchUtility;
|
||||||
/** @author Darkguardsman */
|
/** @author Darkguardsman */
|
||||||
public class TileGutter extends TileFluidNetwork implements IFluidPipe
|
public class TileGutter extends TileFluidNetwork implements IFluidPipe
|
||||||
{
|
{
|
||||||
private int pressure;
|
|
||||||
|
|
||||||
public TileGutter()
|
public TileGutter()
|
||||||
{
|
{
|
||||||
getInternalTank().setCapacity(FluidContainerRegistry.BUCKET_VOLUME);
|
getInternalTank().setCapacity(FluidContainerRegistry.BUCKET_VOLUME);
|
||||||
|
@ -28,11 +27,6 @@ public class TileGutter extends TileFluidNetwork implements IFluidPipe
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if (!worldObj.isRemote)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,6 +94,11 @@ public class TileGutter extends TileFluidNetwork implements IFluidPipe
|
||||||
@Override
|
@Override
|
||||||
public int getPressure(ForgeDirection dir)
|
public int getPressure(ForgeDirection dir)
|
||||||
{
|
{
|
||||||
|
if (dir == ForgeDirection.UP)
|
||||||
|
return - 3;
|
||||||
|
if (dir == ForgeDirection.DOWN)
|
||||||
|
return + 3;
|
||||||
|
|
||||||
return pressure;
|
return pressure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +111,42 @@ public class TileGutter extends TileFluidNetwork implements IFluidPipe
|
||||||
@Override
|
@Override
|
||||||
public int getMaxFlowRate()
|
public int getMaxFlowRate()
|
||||||
{
|
{
|
||||||
return 10;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||||
|
{
|
||||||
|
int fill = getInternalTank().fill(resource, doFill);
|
||||||
|
onFluidChanged();
|
||||||
|
return fill;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
|
{
|
||||||
|
return from != ForgeDirection.UP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return from != ForgeDirection.UP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
*/
|
*/
|
||||||
public abstract class TileFluidNetwork extends TileAdvanced implements IFluidConnector, IPacketReceiverWithID, IInformation
|
public abstract class TileFluidNetwork extends TileAdvanced implements IFluidConnector, IPacketReceiverWithID, IInformation
|
||||||
{
|
{
|
||||||
|
protected int pressure;
|
||||||
|
|
||||||
protected FluidTank tank;
|
protected FluidTank tank;
|
||||||
protected Object[] connectedBlocks = new Object[6];
|
protected Object[] connectedBlocks = new Object[6];
|
||||||
protected int colorID = 0;
|
protected int colorID = 0;
|
||||||
|
@ -224,7 +226,8 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
|
||||||
}
|
}
|
||||||
else if (id == PACKET_TANK)
|
else if (id == PACKET_TANK)
|
||||||
{
|
{
|
||||||
this.tank = new FluidTank(data.readInt()).readFromNBT(PacketHandler.readNBTTagCompound(data));
|
tank = new FluidTank(data.readInt()).readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||||
|
pressure = data.readInt();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,7 +253,7 @@ public abstract class TileFluidNetwork extends TileAdvanced implements IFluidCon
|
||||||
|
|
||||||
public void sendTankUpdate()
|
public void sendTankUpdate()
|
||||||
{
|
{
|
||||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_TANK, this, getInternalTank().getCapacity(), getInternalTank().writeToNBT(new NBTTagCompound())), this.worldObj, new Vector3(this), 60);
|
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_TANK, this, getInternalTank().getCapacity(), getInternalTank().writeToNBT(new NBTTagCompound()), pressure), this.worldObj, new Vector3(this), 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue