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 {
|
||||
void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side,
|
||||
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);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package buildcraft.transport.render;
|
||||
|
||||
import com.sun.prism.util.tess.Tess;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -28,57 +29,12 @@ import buildcraft.transport.PipeIconProvider;
|
|||
|
||||
public class FacadeItemRenderer implements IItemRenderer {
|
||||
|
||||
private static final float zFightOffset = 1F / 4096F;
|
||||
private long lastTime = 0L;
|
||||
|
||||
private int renderState = 0;
|
||||
|
||||
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;
|
||||
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);
|
||||
private void drawCube(Tessellator tessellator, RenderBlocks render, Block block, int decodedMeta) {
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
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);
|
||||
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 5, decodedMeta));
|
||||
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
|
||||
if (block != null && block.getRenderBlockPass() > 0) {
|
||||
|
@ -114,6 +125,7 @@ public class FacadeItemRenderer implements IItemRenderer {
|
|||
RenderUtils.setGLColorFromInt(0xFFFFFF);
|
||||
|
||||
// Render StructurePipe
|
||||
if (!hollow) {
|
||||
block = BuildCraftTransport.genericPipeBlock;
|
||||
IIcon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe
|
||||
|
||||
|
@ -146,6 +158,7 @@ public class FacadeItemRenderer implements IItemRenderer {
|
|||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||
tessellator.draw();
|
||||
}
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue