Merge branch 'master' of github.com:SirSengir/BuildCraft

Conflicts:
	common/net/minecraft/src/buildcraft/factory/BlockFrame.java
	common/net/minecraft/src/buildcraft/factory/BlockPlainPipe.java
	common/net/minecraft/src/buildcraft/transport/PipeLogicDiamond.java
	common/net/minecraft/src/buildcraft/transport/PipeTransportPower.java
	common/net/minecraft/src/buildcraft/transport/TileGenericPipe.java
	common/net/minecraft/src/buildcraft/transport/pipes/PipeLiquidsWood.java
This commit is contained in:
SirSengir 2012-07-25 11:54:43 +02:00
commit fbdefd5d5d
72 changed files with 2732 additions and 1146 deletions

View file

@ -86,21 +86,6 @@ public class CoreProxy {
}
/**
* Adds an override to the buildcraft texture file, mainly to provide pipes
* with icons.
*/
public static int addCustomTexture(String pathToTexture) {
if (!registeredOverrideTextureMap) {
char[] map = new char[256];
// every slot is free!
Arrays.fill(map, '1');
SpriteHelper.registerSpriteMapForFile(DefaultProps.TEXTURE_EXTERNAL, new String(map));
registeredOverrideTextureMap = true;
}
return ModLoader.addOverride(DefaultProps.TEXTURE_EXTERNAL, pathToTexture) + 256;
}
public static void TakenFromCrafting(EntityPlayer entityplayer, ItemStack itemstack, IInventory iinventory) {
ModLoader.takenFromCrafting(entityplayer, itemstack, iinventory);
}

View file

@ -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;
}
}
}

View file

@ -0,0 +1,93 @@
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.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.Tessellator;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.forge.IItemRenderer;
public class PipeItemRenderer implements IItemRenderer {
private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
// GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
Tessellator tessellator = Tessellator.instance;
Block block = BuildCraftTransport.genericPipeBlock;
int textureID = ((ItemPipe) Item.itemsList[item.itemID]).getTextureIndex();
if (textureID > 255)
textureID -= 256;
block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
block.setBlockBoundsForItemRender();
GL11.glTranslatef(translateX, translateY, translateZ);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1F, 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);
}
/** IItemRenderer implementation **/
@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:
renderPipeItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f);
break;
case EQUIPPED:
renderPipeItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f);
break;
case INVENTORY:
renderPipeItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f);
break;
}
}
}

View file

@ -0,0 +1,497 @@
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;
import net.minecraft.src.buildcraft.api.IPipe.WireColor;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.forge.MinecraftForgeClient;
public class PipeWorldRenderer {
/**
* Mirrors the array on the Y axis by calculating offsets from 0.5F
* @param targetArray
*/
private void mirrorY(float[][] targetArray){
float temp = targetArray[1][0];
targetArray[1][0] = (targetArray[1][1] - 0.5F) * -1F + 0.5F; // 1 -> 0.5F -> -0.5F -> 0F
targetArray[1][1] = (temp - 0.5F) * -1F + 0.5F; // 0 -> -0.5F -> 0.5F -> 1F
}
/**
* Shifts the coordinates around effectivly rotating something.
* Zero state is YNeg then -> ZNeg -> XNeg
* Note - To obtain Pos, do a mirrorY() before rotating
* @param targetArray the array that should be rotated
*/
private void rotate(float[][] targetArray) {
for (int i = 0; i < 2; i++){
float temp = targetArray[2][i];
targetArray[2][i] = targetArray[1][i];
targetArray[1][i] = targetArray[0][i];
targetArray[0][i] = temp;
}
}
/**
* @param targetArray the array that should be transformed
* @param direction
*/
private void transform(float[][] targetArray, Orientations direction){
if ( (direction.ordinal() & 0x1) == 1){
mirrorY(targetArray);
}
for (int i = 0; i < (direction.ordinal() >> 1); i++){
rotate(targetArray);
}
}
/**
* Clones both dimensions of a float[][]
* @param source the float[][] to deepClone
* @return
*/
private float[][] deepClone(float[][] source){
float[][] target = source.clone();
for (int i = 0; i < target.length; i++) {
target[i] = source[i].clone();
}
return target;
}
public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, Block block, PipeRenderState state, int x, int y, int z) {
float minSize = Utils.pipeMinPos;
float maxSize = Utils.pipeMaxPos;
MinecraftForgeClient.bindTexture(state.getTextureFile());
state.currentTextureIndex = state.textureMatrix.getTextureIndex(Orientations.Unknown);
block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, x, y, z);
if (state.pipeConnectionMatrix.isConnected(Orientations.XNeg)) {
state.currentTextureIndex = state.textureMatrix.getTextureIndex(Orientations.XNeg);
block.setBlockBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, x, y, z);
}
if (state.pipeConnectionMatrix.isConnected(Orientations.XPos)) {
state.currentTextureIndex = state.textureMatrix.getTextureIndex(Orientations.XPos);
block.setBlockBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
renderblocks.renderStandardBlock(block, x, y, z);
}
if (state.pipeConnectionMatrix.isConnected(Orientations.YNeg)) {
state.currentTextureIndex = state.textureMatrix.getTextureIndex(Orientations.YNeg);
block.setBlockBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
renderblocks.renderStandardBlock(block, x, y, z);
}
if (state.pipeConnectionMatrix.isConnected(Orientations.YPos)) {
state.currentTextureIndex = state.textureMatrix.getTextureIndex(Orientations.YPos);
block.setBlockBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
renderblocks.renderStandardBlock(block, x, y, z);
}
if (state.pipeConnectionMatrix.isConnected(Orientations.ZNeg)) {
state.currentTextureIndex = state.textureMatrix.getTextureIndex(Orientations.ZNeg);
block.setBlockBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
renderblocks.renderStandardBlock(block, x, y, z);
}
if (state.pipeConnectionMatrix.isConnected(Orientations.ZPos)) {
state.currentTextureIndex = state.textureMatrix.getTextureIndex(Orientations.ZPos);
block.setBlockBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
renderblocks.renderStandardBlock(block, x, y, z);
}
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
MinecraftForgeClient.bindTexture(DefaultProps.TEXTURE_BLOCKS);
if (state.wireMatrix.hasWire(WireColor.Red)) {
state.currentTextureIndex = state.wireMatrix.getTextureIndex(WireColor.Red);
pipeWireRender(renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMaxPos,
Utils.pipeMinPos, IPipe.WireColor.Red, x, y, z);
}
if (state.wireMatrix.hasWire(WireColor.Blue)) {
state.currentTextureIndex = state.wireMatrix.getTextureIndex(WireColor.Blue);
pipeWireRender(renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMaxPos,
Utils.pipeMaxPos, IPipe.WireColor.Blue, x, y, z);
}
if (state.wireMatrix.hasWire(WireColor.Green)) {
state.currentTextureIndex = state.wireMatrix.getTextureIndex(WireColor.Green);
pipeWireRender(renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMinPos,
Utils.pipeMinPos, IPipe.WireColor.Green, x, y, z);
}
if (state.wireMatrix.hasWire(WireColor.Yellow)) {
state.currentTextureIndex = state.wireMatrix.getTextureIndex(WireColor.Yellow);
pipeWireRender(renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMinPos,
Utils.pipeMaxPos, IPipe.WireColor.Yellow, x, y, z);
}
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 / 4096F;
float[][] zeroState = new float[3][2];
//X START - END
zeroState[0][0] = 0.0F - zFightOffset / 2;
zeroState[0][1] = 1.0F + zFightOffset / 2;
//Y START - END
zeroState[1][0] = 0.0F - zFightOffset;
zeroState[1][1] = facadeThickness;
//Z START - END
zeroState[2][0] = 0.0F;
zeroState[2][1] = 1.0F;
for (Orientations direction : Orientations.dirs()){
if (state.facadeMatrix.isConnected(direction)){
MinecraftForgeClient.bindTexture(state.facadeMatrix.getTextureFile(direction));
state.currentTextureIndex = state.facadeMatrix.getTextureIndex(direction);
//Hollow facade
if (state.pipeConnectionMatrix.isConnected(direction)){
float[][] rotated = deepClone(zeroState);
rotated[2][0] = 0.0F;
rotated[2][1] = Utils.pipeMinPos;
rotated[1][0] -= zFightOffset / 2;
transform(rotated, direction);
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
rotated = deepClone(zeroState);
rotated[2][0] = Utils.pipeMaxPos;
rotated[1][0] -= zFightOffset/2;
transform(rotated, direction);
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
rotated = deepClone(zeroState);
rotated[0][0] = 0.0F;
rotated[0][1] = Utils.pipeMinPos;
rotated[1][1] -= zFightOffset;
transform(rotated, direction);
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
rotated = deepClone(zeroState);
rotated[0][0] = Utils.pipeMaxPos;
rotated[0][1] = 1F;
rotated[1][1] -= zFightOffset;
transform(rotated, direction);
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
} else { //Solid facade
float[][] rotated = deepClone(zeroState);
transform(rotated, direction);
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
}
}
}
//X START - END
zeroState[0][0] = Utils.pipeMinPos;
zeroState[0][1] = Utils.pipeMaxPos;
//Y START - END
zeroState[1][0] = facadeThickness;
zeroState[1][1] = Utils.pipeMinPos;
//Z START - END
zeroState[2][0] = Utils.pipeMinPos;
zeroState[2][1] = Utils.pipeMaxPos;
MinecraftForgeClient.bindTexture(DefaultProps.TEXTURE_BLOCKS);
state.currentTextureIndex = 7 * 16 + 13; // Structure Pipe
for (Orientations direction : Orientations.dirs()){
if (state.facadeMatrix.isConnected(direction) && !state.pipeConnectionMatrix.isConnected(direction)){
float[][] rotated = deepClone(zeroState);
transform(rotated, direction);
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z);
}
}
/** WHOLE BUNCH OF OLD (WORKING) RENDER CODE, WILL CLEAN UP LATER **/
// 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);
//
// if (state.pipeConnectionMatrix.isConnected(Orientations.YPos)){
// block.setBlockBounds(0.0F, 1F-facadeThickness, 0.0F, 1.0F - Utils.pipeMaxPos, 1.0F + zFightOffset / 2 , 1F);
// renderblocks.renderStandardBlock(block, x, y, z);
//
// block.setBlockBounds(0.0F, 1F-facadeThickness, 0.0F, 1.0F, 1.0F + zFightOffset , 1F - Utils.pipeMaxPos);
// renderblocks.renderStandardBlock(block, x, y, z);
//
// block.setBlockBounds(0.0F + Utils.pipeMaxPos, 1F-facadeThickness, 0.0F, 1.0F, 1.0F + zFightOffset / 2 , 1F);
// renderblocks.renderStandardBlock(block, x, y, z);
//
// block.setBlockBounds(0.0F, 1F-facadeThickness, 0.0F + Utils.pipeMaxPos, 1.0F, 1.0F + zFightOffset , 1F);
// renderblocks.renderStandardBlock(block, x, y, z);
// } else {
// 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) && !state.pipeConnectionMatrix.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) && !state.pipeConnectionMatrix.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) && !state.pipeConnectionMatrix.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) && !state.pipeConnectionMatrix.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) && !state.pipeConnectionMatrix.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) && !state.pipeConnectionMatrix.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;
float minY = Utils.pipeMinPos;
float minZ = Utils.pipeMinPos;
float maxX = Utils.pipeMaxPos;
float maxY = Utils.pipeMaxPos;
float maxZ = Utils.pipeMaxPos;
boolean foundX = false, foundY = false, foundZ = false;
if (state.wireMatrix.isWireConnected(color, Orientations.XNeg)) {
minX = 0;
foundX = true;
}
if (state.wireMatrix.isWireConnected(color, Orientations.XPos)) {
maxX = 1;
foundX = true;
}
if (state.wireMatrix.isWireConnected(color, Orientations.YNeg)) {
minY = 0;
foundY = true;
}
if (state.wireMatrix.isWireConnected(color, Orientations.YPos)) {
maxY = 1;
foundY = true;
}
if (state.wireMatrix.isWireConnected(color, Orientations.ZNeg)) {
minZ = 0;
foundZ = true;
}
if (state.wireMatrix.isWireConnected(color, Orientations.ZPos)) {
maxZ = 1;
foundZ = true;
}
boolean center = false;
if (minX == 0 && maxX != 1 && (foundY || foundZ))
if (cx == Utils.pipeMinPos)
maxX = Utils.pipeMinPos;
else
center = true;
if (minX != 0 && maxX == 1 && (foundY || foundZ))
if (cx == Utils.pipeMaxPos)
minX = Utils.pipeMaxPos;
else
center = true;
if (minY == 0 && maxY != 1 && (foundX || foundZ))
if (cy == Utils.pipeMinPos)
maxY = Utils.pipeMinPos;
else
center = true;
if (minY != 0 && maxY == 1 && (foundX || foundZ))
if (cy == Utils.pipeMaxPos)
minY = Utils.pipeMaxPos;
else
center = true;
if (minZ == 0 && maxZ != 1 && (foundX || foundY))
if (cz == Utils.pipeMinPos)
maxZ = Utils.pipeMinPos;
else
center = true;
if (minZ != 0 && maxZ == 1 && (foundX || foundY))
if (cz == Utils.pipeMaxPos)
minZ = Utils.pipeMaxPos;
else
center = true;
boolean found = foundX || foundY || foundZ;
// Z render
if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ,
cx == Utils.pipeMinPos ? cx : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ);
renderblocks.renderStandardBlock(block, x, y, z);
}
// X render
if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) {
block.setBlockBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX,
cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, x, y, z);
}
// Y render
if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz,
cx == Utils.pipeMinPos ? cx : cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, x, y, z);
}
if (center || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy,
cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx : cx + 0.05F,
cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, x, y, z);
}
}
private void pipeGateRender(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) {
state.currentTextureIndex = state.getGateTextureIndex();
float min = Utils.pipeMinPos + 0.05F;
float max = Utils.pipeMaxPos - 0.05F;
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) && !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) && !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) && !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) && !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) && !state.facadeMatrix.isConnected(Orientations.ZPos)) {
block.setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F);
renderblocks.renderStandardBlock(block, x, y, z);
}
}
}

View file

