touchups
This commit is contained in:
parent
a1e355d32a
commit
60af8ac978
3 changed files with 95 additions and 78 deletions
|
@ -7,5 +7,5 @@ import buildcraft.api.core.render.ITextureStates;
|
||||||
public interface IPipePluggableRenderer {
|
public interface IPipePluggableRenderer {
|
||||||
void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side,
|
void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side,
|
||||||
PipePluggable pipePluggable, ITextureStates blockStateMachine,
|
PipePluggable pipePluggable, ITextureStates blockStateMachine,
|
||||||
int x, int y, int z);
|
int renderPass, int x, int y, int z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,10 @@ public abstract class PipePluggable implements INBTStoreable, ISerializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSolidOnSide(IPipeContainer pipe, ForgeDirection direction) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract AxisAlignedBB getBoundingBox(ForgeDirection side);
|
public abstract AxisAlignedBB getBoundingBox(ForgeDirection side);
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.transport.render;
|
package buildcraft.transport.render;
|
||||||
|
|
||||||
|
import com.sun.prism.util.tess.Tess;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -28,57 +29,12 @@ import buildcraft.transport.PipeIconProvider;
|
||||||
|
|
||||||
public class FacadeItemRenderer implements IItemRenderer {
|
public class FacadeItemRenderer implements IItemRenderer {
|
||||||
|
|
||||||
|
private static final float zFightOffset = 1F / 4096F;
|
||||||
private long lastTime = 0L;
|
private long lastTime = 0L;
|
||||||
|
|
||||||
private int renderState = 0;
|
private int renderState = 0;
|
||||||
|
|
||||||
private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
|
private void drawCube(Tessellator tessellator, RenderBlocks render, Block block, int decodedMeta) {
|
||||||
if (lastTime < System.currentTimeMillis()) {
|
|
||||||
// 12 = LCM(1, 2, 3, 4)
|
|
||||||
renderState = (renderState + 1) % 12;
|
|
||||||
lastTime = System.currentTimeMillis() + 1000L;
|
|
||||||
}
|
|
||||||
|
|
||||||
FacadeType type = ((IFacadeItem) item.getItem()).getFacadeType(item);
|
|
||||||
FacadeState[] states = ItemFacade.getFacadeStates(item);
|
|
||||||
FacadeState activeState = null;
|
|
||||||
|
|
||||||
if (states.length > 0) {
|
|
||||||
// TODO: Figure out why NEI causes states[] to be of length 0
|
|
||||||
if (type == FacadeType.Basic) {
|
|
||||||
activeState = states[0];
|
|
||||||
} else if (type == FacadeType.Phased) {
|
|
||||||
activeState = states[renderState % states.length];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Block block = activeState != null ? activeState.block : null;
|
|
||||||
int decodedMeta = activeState != null ? activeState.metadata : 0;
|
|
||||||
ItemStack decodedStack = new ItemStack(block, 1, decodedMeta);
|
|
||||||
|
|
||||||
try {
|
|
||||||
int color = decodedStack.getItem().getColorFromItemStack(decodedStack, 0);
|
|
||||||
RenderUtils.setGLColorFromInt(color);
|
|
||||||
} catch (Throwable error) {
|
|
||||||
}
|
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
|
|
||||||
if (tryGetBlockIcon(block, 0, decodedMeta) == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render Facade
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
// Enable glBlending for transparency
|
|
||||||
if (block != null && block.getRenderBlockPass() > 0) {
|
|
||||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
render.setRenderBounds(0F, 0F, 1F - 1F / 16F, 1F, 1F, 1F);
|
|
||||||
GL11.glTranslatef(translateX, translateY, translateZ);
|
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||||
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 0, decodedMeta));
|
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 0, decodedMeta));
|
||||||
|
@ -103,6 +59,61 @@ public class FacadeItemRenderer implements IItemRenderer {
|
||||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||||
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 5, decodedMeta));
|
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 5, decodedMeta));
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
|
||||||
|
if (lastTime < System.currentTimeMillis()) {
|
||||||
|
// 12 = LCM(1, 2, 3, 4)
|
||||||
|
renderState = (renderState + 1) % 12;
|
||||||
|
lastTime = System.currentTimeMillis() + 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
FacadeType type = ((IFacadeItem) item.getItem()).getFacadeType(item);
|
||||||
|
FacadeState[] states = ItemFacade.getFacadeStates(item);
|
||||||
|
FacadeState activeState = null;
|
||||||
|
|
||||||
|
if (states.length > 0) {
|
||||||
|
// TODO: Figure out why NEI causes states[] to be of length 0
|
||||||
|
if (type == FacadeType.Basic) {
|
||||||
|
activeState = states[0];
|
||||||
|
} else if (type == FacadeType.Phased) {
|
||||||
|
activeState = states[renderState % states.length];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Block block = activeState != null ? activeState.block : null;
|
||||||
|
int decodedMeta = activeState != null ? activeState.metadata : 0;
|
||||||
|
boolean hollow = activeState != null ? activeState.hollow : false;
|
||||||
|
ItemStack decodedStack = new ItemStack(block, 1, decodedMeta);
|
||||||
|
|
||||||
|
try {
|
||||||
|
int color = decodedStack.getItem().getColorFromItemStack(decodedStack, 0);
|
||||||
|
RenderUtils.setGLColorFromInt(color);
|
||||||
|
} catch (Throwable error) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
|
||||||
|
if (tryGetBlockIcon(block, 0, decodedMeta) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render Facade
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
// Enable glBlending for transparency
|
||||||
|
if (block != null && block.getRenderBlockPass() > 0) {
|
||||||
|
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hollow) {
|
||||||
|
// TODO
|
||||||
|
} else {
|
||||||
|
render.setRenderBounds(0F, 0F, 1F - 1F / 16F, 1F, 1F, 1F);
|
||||||
|
GL11.glTranslatef(translateX, translateY, translateZ);
|
||||||
|
drawCube(tessellator, render, block, decodedMeta);
|
||||||
|
}
|
||||||
|
|
||||||
// Disable blending
|
// Disable blending
|
||||||
if (block != null && block.getRenderBlockPass() > 0) {
|
if (block != null && block.getRenderBlockPass() > 0) {
|
||||||
|
@ -114,38 +125,40 @@ public class FacadeItemRenderer implements IItemRenderer {
|
||||||
RenderUtils.setGLColorFromInt(0xFFFFFF);
|
RenderUtils.setGLColorFromInt(0xFFFFFF);
|
||||||
|
|
||||||
// Render StructurePipe
|
// Render StructurePipe
|
||||||
block = BuildCraftTransport.genericPipeBlock;
|
if (!hollow) {
|
||||||
IIcon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe
|
block = BuildCraftTransport.genericPipeBlock;
|
||||||
|
IIcon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe
|
||||||
|
|
||||||
block.setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS - 1F / 16F);
|
block.setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS - 1F / 16F);
|
||||||
block.setBlockBoundsForItemRender();
|
block.setBlockBoundsForItemRender();
|
||||||
render.setRenderBoundsFromBlock(block);
|
render.setRenderBoundsFromBlock(block);
|
||||||
GL11.glTranslatef(translateX, translateY, translateZ + 0.25F);
|
GL11.glTranslatef(translateX, translateY, translateZ + 0.25F);
|
||||||
|
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
tessellator.setNormal(0.0F, -0F, 0.0F);
|
tessellator.setNormal(0.0F, -0F, 0.0F);
|
||||||
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, textureID);
|
render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||||
render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||||
render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, textureID);
|
render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||||
render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||||
render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, textureID);
|
render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||||
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
}
|
||||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||||
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue