Merge branch 'FacadesRefactor' of github.com:SirSengir/BuildCraft into FacadesRefactor
This commit is contained in:
commit
a0a542a669
10 changed files with 596 additions and 55 deletions
|
@ -0,0 +1,133 @@
|
|||
package net.minecraft.src.buildcraft.transport;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.BuildCraftTransport;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import net.minecraft.src.Tessellator;
|
||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.core.Utils;
|
||||
import net.minecraft.src.forge.IItemRenderer;
|
||||
import net.minecraft.src.forge.MinecraftForgeClient;
|
||||
|
||||
public class FacadeItemRenderer implements IItemRenderer {
|
||||
|
||||
private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
|
||||
|
||||
int decodedMeta = ItemFacade.getMetaData(item.getItemDamage());
|
||||
int decodedBlockId = ItemFacade.getBlockId(item.getItemDamage());
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
Block block = Block.blocksList[decodedBlockId];
|
||||
if (block == null){
|
||||
return;
|
||||
}
|
||||
|
||||
//Render Facade
|
||||
GL11.glPushMatrix();
|
||||
MinecraftForgeClient.bindTexture(block.getTextureFile());
|
||||
block.setBlockBounds(0F, 0F, 1F - 1F/16F, 1F, 1F, 1F);
|
||||
GL11.glTranslatef(translateX, translateY, translateZ);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
render.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
render.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
render.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
render.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
render.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, decodedMeta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
render.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, decodedMeta));
|
||||
tessellator.draw();
|
||||
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
||||
//Render StructurePipe
|
||||
MinecraftForgeClient.bindTexture(DefaultProps.TEXTURE_BLOCKS);
|
||||
block = BuildCraftTransport.genericPipeBlock;
|
||||
int textureID = 7 * 16 + 13; //Structure pipe
|
||||
block.setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos - 1F/16F);
|
||||
block.setBlockBoundsForItemRender();
|
||||
GL11.glTranslatef(translateX, translateY, translateZ + 0.25F);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -0F, 0.0F);
|
||||
render.renderBottomFace(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
render.renderTopFace(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
render.renderEastFace(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
render.renderWestFace(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
render.renderNorthFace(block, 0.0D, 0.0D, 0.0D, textureID);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
render.renderSouthFace(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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
switch (type){
|
||||
case ENTITY: return true;
|
||||
case EQUIPPED: return true;
|
||||
case INVENTORY: return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
GL11.glScalef(0.50F, 0.50F, 0.50F);
|
||||
renderFacadeItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F);
|
||||
break;
|
||||
case EQUIPPED:
|
||||
renderFacadeItem((RenderBlocks) data[0], item, 0F, 0F, 0f);
|
||||
break;
|
||||
case INVENTORY:
|
||||
GL11.glScalef(1.1F, 1.1F, 1.1F);
|
||||
renderFacadeItem((RenderBlocks) data[0], item, -0.3f, -0.35f, -0.7f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,17 @@
|
|||
package net.minecraft.src.buildcraft.transport;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemBlock;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import net.minecraft.src.buildcraft.api.IPipe;
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
|
@ -89,8 +99,95 @@ public class PipeWorldRenderer {
|
|||
|
||||
if (state.hasGate())
|
||||
pipeGateRender(renderblocks, block, state, x, y, z);
|
||||
|
||||
pipeFacadeRenderer(renderblocks, block, state, x, y, z);
|
||||
|
||||
}
|
||||
|
||||
private void pipeFacadeRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
|
||||
|
||||
float facadeThickness = 1F / 16F;
|
||||
float zFightOffset = 1F / 8192F;
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.XNeg)){
|
||||
MinecraftForgeClient.bindTexture(state.facadeMatrix.getTextureFile(Orientations.XNeg));
|
||||
state.currentTextureIndex = state.facadeMatrix.getTextureIndex(Orientations.XNeg);
|
||||
block.setBlockBounds(0.0F - zFightOffset, 0.0F, 0.0F, facadeThickness, 1.0F, 1F);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.XPos)){
|
||||
MinecraftForgeClient.bindTexture(state.facadeMatrix.getTextureFile(Orientations.XPos));
|
||||
state.currentTextureIndex = state.facadeMatrix.getTextureIndex(Orientations.XPos);
|
||||
block.setBlockBounds(1F-facadeThickness, 0.0F, 0.0F, 1.0F + zFightOffset, 1.0F, 1F);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.YNeg)){
|
||||
MinecraftForgeClient.bindTexture(state.facadeMatrix.getTextureFile(Orientations.YNeg));
|
||||
state.currentTextureIndex = state.facadeMatrix.getTextureIndex(Orientations.YNeg);
|
||||
block.setBlockBounds(0.0F, 0.0F - zFightOffset, 0.0F, 1.0F, facadeThickness, 1F);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.YPos)){
|
||||
MinecraftForgeClient.bindTexture(state.facadeMatrix.getTextureFile(Orientations.YPos));
|
||||
state.currentTextureIndex = state.facadeMatrix.getTextureIndex(Orientations.YPos);
|
||||
block.setBlockBounds(0.0F, 1F-facadeThickness, 0.0F, 1.0F, 1.0F + zFightOffset , 1F);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.ZNeg)){
|
||||
MinecraftForgeClient.bindTexture(state.facadeMatrix.getTextureFile(Orientations.ZNeg));
|
||||
state.currentTextureIndex = state.facadeMatrix.getTextureIndex(Orientations.ZNeg);
|
||||
block.setBlockBounds(0.0F, 0.0F, 0.0F - zFightOffset, 1.0F, 1F, facadeThickness);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.ZPos)){
|
||||
MinecraftForgeClient.bindTexture(state.facadeMatrix.getTextureFile(Orientations.ZPos));
|
||||
state.currentTextureIndex = state.facadeMatrix.getTextureIndex(Orientations.ZPos);
|
||||
block.setBlockBounds(0.0F, 0.0F, 1F-facadeThickness, 1.0F, 1F, 1.0F + zFightOffset);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
MinecraftForgeClient.bindTexture(DefaultProps.TEXTURE_BLOCKS);
|
||||
state.currentTextureIndex = 7 * 16 + 13; // Structure Pipe
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.XNeg)){
|
||||
block.setBlockBounds(0 + facadeThickness, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.XPos)){
|
||||
block.setBlockBounds(Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMinPos, 1F - facadeThickness, Utils.pipeMaxPos, Utils.pipeMaxPos);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.YNeg)){
|
||||
block.setBlockBounds(Utils.pipeMinPos, 0 + facadeThickness, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMaxPos);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.YPos)){
|
||||
block.setBlockBounds(Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMaxPos, 1F - facadeThickness, Utils.pipeMaxPos);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.ZNeg)){
|
||||
block.setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, 0 + facadeThickness, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMinPos);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (state.facadeMatrix.isConnected(Orientations.ZPos)){
|
||||
block.setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos, 1F - facadeThickness);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
private void pipeWireRender(RenderBlocks renderblocks, Block block, PipeRenderState state, float cx, float cy, float cz, IPipe.WireColor color, int x, int y, int z) {
|
||||
|
||||
float minX = Utils.pipeMinPos;
|
||||
|
@ -217,32 +314,32 @@ public class PipeWorldRenderer {
|
|||
float min = Utils.pipeMinPos + 0.05F;
|
||||
float max = Utils.pipeMaxPos - 0.05F;
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.XNeg)) {
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.XNeg) && !state.facadeMatrix.isConnected(Orientations.XNeg)) {
|
||||
block.setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.XPos)) {
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.XPos) && !state.facadeMatrix.isConnected(Orientations.XPos)) {
|
||||
block.setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.YNeg)) {
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.YNeg) && !state.facadeMatrix.isConnected(Orientations.YNeg)) {
|
||||
block.setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.YPos)) {
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.YPos) && !state.facadeMatrix.isConnected(Orientations.YPos)) {
|
||||
block.setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.ZNeg)) {
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.ZNeg) && !state.facadeMatrix.isConnected(Orientations.ZNeg)) {
|
||||
block.setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.ZPos)) {
|
||||
if (!state.pipeConnectionMatrix.isConnected(Orientations.ZPos) && !state.facadeMatrix.isConnected(Orientations.ZPos)) {
|
||||
block.setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
|
|
@ -197,50 +197,50 @@ public class mod_BuildCraftCore extends NetworkMod {
|
|||
|
||||
RenderItem itemRenderer = new RenderItem();
|
||||
|
||||
// @Override
|
||||
// public void renderInvBlock(RenderBlocks renderblocks, Block block, int i, int j) {
|
||||
// if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
|
||||
//
|
||||
// EntityRenderIndex index = new EntityRenderIndex(block, i);
|
||||
//
|
||||
// if (blockByEntityRenders.containsKey(index))
|
||||
// blockByEntityRenders.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0);
|
||||
// } else if (block.getRenderType() == BuildCraftCore.markerModel) {
|
||||
// // Do nothing here...
|
||||
// } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
|
||||
// Tessellator tessellator = Tessellator.instance;
|
||||
//
|
||||
// block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
|
||||
// block.setBlockBoundsForItemRender();
|
||||
// GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
// tessellator.startDrawingQuads();
|
||||
// tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
// renderblocks.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, i));
|
||||
// tessellator.draw();
|
||||
// tessellator.startDrawingQuads();
|
||||
// tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
// renderblocks.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, i));
|
||||
// tessellator.draw();
|
||||
// tessellator.startDrawingQuads();
|
||||
// tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
// renderblocks.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, i));
|
||||
// tessellator.draw();
|
||||
// tessellator.startDrawingQuads();
|
||||
// tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
// renderblocks.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, i));
|
||||
// tessellator.draw();
|
||||
// tessellator.startDrawingQuads();
|
||||
// tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
// renderblocks.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, i));
|
||||
// tessellator.draw();
|
||||
// tessellator.startDrawingQuads();
|
||||
// tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
// renderblocks.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, i));
|
||||
// tessellator.draw();
|
||||
// GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
// block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
public void renderInvBlock(RenderBlocks renderblocks, Block block, int i, int j) {
|
||||
if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
|
||||
|
||||
EntityRenderIndex index = new EntityRenderIndex(block, i);
|
||||
|
||||
if (blockByEntityRenders.containsKey(index))
|
||||
blockByEntityRenders.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0);
|
||||
} else if (block.getRenderType() == BuildCraftCore.markerModel) {
|
||||
// Do nothing here...
|
||||
} else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
|
||||
block.setBlockBoundsForItemRender();
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderblocks.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, i));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderblocks.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, i));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderblocks.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, i));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderblocks.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, i));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderblocks.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, i));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderblocks.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, i));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
public static double frontX[][][] = new double[6][3][4];
|
||||
public static double frontZ[][][] = new double[6][3][4];
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.transport.FacadeItemRenderer;
|
||||
import net.minecraft.src.buildcraft.transport.IPipeRenderState;
|
||||
import net.minecraft.src.buildcraft.transport.PipeItemRenderer;
|
||||
import net.minecraft.src.buildcraft.transport.PipeWorldRenderer;
|
||||
|
@ -23,6 +24,7 @@ public class mod_BuildCraftTransport extends NetworkMod {
|
|||
public static mod_BuildCraftTransport instance;
|
||||
public final static PipeItemRenderer pipeItemRenderer = new PipeItemRenderer();
|
||||
public final static PipeWorldRenderer pipeWorldRenderer = new PipeWorldRenderer();
|
||||
public final static FacadeItemRenderer facadeItemRenderer = new FacadeItemRenderer();
|
||||
|
||||
public mod_BuildCraftTransport() {
|
||||
instance = this;
|
||||
|
@ -58,6 +60,8 @@ public class mod_BuildCraftTransport extends NetworkMod {
|
|||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsVoid.shiftedIndex, pipeItemRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsSandstone.shiftedIndex, pipeItemRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsSandstone.shiftedIndex, pipeItemRenderer);
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.facadeItem.shiftedIndex, facadeItemRenderer);
|
||||
}
|
||||
|
||||
public static void registerTilePipe(Class<? extends TileEntity> clas, String name) {
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import net.minecraft.src.buildcraft.api.Action;
|
||||
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
|
||||
|
@ -26,6 +29,7 @@ import net.minecraft.src.buildcraft.transport.BptItemPipeDiamond;
|
|||
import net.minecraft.src.buildcraft.transport.BptItemPipeIron;
|
||||
import net.minecraft.src.buildcraft.transport.BptItemPipeWodden;
|
||||
import net.minecraft.src.buildcraft.transport.GuiHandler;
|
||||
import net.minecraft.src.buildcraft.transport.ItemFacade;
|
||||
import net.minecraft.src.buildcraft.transport.ItemGate;
|
||||
import net.minecraft.src.buildcraft.transport.Pipe;
|
||||
import net.minecraft.src.buildcraft.transport.PipeLogicWood;
|
||||
|
@ -102,6 +106,8 @@ public class BuildCraftTransport {
|
|||
public static Item pipePowerWood;
|
||||
public static Item pipePowerStone;
|
||||
public static Item pipePowerGold;
|
||||
|
||||
public static Item facadeItem;
|
||||
|
||||
public static Item pipeItemsStipes;
|
||||
public static Item pipeStructureCobblestone;
|
||||
|
@ -303,6 +309,10 @@ public class BuildCraftTransport {
|
|||
|
||||
pipeGateAutarchic = new ItemGate(DefaultProps.GATE_AUTARCHIC_ID, 1).setIconIndex(2 * 16 + 3);
|
||||
pipeGateAutarchic.setItemName("pipeGateAutarchic");
|
||||
|
||||
facadeItem = new ItemFacade(DefaultProps.PIPE_FACADE_ID);
|
||||
facadeItem.setItemName("pipeFacade");
|
||||
ItemFacade.initialize();
|
||||
|
||||
alwaysConnectPipes = Boolean.parseBoolean(alwaysConnect.value);
|
||||
|
||||
|
@ -372,4 +382,6 @@ public class BuildCraftTransport {
|
|||
public static void initializeModel(mod_BuildCraftTransport mod) {
|
||||
pipeModel = ModLoader.getUniqueBlockModelID(mod, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public class DefaultProps {
|
|||
|
||||
// Moving to safer id range
|
||||
public static int GATE_AUTARCHIC_ID = 19000;
|
||||
public static int PIPE_FACADE_ID = 19001;
|
||||
|
||||
public static int PIPE_ITEMS_WOOD_ID = 4050;
|
||||
public static int PIPE_ITEMS_COBBLESTONE_ID = 4051;
|
||||
|
|
184
common/net/minecraft/src/buildcraft/transport/ItemFacade.java
Normal file
184
common/net/minecraft/src/buildcraft/transport/ItemFacade.java
Normal file
|
@ -0,0 +1,184 @@
|
|||
package net.minecraft.src.buildcraft.transport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.BuildCraftTransport;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemBlock;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
import net.minecraft.src.buildcraft.core.ItemBuildCraft;
|
||||
|
||||
public class ItemFacade extends ItemBuildCraft {
|
||||
|
||||
public final static LinkedList<ItemStack> allFacades = new LinkedList<ItemStack>();
|
||||
|
||||
public ItemFacade(int i) {
|
||||
super(i);
|
||||
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemNameIS(ItemStack itemstack) {
|
||||
|
||||
|
||||
//FIXME PROPER NAMES
|
||||
int decodedBlockId = ItemFacade.getBlockId(itemstack.getItemDamage());
|
||||
int decodedMeta = ItemFacade.getMetaData(itemstack.getItemDamage());
|
||||
|
||||
if (Block.blocksList[decodedBlockId] == null) return "<BROKEN>";
|
||||
|
||||
return "Block: " + decodedBlockId + "- Meta: " + decodedMeta;
|
||||
|
||||
|
||||
//return (new StringBuilder()).append(super.getItemName()).append(".").append(itemstack.getItemDamage()).toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
for (ItemStack stack : allFacades){
|
||||
itemList.add(stack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side) {
|
||||
TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
|
||||
if (!(tile instanceof TileGenericPipe)) return false;
|
||||
|
||||
((TileGenericPipe)tile).addFacade(Orientations.values()[side], ItemFacade.getBlockId(stack.getItemDamage()), ItemFacade.getMetaData(stack.getItemDamage()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static void initialize(){
|
||||
List creativeItems = getCreativeContents();
|
||||
ListIterator creativeIterator = creativeItems.listIterator();
|
||||
|
||||
while(creativeIterator.hasNext()){
|
||||
ItemStack stack = (ItemStack) creativeIterator.next();
|
||||
if (stack.getItem() instanceof ItemBlock){
|
||||
ItemBlock itemBlock = (ItemBlock) stack.getItem();
|
||||
int blockId = itemBlock.getBlockID();
|
||||
//Block certain IDs
|
||||
if (blockId == 7 || blockId == 18 || blockId == 19) continue;
|
||||
|
||||
if (Block.blocksList[blockId] != null
|
||||
&& Block.blocksList[blockId].isOpaqueCube()
|
||||
&& Block.blocksList[blockId].getBlockName() != null
|
||||
&& !Block.blocksList[blockId].hasTileEntity()
|
||||
&& Block.blocksList[blockId].renderAsNormalBlock())
|
||||
{
|
||||
allFacades.add(new ItemStack(BuildCraftTransport.facadeItem, 1, ItemFacade.encode(blockId, stack.getItemDamage())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private static List getCreativeContents(){
|
||||
List itemList = new ArrayList();
|
||||
|
||||
Block[] var2 = new Block[] {Block.cobblestone, Block.stone, Block.oreDiamond, Block.oreGold, Block.oreIron, Block.oreCoal, Block.oreLapis, Block.oreRedstone, Block.stoneBrick, Block.stoneBrick, Block.stoneBrick, Block.stoneBrick, Block.blockClay, Block.blockDiamond, Block.blockGold, Block.blockSteel, Block.bedrock, Block.blockLapis, Block.brick, Block.cobblestoneMossy, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.stairSingle, Block.obsidian, Block.netherrack, Block.slowSand, Block.glowStone, Block.wood, Block.wood, Block.wood, Block.wood, Block.leaves, Block.leaves, Block.leaves, Block.leaves, Block.dirt, Block.grass, Block.sand, Block.sandStone, Block.sandStone, Block.sandStone, Block.gravel, Block.web, Block.planks, Block.planks, Block.planks, Block.planks, Block.sapling, Block.sapling, Block.sapling, Block.sapling, Block.deadBush, Block.sponge, Block.ice, Block.blockSnow, Block.plantYellow, Block.plantRed, Block.mushroomBrown, Block.mushroomRed, Block.cactus, Block.melon, Block.pumpkin, Block.pumpkinLantern, Block.vine, Block.fenceIron, Block.thinGlass, Block.netherBrick, Block.netherFence, Block.stairsNetherBrick, Block.whiteStone, Block.mycelium, Block.waterlily, Block.tallGrass, Block.tallGrass, Block.chest, Block.workbench, Block.glass, Block.tnt, Block.bookShelf, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.cloth, Block.dispenser, Block.stoneOvenIdle, Block.music, Block.jukebox, Block.pistonStickyBase, Block.pistonBase, Block.fence, Block.fenceGate, Block.ladder, Block.rail, Block.railPowered, Block.railDetector, Block.torchWood, Block.stairCompactPlanks, Block.stairCompactCobblestone, Block.stairsBrick, Block.stairsStoneBrickSmooth, Block.lever, Block.pressurePlateStone, Block.pressurePlatePlanks, Block.torchRedstoneActive, Block.button, Block.trapdoor, Block.enchantmentTable, Block.redstoneLampIdle};
|
||||
int var3 = 0;
|
||||
int var4 = 0;
|
||||
int var5 = 0;
|
||||
int var6 = 0;
|
||||
int var7 = 0;
|
||||
int var8 = 0;
|
||||
int var9 = 0;
|
||||
int var10 = 0;
|
||||
int var11 = 1;
|
||||
int var12;
|
||||
int var13;
|
||||
|
||||
for (var12 = 0; var12 < var2.length; ++var12)
|
||||
{
|
||||
var13 = 0;
|
||||
|
||||
if (var2[var12] == Block.cloth)
|
||||
{
|
||||
var13 = var3++;
|
||||
}
|
||||
else if (var2[var12] == Block.stairSingle)
|
||||
{
|
||||
var13 = var4++;
|
||||
}
|
||||
else if (var2[var12] == Block.wood)
|
||||
{
|
||||
var13 = var5++;
|
||||
}
|
||||
else if (var2[var12] == Block.planks)
|
||||
{
|
||||
var13 = var6++;
|
||||
}
|
||||
else if (var2[var12] == Block.sapling)
|
||||
{
|
||||
var13 = var7++;
|
||||
}
|
||||
else if (var2[var12] == Block.stoneBrick)
|
||||
{
|
||||
var13 = var8++;
|
||||
}
|
||||
else if (var2[var12] == Block.sandStone)
|
||||
{
|
||||
var13 = var9++;
|
||||
}
|
||||
else if (var2[var12] == Block.tallGrass)
|
||||
{
|
||||
var13 = var11++;
|
||||
}
|
||||
else if (var2[var12] == Block.leaves)
|
||||
{
|
||||
var13 = var10++;
|
||||
}
|
||||
|
||||
itemList.add(new ItemStack(var2[var12], 1, var13));
|
||||
}
|
||||
|
||||
for (Block block : Block.blocksList)
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
block.addCreativeItems((ArrayList) itemList);
|
||||
}
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
for (Item item : Item.itemsList)
|
||||
{
|
||||
if (x++ >= 256 && item != null)
|
||||
{
|
||||
item.addCreativeItems((ArrayList) itemList);
|
||||
}
|
||||
}
|
||||
|
||||
return itemList;
|
||||
}
|
||||
|
||||
public static int encode(int blockId, int metaData){
|
||||
return metaData + (blockId << 4);
|
||||
}
|
||||
|
||||
public static int getMetaData(int encoded){
|
||||
return encoded & 0x0000F;
|
||||
}
|
||||
|
||||
public static int getBlockId(int encoded){
|
||||
return encoded >>> 4;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -4,8 +4,10 @@ import java.io.DataInputStream;
|
|||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.transport.utils.ConnectionMatrix;
|
||||
import net.minecraft.src.buildcraft.transport.utils.FacadeMatrix;
|
||||
import net.minecraft.src.buildcraft.transport.utils.TextureMatrix;
|
||||
import net.minecraft.src.buildcraft.transport.utils.WireMatrix;
|
||||
|
||||
|
@ -19,13 +21,25 @@ public class PipeRenderState {
|
|||
public final TextureMatrix textureMatrix = new TextureMatrix();
|
||||
public final WireMatrix wireMatrix = new WireMatrix();
|
||||
|
||||
public final FacadeMatrix facadeMatrix = new FacadeMatrix();
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean dirty = false;
|
||||
|
||||
|
||||
/**This is a placeholder for the pipe renderer to set to a value that the BlockGenericPipe->TileGenericPipe will
|
||||
* then return the the WorldRenderer
|
||||
*/
|
||||
/*This is a placeholder for the pipe renderer to set to a value that the BlockGenericPipe->TileGenericPipe will
|
||||
* then return the the WorldRenderer */
|
||||
public int currentTextureIndex;
|
||||
|
||||
public PipeRenderState() {
|
||||
// for (Orientations direction : Orientations.dirs()){
|
||||
// facadeMatrix.setConnected(direction, true);
|
||||
// facadeMatrix.setTextureFile(direction, "/terrain.png");
|
||||
// facadeMatrix.setTextureIndex(direction, direction.ordinal());
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
public void setTextureFile(String textureFile){
|
||||
|
@ -66,10 +80,11 @@ public class PipeRenderState {
|
|||
pipeConnectionMatrix.clean();
|
||||
textureMatrix.clean();
|
||||
wireMatrix.clean();
|
||||
facadeMatrix.clean();
|
||||
}
|
||||
|
||||
public boolean isDirty(){
|
||||
return dirty || pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || wireMatrix.isDirty();
|
||||
return dirty || pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || wireMatrix.isDirty() || facadeMatrix.isDirty();
|
||||
}
|
||||
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
|
|
|
@ -11,6 +11,7 @@ package net.minecraft.src.buildcraft.transport;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.BuildCraftCore;
|
||||
import net.minecraft.src.BuildCraftTransport;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
@ -64,6 +65,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
private boolean refreshRenderState = false;
|
||||
private boolean pipeBound = false;
|
||||
|
||||
private int[] facadeBlocks = new int[Orientations.dirs().length];
|
||||
private int[] facadeMeta = new int[Orientations.dirs().length];
|
||||
|
||||
//Store the pipe key to prevent losing pipes when a user forgets to include an addon
|
||||
int key;
|
||||
|
||||
|
@ -210,7 +214,19 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
// Gate Textures
|
||||
renderState.setHasGate(pipe.hasGate());
|
||||
renderState.setGateTexture(!pipe.hasGate()?0:pipe.gate.getTexture(pipe.isGateActive()));
|
||||
|
||||
|
||||
// Facades
|
||||
for (Orientations direction:Orientations.dirs()){
|
||||
int blockId = this.facadeBlocks[direction.ordinal()];
|
||||
renderState.facadeMatrix.setConnected(direction, blockId != 0 && Block.blocksList[blockId] != null);
|
||||
if (Block.blocksList[blockId] != null){
|
||||
Block block = Block.blocksList[blockId];
|
||||
renderState.facadeMatrix.setTextureFile(direction, block.getTextureFile());
|
||||
renderState.facadeMatrix.setTextureIndex(direction, block.getBlockTextureFromSideAndMetadata(direction.ordinal(), this.facadeMeta[direction.ordinal()]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (renderState.isDirty()){
|
||||
//worldObj.markBlockAsNeedsUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
worldObj.markBlockNeedsUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
@ -512,6 +528,14 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
refreshRenderState = true;
|
||||
}
|
||||
|
||||
public void addFacade(Orientations direction, int blockid, int meta){
|
||||
if (this.worldObj.isRemote) return;
|
||||
|
||||
this.facadeBlocks[direction.ordinal()] = blockid;
|
||||
this.facadeMeta[direction.ordinal()] = meta;
|
||||
refreshRenderState();
|
||||
}
|
||||
|
||||
/** IPipeRenderState implementation **/
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package net.minecraft.src.buildcraft.transport.utils;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
|
||||
public class FacadeMatrix extends ConnectionMatrix {
|
||||
private String[] _textureFiles = new String[Orientations.dirs().length];
|
||||
private int[] _textureIndex = new int[Orientations.dirs().length];
|
||||
|
||||
private boolean dirty = false;
|
||||
|
||||
public FacadeMatrix() {
|
||||
for (Orientations direction : Orientations.dirs()){
|
||||
_textureFiles[direction.ordinal()] = "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getTextureFile(Orientations direction){
|
||||
return _textureFiles[direction.ordinal()];
|
||||
}
|
||||
|
||||
public void setTextureFile(Orientations direction, String filePath){
|
||||
if (!_textureFiles[direction.ordinal()].equals(filePath)){
|
||||
_textureFiles[direction.ordinal()] = filePath;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getTextureIndex(Orientations direction){
|
||||
return _textureIndex[direction.ordinal()];
|
||||
}
|
||||
|
||||
public void setTextureIndex(Orientations direction, int value){
|
||||
if (_textureIndex[direction.ordinal()] != value){
|
||||
_textureIndex[direction.ordinal()] = value;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return dirty || super.isDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clean() {
|
||||
super.clean();
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
super.readData(data);
|
||||
for (int i = 0; i < Orientations.dirs().length; i++){
|
||||
_textureFiles[i] = data.readUTF();
|
||||
_textureIndex[i] = data.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
super.writeData(data);
|
||||
for (int i = 0; i < Orientations.dirs().length; i++){
|
||||
data.writeUTF(_textureFiles[i]);
|
||||
data.writeInt(_textureIndex[i]);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue