Fixed gutter z-fighting

This commit is contained in:
Calclavia 2014-03-10 03:15:26 +08:00
parent 3a4b3b1648
commit a14d9b9dc2
4 changed files with 42 additions and 28 deletions

View file

@ -3,11 +3,11 @@ package resonantinduction.archaic.fluid.gutter;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@ -22,6 +22,9 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.IFluidHandler;
import org.lwjgl.opengl.GL11;
import resonantinduction.archaic.fluid.grate.TileGrate;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
@ -35,6 +38,8 @@ import calclavia.lib.render.FluidRenderUtility;
import calclavia.lib.render.RenderUtility;
import calclavia.lib.utility.FluidUtility;
import calclavia.lib.utility.WorldUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* The gutter, used for fluid transfer.
@ -75,9 +80,11 @@ public class TileGutter extends TilePressureNode
if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this))
{
renderSides = WorldUtility.setEnableSide(renderSides, dir, true);
connections.put(check, dir);
if (tile instanceof TileGutter)
renderSides = WorldUtility.setEnableSide(renderSides, dir, true);
}
}
else
@ -85,12 +92,10 @@ public class TileGutter extends TilePressureNode
connections.put(tile, dir);
if (tile instanceof TileGrate)
{
renderSides = WorldUtility.setEnableSide(renderSides, dir, true);
}
}
}
}
/** Only send packet updates if visuallyConnected changed. */
if (previousConnections != renderSides)
@ -263,7 +268,7 @@ public class TileGutter extends TilePressureNode
public final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "gutter.png");
@Override
public boolean renderStatic(Vector3 position)
public boolean renderStatic(RenderBlocks renderer, Vector3 position)
{
return true;
}
@ -314,18 +319,36 @@ public class TileGutter extends TilePressureNode
public void render(int meta, byte sides)
{
RenderUtility.bind(TEXTURE);
// RenderUtility.bind(TextureMap.locationBlocksTexture);
double thickness = 0.055;
double height = 0.5;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN)
{
if (!WorldUtility.isEnabledSide(sides, dir))
{
GL11.glPushMatrix();
RenderUtility.rotateBlockBasedOnDirection(dir);
MODEL.renderOnly("left", "backCornerL", "frontCornerL");
GL11.glPopMatrix();
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");
}
/**
* Render strips
*/
MODEL.renderOnly("backCornerL");
GL11.glPopMatrix();
}
}
@ -333,18 +356,7 @@ public class TileGutter extends TilePressureNode
{
MODEL.renderOnly("base");
}
else
{
GL11.glPushMatrix();
GL11.glRotatef(-90, 0, 0, 1);
MODEL.renderOnly("backCornerL", "frontCornerL");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotatef(90, 0, 1, 0);
GL11.glRotatef(-90, 0, 0, 1);
MODEL.renderOnly("backCornerL", "frontCornerL");
GL11.glPopMatrix();
}
}
};
}

View file

@ -623,7 +623,7 @@ public class PartLevitator extends PartFace
Vector3 start = getPosition();
Vector3 target = new Vector3(getLink().x(), getLink().y(), getLink().z());
if (start.distance(target) < Settings.MAX_CONTRACTOR_DISTANCE)
if (start.distance(target) < Settings.MAX_LEVITATOR_DISTANCE)
{
if (canBeMovePath(world(), start) && canBeMovePath(world(), target))
{

View file

@ -5,6 +5,7 @@ import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@ -217,6 +218,7 @@ public class TileSorter extends TileInventory
}
@SideOnly(Side.CLIENT)
@Override
protected TileRender newRenderer()
{
return new TileRender()
@ -225,7 +227,7 @@ public class TileSorter extends TileInventory
final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "sorter.png");
@Override
public boolean renderStatic(Vector3 position)
public boolean renderStatic(RenderBlocks renderer, Vector3 position)
{
return true;
}

View file

@ -53,7 +53,7 @@ public class Settings
public static boolean ALLOW_ENGINEERING_AUTOCRAFT = true;
public static boolean SOUND_FXS = true;
public static boolean SHINY_SILVER = true;
public static int MAX_CONTRACTOR_DISTANCE = 200;
public static int MAX_LEVITATOR_DISTANCE = 200;
/**
* Called from RI's core.
@ -68,7 +68,7 @@ public class Settings
ALLOW_ENGINEERING_AUTOCRAFT = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Engineering Table Autocraft", ALLOW_ENGINEERING_AUTOCRAFT).getBoolean(ALLOW_ENGINEERING_AUTOCRAFT);
SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS);
SHINY_SILVER = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Shiny silver wires", SHINY_SILVER).getBoolean(SHINY_SILVER);
MAX_CONTRACTOR_DISTANCE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_CONTRACTOR_DISTANCE).getInt(MAX_CONTRACTOR_DISTANCE);
MAX_LEVITATOR_DISTANCE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_LEVITATOR_DISTANCE).getInt(MAX_LEVITATOR_DISTANCE);
LEVITATOR_ACCELERATION = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Levitator Item Acceleration", Settings.LEVITATOR_ACCELERATION).getDouble(Settings.LEVITATOR_ACCELERATION);
LEVITATOR_MAX_REACH = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Levitator Max Item Reach", Settings.LEVITATOR_MAX_REACH).getInt(Settings.LEVITATOR_MAX_REACH);