@ -26,10 +26,10 @@ import net.minecraft.src.Tessellator;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.liquids.ILiquidTank;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.RenderEntityBlock;
import net.minecraft.src.buildcraft.core.RenderEntityBlock.BlockInterface;
@ -399,7 +399,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
if(count >= numItemsToRender)
break;
doRenderItem(data.item, x + data.item.posX - pipe.xCoord, y + data.item.posY - pipe.yCoord, z + data.item.posZ
doRenderItem(data.item, x + data.item.getPosition().x - pipe.xCoord, y + data.item.getPosition().y - pipe.yCoord, z + data.item.getPosition().z
- pipe.zCoord, light);
count++;
}
@ -410,18 +410,18 @@ public class RenderPipe extends TileEntitySpecialRenderer {
private Random random = new Random();
public void doRenderItem(EntityPassiveItem entityitem, double d, double d1, double d2, float f1) {
public void doRenderItem(IPipedItem entityitem, double d, double d1, double d2, float f1) {
if (entityitem == null || entityitem.item == null)
if (entityitem == null || entityitem.getItemStack() == null)
return;
ItemStack itemstack = entityitem.item;
ItemStack itemstack = entityitem.getItemStack();
random.setSeed(187L);
GL11.glPushMatrix();
byte quantity = 1;
if (entityitem.item.stackSize > 1)
if (entityitem.getItemStack().stackSize > 1)
quantity = 2;
GL11.glTranslatef((float) d, (float) d1, (float) d2);

View file

@ -19,7 +19,10 @@ import net.minecraft.src.buildcraft.core.network.PacketPipeTransportContent;
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
import net.minecraft.src.buildcraft.transport.CraftingGateInterface;
import net.minecraft.src.buildcraft.transport.PipeLogicDiamond;
import net.minecraft.src.buildcraft.transport.PipeRenderState;
import net.minecraft.src.buildcraft.transport.PipeTransportItems;
import net.minecraft.src.buildcraft.transport.PipeTransportLiquids;
import net.minecraft.src.buildcraft.transport.PipeTransportPower;
import net.minecraft.src.buildcraft.transport.TileGenericPipe;
import net.minecraft.src.forge.IPacketHandler;
@ -41,10 +44,23 @@ public class PacketHandler implements IPacketHandler {
packetN.readData(data);
onDiamondContents(packetN);
break;
case PacketIds.PIPE_POWER:
PacketPowerUpdate packetPower= new PacketPowerUpdate();
packetPower.readData(data);
onPacketPower(packetPower);
break;
case PacketIds.PIPE_LIQUID:
PacketLiquidUpdate packetLiquid = new PacketLiquidUpdate();
packetLiquid.readData(data);
onPacketLiquid(packetLiquid);
break;
case PacketIds.PIPE_DESCRIPTION:
PacketPipeDescription packetU = new PacketPipeDescription();
packetU.readData(data);
onPipeDescription(packetU);
PipeRenderStatePacket descPacket = new PipeRenderStatePacket();
descPacket.readData(data);
onPipeDescription(descPacket);
// PacketPipeDescription packetU = new PacketPipeDescription();
// packetU.readData(data);
// onPipeDescription(packetU);
break;
case PacketIds.PIPE_CONTENTS:
PacketPipeTransportContent packetC = new PacketPipeTransportContent();
@ -116,20 +132,26 @@ public class PacketHandler implements IPacketHandler {
* Handles a pipe description packet. (Creates the pipe object client side
* if needed.)
*
* @param packet
* @param descPacket
*/
private void onPipeDescription(PacketPipeDescription packet) {
private void onPipeDescription(PipeRenderStatePacket descPacket) {
World world = ModLoader.getMinecraftInstance().theWorld;
if (!world.blockExists(packet.posX, packet.posY, packet.posZ))
if (!world.blockExists(descPacket.posX, descPacket.posY, descPacket.posZ))
return;
TileEntity entity = world.getBlockTileEntity(packet.posX, packet.posY, packet.posZ);
if (!(entity instanceof ISynchronizedTile))
TileEntity entity = world.getBlockTileEntity(descPacket.posX, descPacket.posY, descPacket.posZ);
if (entity == null){
return;
// entity = new TileGenericPipeProxy();
// world.setBlockTileEntity(descPacket.posX, descPacket.posY, descPacket.posZ, entity);
}
if (!(entity instanceof TileGenericPipe))
return;
ISynchronizedTile tile = (ISynchronizedTile) entity;
tile.handleDescriptionPacket(packet);
TileGenericPipe tile = (TileGenericPipe) entity;
tile.handleDescriptionPacket(descPacket);
}
/**
@ -157,6 +179,51 @@ public class PacketHandler implements IPacketHandler {
((PipeTransportItems) pipe.pipe.transport).handleItemPacket(packet);
}
/**
* Updates the display power on a power pipe
* @param packetPower
*/
private void onPacketPower(PacketPowerUpdate packetPower) {
World world = ModLoader.getMinecraftInstance().theWorld;
if (!world.blockExists(packetPower.posX, packetPower.posY, packetPower.posZ))
return;
TileEntity entity = world.getBlockTileEntity(packetPower.posX, packetPower.posY, packetPower.posZ);
if (!(entity instanceof TileGenericPipe))
return;
TileGenericPipe pipe = (TileGenericPipe) entity;
if (pipe.pipe == null)
return;
if (!(pipe.pipe.transport instanceof PipeTransportPower))
return;
((PipeTransportPower) pipe.pipe.transport).handlePowerPacket(packetPower);
}
private void onPacketLiquid(PacketLiquidUpdate packetLiquid) {
World world = ModLoader.getMinecraftInstance().theWorld;
if (!world.blockExists(packetLiquid.posX, packetLiquid.posY, packetLiquid.posZ))
return;
TileEntity entity = world.getBlockTileEntity(packetLiquid.posX, packetLiquid.posY, packetLiquid.posZ);
if (!(entity instanceof TileGenericPipe))
return;
TileGenericPipe pipe = (TileGenericPipe) entity;
if (pipe.pipe == null)
return;
if (!(pipe.pipe.transport instanceof PipeTransportLiquids))
return;
((PipeTransportLiquids) pipe.pipe.transport).handleLiquidPacket(packetLiquid);
}
/**
* Updates contents of a diamond pipe.
*

View file

@ -14,11 +14,6 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.src.buildcraft.api.IBlockPipe;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.IPipe.DrawingState;
import net.minecraft.src.buildcraft.api.IPipeTile;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.ClassMapping;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.EntityBlock;
@ -26,14 +21,12 @@ import net.minecraft.src.buildcraft.core.EntityEnergyLaser;
import net.minecraft.src.buildcraft.core.EntityLaser;
import net.minecraft.src.buildcraft.core.EntityRobot;
import net.minecraft.src.buildcraft.core.IInventoryRenderer;
import net.minecraft.src.buildcraft.core.ITileBufferHolder;
import net.minecraft.src.buildcraft.core.RenderEnergyLaser;
import net.minecraft.src.buildcraft.core.RenderEntityBlock;
import net.minecraft.src.buildcraft.core.RenderLaser;
import net.minecraft.src.buildcraft.core.RenderRobot;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.core.utils.Localization;
import net.minecraft.src.buildcraft.transport.TileGenericPipe;
import net.minecraft.src.forge.MinecraftForgeClient;
import net.minecraft.src.forge.NetworkMod;
@ -87,7 +80,6 @@ public class mod_BuildCraftCore extends NetworkMod {
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_BLOCKS);
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_ITEMS);
MinecraftForgeClient.preloadTexture(DefaultProps.TEXTURE_EXTERNAL);
//Initialize localization
Localization.addLocalization("/lang/buildcraft/", DefaultProps.DEFAULT_LANGUAGE);
@ -136,16 +128,9 @@ public class mod_BuildCraftCore extends NetworkMod {
tessellator.setColorOpaque_F(f, f, f);
renderMarkerWithMeta(iblockaccess, block, i, j, k, iblockaccess.getBlockMetadata(i, j, k));
} else if (block.getRenderType() == BuildCraftCore.pipeModel) {
} else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
TileEntity tile = iblockaccess.getBlockTileEntity(i, j, k);
if (tile != null && tile instanceof IPipeTile && ((IPipeTile)tile).isInitialized()) {
pipeRender(renderblocks, iblockaccess, tile, block, l);
}
else {
legacyPipeRender(renderblocks, iblockaccess, i, j, k, block, l);
}
} else if (block.getRenderType() == BuildCraftCore.oilModel)
renderblocks.renderBlockFluids(block, i, j, k);
@ -153,310 +138,44 @@ public class mod_BuildCraftCore extends NetworkMod {
return true;
}
private void pipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, Block block, int l) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
float minSize = Utils.pipeMinPos;
float maxSize = Utils.pipeMaxPos;
IPipe pipe = ((TileGenericPipe)tile).pipe;
pipe.setDrawingState(DrawingState.DrawingPipe);
pipe.prepareTextureFor(Orientations.Unknown);
block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.XNeg))) {
pipe.prepareTextureFor(Orientations.XNeg);
block.setBlockBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.XPos))) {
pipe.prepareTextureFor(Orientations.XPos);
block.setBlockBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.YNeg))) {
pipe.prepareTextureFor(Orientations.YNeg);
block.setBlockBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.YPos))) {
pipe.prepareTextureFor(Orientations.YPos);
block.setBlockBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZNeg))) {
pipe.prepareTextureFor(Orientations.ZNeg);
block.setBlockBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZPos))) {
pipe.prepareTextureFor(Orientations.ZPos);
block.setBlockBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
pipe.prepareTextureFor(Orientations.Unknown);
MinecraftForgeClient.bindTexture(DefaultProps.TEXTURE_BLOCKS);
if (pipe.isWired(IPipe.WireColor.Red)) {
pipe.setDrawingState(DrawingState.DrawingRedWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, Utils.pipeMinPos, Utils.pipeMaxPos,
Utils.pipeMinPos, IPipe.WireColor.Red);
}
if (pipe.isWired(IPipe.WireColor.Blue)) {
pipe.setDrawingState(DrawingState.DrawingBlueWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, Utils.pipeMaxPos, Utils.pipeMaxPos,
Utils.pipeMaxPos, IPipe.WireColor.Blue);
}
if (pipe.isWired(IPipe.WireColor.Green)) {
pipe.setDrawingState(DrawingState.DrawingGreenWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, Utils.pipeMaxPos, Utils.pipeMinPos,
Utils.pipeMinPos, IPipe.WireColor.Green);
}
if (pipe.isWired(IPipe.WireColor.Yellow)) {
pipe.setDrawingState(DrawingState.DrawingYellowWire);
pipeRedstoneRender(renderblocks, iblockaccess, tile, pipe, block, l, Utils.pipeMinPos, Utils.pipeMinPos,
Utils.pipeMaxPos, IPipe.WireColor.Yellow);
}
if (pipe.hasInterface())
pipeInterfaceRender(renderblocks, iblockaccess, tile, pipe, block, l);
}
private boolean isConnectedWiredPipe(IPipe pipe, TileEntity tile2, IPipe.WireColor color) {
return pipe.isWireConnectedTo(tile2, color);
}
private void pipeRedstoneRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe,
Block block, int l, float cx, float cy, float cz, IPipe.WireColor color) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
float minX = Utils.pipeMinPos;
float minY = Utils.pipeMinPos;
float minZ = Utils.pipeMinPos;
float maxX = Utils.pipeMaxPos;
float maxY = Utils.pipeMaxPos;
float maxZ = Utils.pipeMaxPos;
boolean foundX = false, foundY = false, foundZ = false;
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.XNeg), color)) {
minX = 0;
foundX = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.XPos), color)) {
maxX = 1;
foundX = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.YNeg), color)) {
minY = 0;
foundY = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.YPos), color)) {
maxY = 1;
foundY = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.ZNeg), color)) {
minZ = 0;
foundZ = true;
}
if (isConnectedWiredPipe(pipe, holder.getTile(Orientations.ZPos), color)) {
maxZ = 1;
foundZ = true;
}
boolean center = false;
if (minX == 0 && maxX != 1 && (foundY || foundZ))
if (cx == Utils.pipeMinPos)
maxX = Utils.pipeMinPos;
else
center = true;
if (minX != 0 && maxX == 1 && (foundY || foundZ))
if (cx == Utils.pipeMaxPos)
minX = Utils.pipeMaxPos;
else
center = true;
if (minY == 0 && maxY != 1 && (foundX || foundZ))
if (cy == Utils.pipeMinPos)
maxY = Utils.pipeMinPos;
else
center = true;
if (minY != 0 && maxY == 1 && (foundX || foundZ))
if (cy == Utils.pipeMaxPos)
minY = Utils.pipeMaxPos;
else
center = true;
if (minZ == 0 && maxZ != 1 && (foundX || foundY))
if (cz == Utils.pipeMinPos)
maxZ = Utils.pipeMinPos;
else
center = true;
if (minZ != 0 && maxZ == 1 && (foundX || foundY))
if (cz == Utils.pipeMaxPos)
minZ = Utils.pipeMaxPos;
else
center = true;
boolean found = foundX || foundY || foundZ;
// Z render
if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ,
cx == Utils.pipeMinPos ? cx : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
// X render
if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) {
block.setBlockBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX,
cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
// Y render
if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz,
cx == Utils.pipeMinPos ? cx : cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (center || !found) {
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy,
cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx : cx + 0.05F,
cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
}
private void pipeInterfaceRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, TileEntity tile, IPipe pipe,
Block block, int l) {
ITileBufferHolder holder = (ITileBufferHolder) tile;
pipe.setDrawingState(DrawingState.DrawingGate);
float min = Utils.pipeMinPos + 0.05F;
float max = Utils.pipeMaxPos - 0.05F;
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.XNeg))) {
block.setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.XPos))) {
block.setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.YNeg))) {
block.setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.YPos))) {
block.setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZNeg))) {
block.setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
if (!Utils.checkPipesConnections(tile, holder.getTile(Orientations.ZPos))) {
block.setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F);
renderblocks.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord);
}
}
private void legacyPipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l) {
float minSize = Utils.pipeMinPos;
float maxSize = Utils.pipeMaxPos;
((IBlockPipe) block).prepareTextureFor(iblockaccess, i, j, k, Orientations.Unknown);
block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, i, j, k);
if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i - 1, j, k)) {
((IBlockPipe) block).prepareTextureFor(iblockaccess, i, j, k, Orientations.XNeg);
block.setBlockBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
renderblocks.renderStandardBlock(block, i, j, k);
}
if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i + 1, j, k)) {
((IBlockPipe) block).prepareTextureFor(iblockaccess, i, j, k, Orientations.XPos);
block.setBlockBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
renderblocks.renderStandardBlock(block, i, j, k);
}
if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j - 1, k)) {
((IBlockPipe) block).prepareTextureFor(iblockaccess, i, j, k, Orientations.YNeg);
block.setBlockBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
renderblocks.renderStandardBlock(block, i, j, k);
}
if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j + 1, k)) {
((IBlockPipe) block).prepareTextureFor(iblockaccess, i, j, k, Orientations.YPos);
block.setBlockBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
renderblocks.renderStandardBlock(block, i, j, k);
}
if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j, k - 1)) {
((IBlockPipe) block).prepareTextureFor(iblockaccess, i, j, k, Orientations.ZNeg);
block.setBlockBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
renderblocks.renderStandardBlock(block, i, j, k);
}
if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j, k + 1)) {
((IBlockPipe) block).prepareTextureFor(iblockaccess, i, j, k, Orientations.ZPos);
block.setBlockBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
renderblocks.renderStandardBlock(block, i, j, k);
}
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
((IBlockPipe) block).prepareTextureFor(iblockaccess, i, j, k, Orientations.Unknown);
}
RenderItem itemRenderer = new RenderItem();
@ -471,7 +190,7 @@ public class mod_BuildCraftCore extends NetworkMod {
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.pipeModel) {
} else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
Tessellator tessellator = Tessellator.instance;
block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);

View file

@ -10,18 +10,21 @@
package net.minecraft.src;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.transport.ItemPipe;
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;
import net.minecraft.src.buildcraft.transport.RenderPipe;
import net.minecraft.src.forge.IItemRenderer;
import net.minecraft.src.buildcraft.transport.TileGenericPipe;
import net.minecraft.src.forge.MinecraftForgeClient;
import net.minecraft.src.forge.NetworkMod;
import org.lwjgl.opengl.GL11;
public class mod_BuildCraftTransport extends NetworkMod implements IItemRenderer {
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;
@ -31,96 +34,40 @@ public class mod_BuildCraftTransport extends NetworkMod implements IItemRenderer
public void modsLoaded() {
super.modsLoaded();
BuildCraftTransport.initialize();
BuildCraftTransport.initializeModel(this);
// CoreProxy.registerGUI(this,
// Utils.packetIdToInt(PacketIds.DiamondPipeGUI));
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsWood.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsCobblestone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsIron.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsGold.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsDiamond.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsObsidian.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsWood.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsCobblestone.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStone.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsIron.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsGold.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsDiamond.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsObsidian.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsWood.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsCobblestone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsStone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsIron.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsGold.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsWood.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsCobblestone.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsStone.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsIron.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsGold.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerWood.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerStone.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerGold.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeStructureCobblestone.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStipes.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsVoid.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsVoid.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsSandstone.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsSandstone.shiftedIndex, this);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerWood.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerStone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerGold.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeStructureCobblestone.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStipes.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsVoid.shiftedIndex, pipeItemRenderer);
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) {
ModLoader.registerTileEntity(clas, name, new RenderPipe());
}
/**
* Needs to handle all rendering types.
*/
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
switch (type) {
case ENTITY:
return true;
case EQUIPPED:
return true;
case INVENTORY:
return true;
}
return false;
}
private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
// GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
Tessellator tessellator = Tessellator.instance;
Block block = BuildCraftTransport.genericPipeBlock;
int textureID = ((ItemPipe) Item.itemsList[item.itemID]).getTextureIndex();
if (textureID > 255)
textureID -= 256;
block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
block.setBlockBoundsForItemRender();
GL11.glTranslatef(translateX, translateY, translateZ);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1F, 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 String getVersion() {
return DefaultProps.VERSION;
@ -131,53 +78,6 @@ public class mod_BuildCraftTransport extends NetworkMod implements IItemRenderer
BuildCraftTransport.load();
}
/*
* @Override public GuiScreen handleGUI(int i) { if (Utils.intToPacketId(i)
* == PacketIds.DiamondPipeGUI) { TileGenericPipe tmp = new
* TileGenericPipe(); tmp.pipe = new PipeItemsDiamond(
* BuildCraftTransport.pipeItemsDiamond.shiftedIndex);
*
* return new GuiDiamondPipe(
* ModLoader.getMinecraftInstance().thePlayer.inventory, tmp); } else {
* return null; } }
*/
/*
* @Override public void handlePacket(Packet230ModLoader packet) { int x =
* packet.dataInt [0]; int y = packet.dataInt [1]; int z = packet.dataInt
* [2];
*
* World w = ModLoader.getMinecraftInstance().theWorld;
*
* if (packet.packetType == PacketIds.PipeItem.ordinal()) { if
* (w.blockExists(x, y, z)) { TileEntity tile = w.getBlockTileEntity(x, y,
* z);
*
* if (tile instanceof TileGenericPipe) { TileGenericPipe pipe =
* ((TileGenericPipe) tile);
*
* if (pipe.pipe != null && pipe.pipe.transport instanceof
* PipeTransportItems) { ((PipeTransportItems)
* pipe.pipe.transport).handleItemPacket(packet); } } }
*
* return; } else if (packet.packetType ==
* PacketIds.DiamondPipeContents.ordinal()) { if (w.blockExists(x, y, z)) {
* TileEntity tile = w.getBlockTileEntity(x, y, z);
*
* if (tile instanceof TileGenericPipe) { TileGenericPipe pipe =
* ((TileGenericPipe) tile);
*
* if (pipe.pipe.logic instanceof PipeLogicDiamond) { ((PipeLogicDiamond)
* pipe.pipe.logic).handleContentsPacket(packet); } } }
*
* BlockIndex index = new BlockIndex(x, y, z);
*
* if (BuildCraftCore.bufferedDescriptions.containsKey(index)) {
* BuildCraftCore.bufferedDescriptions.remove(index); }
*
* BuildCraftCore.bufferedDescriptions.put(index, packet); } }
*/
@Override
public boolean clientSideRequired() {
return true;
@ -187,25 +87,24 @@ public class mod_BuildCraftTransport extends NetworkMod implements IItemRenderer
public boolean serverSideRequired() {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID) {
if (modelID != BuildCraftTransport.pipeModel) return true;
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof IPipeRenderState){
IPipeRenderState pipeTile = (IPipeRenderState) tile;
pipeWorldRenderer.renderPipe(renderer, world, block, pipeTile.getRenderState(), x, y, z);
}
// if (tile != null && tile instanceof IPipeTile && ((IPipeTile)tile).isInitialized()) {
// pipeWorldRenderer.renderPipe(renderer, world, tile, block);
// }
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
switch (type) {
case ENTITY:
renderPipeItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f);
break;
case EQUIPPED:
renderPipeItem((RenderBlocks) data[0], item, -0.4f, 0.50f, 0.35f);
break;
case INVENTORY:
renderPipeItem((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f);
break;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -24,6 +24,7 @@ public class mod_BuildCraftTransport extends NetworkMod {
public void modsLoaded() {
super.modsLoaded();
BuildCraftTransport.initialize();
BuildCraftTransport.initializeModel(this);
}
public static void registerTilePipe(Class<? extends TileEntity> clas, String name) {

View file

@ -84,7 +84,7 @@ public class BuildCraftCore {
public static int transparentTexture;
public static int blockByEntityModel;
public static int pipeModel;
public static int legacyPipeModel;
public static int markerModel;
public static int oilModel;
@ -295,7 +295,7 @@ public class BuildCraftCore {
public static void initializeModel(BaseMod mod) {
blockByEntityModel = ModLoader.getUniqueBlockModelID(mod, true);
pipeModel = ModLoader.getUniqueBlockModelID(mod, true);
legacyPipeModel = ModLoader.getUniqueBlockModelID(mod, true);
markerModel = ModLoader.getUniqueBlockModelID(mod, false);
oilModel = ModLoader.getUniqueBlockModelID(mod, false);
}

View file

@ -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.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.IPipe;
@ -27,7 +30,9 @@ 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.ItemPipe;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicWood;
import net.minecraft.src.buildcraft.transport.PipeTriggerProvider;
@ -103,6 +108,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;
@ -134,6 +141,8 @@ public class BuildCraftTransport {
public static Action actionGreenSignal = new ActionSignalOutput(DefaultProps.ACTION_GREEN_SIGNAL, IPipe.WireColor.Green);
public static Action actionYellowSignal = new ActionSignalOutput(DefaultProps.ACTION_YELLOW_SIGNAL, IPipe.WireColor.Yellow);
public static Action actionEnergyPulser = new ActionEnergyPulser(DefaultProps.ACTION_ENERGY_PULSER);
public static int pipeModel;
private static class PipeRecipe {
@ -302,6 +311,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);
@ -344,7 +357,7 @@ public class BuildCraftTransport {
defaultID);
int id = Integer.parseInt(prop.value);
Item res = BlockGenericPipe.registerPipe(id, clas);
ItemPipe res = BlockGenericPipe.registerPipe(id, clas);
res.setItemName(clas.getSimpleName());
CoreProxy.addName(res, descr);
@ -367,4 +380,10 @@ public class BuildCraftTransport {
return res;
}
public static void initializeModel(mod_BuildCraftTransport mod) {
pipeModel = ModLoader.getUniqueBlockModelID(mod, true);
}
}

View file

@ -1,210 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api;
import java.util.TreeMap;
import net.minecraft.src.EntityItem;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.MathHelper;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
public class EntityPassiveItem {
private static TreeMap<String, IPassiveItemContribution> contributions = new TreeMap<String, IPassiveItemContribution>();
public static TreeMap<Integer, EntityPassiveItem> allEntities = new TreeMap<Integer, EntityPassiveItem>();
public float speed = 0.01F;
public ItemStack item;
public TileEntity container;
public SafeTimeTracker synchroTracker = new SafeTimeTracker();
public int deterministicRandomization = 0;
public EntityPassiveItem(World world) {
this(world, maxId != Integer.MAX_VALUE ? ++maxId : (maxId = 0));
}
public EntityPassiveItem(World world, int id) {
entityId = id;
allEntities.put(entityId, this);
worldObj = world;
}
public static EntityPassiveItem getOrCreate(World world, int id) {
if (allEntities.containsKey(id)) {
return allEntities.get(id);
} else {
return new EntityPassiveItem(world, id);
}
}
World worldObj;
public double posX, posY, posZ;
public int entityId;
private static int maxId = 0;
public void setWorld(World world) {
worldObj = world;
}
public EntityPassiveItem(World world, double d, double d1, double d2) {
this(world);
posX = d;
posY = d1;
posZ = d2;
worldObj = world;
}
public void setPosition(double x, double y, double z) {
posX = x;
posY = y;
posZ = z;
}
public EntityPassiveItem(World world, double d, double d1, double d2, ItemStack itemstack) {
this(world, d, d1, d2);
this.item = itemstack.copy();
}
public void readFromNBT(NBTTagCompound nbttagcompound) {
posX = nbttagcompound.getDouble("x");
posY = nbttagcompound.getDouble("y");
posZ = nbttagcompound.getDouble("z");
speed = nbttagcompound.getFloat("speed");
item = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Item"));
NBTTagList contribList = nbttagcompound.getTagList("contribList");
for (int i = 0; i < contribList.tagCount(); ++i) {
NBTTagCompound cpt = (NBTTagCompound) contribList.tagAt(i);
String key = cpt.getString("key");
String className = cpt.getString("class");
if (getClass().getName().startsWith("net.minecraft.src")) {
className = "net.minecraft.src." + className;
}
try {
IPassiveItemContribution contrib = ((IPassiveItemContribution) Class.forName(className).newInstance());
contrib.readFromNBT(cpt);
contributions.put(key, contrib);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
public void writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setDouble("x", posX);
nbttagcompound.setDouble("y", posY);
nbttagcompound.setDouble("z", posZ);
nbttagcompound.setFloat("speed", speed);
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
item.writeToNBT(nbttagcompound2);
nbttagcompound.setCompoundTag("Item", nbttagcompound2);
NBTTagList contribList = new NBTTagList();
for (String key : contributions.keySet()) {
IPassiveItemContribution contrib = contributions.get(key);
NBTTagCompound cpt = new NBTTagCompound();
contrib.writeToNBT(cpt);
cpt.setString("key", key);
String className = contrib.getClass().getName();
if (className.startsWith("net.minecraft.src.")) {
className = className.replace("net.minecraft.src.", "");
}
cpt.setString("class", className);
contribList.appendTag(cpt);
}
nbttagcompound.setTag("contribList", contribList);
}
public EntityItem toEntityItem(Orientations dir) {
if (!APIProxy.isClient(worldObj)) {
if (item.stackSize <= 0) {
return null;
}
Position motion = new Position(0, 0, 0, dir);
motion.moveForwards(0.1 + speed * 2F);
EntityItem entityitem = new EntityItem(worldObj, posX, posY, posZ, item);
float f3 = 0.00F + worldObj.rand.nextFloat() * 0.04F - 0.02F;
entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3 + motion.x;
entityitem.motionY = (float) worldObj.rand.nextGaussian() * f3 + motion.y;
entityitem.motionZ = (float) worldObj.rand.nextGaussian() * f3 + +motion.z;
worldObj.spawnEntityInWorld(entityitem);
remove();
entityitem.delayBeforeCanPickup = 20;
return entityitem;
} else {
return null;
}
}
public void remove() {
if (allEntities.containsKey(entityId)) {
allEntities.remove(entityId);
}
}
public float getEntityBrightness(float f) {
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(posZ);
worldObj.getClass();
if (worldObj.blockExists(i, 128 / 2, j)) {
double d = 0.66000000000000003D;
int k = MathHelper.floor_double(posY + d);
return worldObj.getLightBrightness(i, k, j);
} else {
return 0.0F;
}
}
public boolean isCorrupted() {
return item == null || item.stackSize <= 0 || Item.itemsList[item.itemID] == null;
}
public void addContribution(String key, IPassiveItemContribution contribution) {
contributions.put(key, contribution);
}
public IPassiveItemContribution getContribution(String key) {
return contributions.get(key);
}
public boolean hasContributions() {
return contributions.size() > 0;
}
}

View file

@ -1,22 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api;
import net.minecraft.src.IBlockAccess;
public interface IBlockPipe {
/**
* With special kind of pipes, connectors texture has to vary (e.g. diamond
* or iron pipes.
*/
public void prepareTextureFor(IBlockAccess blockAccess, int i, int j, int k, Orientations connection);
}

View file

@ -34,14 +34,6 @@ public interface IPipe {
}
}
/**
* With special kind of pipes, connectors texture has to vary (e.g. diamond
* or iron pipes.
*/
public void prepareTextureFor(Orientations connection);
public void setDrawingState(DrawingState state);
public boolean isWired(WireColor color);
public boolean hasInterface();

View file

@ -9,12 +9,14 @@
package net.minecraft.src.buildcraft.api;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
/**
* Interface used to put objects into pipes, implemented by pipe tile entities.
*/
public interface IPipeEntry {
public void entityEntering(EntityPassiveItem item, Orientations orientation);
public void entityEntering(IPipedItem item, Orientations orientation);
public boolean acceptItems();
}

View file

@ -0,0 +1,101 @@
package net.minecraft.src.buildcraft.api.transport;
import net.minecraft.src.EntityItem;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.IPassiveItemContribution;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
public interface IPipedItem {
public abstract void remove();
/* GETTING & SETTING */
public abstract void setWorld(World world);
public abstract Position getPosition();
public abstract void setPosition(double x, double y, double z);
/**
* @return the speed
*/
public abstract float getSpeed();
/**
* @param speed the speed to set
*/
public abstract void setSpeed(float speed);
/**
* @return the item
*/
public abstract ItemStack getItemStack();
/**
* @param item the item to set
*/
public abstract void setItemStack(ItemStack item);
/**
* @return the container
*/
public abstract TileEntity getContainer();
/**
* @param container the container to set
*/
public abstract void setContainer(TileEntity container);
/**
* @return the synchroTracker
*/
public abstract SafeTimeTracker getSynchroTracker();
/**
* @param synchroTracker the synchroTracker to set
*/
public abstract void setSynchroTracker(SafeTimeTracker synchroTracker);
/**
* @return the deterministicRandomization
*/
public abstract int getDeterministicRandomization();
/**
* @param deterministicRandomization the deterministicRandomization to set
*/
public abstract void setDeterministicRandomization(int deterministicRandomization);
/**
* @return the entityId
*/
public abstract int getEntityId();
/**
* @param entityId the entityId to set
*/
public abstract void setEntityId(int entityId);
/* SAVING & LOADING */
public abstract void readFromNBT(NBTTagCompound nbttagcompound);
public abstract void writeToNBT(NBTTagCompound nbttagcompound);
public abstract EntityItem toEntityItem(Orientations dir);
public abstract float getEntityBrightness(float f);
public abstract boolean isCorrupted();
public abstract void addContribution(String key, IPassiveItemContribution contribution);
public abstract IPassiveItemContribution getContribution(String key);
public abstract boolean hasContributions();
}

View file

@ -22,7 +22,6 @@ public class DefaultProps {
public static String TEXTURE_PATH_ENTITIES = "/gfx/buildcraft/entities";
public static String TEXTURE_BLOCKS = TEXTURE_PATH_BLOCKS + "/blocks.png";
public static String TEXTURE_EXTERNAL = TEXTURE_PATH_BLOCKS + "/external.png";
public static String TEXTURE_ITEMS = "/gfx/buildcraft/items/items.png";
public static String TEXTURE_ICONS = TEXTURE_PATH_GUI + "/icons.png";
public static String TEXTURE_TRIGGERS = TEXTURE_PATH_GUI + "/triggers.png";
@ -50,6 +49,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;

View file

@ -0,0 +1,364 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.core;
import java.util.TreeMap;
import net.minecraft.src.EntityItem;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.MathHelper;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.IPassiveItemContribution;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
public class EntityPassiveItem implements IPipedItem {
private static TreeMap<String, IPassiveItemContribution> contributions = new TreeMap<String, IPassiveItemContribution>();
public static TreeMap<Integer, EntityPassiveItem> allEntities = new TreeMap<Integer, EntityPassiveItem>();
protected static int maxId = 0;
protected World worldObj;
protected float speed = 0.01F;
protected ItemStack item;
protected TileEntity container;
protected SafeTimeTracker synchroTracker = new SafeTimeTracker();
protected int deterministicRandomization = 0;
protected Position position;
protected int entityId;
/* CONSTRUCTORS */
public EntityPassiveItem(World world) {
this(world, maxId != Integer.MAX_VALUE ? ++maxId : (maxId = 0));
}
public EntityPassiveItem(World world, int id) {
setEntityId(id);
allEntities.put(getEntityId(), this);
worldObj = world;
}
public EntityPassiveItem(World world, double d, double d1, double d2) {
this(world);
position = new Position(d, d1, d2);
worldObj = world;
}
public EntityPassiveItem(World world, double d, double d1, double d2, ItemStack itemstack) {
this(world, d, d1, d2);
this.setItemStack(itemstack.copy());
}
/* CREATING & CACHING */
public static IPipedItem getOrCreate(World world, int id) {
if (allEntities.containsKey(id)) {
return allEntities.get(id);
} else {
return new EntityPassiveItem(world, id);
}
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#remove()
*/
@Override
public void remove() {
if (allEntities.containsKey(getEntityId())) {
allEntities.remove(getEntityId());
}
}
/* GETTING & SETTING */
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#setWorld(net.minecraft.src.World)
*/
@Override
public void setWorld(World world) {
worldObj = world;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#getPosition()
*/
@Override
public Position getPosition() {
return position;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#setPosition(double, double, double)
*/
@Override
public void setPosition(double x, double y, double z) {
position = new Position(x, y, z);
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#getSpeed()
*/
@Override
public float getSpeed() {
return speed;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#setSpeed(float)
*/
@Override
public void setSpeed(float speed) {
this.speed = speed;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#getItemStack()
*/
@Override
public ItemStack getItemStack() {
return item;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#setItemStack(net.minecraft.src.ItemStack)
*/
@Override
public void setItemStack(ItemStack item) {
this.item = item;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#getContainer()
*/
@Override
public TileEntity getContainer() {
return container;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#setContainer(net.minecraft.src.TileEntity)
*/
@Override
public void setContainer(TileEntity container) {
this.container = container;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#getSynchroTracker()
*/
@Override
public SafeTimeTracker getSynchroTracker() {
return synchroTracker;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#setSynchroTracker(net.minecraft.src.buildcraft.api.SafeTimeTracker)
*/
@Override
public void setSynchroTracker(SafeTimeTracker synchroTracker) {
this.synchroTracker = synchroTracker;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#getDeterministicRandomization()
*/
@Override
public int getDeterministicRandomization() {
return deterministicRandomization;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#setDeterministicRandomization(int)
*/
@Override
public void setDeterministicRandomization(int deterministicRandomization) {
this.deterministicRandomization = deterministicRandomization;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#getEntityId()
*/
@Override
public int getEntityId() {
return entityId;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#setEntityId(int)
*/
@Override
public void setEntityId(int entityId) {
this.entityId = entityId;
}
/* SAVING & LOADING */
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#readFromNBT(net.minecraft.src.NBTTagCompound)
*/
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
setPosition(nbttagcompound.getDouble("x"),
nbttagcompound.getDouble("y"),
nbttagcompound.getDouble("z"));
setSpeed(nbttagcompound.getFloat("speed"));
setItemStack(ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Item")));
NBTTagList contribList = nbttagcompound.getTagList("contribList");
for (int i = 0; i < contribList.tagCount(); ++i) {
NBTTagCompound cpt = (NBTTagCompound) contribList.tagAt(i);
String key = cpt.getString("key");
String className = cpt.getString("class");
if (getClass().getName().startsWith("net.minecraft.src")) {
className = "net.minecraft.src." + className;
}
try {
IPassiveItemContribution contrib = ((IPassiveItemContribution) Class.forName(className).newInstance());
contrib.readFromNBT(cpt);
contributions.put(key, contrib);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#writeToNBT(net.minecraft.src.NBTTagCompound)
*/
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setDouble("x", position.x);
nbttagcompound.setDouble("y", position.y);
nbttagcompound.setDouble("z", position.z);
nbttagcompound.setFloat("speed", getSpeed());
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
getItemStack().writeToNBT(nbttagcompound2);
nbttagcompound.setCompoundTag("Item", nbttagcompound2);
NBTTagList contribList = new NBTTagList();
for (String key : contributions.keySet()) {
IPassiveItemContribution contrib = contributions.get(key);
NBTTagCompound cpt = new NBTTagCompound();
contrib.writeToNBT(cpt);
cpt.setString("key", key);
String className = contrib.getClass().getName();
if (className.startsWith("net.minecraft.src.")) {
className = className.replace("net.minecraft.src.", "");
}
cpt.setString("class", className);
contribList.appendTag(cpt);
}
nbttagcompound.setTag("contribList", contribList);
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#toEntityItem(net.minecraft.src.buildcraft.api.Orientations)
*/
@Override
public EntityItem toEntityItem(Orientations dir) {
if (!APIProxy.isClient(worldObj)) {
if (getItemStack().stackSize <= 0) {
return null;
}
Position motion = new Position(0, 0, 0, dir);
motion.moveForwards(0.1 + getSpeed() * 2F);
EntityItem entityitem = new EntityItem(worldObj, position.x, position.y, position.z, getItemStack());
float f3 = 0.00F + worldObj.rand.nextFloat() * 0.04F - 0.02F;
entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3 + motion.x;
entityitem.motionY = (float) worldObj.rand.nextGaussian() * f3 + motion.y;
entityitem.motionZ = (float) worldObj.rand.nextGaussian() * f3 + +motion.z;
worldObj.spawnEntityInWorld(entityitem);
remove();
entityitem.delayBeforeCanPickup = 20;
return entityitem;
} else {
return null;
}
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#getEntityBrightness(float)
*/
@Override
public float getEntityBrightness(float f) {
int i = MathHelper.floor_double(position.x);
int j = MathHelper.floor_double(position.z);
worldObj.getClass();
if (worldObj.blockExists(i, 128 / 2, j)) {
double d = 0.66000000000000003D;
int k = MathHelper.floor_double(position.y + d);
return worldObj.getLightBrightness(i, k, j);
} else {
return 0.0F;
}
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#isCorrupted()
*/
@Override
public boolean isCorrupted() {
return getItemStack() == null || getItemStack().stackSize <= 0 || Item.itemsList[getItemStack().itemID] == null;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#addContribution(java.lang.String, net.minecraft.src.buildcraft.api.IPassiveItemContribution)
*/
@Override
public void addContribution(String key, IPassiveItemContribution contribution) {
contributions.put(key, contribution);
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#getContribution(java.lang.String)
*/
@Override
public IPassiveItemContribution getContribution(String key) {
return contributions.get(key);
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.IPipedItem#hasContributions()
*/
@Override
public boolean hasContributions() {
return contributions.size() > 0;
}
}

View file

@ -18,16 +18,11 @@ public class ItemBuildCraft extends Item implements ITextureProvider {
public ItemBuildCraft(int i) {
super(i);
setTextureFile(DefaultProps.TEXTURE_ITEMS);
}
// @Override Client side only
public String getItemDisplayName(ItemStack itemstack) {
return StringUtil.localize(getItemNameIS(itemstack));
}
@Override
public String getTextureFile() {
return DefaultProps.TEXTURE_ITEMS;
}
}

View file

@ -25,7 +25,6 @@ import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntityChest;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.IAreaProvider;
import net.minecraft.src.buildcraft.api.IPipeConnection;
import net.minecraft.src.buildcraft.api.IPipeEntry;
@ -33,6 +32,7 @@ import net.minecraft.src.buildcraft.api.LaserKind;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.liquids.ILiquid;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.network.ISynchronizedTile;
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
@ -120,7 +120,7 @@ public class Utils {
IPipeEntry pipeEntry = (IPipeEntry) w.getBlockTileEntity((int) pipePos.x, (int) pipePos.y, (int) pipePos.z);
EntityPassiveItem entity = new EntityPassiveItem(w, entityPos.x, entityPos.y, entityPos.z, items);
IPipedItem entity = new EntityPassiveItem(w, entityPos.x, entityPos.y, entityPos.z, items);
pipeEntry.entityEntering(entity, entityPos.orientation);
items.stackSize = 0;

View file

@ -5,6 +5,8 @@ public class PacketIds {
public static final int TILE_UPDATE = 0;
public static final int PIPE_DESCRIPTION = 1;
public static final int PIPE_CONTENTS = 2;
public static final int PIPE_LIQUID = 3;
public static final int PIPE_POWER = 4;
public static final int SELECTION_ASSEMBLY_GET = 20;
public static final int SELECTION_ASSEMBLY = 21;
public static final int DIAMOND_PIPE_CONTENTS = 30;

View file

@ -1,7 +1,7 @@
package net.minecraft.src.buildcraft.core.network;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
public class PacketPipeTransportContent extends PacketUpdate {
@ -9,7 +9,7 @@ public class PacketPipeTransportContent extends PacketUpdate {
super(PacketIds.PIPE_CONTENTS);
}
public PacketPipeTransportContent(int x, int y, int z, EntityPassiveItem item, Orientations orientation) {
public PacketPipeTransportContent(int x, int y, int z, IPipedItem item, Orientations orientation) {
this();
this.posX = x;
@ -18,17 +18,17 @@ public class PacketPipeTransportContent extends PacketUpdate {
this.payload = new PacketPayload(6, 4, 0);
payload.intPayload[0] = item.entityId;
payload.intPayload[0] = item.getEntityId();
payload.intPayload[1] = orientation.ordinal();
payload.intPayload[2] = item.item.itemID;
payload.intPayload[3] = item.item.stackSize;
payload.intPayload[4] = item.item.getItemDamage();
payload.intPayload[5] = item.deterministicRandomization;
payload.intPayload[2] = item.getItemStack().itemID;
payload.intPayload[3] = item.getItemStack().stackSize;
payload.intPayload[4] = item.getItemStack().getItemDamage();
payload.intPayload[5] = item.getDeterministicRandomization();
payload.floatPayload[0] = (float) item.posX;
payload.floatPayload[1] = (float) item.posY;
payload.floatPayload[2] = (float) item.posZ;
payload.floatPayload[3] = item.speed;
payload.floatPayload[0] = (float) item.getPosition().x;
payload.floatPayload[1] = (float) item.getPosition().y;
payload.floatPayload[2] = (float) item.getPosition().z;
payload.floatPayload[3] = item.getSpeed();
}
public int getEntityId() {

View file

@ -15,22 +15,18 @@ import java.util.Random;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.Block;
import net.minecraft.src.BuildCraftCore;
import net.minecraft.src.BuildCraftFactory;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.MovingObjectPosition;
import net.minecraft.src.Vec3D;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.IBlockPipe;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.IFramePipeConnection;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.forge.ITextureProvider;
public class BlockFrame extends Block implements IFramePipeConnection, IBlockPipe, ITextureProvider {
public class BlockFrame extends Block implements IFramePipeConnection, ITextureProvider {
public BlockFrame(int i) {
super(i, Material.glass);
@ -68,7 +64,7 @@ public class BlockFrame extends Block implements IFramePipeConnection, IBlockPip
@Override
public int getRenderType() {
return BuildCraftCore.pipeModel;
return BuildCraftCore.legacyPipeModel;
}
@Override
@ -195,12 +191,6 @@ public class BlockFrame extends Block implements IFramePipeConnection, IBlockPip
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public void prepareTextureFor(IBlockAccess blockAccess, int i, int j, int k, Orientations connection) {
// TODO Auto-generated method stub
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addCreativeItems(ArrayList itemList) {

View file

@ -16,14 +16,12 @@ import net.minecraft.src.Block;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.buildcraft.api.IBlockPipe;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.IFramePipeConnection;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.forge.ITextureProvider;
public class BlockPlainPipe extends Block implements IFramePipeConnection, IBlockPipe, ITextureProvider {
public class BlockPlainPipe extends Block implements IFramePipeConnection, ITextureProvider {
public BlockPlainPipe(int i) {
super(i, Material.glass);
@ -72,12 +70,6 @@ public class BlockPlainPipe extends Block implements IFramePipeConnection, IBloc
return 0.5F;
}
@Override
public void prepareTextureFor(IBlockAccess blockAccess, int i, int j, int k, Orientations connection) {
// TODO Auto-generated method stub
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addCreativeItems(ArrayList itemList) {

View file

@ -15,7 +15,6 @@ import java.util.TreeMap;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.BlockContainer;
import net.minecraft.src.BuildCraftCore;
import net.minecraft.src.BuildCraftTransport;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityPlayer;
@ -28,17 +27,14 @@ import net.minecraft.src.TileEntity;
import net.minecraft.src.Vec3D;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.IBlockPipe;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.tools.IToolWrench;
import net.minecraft.src.buildcraft.core.BlockIndex;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.forge.ITextureProvider;
public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITextureProvider {
public class BlockGenericPipe extends BlockContainer implements ITextureProvider {
/** Defined subprograms **************************************************/
@ -49,7 +45,7 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
@Override
public int getRenderType() {
return BuildCraftCore.pipeModel;
return BuildCraftTransport.pipeModel;
}
@Override
@ -254,10 +250,10 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
/** Wrappers *************************************************************/
@Override
public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
super.onNeighborBlockChange(world, i, j, k, l);
public void onNeighborBlockChange(World world, int x, int y, int z, int l) {
super.onNeighborBlockChange(world, x, y, z, l);
Pipe pipe = getPipe(world, i, j, k);
Pipe pipe = getPipe(world, x, y, z);
if (isValid(pipe))
pipe.container.scheduleNeighborChange();
@ -272,7 +268,7 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
if (isValid(pipe))
pipe.onBlockPlaced();
}
@Override
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
super.blockActivated(world, i, j, k, entityplayer);
@ -305,7 +301,8 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
if (!pipe.wireSet[IPipe.WireColor.Red.ordinal()]) {
pipe.wireSet[IPipe.WireColor.Red.ordinal()] = true;
entityplayer.getCurrentEquippedItem().splitStack(1);
world.markBlockNeedsUpdate(i, j, k);
pipe.container.scheduleRenderUpdate();
//world.markBlockNeedsUpdate(i, j, k);
return true;
}
@ -313,7 +310,8 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
if (!pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) {
pipe.wireSet[IPipe.WireColor.Blue.ordinal()] = true;
entityplayer.getCurrentEquippedItem().splitStack(1);
world.markBlockNeedsUpdate(i, j, k);
pipe.container.scheduleRenderUpdate();
//world.markBlockNeedsUpdate(i, j, k);
return true;
}
@ -321,7 +319,8 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
if (!pipe.wireSet[IPipe.WireColor.Green.ordinal()]) {
pipe.wireSet[IPipe.WireColor.Green.ordinal()] = true;
entityplayer.getCurrentEquippedItem().splitStack(1);
world.markBlockNeedsUpdate(i, j, k);
pipe.container.scheduleRenderUpdate();
//world.markBlockNeedsUpdate(i, j, k);
return true;
}
@ -329,7 +328,8 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
if (!pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) {
pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] = true;
entityplayer.getCurrentEquippedItem().splitStack(1);
world.markBlockNeedsUpdate(i, j, k);
pipe.container.scheduleRenderUpdate();
//world.markBlockNeedsUpdate(i, j, k);
return true;
}
@ -339,7 +339,8 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
pipe.gate = new GateVanilla(pipe, entityplayer.getCurrentEquippedItem());
entityplayer.getCurrentEquippedItem().splitStack(1);
world.markBlockNeedsUpdate(i, j, k);
pipe.container.scheduleRenderUpdate();
//world.markBlockNeedsUpdate(i, j, k);
return true;
}
@ -363,7 +364,8 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
if (!APIProxy.isRemote())
dropWire(color.reverse(), pipe.worldObj, pipe.xCoord, pipe.yCoord, pipe.zCoord);
pipe.wireSet[color.reverse().ordinal()] = false;
pipe.worldObj.markBlockNeedsUpdate(pipe.xCoord, pipe.yCoord, pipe.zCoord);
//pipe.worldObj.markBlockNeedsUpdate(pipe.xCoord, pipe.yCoord, pipe.zCoord);
pipe.container.scheduleRenderUpdate();
return true;
}
@ -403,28 +405,26 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
}
@Override
public void prepareTextureFor(IBlockAccess blockAccess, int i, int j, int k, Orientations connection) {
Pipe pipe = getPipe(blockAccess, i, j, k);
if (isValid(pipe))
pipe.prepareTextureFor(connection);
}
@SuppressWarnings({ "all" })
public int getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) {
Pipe pipe = getPipe(iblockaccess, i, j, k);
if (!isValid(pipe)) {
CoreProxy.BindTexture(DefaultProps.TEXTURE_BLOCKS);
return 0;
}
int pipeTexture = pipe.getPipeTexture();
if (pipeTexture > 255) {
CoreProxy.BindTexture(DefaultProps.TEXTURE_EXTERNAL);
return pipeTexture - 256;
}
CoreProxy.BindTexture(DefaultProps.TEXTURE_BLOCKS);
return pipeTexture;
TileEntity tile = iblockaccess.getBlockTileEntity(i, j, k);
if (!(tile instanceof IPipeRenderState)) return 0;
return ((IPipeRenderState)tile).getRenderState().currentTextureIndex;
// Pipe pipe = getPipe(iblockaccess, i, j, k);
// if (!isValid(pipe)) {
// CoreProxy.BindTexture(DefaultProps.TEXTURE_BLOCKS);
// return 0;
// }
// int pipeTexture = pipe.getPipeTexture();
// if (pipeTexture > 255) {
// CoreProxy.BindTexture(DefaultProps.TEXTURE_EXTERNAL);
// return pipeTexture - 256;
// }
// CoreProxy.BindTexture(DefaultProps.TEXTURE_BLOCKS);
// return pipeTexture;
}
@Override
@ -478,11 +478,17 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
static long lastRemovedDate = -1;
public static TreeMap<BlockIndex, Pipe> pipeRemoved = new TreeMap<BlockIndex, Pipe>();
public static Item registerPipe(int key, Class<? extends Pipe> clas) {
Item item = new ItemPipe(key);
public static ItemPipe registerPipe(int key, Class<? extends Pipe> clas) {
ItemPipe item = new ItemPipe(key);
pipes.put(item.shiftedIndex, clas);
Pipe dummyPipe = createPipe(item.shiftedIndex);
if (dummyPipe != null){
item.setTextureFile(dummyPipe.getTextureFile());
item.setTextureIndex(dummyPipe.getTextureIndexForItem());
}
return item;
}
@ -504,6 +510,7 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
}
public static boolean placePipe(Pipe pipe, World world, int i, int j, int k, int blockId, int meta) {
if (world.isRemote) return true;
boolean placed = world.setBlockAndMetadataWithNotify(i, j, k, blockId, meta);

View file

@ -20,6 +20,7 @@ public class EnergyPulser {
}
public void update() {
if (powerReceptor == null) return;
// Set current pulse speed
pulseSpeed = getPulseSpeed();

View file

@ -1,17 +1,17 @@
package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
public class EntityData {
// TODO: Move passive data here too, like position, speed and all?
boolean toCenter = true;
public EntityPassiveItem item;
public IPipedItem item;
public Orientations orientation;
public EntityData(EntityPassiveItem citem, Orientations orientation) {
public EntityData(IPipedItem citem, Orientations orientation) {
item = citem;
this.orientation = orientation;

View file

@ -97,9 +97,10 @@ public class GateVanilla extends Gate {
return "Golden OR Gate";
case OR_4:
return "Diamond OR Gate";
default:
return "";
}
return "";
}
@Override
@ -119,9 +120,10 @@ public class GateVanilla extends Gate {
* @return
*/
private boolean addEnergyPulser(Pipe pipe) {
if (!(pipe instanceof IPowerReceptor))
if (!(pipe instanceof IPowerReceptor)){
pulser = new EnergyPulser(null);
return false;
}
pulser = new EnergyPulser((IPowerReceptor) pipe);
return true;

View file

@ -0,0 +1,5 @@
package net.minecraft.src.buildcraft.transport;
public interface IPipeRenderState {
public PipeRenderState getRenderState();
}

View file

@ -11,16 +11,16 @@ package net.minecraft.src.buildcraft.transport;
import java.util.LinkedList;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
public interface IPipeTransportItemsHook {
public LinkedList<Orientations> filterPossibleMovements(LinkedList<Orientations> possibleOrientations, Position pos,
EntityPassiveItem item);
IPipedItem item);
public void entityEntered(EntityPassiveItem item, Orientations orientation);
public void entityEntered(IPipedItem item, Orientations orientation);
public void readjustSpeed(EntityPassiveItem item);
public void readjustSpeed(IPipedItem item);
}

View file

@ -0,0 +1,203 @@
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.BuildCraftCore;
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.api.recipes.AssemblyRecipe;
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 onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side) {
if (worldObj.isRemote) return false;
TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
if (!(tile instanceof TileGenericPipe)) return false;
TileGenericPipe pipeTile = (TileGenericPipe)tile;
if (player.isSneaking()) { //Strip facade
if (!pipeTile.hasFacade(Orientations.dirs()[side])) return false;
pipeTile.dropFacade(Orientations.dirs()[side]);
return true;
} else {
if (((TileGenericPipe)tile).addFacade(Orientations.values()[side], ItemFacade.getBlockId(stack.getItemDamage()), ItemFacade.getMetaData(stack.getItemDamage()))){
stack.stackSize--;
return true;
}
return false;
}
}
@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())));
//3 Structurepipes + this block makes 6 facades
AssemblyRecipe.assemblyRecipes.add(
new AssemblyRecipe(
new ItemStack[] {new ItemStack(BuildCraftTransport.pipeStructureCobblestone, 3), new ItemStack(blockId, 1, stack.getItemDamage())},
8000,
new ItemStack(BuildCraftTransport.facadeItem, 6, 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;
}
}

View file

@ -14,13 +14,14 @@ import net.minecraft.src.BuildCraftTransport;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.IItemPipe;
import net.minecraft.src.buildcraft.core.ItemBuildCraft;
public class ItemPipe extends ItemBuildCraft implements IItemPipe {
Pipe dummyPipe;
private int textureIndex = 0;
protected ItemPipe(int i) {
super(i);
@ -69,19 +70,13 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
return false;
}
@Override
public String getTextureFile() {
if (getTextureIndex() > 255) {
return DefaultProps.TEXTURE_EXTERNAL;
}
return DefaultProps.TEXTURE_BLOCKS;
public ItemPipe setTextureIndex(int textureIndex){
this.textureIndex = textureIndex;
return this;
}
public int getTextureIndex() {
if (dummyPipe == null)
dummyPipe = BlockGenericPipe.createPipe(shiftedIndex);
return dummyPipe.getPipeTexture();
return textureIndex;
}
}

View file

@ -22,6 +22,8 @@ import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
@ -43,7 +45,7 @@ import net.minecraft.src.buildcraft.core.network.TileNetworkData;
import net.minecraft.src.buildcraft.core.network.TilePacketWrapper;
import net.minecraft.src.buildcraft.transport.Gate.GateConditional;
public class Pipe implements IPipe, IDropControlInventory {
public abstract class Pipe implements IPipe, IDropControlInventory {
public int[] signalStrength = new int[] { 0, 0, 0, 0 };
@ -141,52 +143,28 @@ public class Pipe implements IPipe, IDropControlInventory {
return logic.isPipeConnected(tile) && transport.isPipeConnected(tile);
}
public final int getPipeTexture() {
if (drawingState == DrawingState.DrawingPipe)
return getMainBlockTexture();
else if (drawingState == DrawingState.DrawingRedWire) {
if (signalStrength[IPipe.WireColor.Red.ordinal()] > 0)
return 6;
else
return 5;
} else if (drawingState == DrawingState.DrawingBlueWire) {
if (signalStrength[IPipe.WireColor.Blue.ordinal()] > 0)
return 8;
else
return 7;
} else if (drawingState == DrawingState.DrawingGreenWire) {
if (signalStrength[IPipe.WireColor.Green.ordinal()] > 0)
return 10;
else
return 9;
} else if (drawingState == DrawingState.DrawingYellowWire) {
if (signalStrength[IPipe.WireColor.Yellow.ordinal()] > 0)
return 12;
else
return 11;
} else if (drawingState == DrawingState.DrawingGate) {
boolean activeSignal = false;
/**
* Should return the texture file that is used to render this pipe
*/
public abstract String getTextureFile();
for (boolean b : broadcastSignal)
if (b)
activeSignal = true;
return gate.getTexture(activeSignal || broadcastRedstone);
}
return getPipeTexture();
/**
* Should return the textureindex in the file specified by getTextureFile()
* @param direction The orientation for the texture that is requested. Unknown for the center pipe center
* @return the index in the texture sheet
*/
public abstract int getTextureIndex(Orientations direction);
/**
* Should return the textureindex used by the Pipe Item Renderer, as this is done client-side the default implementation might
* not work if your getTextureIndex(Orienations.Unknown) has logic
* @return
*/
public int getTextureIndexForItem(){
return getTextureIndex(Orientations.Unknown);
}
public int getMainBlockTexture() {
return 1 * 16 + 0;
}
@Override
public void prepareTextureFor(Orientations connection) {
}
public void updateEntity() {
transport.updateEntity();
@ -197,6 +175,10 @@ public class Pipe implements IPipe, IDropControlInventory {
internalUpdateScheduled = false;
}
// Do not try to update gates client side.
if(APIProxy.isRemote())
return;
if (actionTracker.markTimeIfDelay(worldObj, 10))
resolveActions();
@ -298,7 +280,9 @@ public class Pipe implements IPipe, IDropControlInventory {
if (!foundBiggerSignal && signalStrength[color.ordinal()] != 0) {
signalStrength[color.ordinal()] = 0;
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
//worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
container.scheduleRenderUpdate();
for (Orientations o : Orientations.dirs()) {
TileEntity tile = container.getTile(o);
@ -355,8 +339,11 @@ public class Pipe implements IPipe, IDropControlInventory {
signalStrength[color.ordinal()] = signal;
internalUpdateScheduled = true;
if (oldSignal == 0)
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
if (oldSignal == 0) {
//worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
container.scheduleRenderUpdate();
}
return true;
} else
@ -435,13 +422,6 @@ public class Pipe implements IPipe, IDropControlInventory {
public void randomDisplayTick(Random random) {}
private DrawingState drawingState = DrawingState.DrawingPipe;
@Override
public void setDrawingState(DrawingState state) {
drawingState = state;
}
// / @Override TODO: should be in IPipe
public boolean isWired() {
for (WireColor color : WireColor.values())
@ -480,6 +460,12 @@ public class Pipe implements IPipe, IDropControlInventory {
if (hasGate())
gate.dropGate(worldObj, xCoord, yCoord, zCoord);
for (Orientations direction : Orientations.dirs()){
if (container.hasFacade(direction)){
container.dropFacade(direction);
}
}
}
public void setTrigger(int position, ITrigger trigger) {
@ -540,8 +526,9 @@ public class Pipe implements IPipe, IDropControlInventory {
activatedActions = new Action[activatedActions.length];
broadcastSignal = new boolean[] { false, false, false, false };
broadcastRedstone = false;
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID);
//worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
container.scheduleRenderUpdate();
//worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID);
}
private void resolveActions() {
@ -597,13 +584,15 @@ public class Pipe implements IPipe, IDropControlInventory {
actionsActivated(actions);
if (oldBroadcastRedstone != broadcastRedstone) {
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
container.scheduleRenderUpdate();
//worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID);
}
for (int i = 0; i < oldBroadcastSignal.length; ++i)
if (oldBroadcastSignal[i] != broadcastSignal[i]) {
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
//worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
container.scheduleRenderUpdate();
updateSignalState();
break;
}
@ -670,6 +659,14 @@ public class Pipe implements IPipe, IDropControlInventory {
public boolean doDrop() {
return logic.doDrop();
}
public boolean isGateActive(){
for (boolean b : broadcastSignal){
if (b) return true;
}
return broadcastRedstone;
}
/**
* Called when TileGenericPipe.invalidate() is called

View file

@ -14,8 +14,6 @@ import net.minecraft.src.BuildCraftCore;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.Packet;
import net.minecraft.src.mod_BuildCraftTransport;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.Orientations;
@ -26,9 +24,6 @@ import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.GuiIds;
import net.minecraft.src.buildcraft.core.network.PacketIds;
import net.minecraft.src.buildcraft.core.network.PacketNBT;
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
import net.minecraft.src.buildcraft.core.network.TileNetworkData;
import net.minecraft.src.buildcraft.core.network.TilePacketWrapper;
import net.minecraft.src.buildcraft.core.utils.SimpleInventory;
public class PipeLogicDiamond extends PipeLogic implements ISpecialInventory {

View file

@ -53,6 +53,7 @@ public class PipeLogicIron extends PipeLogic {
|| tile instanceof TileGenericPipe) {
worldObj.setBlockMetadata(xCoord, yCoord, zCoord, nextMetadata);
container.scheduleRenderUpdate();
return;
}
}

View file

@ -46,7 +46,8 @@ public class PipeLogicWood extends PipeLogic {
if (newMeta != meta) {
worldObj.setBlockMetadata(xCoord, yCoord, zCoord, newMeta);
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
container.scheduleRenderUpdate();
//worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
}

View file

@ -0,0 +1,109 @@
package net.minecraft.src.buildcraft.transport;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
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;
public class PipeRenderState {
private String textureFile = DefaultProps.TEXTURE_BLOCKS;
private boolean hasGate = false;
private int gateTextureIndex = 0;
public final ConnectionMatrix pipeConnectionMatrix = new ConnectionMatrix();
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 */
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){
if (this.textureFile != textureFile){
this.textureFile = textureFile;
this.dirty = true;
}
}
public String getTextureFile(){
return this.textureFile;
}
public void setHasGate(boolean value){
if (hasGate != value){
hasGate = value;
dirty = true;
}
}
public boolean hasGate(){
return hasGate;
}
public void setGateTexture(int value){
if (gateTextureIndex != value){
gateTextureIndex = value;
dirty = true;
}
}
public int getGateTextureIndex(){
return gateTextureIndex;
}
public void clean(){
dirty = false;
pipeConnectionMatrix.clean();
textureMatrix.clean();
wireMatrix.clean();
facadeMatrix.clean();
}
public boolean isDirty(){
return dirty || pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || wireMatrix.isDirty() || facadeMatrix.isDirty();
}
public void writeData(DataOutputStream data) throws IOException {
data.writeUTF(textureFile);
data.writeBoolean(hasGate);
data.writeInt(gateTextureIndex);
pipeConnectionMatrix.writeData(data);
textureMatrix.writeData(data);
wireMatrix.writeData(data);
facadeMatrix.writeData(data);
}
public void readData(DataInputStream data) throws IOException {
textureFile = data.readUTF();
hasGate = data.readBoolean();
gateTextureIndex = data.readInt();
pipeConnectionMatrix.readData(data);
textureMatrix.readData(data);
wireMatrix.readData(data);
facadeMatrix.readData(data);
}
}

View file

@ -12,8 +12,8 @@ package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
public abstract class PipeTransport {
@ -77,7 +77,7 @@ public abstract class PipeTransport {
return false;
}
public void entityEntering(EntityPassiveItem item, Orientations orientation) {
public void entityEntering(IPipedItem item, Orientations orientation) {
}

View file

@ -26,13 +26,14 @@ import net.minecraft.src.Packet;
import net.minecraft.src.TileEntity;
import net.minecraft.src.mod_BuildCraftTransport;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.IPipeEntry;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.gates.ITrigger;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.EntityPassiveItem;
import net.minecraft.src.buildcraft.core.IMachine;
import net.minecraft.src.buildcraft.core.StackUtil;
import net.minecraft.src.buildcraft.core.Utils;
@ -48,24 +49,24 @@ public class PipeTransportItems extends PipeTransport {
// TODO: generalize the use of this hook in particular for obsidian pipe
public IItemTravelingHook travelHook;
public void readjustSpeed(EntityPassiveItem item) {
public void readjustSpeed(IPipedItem item) {
if (container.pipe instanceof IPipeTransportItemsHook)
((IPipeTransportItemsHook) container.pipe).readjustSpeed(item);
else
defaultReajustSpeed(item);
}
public void defaultReajustSpeed(EntityPassiveItem item) {
public void defaultReajustSpeed(IPipedItem item) {
if (item.speed > Utils.pipeNormalSpeed)
item.speed = item.speed - Utils.pipeNormalSpeed;
if (item.getSpeed() > Utils.pipeNormalSpeed)
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed);
if (item.speed < Utils.pipeNormalSpeed)
item.speed = Utils.pipeNormalSpeed;
if (item.getSpeed() < Utils.pipeNormalSpeed)
item.setSpeed(Utils.pipeNormalSpeed);
}
@Override
public void entityEntering(EntityPassiveItem item, Orientations orientation) {
public void entityEntering(IPipedItem item, Orientations orientation) {
if (item.isCorrupted())
// Safe guard - if for any reason the item is corrupted at this
// stage, avoid adding it to the pipe to avoid further exceptions.
@ -73,25 +74,25 @@ public class PipeTransportItems extends PipeTransport {
readjustSpeed(item);
if (!travelingEntities.containsKey(new Integer(item.entityId))) {
travelingEntities.put(new Integer(item.entityId), new EntityData(item, orientation));
if (!travelingEntities.containsKey(new Integer(item.getEntityId()))) {
travelingEntities.put(new Integer(item.getEntityId()), new EntityData(item, orientation));
if (item.container != null && item.container != this.container)
((PipeTransportItems) ((TileGenericPipe) item.container).pipe.transport).scheduleRemoval(item);
if (item.getContainer() != null && item.getContainer() != this.container)
((PipeTransportItems) ((TileGenericPipe) item.getContainer()).pipe.transport).scheduleRemoval(item);
item.container = container;
item.setContainer(container);
}
// Reajusting Ypos to make sure the object looks like sitting on the
// pipe.
if (orientation != Orientations.YPos && orientation != Orientations.YNeg)
item.setPosition(item.posX, yCoord + Utils.getPipeFloorOf(item.item), item.posZ);
item.setPosition(item.getPosition().x, yCoord + Utils.getPipeFloorOf(item.getItemStack()), item.getPosition().z);
if (container.pipe instanceof IPipeTransportItemsHook)
((IPipeTransportItemsHook) container.pipe).entityEntered(item, orientation);
if (APIProxy.isServerSide())
if (item.synchroTracker.markTimeIfDelay(worldObj, 6 * BuildCraftCore.updateFactor))
if (item.getSynchroTracker().markTimeIfDelay(worldObj, 6 * BuildCraftCore.updateFactor))
CoreProxy.sendToPlayers(createItemPacket(item, orientation), worldObj, xCoord, yCoord, zCoord,
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftTransport.instance);
@ -107,7 +108,7 @@ public class PipeTransportItems extends PipeTransport {
* Returns a list of all possible movements, that is to say adjacent
* implementers of IPipeEntry or TileEntityChest.
*/
public LinkedList<Orientations> getPossibleMovements(Position pos, EntityPassiveItem item) {
public LinkedList<Orientations> getPossibleMovements(Position pos, IPipedItem item) {
LinkedList<Orientations> result = new LinkedList<Orientations>();
for (Orientations o : Orientations.dirs())
@ -130,7 +131,7 @@ public class PipeTransportItems extends PipeTransport {
return result;
}
public boolean canReceivePipeObjects(Orientations o, EntityPassiveItem item) {
public boolean canReceivePipeObjects(Orientations o, IPipedItem item) {
TileEntity entity = container.getTile(o);
if (!Utils.checkPipesConnections(entity, container))
@ -143,7 +144,7 @@ public class PipeTransportItems extends PipeTransport {
return pipe.pipe.transport instanceof PipeTransportItems;
} else if (entity instanceof IInventory)
if (new StackUtil(item.item).checkAvailableSlot((IInventory) entity, false, o.reverse()))
if (new StackUtil(item.getItemStack()).checkAvailableSlot((IInventory) entity, false, o.reverse()))
return true;
return false;
@ -156,9 +157,9 @@ public class PipeTransportItems extends PipeTransport {
HashSet<Integer> toRemove = new HashSet<Integer>();
public void scheduleRemoval(EntityPassiveItem item) {
if (!toRemove.contains(item.entityId))
toRemove.add(item.entityId);
public void scheduleRemoval(IPipedItem item) {
if (!toRemove.contains(item.getEntityId()))
toRemove.add(item.getEntityId());
}
public void performRemoval() {
@ -169,7 +170,7 @@ public class PipeTransportItems extends PipeTransport {
private void moveSolids() {
for (EntityData data : entitiesToLoad) {
data.item.setWorld(worldObj);
travelingEntities.put(new Integer(data.item.entityId), data);
travelingEntities.put(new Integer(data.item.getEntityId()), data);
}
entitiesToLoad.clear();
@ -183,16 +184,16 @@ public class PipeTransportItems extends PipeTransport {
}
Position motion = new Position(0, 0, 0, data.orientation);
motion.moveForwards(data.item.speed);
motion.moveForwards(data.item.getSpeed());
data.item.setPosition(data.item.posX + motion.x, data.item.posY + motion.y, data.item.posZ + motion.z);
data.item.setPosition(data.item.getPosition().x + motion.x, data.item.getPosition().y + motion.y, data.item.getPosition().z + motion.z);
if ((data.toCenter && middleReached(data)) || outOfBounds(data)) {
data.toCenter = false;
// Reajusting to the middle
data.item.setPosition(xCoord + 0.5, yCoord + Utils.getPipeFloorOf(data.item.item), zCoord + +0.5);
data.item.setPosition(xCoord + 0.5, yCoord + Utils.getPipeFloorOf(data.item.getItemStack()), zCoord + +0.5);
Orientations nextOrientation = resolveDestination(data);
@ -202,7 +203,7 @@ public class PipeTransportItems extends PipeTransport {
EntityItem dropped = null;
if (!toRemove.contains(data.item.entityId))
if (!toRemove.contains(data.item.getEntityId()))
dropped = data.item.toEntityItem(data.orientation);
scheduleRemoval(data.item);
@ -227,7 +228,7 @@ public class PipeTransportItems extends PipeTransport {
travelHook.endReached(this, data, tile);
// If the item has not been scheduled to removal by the hook
if (!toRemove.contains(data.item.entityId)) {
if (!toRemove.contains(data.item.getEntityId())) {
scheduleRemoval(data.item);
handleTileReached(data, tile);
}
@ -246,13 +247,13 @@ public class PipeTransportItems extends PipeTransport {
((PipeTransportItems) pipe.pipe.transport).entityEntering(data.item, data.orientation);
} else if (tile instanceof IInventory) {
StackUtil utils = new StackUtil(data.item.item);
StackUtil utils = new StackUtil(data.item.getItemStack());
if (!APIProxy.isClient(worldObj))
if (utils.checkAvailableSlot((IInventory) tile, true, data.orientation.reverse()) && utils.items.stackSize == 0)
data.item.remove();
else {
data.item.item = utils.items;
data.item.setItemStack(utils.items);
EntityItem dropped = data.item.toEntityItem(data.orientation);
if (dropped != null)
@ -274,20 +275,20 @@ public class PipeTransportItems extends PipeTransport {
}
public boolean middleReached(EntityData entity) {
float middleLimit = entity.item.speed * 1.01F;
return (Math.abs(xCoord + 0.5 - entity.item.posX) < middleLimit
&& Math.abs(yCoord + Utils.getPipeFloorOf(entity.item.item) - entity.item.posY) < middleLimit && Math.abs(zCoord
+ 0.5 - entity.item.posZ) < middleLimit);
float middleLimit = entity.item.getSpeed() * 1.01F;
return (Math.abs(xCoord + 0.5 - entity.item.getPosition().x) < middleLimit
&& Math.abs(yCoord + Utils.getPipeFloorOf(entity.item.getItemStack()) - entity.item.getPosition().y) < middleLimit && Math.abs(zCoord
+ 0.5 - entity.item.getPosition().z) < middleLimit);
}
public boolean endReached(EntityData entity) {
return entity.item.posX > xCoord + 1.0 || entity.item.posX < xCoord || entity.item.posY > yCoord + 1.0
|| entity.item.posY < yCoord || entity.item.posZ > zCoord + 1.0 || entity.item.posZ < zCoord;
return entity.item.getPosition().x > xCoord + 1.0 || entity.item.getPosition().x < xCoord || entity.item.getPosition().y > yCoord + 1.0
|| entity.item.getPosition().y < yCoord || entity.item.getPosition().z > zCoord + 1.0 || entity.item.getPosition().z < zCoord;
}
public boolean outOfBounds(EntityData entity) {
return entity.item.posX > xCoord + 2.0 || entity.item.posX < xCoord - 1.0 || entity.item.posY > yCoord + 2.0
|| entity.item.posY < yCoord - 1.0 || entity.item.posZ > zCoord + 2.0 || entity.item.posZ < zCoord - 1.0;
return entity.item.getPosition().x > xCoord + 2.0 || entity.item.getPosition().x < xCoord - 1.0 || entity.item.getPosition().y > yCoord + 2.0
|| entity.item.getPosition().y < yCoord - 1.0 || entity.item.getPosition().z > zCoord + 2.0 || entity.item.getPosition().z < zCoord - 1.0;
}
public Position getPosition() {
@ -304,7 +305,7 @@ public class PipeTransportItems extends PipeTransport {
try {
NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist.tagAt(j);
EntityPassiveItem entity = new EntityPassiveItem(null);
IPipedItem entity = new EntityPassiveItem(null);
entity.readFromNBT(nbttagcompound2);
if (entity.isCorrupted()) {
@ -312,7 +313,7 @@ public class PipeTransportItems extends PipeTransport {
continue;
}
entity.container = container;
entity.setContainer(container);
EntityData data = new EntityData(entity, Orientations.values()[nbttagcompound2.getInteger("orientation")]);
data.toCenter = nbttagcompound2.getBoolean("toCenter");
@ -353,9 +354,9 @@ public class PipeTransportItems extends PipeTransport {
if (APIProxy.isClient(worldObj) || APIProxy.isServerSide())
{
i = Math.abs(data.item.entityId + xCoord + yCoord + zCoord + data.item.deterministicRandomization)
i = Math.abs(data.item.getEntityId() + xCoord + yCoord + zCoord + data.item.getDeterministicRandomization())
% listOfPossibleMovements.size();
data.item.deterministicRandomization*=11;
data.item.setDeterministicRandomization(data.item.getDeterministicRandomization() * 11);
}
else
@ -377,24 +378,24 @@ public class PipeTransportItems extends PipeTransport {
if (packet.getID() != PacketIds.PIPE_CONTENTS)
return;
EntityPassiveItem item = EntityPassiveItem.getOrCreate(worldObj, packet.getEntityId());
IPipedItem item = EntityPassiveItem.getOrCreate(worldObj, packet.getEntityId());
item.item = new ItemStack(packet.getItemId(), packet.getStackSize(), packet.getItemDamage());
item.setItemStack(new ItemStack(packet.getItemId(), packet.getStackSize(), packet.getItemDamage()));
item.setPosition(packet.getPosX(), packet.getPosY(), packet.getPosZ());
item.speed = packet.getSpeed();
item.deterministicRandomization = packet.getRandomization();
item.setSpeed(packet.getSpeed());
item.setDeterministicRandomization(packet.getRandomization());
if (item.container != this.container || !travelingEntities.containsKey(item.entityId)) {
if (item.getContainer() != this.container || !travelingEntities.containsKey(item.getEntityId())) {
if (item.container != null)
((PipeTransportItems) ((TileGenericPipe) item.container).pipe.transport).scheduleRemoval(item);
if (item.getContainer() != null)
((PipeTransportItems) ((TileGenericPipe) item.getContainer()).pipe.transport).scheduleRemoval(item);
travelingEntities.put(new Integer(item.entityId), new EntityData(item, packet.getOrientation()));
item.container = container;
travelingEntities.put(new Integer(item.getEntityId()), new EntityData(item, packet.getOrientation()));
item.setContainer(container);
} else
travelingEntities.get(new Integer(item.entityId)).orientation = packet.getOrientation();
travelingEntities.get(new Integer(item.getEntityId())).orientation = packet.getOrientation();
}
@ -405,9 +406,9 @@ public class PipeTransportItems extends PipeTransport {
* @param orientation
* @return
*/
public Packet createItemPacket(EntityPassiveItem item, Orientations orientation) {
public Packet createItemPacket(IPipedItem item, Orientations orientation) {
item.deterministicRandomization += worldObj.rand.nextInt(6);
item.setDeterministicRandomization(item.getDeterministicRandomization() + worldObj.rand.nextInt(6));
PacketPipeTransportContent packet = new PacketPipeTransportContent(container.xCoord, container.yCoord, container.zCoord,
item, orientation);
@ -456,14 +457,14 @@ public class PipeTransportItems extends PipeTransport {
for (int j = i + 1; j < entities.length; ++j) {
EntityData data2 = entities[j];
if (data1.item.item.itemID == data2.item.item.itemID
&& data1.item.item.getItemDamage() == data2.item.item.getItemDamage()
&& !toRemove.contains(data1.item.entityId) && !toRemove.contains(data2.item.entityId)
if (data1.item.getItemStack().itemID == data2.item.getItemStack().itemID
&& data1.item.getItemStack().getItemDamage() == data2.item.getItemStack().getItemDamage()
&& !toRemove.contains(data1.item.getEntityId()) && !toRemove.contains(data2.item.getEntityId())
&& !data1.item.hasContributions() && !data2.item.hasContributions()
&& data1.item.item.stackSize + data2.item.item.stackSize < data1.item.item.getMaxStackSize()) {
&& data1.item.getItemStack().stackSize + data2.item.getItemStack().stackSize < data1.item.getItemStack().getMaxStackSize()) {
data1.item.item.stackSize += data2.item.item.stackSize;
toRemove.add(data2.item.entityId);
data1.item.getItemStack().stackSize += data2.item.getItemStack().stackSize;
toRemove.add(data2.item.getEntityId());
}
}
}
@ -479,7 +480,7 @@ public class PipeTransportItems extends PipeTransport {
groupEntities();
for (EntityData data : travelingEntities.values())
Utils.dropItems(worldObj, data.item.item, xCoord, yCoord, zCoord);
Utils.dropItems(worldObj, data.item.getItemStack(), xCoord, yCoord, zCoord);
travelingEntities.clear();
}

View file

@ -12,17 +12,23 @@ package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.BuildCraftCore;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraft.src.mod_BuildCraftCore;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.IPipeEntry;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
import net.minecraft.src.buildcraft.api.gates.ITrigger;
import net.minecraft.src.buildcraft.api.liquids.ILiquidTank;
import net.minecraft.src.buildcraft.api.liquids.ITankContainer;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.api.liquids.LiquidTank;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.IMachine;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.transport.network.PacketLiquidUpdate;
import net.minecraft.src.buildcraft.transport.network.PacketPowerUpdate;
public class PipeTransportLiquids extends PipeTransport implements ITankContainer {
@ -130,7 +136,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
public short travelDelay = 12;
public short flowRate = 20;
public final LiquidStack[] renderCache = new LiquidStack[Orientations.values().length];
public LiquidStack[] renderCache = new LiquidStack[Orientations.values().length];
private final PipeSection[] internalTanks = new PipeSection[Orientations.values().length];
@ -140,6 +146,8 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
private final short[] outputTTL = new short[] { OUTPUT_TTL, OUTPUT_TTL, OUTPUT_TTL, OUTPUT_TTL, OUTPUT_TTL, OUTPUT_TTL };
private final short[] outputCooldown = new short[] {0, 0, 0, 0, 0, 0 };
private final SafeTimeTracker tracker = new SafeTimeTracker();
public PipeTransportLiquids() {
for (Orientations direction : Orientations.values()) {
@ -204,7 +212,17 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
// }
}
this.container.synchronizeIfDelay(1 * BuildCraftCore.updateFactor);
if (APIProxy.isServerSide())
if (tracker.markTimeIfDelay(worldObj, 1 * BuildCraftCore.updateFactor)){
PacketLiquidUpdate packet = new PacketLiquidUpdate(xCoord, yCoord, zCoord);
packet.displayLiquid = this.renderCache;
CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
}
//this.container.synchronizeIfDelay(1 * BuildCraftCore.updateFactor);
}
@Override
@ -416,6 +434,11 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
return with instanceof PipeTransportLiquids;
}
public void handleLiquidPacket(PacketLiquidUpdate packetLiquid) {
this.renderCache = packetLiquid.displayLiquid;
}
/** ITankContainer implementation **/
@Override

View file

@ -23,8 +23,12 @@ import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.IMachine;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.core.network.TileNetworkData;
import net.minecraft.src.buildcraft.transport.network.PacketPowerUpdate;
public class PipeTransportPower extends PipeTransport {
@TileNetworkData(staticSize = 6)
public short[] displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
public int[] powerQuery = new int[6];
public int[] nextPowerQuery = new int[6];
@ -33,9 +37,6 @@ public class PipeTransportPower extends PipeTransport {
public double[] internalPower = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
public double[] internalNextPower = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
@TileNetworkData(staticSize = 6)
public short[] displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
public double powerResitance = 0.01;
public PipeTransportPower() {
@ -151,9 +152,13 @@ public class PipeTransportPower extends PipeTransport {
}
if (APIProxy.isServerSide())
if (tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor))
CoreProxy.sendToPlayers(this.container.getUpdatePacket(), worldObj, xCoord, yCoord, zCoord,
if (tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)){
PacketPowerUpdate packet = new PacketPowerUpdate(xCoord, yCoord, zCoord);
packet.displayPower = displayPower;
CoreProxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
DefaultProps.NETWORK_UPDATE_RANGE, mod_BuildCraftCore.instance);
}
}
@ -230,4 +235,12 @@ public class PipeTransportPower extends PipeTransport {
return with instanceof PipeTransportPower;
}
/**
* Client-side handler for receiving power updates from the server;
* @param packetPower
*/
public void handlePowerPacket(PacketPowerUpdate packetPower) {
displayPower = packetPower.displayPower;
}
}

View file

@ -11,15 +11,17 @@ 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.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.Packet;
import net.minecraft.src.TileEntity;
import net.minecraft.src.mod_BuildCraftCore;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.IPipe.WireColor;
import net.minecraft.src.buildcraft.api.IPipeConnection;
import net.minecraft.src.buildcraft.api.IPipeEntry;
import net.minecraft.src.buildcraft.api.IPipeTile;
@ -34,21 +36,25 @@ import net.minecraft.src.buildcraft.api.liquids.ITankContainer;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.api.power.IPowerProvider;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.IDropControlInventory;
import net.minecraft.src.buildcraft.core.ITileBufferHolder;
import net.minecraft.src.buildcraft.core.TileBuffer;
import net.minecraft.src.buildcraft.core.network.ISynchronizedTile;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.core.network.IndexInPayload;
import net.minecraft.src.buildcraft.core.network.PacketPayload;
import net.minecraft.src.buildcraft.core.network.PacketPipeDescription;
import net.minecraft.src.buildcraft.core.network.PacketTileUpdate;
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
import net.minecraft.src.buildcraft.core.network.TileNetworkData;
import net.minecraft.src.buildcraft.transport.network.PipeRenderStatePacket;
public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITankContainer, IPipeEntry,
IPipeTile, ISynchronizedTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory {
IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory, IPipeRenderState {
private PipeRenderState renderState = new PipeRenderState();
public TileBuffer[] tileBuffer;
public boolean[] pipeConnectionsBuffer = new boolean[6];
@ -57,8 +63,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
public Pipe pipe;
private boolean blockNeighborChange = false;
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;
@ -78,6 +88,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
pipe.writeToNBT(nbttagcompound);
} else
nbttagcompound.setInteger("pipeId", key);
for (int i = 0; i < Orientations.dirs().length; i++){
nbttagcompound.setInteger("facadeBlocks[" + i + "]", facadeBlocks[i]);
nbttagcompound.setInteger("facadeMeta[" + i + "]", facadeMeta[i]);
}
}
@Override
@ -91,13 +107,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
if (pipe != null) {
pipe.readFromNBT(nbttagcompound);
}
}
for (int i = 0; i < Orientations.dirs().length; i++){
facadeBlocks[i] = nbttagcompound.getInteger("facadeBlocks[" + i + "]");
facadeMeta[i] = nbttagcompound.getInteger("facadeMeta[" + i + "]");
}
public void synchronizeIfDelay(int delay) {
if (APIProxy.isServerSide())
if (networkSyncTracker.markTimeIfDelay(worldObj, delay))
CoreProxy.sendToPlayers(getUpdatePacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE,
mod_BuildCraftCore.instance);
}
@Override
@ -140,6 +155,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
computeConnections();
pipe.onNeighborBlockChange(0);
blockNeighborChange = false;
refreshRenderState = true;
}
if (refreshRenderState){
refreshRenderState();
refreshRenderState = false;
}
IPowerProvider provider = getPowerProvider();
@ -151,6 +172,80 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
pipe.updateEntity();
}
//PRECONDITION: worldObj must not be null
private void refreshRenderState() {
//Only done on server/SSP
if (worldObj.isRemote) return;
// Pipe connections;
for(Orientations o : Orientations.dirs()){
renderState.pipeConnectionMatrix.setConnected(o, this.pipeConnectionsBuffer[o.ordinal()]);
}
// Pipe Textures
for(Orientations o: Orientations.values()){
renderState.textureMatrix.setTextureIndex(o, pipe.getTextureIndex(o));
}
// WireState
for (IPipe.WireColor color : IPipe.WireColor.values()){
renderState.wireMatrix.setWire(color, pipe.wireSet[color.ordinal()]);
for (Orientations direction : Orientations.dirs()){
renderState.wireMatrix.setWireConnected(color, direction, pipe.isWireConnectedTo(this.getTile(direction), color));
}
}
// Wire Textures
if (pipe.wireSet[IPipe.WireColor.Red.ordinal()]) {
renderState.wireMatrix.setTextureIndex(WireColor.Red, pipe.signalStrength[IPipe.WireColor.Red.ordinal()] > 0 ? 6 : 5);
} else {
renderState.wireMatrix.setTextureIndex(WireColor.Red, 0);
}
if (pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) {
renderState.wireMatrix.setTextureIndex(WireColor.Blue, pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] > 0 ? 8 : 7);
} else {
renderState.wireMatrix.setTextureIndex(WireColor.Blue, 0);
}
if (pipe.wireSet[IPipe.WireColor.Green.ordinal()]) {
renderState.wireMatrix.setTextureIndex(WireColor.Green, pipe.signalStrength[IPipe.WireColor.Green.ordinal()] > 0 ? 10 : 9);
} else {
renderState.wireMatrix.setTextureIndex(WireColor.Green, 0);
}
if (pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) {
renderState.wireMatrix.setTextureIndex(WireColor.Yellow, pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] > 0 ? 12 : 11);
} else {
renderState.wireMatrix.setTextureIndex(WireColor.Yellow, 0);
}
// 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);
renderState.clean();
}
}
public void initialize(Pipe pipe) {
this.pipe = pipe;
@ -175,6 +270,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
bindPipe();
computeConnections();
scheduleRenderUpdate();
if (pipe != null)
pipe.initialize();
@ -229,7 +325,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
}
@Override
public void entityEntering(EntityPassiveItem item, Orientations orientation) {
public void entityEntering(IPipedItem item, Orientations orientation) {
if (BlockGenericPipe.isValid(pipe))
pipe.transport.entityEntering(item, orientation);
}
@ -242,57 +338,26 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
return false;
}
/**
* Description packets and update packets are handled differently. They
* should be unified.
*/
@Override
public void handleDescriptionPacket(PacketUpdate packet) {
if (pipe == null && packet.payload.intPayload[0] != 0) {
initialize(BlockGenericPipe.createPipe(packet.payload.intPayload[0]));
// Check for wire information
pipe.handleWirePayload(packet.payload, new IndexInPayload(1, 0, 0));
// Check for gate information
if (packet.payload.intPayload.length > 5)
pipe.handleGatePayload(packet.payload, new IndexInPayload(5, 0, 0));
public void handleDescriptionPacket(PipeRenderStatePacket packet) {
if (worldObj.isRemote){
if (pipe == null && packet.getPipeId() != 0){
initialize(BlockGenericPipe.createPipe(packet.getPipeId()));
}
renderState = packet.getRenderState();
worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord);
}
return;
}
@Override
public void handleUpdatePacket(PacketUpdate packet) {
if (BlockGenericPipe.isValid(pipe))
pipe.handlePacket(packet);
}
@Override
public void postPacketHandling(PacketUpdate packet) {}
@Override
public Packet getUpdatePacket() {
return new PacketTileUpdate(this).getPacket();
}
@Override
public Packet getDescriptionPacket() {
bindPipe();
PacketPipeDescription packet;
if (pipe != null)
packet = new PacketPipeDescription(xCoord, yCoord, zCoord, pipe);
else
packet = new PacketPipeDescription(xCoord, yCoord, zCoord, null);
PipeRenderStatePacket packet = new PipeRenderStatePacket(this.renderState, this.pipeId, xCoord, yCoord, zCoord);
return packet.getPacket();
}
@Override
public PacketPayload getPacketPayload() {
return pipe.getNetworkPacket();
}
@Override
public int powerRequest() {
return getPowerProvider().getMaxEnergyReceived();
@ -381,7 +446,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
if (oldConnections[i] != pipeConnectionsBuffer[i]) {
Position pos = new Position(xCoord, yCoord, zCoord, Orientations.values()[i]);
pos.moveForwards(1.0);
worldObj.markBlockAsNeedsUpdate((int) pos.x, (int) pos.y, (int) pos.z);
scheduleRenderUpdate();
}
}
}
@ -448,4 +513,46 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
else
return null;
}
public void scheduleRenderUpdate(){
refreshRenderState = true;
}
public boolean addFacade(Orientations direction, int blockid, int meta){
if (this.worldObj.isRemote) return false;
if (this.facadeBlocks[direction.ordinal()] == blockid) return false;
if (hasFacade(direction)){
dropFacade(direction);
}
this.facadeBlocks[direction.ordinal()] = blockid;
this.facadeMeta[direction.ordinal()] = meta;
scheduleRenderUpdate();
//refreshRenderState();
return true;
}
public boolean hasFacade(Orientations direction){
if (this.worldObj.isRemote) return false;
return (this.facadeBlocks[direction.ordinal()] != 0);
}
public void dropFacade(Orientations direction){
if (this.worldObj.isRemote) return;
if (!hasFacade(direction)) return;
Utils.dropItems(worldObj, new ItemStack(BuildCraftTransport.facadeItem, 1, ItemFacade.encode(this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()])), this.xCoord, this.yCoord, this.zCoord);
this.facadeBlocks[direction.ordinal()] = 0;
this.facadeMeta[direction.ordinal()] = 0;
scheduleRenderUpdate();
//refreshRenderState();
}
/** IPipeRenderState implementation **/
@Override
public PipeRenderState getRenderState() {
return renderState;
}
}

View file

@ -82,8 +82,8 @@ public class TriggerPipeContents extends Trigger implements ITriggerPipe {
else if (kind == Kind.ContainsItems)
if (parameter != null && parameter.getItem() != null) {
for (EntityData data : transportItems.travelingEntities.values())
if (data.item.item.itemID == parameter.getItem().itemID
&& data.item.item.getItemDamage() == parameter.getItem().getItemDamage())
if (data.item.getItemStack().itemID == parameter.getItem().itemID
&& data.item.getItemStack().getItemDamage() == parameter.getItem().getItemDamage())
return true;
} else
return !transportItems.travelingEntities.isEmpty();

View file

@ -0,0 +1,53 @@
package net.minecraft.src.buildcraft.transport.network;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.core.network.PacketCoordinates;
import net.minecraft.src.buildcraft.core.network.PacketIds;
public class PacketLiquidUpdate extends PacketCoordinates{
public LiquidStack[] displayLiquid = new LiquidStack[Orientations.values().length];
public PacketLiquidUpdate(int xCoord, int yCoord, int zCoord) {
super(PacketIds.PIPE_LIQUID, xCoord, yCoord, zCoord);
}
public PacketLiquidUpdate() {
}
@Override
public void readData(DataInputStream data) throws IOException {
super.readData(data);
for (Orientations direction : Orientations.values()){
int liquidId = data.readInt();
int liquidQuantity = data.readInt();
int liquidMeta = data.readInt();
displayLiquid[direction.ordinal()] = new LiquidStack(liquidId, liquidQuantity, liquidMeta);
}
}
@Override
public void writeData(DataOutputStream data) throws IOException {
super.writeData(data);
for (Orientations direction : Orientations.values()){
if (displayLiquid[direction.ordinal()] != null){
data.writeInt(displayLiquid[direction.ordinal()].itemID);
data.writeInt(displayLiquid[direction.ordinal()].amount);
data.writeInt(displayLiquid[direction.ordinal()].itemMeta);
} else {
data.writeInt(0);
data.writeInt(0);
data.writeInt(0);
}
}
}
}

View file

@ -0,0 +1,37 @@
package net.minecraft.src.buildcraft.transport.network;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.src.buildcraft.core.network.PacketCoordinates;
import net.minecraft.src.buildcraft.core.network.PacketIds;
public class PacketPowerUpdate extends PacketCoordinates {
public short[] displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
public PacketPowerUpdate(){
}
public PacketPowerUpdate(int x, int y, int z) {
super(PacketIds.PIPE_POWER, x, y, z);
}
@Override
public void readData(DataInputStream data) throws IOException {
super.readData(data);
for (int i = 0; i < displayPower.length; i++){
displayPower[i] = data.readShort();
}
}
@Override
public void writeData(DataOutputStream data) throws IOException {
super.writeData(data);
for (int i = 0; i < displayPower.length; i++){
data.writeShort(displayPower[i]);
}
}
}

View file

@ -0,0 +1,60 @@
package net.minecraft.src.buildcraft.transport.network;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.src.buildcraft.core.network.PacketCoordinates;
import net.minecraft.src.buildcraft.core.network.PacketIds;
import net.minecraft.src.buildcraft.transport.PipeRenderState;
public class PipeRenderStatePacket extends PacketCoordinates {
private PipeRenderState renderState;
public int pipeId;
public PipeRenderStatePacket(){
}
public PipeRenderStatePacket(PipeRenderState renderState, int pipeId, int x, int y, int z) {
super(PacketIds.PIPE_DESCRIPTION, x, y, z);
this.pipeId = pipeId;
this.isChunkDataPacket = true;
this.renderState = renderState;
}
public PipeRenderState getRenderState(){
return this.renderState;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
super.writeData(data);
data.writeInt(pipeId);
renderState.writeData(data);
}
@Override
public void readData(DataInputStream data) throws IOException {
super.readData(data);
pipeId = data.readInt();
renderState = new PipeRenderState();
renderState.readData(data);
}
@Override
public int getID() {
return PacketIds.PIPE_DESCRIPTION;
}
public void setPipeId(int pipeId){
this.pipeId = pipeId;
}
public int getPipeId() {
return pipeId;
}
}

View file

@ -8,6 +8,8 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicCobblestone;
import net.minecraft.src.buildcraft.transport.PipeTransportItems;
@ -20,7 +22,12 @@ public class PipeItemsCobblestone extends Pipe {
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 1 * 16 + 1;
}

View file

@ -13,9 +13,10 @@ import java.util.LinkedList;
import net.minecraft.src.BuildCraftTransport;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.IPipeTransportItemsHook;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicDiamond;
@ -23,28 +24,26 @@ import net.minecraft.src.buildcraft.transport.PipeTransportItems;
public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook {
int nextTexture = 1 * 16 + 5;
public PipeItemsDiamond(int itemID) {
super(new PipeTransportItems(), new PipeLogicDiamond(), itemID);
}
@Override
public int getMainBlockTexture() {
return nextTexture;
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public void prepareTextureFor(Orientations connection) {
if (connection == Orientations.Unknown)
nextTexture = 1 * 16 + 5;
else
nextTexture = BuildCraftTransport.diamondTextures[connection.ordinal()];
public int getTextureIndex(Orientations direction) {
if (direction == Orientations.Unknown){
return 1 * 16 + 5;
}
return BuildCraftTransport.diamondTextures[direction.ordinal()];
}
@Override
public LinkedList<Orientations> filterPossibleMovements(LinkedList<Orientations> possibleOrientations, Position pos,
EntityPassiveItem item) {
IPipedItem item) {
LinkedList<Orientations> filteredOrientations = new LinkedList<Orientations>();
LinkedList<Orientations> defaultOrientations = new LinkedList<Orientations>();
@ -62,10 +61,10 @@ public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook {
if (stack != null)
foundFilter = true;
if (stack != null && stack.itemID == item.item.itemID)
if ((Item.itemsList[item.item.itemID].isDamageable()))
if (stack != null && stack.itemID == item.getItemStack().itemID)
if ((Item.itemsList[item.getItemStack().itemID].isDamageable()))
filteredOrientations.add(dir);
else if (stack.getItemDamage() == item.item.getItemDamage())
else if (stack.getItemDamage() == item.getItemStack().getItemDamage())
filteredOrientations.add(dir);
}
if (!foundFilter)
@ -78,12 +77,12 @@ public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook {
}
@Override
public void entityEntered(EntityPassiveItem item, Orientations orientation) {
public void entityEntered(IPipedItem item, Orientations orientation) {
}
@Override
public void readjustSpeed(EntityPassiveItem item) {
public void readjustSpeed(IPipedItem item) {
((PipeTransportItems) transport).defaultReajustSpeed(item);
}

View file

@ -12,9 +12,10 @@ import java.util.LinkedList;
import net.minecraft.src.BuildCraftTransport;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.transport.IPipeTransportItemsHook;
import net.minecraft.src.buildcraft.transport.Pipe;
@ -29,13 +30,18 @@ public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook {
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
if (worldObj != null && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))
return 1 * 16 + 14;
else
return 1 * 16 + 4;
}
@Override
public boolean isPipeConnected(TileEntity tile) {
if (!super.isPipeConnected(tile))
@ -54,18 +60,18 @@ public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook {
@Override
public LinkedList<Orientations> filterPossibleMovements(LinkedList<Orientations> possibleOrientations, Position pos,
EntityPassiveItem item) {
IPipedItem item) {
return possibleOrientations;
}
@Override
public void entityEntered(EntityPassiveItem item, Orientations orientation) {
public void entityEntered(IPipedItem item, Orientations orientation) {
if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))
item.speed = Utils.pipeNormalSpeed * 20F;
item.setSpeed(Utils.pipeNormalSpeed * 20F);
}
@Override
public void readjustSpeed(EntityPassiveItem item) {
public void readjustSpeed(IPipedItem item) {
((PipeTransportItems) transport).defaultReajustSpeed(item);
}
}

View file

@ -9,6 +9,7 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicIron;
import net.minecraft.src.buildcraft.transport.PipeTransportItems;
@ -17,31 +18,31 @@ public class PipeItemsIron extends Pipe {
private int baseTexture = 1 * 16 + 2;
private int plainTexture = 1 * 16 + 3;
private int nextTexture = baseTexture;
public PipeItemsIron(int itemID) {
super(new PipeTransportItems(), new PipeLogicIron(), itemID);
((PipeTransportItems) transport).allowBouncing = true;
}
@Override
public void prepareTextureFor(Orientations connection) {
if (connection == Orientations.Unknown)
nextTexture = baseTexture;
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
if (direction == Orientations.Unknown)
return baseTexture;
else {
int metadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (metadata == connection.ordinal())
nextTexture = baseTexture;
if (metadata == direction.ordinal())
return baseTexture;
else
nextTexture = plainTexture;
return plainTexture;
}
}
@Override
public int getMainBlockTexture() {
return nextTexture;
}
}

View file

@ -19,13 +19,15 @@ import net.minecraft.src.IInventory;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.power.IPowerProvider;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
import net.minecraft.src.buildcraft.api.power.PowerFramework;
import net.minecraft.src.buildcraft.api.power.PowerProvider;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.EntityPassiveItem;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicObsidian;
@ -53,10 +55,16 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 1 * 16 + 12;
}
@Override
public void onEntityCollidedWithBlock(Entity entity) {
super.onEntityCollidedWithBlock(entity);
@ -229,10 +237,10 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
APIProxy.removeEntity(entity);
}
EntityPassiveItem passive = new EntityPassiveItem(worldObj, xCoord + 0.5, yCoord + Utils.getPipeFloorOf(stack),
IPipedItem passive = new EntityPassiveItem(worldObj, xCoord + 0.5, yCoord + Utils.getPipeFloorOf(stack),
zCoord + 0.5, stack);
passive.speed = (float) speed;
passive.setSpeed((float) speed);
((PipeTransportItems) transport).entityEntering(passive, orientation);
}

View file

@ -9,18 +9,24 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicSandstone;
import net.minecraft.src.buildcraft.transport.PipeTransportItems;
public class PipeItemsSandstone extends Pipe{
public PipeItemsSandstone(int itemID) {
super(new PipeTransportItems(), new PipeLogicSandstone(), itemID);
public PipeItemsSandstone(int itemID) {
super(new PipeTransportItems(), new PipeLogicSandstone(), itemID);
}
@Override
public int getMainBlockTexture() {
return 8 * 16 + 15;
@Override
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 8 * 16 + 15;
}
}

View file

@ -10,9 +10,10 @@ package net.minecraft.src.buildcraft.transport.pipes;
import java.util.LinkedList;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.transport.IPipeTransportItemsHook;
import net.minecraft.src.buildcraft.transport.Pipe;
@ -27,27 +28,32 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 1 * 16 + 13;
}
@Override
public void readjustSpeed(EntityPassiveItem item) {
if (item.speed > Utils.pipeNormalSpeed)
item.speed = item.speed - Utils.pipeNormalSpeed / 2.0F;
public void readjustSpeed(IPipedItem item) {
if (item.getSpeed() > Utils.pipeNormalSpeed)
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 2.0F);
if (item.speed < Utils.pipeNormalSpeed)
item.speed = Utils.pipeNormalSpeed;
if (item.getSpeed() < Utils.pipeNormalSpeed)
item.setSpeed(Utils.pipeNormalSpeed);
}
@Override
public LinkedList<Orientations> filterPossibleMovements(LinkedList<Orientations> possibleOrientations, Position pos,
EntityPassiveItem item) {
IPipedItem item) {
return possibleOrientations;
}
@Override
public void entityEntered(EntityPassiveItem item, Orientations orientation) {
public void entityEntered(IPipedItem item, Orientations orientation) {
}

View file

@ -16,13 +16,15 @@ import net.minecraft.src.BuildCraftTransport;
import net.minecraft.src.ItemStack;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.power.IPowerProvider;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
import net.minecraft.src.buildcraft.api.power.PowerFramework;
import net.minecraft.src.buildcraft.api.power.PowerProvider;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.EntityPassiveItem;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.transport.BlockGenericPipe;
import net.minecraft.src.buildcraft.transport.EntityData;
@ -47,10 +49,16 @@ public class PipeItemsStripes extends Pipe implements IItemTravelingHook, IPower
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 16 * 7 + 14;
}
@Override
public void doWork() {
if (powerProvider.useEnergy(1, 1, true) == 1) {
@ -66,7 +74,7 @@ public class PipeItemsStripes extends Pipe implements IItemTravelingHook, IPower
if (stacks != null)
for (ItemStack s : stacks)
if (s != null) {
EntityPassiveItem newItem = new EntityPassiveItem(worldObj, xCoord + 0.5, yCoord
IPipedItem newItem = new EntityPassiveItem(worldObj, xCoord + 0.5, yCoord
+ Utils.getPipeFloorOf(s), zCoord + 0.5, s);
this.container.entityEntering(newItem, o.reverse());
@ -87,10 +95,10 @@ public class PipeItemsStripes extends Pipe implements IItemTravelingHook, IPower
BuildCraftTransport.pipeItemsStipes.onItemUse(new ItemStack(BuildCraftTransport.pipeItemsStipes),
BuildCraftAPI.getBuildCraftPlayer(worldObj), worldObj, (int) p.x, (int) p.y - 1, (int) p.z, 1);
else if (worldObj.getBlockId((int) p.x, (int) p.y, (int) p.z) == 0)
data.item.item.getItem().onItemUse(data.item.item, BuildCraftAPI.getBuildCraftPlayer(worldObj), worldObj, (int) p.x,
data.item.getItemStack().getItem().onItemUse(data.item.getItemStack(), BuildCraftAPI.getBuildCraftPlayer(worldObj), worldObj, (int) p.x,
(int) p.y - 1, (int) p.z, 1);
else
data.item.item.getItem().onItemUse(data.item.item, BuildCraftAPI.getBuildCraftPlayer(worldObj), worldObj, (int) p.x,
data.item.getItemStack().getItem().onItemUse(data.item.getItemStack(), BuildCraftAPI.getBuildCraftPlayer(worldObj), worldObj, (int) p.x,
(int) p.y, (int) p.z, 1);
}
@ -102,20 +110,20 @@ public class PipeItemsStripes extends Pipe implements IItemTravelingHook, IPower
@SuppressWarnings("unchecked")
public boolean convertPipe(PipeTransportItems pipe, EntityData data) {
if (data.item.item.getItem() instanceof ItemPipe)
if (data.item.getItemStack().getItem() instanceof ItemPipe)
if (!(data.item.item.itemID == BuildCraftTransport.pipeItemsStipes.shiftedIndex)) {
if (!(data.item.getItemStack().itemID == BuildCraftTransport.pipeItemsStipes.shiftedIndex)) {
Pipe newPipe = BlockGenericPipe.createPipe(data.item.item.itemID);
Pipe newPipe = BlockGenericPipe.createPipe(data.item.getItemStack().itemID);
newPipe.setTile(this.container);
this.container.pipe = newPipe;
((PipeTransportItems) newPipe.transport).travelingEntities = (TreeMap<Integer, EntityData>) pipe.travelingEntities
.clone();
data.item.item.stackSize--;
data.item.getItemStack().stackSize--;
if (data.item.item.stackSize <= 0)
((PipeTransportItems) newPipe.transport).travelingEntities.remove(data.item.entityId);
if (data.item.getItemStack().stackSize <= 0)
((PipeTransportItems) newPipe.transport).travelingEntities.remove(data.item.getEntityId());
pipe.scheduleRemoval(data.item);

View file

@ -10,6 +10,8 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.EntityData;
import net.minecraft.src.buildcraft.transport.IItemTravelingHook;
import net.minecraft.src.buildcraft.transport.Pipe;
@ -24,14 +26,20 @@ public class PipeItemsVoid extends Pipe implements IItemTravelingHook{
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 8 * 16 + 14;
}
//This is called if the void pipe is only connected to one pipe
@Override
public void drop(PipeTransportItems pipe, EntityData data) {
data.item.item.stackSize = 0;
data.item.getItemStack().stackSize = 0;
}
//This is called when the void pipe is connected to multiple pipes

View file

@ -13,7 +13,6 @@ import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.inventory.ISpecialInventory;
@ -22,6 +21,9 @@ import net.minecraft.src.buildcraft.api.power.IPowerProvider;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
import net.minecraft.src.buildcraft.api.power.PowerFramework;
import net.minecraft.src.buildcraft.api.power.PowerProvider;
import net.minecraft.src.buildcraft.api.transport.IPipedItem;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.EntityPassiveItem;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicWood;
@ -34,7 +36,6 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
private int baseTexture = 1 * 16 + 0;
private int plainTexture = 1 * 16 + 15;
private int nextTexture = baseTexture;
protected PipeItemsWood(int itemID, PipeTransportItems transport) {
super(transport, new PipeLogicWood(), itemID);
@ -49,23 +50,22 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
}
@Override
public int getMainBlockTexture() {
return nextTexture;
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public void prepareTextureFor(Orientations connection) {
if (connection == Orientations.Unknown)
nextTexture = baseTexture;
public int getTextureIndex(Orientations direction) {
if (direction == Orientations.Unknown)
return baseTexture;
else {
int metadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (metadata == connection.ordinal())
nextTexture = plainTexture;
if (metadata == direction.ordinal())
return plainTexture;
else
nextTexture = baseTexture;
return baseTexture;
}
}
@Override
@ -107,22 +107,22 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
return;
for(ItemStack stack : extracted) {
if (stack == null || stack.stackSize == 0) {
powerProvider.useEnergy(1, 1, false);
if (stack == null || stack.stackSize == 0) {
powerProvider.useEnergy(1, 1, false);
continue;
}
Position entityPos = new Position(pos.x + 0.5, pos.y + Utils.getPipeFloorOf(stack), pos.z + 0.5,
pos.orientation.reverse());
entityPos.moveForwards(0.5);
EntityPassiveItem entity = new EntityPassiveItem(w, entityPos.x, entityPos.y, entityPos.z, stack);
((PipeTransportItems) transport).entityEntering(entity, entityPos.orientation);
}
Position entityPos = new Position(pos.x + 0.5, pos.y + Utils.getPipeFloorOf(stack), pos.z + 0.5,
pos.orientation.reverse());
entityPos.moveForwards(0.5);
IPipedItem entity = new EntityPassiveItem(w, entityPos.x, entityPos.y, entityPos.z, stack);
((PipeTransportItems) transport).entityEntering(entity, entityPos.orientation);
}
}
}
/**
* Return the itemstack that can be if something can be extracted from this

View file

@ -8,6 +8,8 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicCobblestone;
import net.minecraft.src.buildcraft.transport.PipeTransportLiquids;
@ -19,7 +21,12 @@ public class PipeLiquidsCobblestone extends Pipe {
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 7 * 16 + 1;
}
}

View file

@ -8,6 +8,8 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicGold;
import net.minecraft.src.buildcraft.transport.PipeTransportLiquids;
@ -22,7 +24,13 @@ public class PipeLiquidsGold extends Pipe {
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 7 * 16 + 4;
}
}

View file

@ -9,6 +9,7 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicIron;
import net.minecraft.src.buildcraft.transport.PipeTransportLiquids;
@ -17,29 +18,29 @@ public class PipeLiquidsIron extends Pipe {
private int baseTexture = 7 * 16 + 3;
private int plainTexture = 1 * 16 + 3;
private int nextTexture = baseTexture;
public PipeLiquidsIron(int itemID) {
super(new PipeTransportLiquids(), new PipeLogicIron(), itemID);
}
@Override
public void prepareTextureFor(Orientations connection) {
if (connection == Orientations.Unknown)
nextTexture = baseTexture;
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
if (direction == Orientations.Unknown)
return baseTexture;
else {
int metadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (metadata == connection.ordinal())
nextTexture = baseTexture;
if (metadata == direction.ordinal())
return baseTexture;
else
nextTexture = plainTexture;
return plainTexture;
}
}
@Override
public int getMainBlockTexture() {
return nextTexture;
}
}

View file

@ -10,6 +10,7 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.transport.IPipeTransportLiquidsHook;
import net.minecraft.src.buildcraft.transport.Pipe;
@ -22,11 +23,17 @@ public class PipeLiquidsSandstone extends Pipe implements IPipeTransportLiquidsH
super(new PipeTransportLiquids(), new PipeLogicSandstone(), itemID);
}
@Override
public int getMainBlockTexture() {
@Override
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 9 * 16 + 15;
}
@Override
public int fill(Orientations from, LiquidStack resource, boolean doFill) {
if (container.tileBuffer == null || container.tileBuffer[from.ordinal()] == null)

View file

@ -8,6 +8,8 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicStone;
import net.minecraft.src.buildcraft.transport.PipeTransportLiquids;
@ -21,7 +23,13 @@ public class PipeLiquidsStone extends Pipe {
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 7 * 16 + 2;
}
}

View file

@ -10,6 +10,7 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.transport.IPipeTransportLiquidsHook;
import net.minecraft.src.buildcraft.transport.Pipe;
@ -23,10 +24,16 @@ public class PipeLiquidsVoid extends Pipe implements IPipeTransportLiquidsHook{
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 9 * 16 + 14;
}
@Override
public int fill(Orientations from, LiquidStack resource, boolean doFill) {
return resource.amount;

View file

@ -19,6 +19,7 @@ import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
import net.minecraft.src.buildcraft.api.power.IPowerProvider;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
import net.minecraft.src.buildcraft.api.power.PowerFramework;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.network.TileNetworkData;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicWood;
@ -32,7 +33,6 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
private IPowerProvider powerProvider;
private int baseTexture = 7 * 16 + 0;
private int plainTexture = 1 * 16 + 15;
private int nextTexture = baseTexture;
long lastMining = 0;
boolean lastPower = false;
@ -113,23 +113,23 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
}
@Override
public void prepareTextureFor(Orientations connection) {
if (connection == Orientations.Unknown)
nextTexture = baseTexture;
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
if (direction == Orientations.Unknown)
return baseTexture;
else {
int metadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (metadata == connection.ordinal())
nextTexture = plainTexture;
if (metadata == direction.ordinal())
return plainTexture;
else
nextTexture = baseTexture;
}
}
return baseTexture;
} }
@Override
public int getMainBlockTexture() {
return nextTexture;
}
@Override
public int powerRequest() {

View file

@ -8,6 +8,8 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicGold;
import net.minecraft.src.buildcraft.transport.PipeTransportPower;
@ -19,10 +21,16 @@ public class PipePowerGold extends Pipe {
((PipeTransportPower) transport).powerResitance = 0.001;
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 7 * 16 + 10;
}
}

View file

@ -8,6 +8,8 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicStone;
import net.minecraft.src.buildcraft.transport.PipeTransportPower;
@ -16,12 +18,17 @@ public class PipePowerStone extends Pipe {
public PipePowerStone(int itemID) {
super(new PipeTransportPower(), new PipeLogicStone(), itemID);
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 7 * 16 + 8;
}
}

View file

@ -14,6 +14,7 @@ import net.minecraft.src.buildcraft.api.power.IPowerProvider;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
import net.minecraft.src.buildcraft.api.power.PowerFramework;
import net.minecraft.src.buildcraft.api.power.PowerProvider;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.Utils;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicWood;
@ -26,7 +27,6 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
private int baseTexture = 7 * 16 + 6;
private int plainTexture = 1 * 16 + 15;
private int nextTexture = baseTexture;
public PipePowerWood(int itemID) {
super(new PipeTransportPower(), new PipeLogicWood(), itemID);
@ -37,8 +37,22 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
}
@Override
public int getMainBlockTexture() {
return nextTexture;
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
if (direction == Orientations.Unknown)
return baseTexture;
else {
int metadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (metadata == direction.ordinal())
return plainTexture;
else
return baseTexture;
}
}
@Override
@ -86,26 +100,13 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
pow.receiveEnergy(o.reverse(), energyUsed);
if (worldObj.isRemote) return;
((PipeTransportPower) transport).displayPower[o.ordinal()] += energyUsed;
}
}
}
@Override
public void prepareTextureFor(Orientations connection) {
if (connection == Orientations.Unknown)
nextTexture = baseTexture;
else {
int metadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (metadata == connection.ordinal())
nextTexture = plainTexture;
else
nextTexture = baseTexture;
}
}
@Override
public int powerRequest() {
return getPowerProvider().getMaxEnergyReceived();

View file

@ -1,5 +1,7 @@
package net.minecraft.src.buildcraft.transport.pipes;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.Pipe;
import net.minecraft.src.buildcraft.transport.PipeLogicCobblestone;
import net.minecraft.src.buildcraft.transport.PipeTransportStructure;
@ -12,8 +14,14 @@ public class PipeStructureCobblestone extends Pipe {
}
@Override
public int getMainBlockTexture() {
public String getTextureFile() {
return DefaultProps.TEXTURE_BLOCKS;
}
@Override
public int getTextureIndex(Orientations direction) {
return 7 * 16 + 13;
}
}

View file

@ -0,0 +1,45 @@
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 ConnectionMatrix {
private final boolean[] _connected = new boolean[Orientations.dirs().length];
private boolean dirty = false;
public boolean isConnected(Orientations direction){
return _connected[direction.ordinal()];
}
public void setConnected(Orientations direction, boolean value){
if (_connected[direction.ordinal()] != value){
_connected[direction.ordinal()] = value;
dirty = true;
}
}
public boolean isDirty() {
return dirty;
}
public void clean() {
dirty = false;
}
public void writeData(DataOutputStream data) throws IOException {
for(int i = 0; i < Orientations.dirs().length; i++){
data.writeBoolean(_connected[i]);
}
}
public void readData(DataInputStream data) throws IOException {
for (int i = 0; i < Orientations.dirs().length; i++){
_connected[i] = data.readBoolean();
}
}
}

View file

@ -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]);
}
}
}

View file

@ -0,0 +1,45 @@
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 TextureMatrix {
private final int[] _textureIndexes = new int[Orientations.values().length];
private boolean dirty = false;
public int getTextureIndex(Orientations direction){
return _textureIndexes[direction.ordinal()];
}
public void setTextureIndex(Orientations direction, int value){
if (_textureIndexes[direction.ordinal()] != value){
_textureIndexes[direction.ordinal()] = value;
dirty = true;
}
}
public boolean isDirty() {
return dirty;
}
public void clean() {
dirty = false;
}
public void writeData(DataOutputStream data) throws IOException {
for(int i = 0; i < Orientations.values().length; i++){
data.writeInt(_textureIndexes[i]);
}
}
public void readData(DataInputStream data) throws IOException {
for (int i = 0; i < Orientations.values().length; i++){
_textureIndexes[i] = data.readInt();
}
}
}

View file

@ -0,0 +1,85 @@
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.IPipe;
import net.minecraft.src.buildcraft.api.Orientations;
public class WireMatrix {
private final boolean[] _hasWire = new boolean[IPipe.WireColor.values().length];
private final ConnectionMatrix _wires[] = new ConnectionMatrix[IPipe.WireColor.values().length];
private int _wireTextureIndex[] = new int[IPipe.WireColor.values().length];
private boolean dirty = false;
public WireMatrix(){
for (int i = 0; i < IPipe.WireColor.values().length; i++){
_wires[i] = new ConnectionMatrix();
}
}
public boolean hasWire(IPipe.WireColor color){
return _hasWire[color.ordinal()];
}
public void setWire(IPipe.WireColor color, boolean value){
if (_hasWire[color.ordinal()] != value){
_hasWire[color.ordinal()] = value;
dirty = true;
}
}
public boolean isWireConnected(IPipe.WireColor color, Orientations direction){
return _wires[color.ordinal()].isConnected(direction);
}
public void setWireConnected(IPipe.WireColor color, Orientations direction, boolean value){
_wires[color.ordinal()].setConnected(direction, value);
}
public int getTextureIndex(IPipe.WireColor color){
return _wireTextureIndex[color.ordinal()];
}
public void setTextureIndex(IPipe.WireColor color, int value){
if (_wireTextureIndex[color.ordinal()] != value){
_wireTextureIndex[color.ordinal()] = value;
dirty = true;
}
}
public boolean isDirty() {
for (int i = 0; i < IPipe.WireColor.values().length; i++){
if (_wires[i].isDirty()) return true;
}
return dirty;
}
public void clean() {
for (int i = 0; i < IPipe.WireColor.values().length; i++){
_wires[i].clean();
}
dirty = false;
}
public void writeData(DataOutputStream data) throws IOException {
for (int i = 0; i < IPipe.WireColor.values().length; i++){
data.writeBoolean(_hasWire[i]);
_wires[i].writeData(data);
data.writeInt(_wireTextureIndex[i]);
}
}
public void readData(DataInputStream data) throws IOException {
for (int i = 0; i < IPipe.WireColor.values().length; i++){
_hasWire[i] = data.readBoolean();
_wires[i].readData(data);
_wireTextureIndex[i] = data.readInt();
}
}
}