Merge remote-tracking branch 'upstream/master'

This commit is contained in:
CovertJaguar 2012-10-11 14:11:50 -07:00
commit 7e06d2c2d7
6 changed files with 94 additions and 22 deletions

View file

@ -148,8 +148,12 @@ public class Utils {
TileEntity pipeEntry = w.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
if (pipeEntry instanceof IPipeEntry && ((IPipeEntry) pipeEntry).acceptItems())
if (pipeEntry instanceof IPipeEntry && ((IPipeEntry) pipeEntry).acceptItems()) {
if( pipeEntry instanceof IPipeConnection )
if( !((IPipeConnection) pipeEntry).isPipeConnected(from.reverse()) )
continue;
possiblePipes.add(Orientations.values()[j]);
}
}
if (possiblePipes.size() > 0) {

View file

@ -17,12 +17,14 @@ import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.Orientations;
import buildcraft.api.tools.IToolWrench;
import buildcraft.api.transport.IPipe;
import buildcraft.core.BlockIndex;
import buildcraft.core.DefaultProps;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils;
import buildcraft.transport.render.PipeWorldRenderer;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.BlockContainer;
@ -73,6 +75,7 @@ public class BlockGenericPipe extends BlockContainer {
super.addCollidingBlockToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
TileEntity tile1 = world.getBlockTileEntity(i, j, k);
TileGenericPipe tileG = (TileGenericPipe) tile1;
if (Utils.checkPipesConnections(world, tile1, i - 1, j, k)) {
setBlockBounds(0.0F, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos);
@ -104,43 +107,95 @@ public class BlockGenericPipe extends BlockContainer {
super.addCollidingBlockToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG != null) {
float facadeThickness = PipeWorldRenderer.facadeThickness;
if (tileG.hasFacade(Orientations.XPos)) {
setBlockBounds(1 - facadeThickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.addCollidingBlockToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.hasFacade(Orientations.XNeg)) {
setBlockBounds(0.0F, 0.0F, 0.0F, facadeThickness, 1.0F, 1.0F);
super.addCollidingBlockToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.hasFacade(Orientations.YPos)) {
setBlockBounds(0.0F, 1 - facadeThickness, 0.0F, 1.0F, 1.0F, 1.0F);
super.addCollidingBlockToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.hasFacade(Orientations.YNeg)) {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, facadeThickness, 1.0F);
super.addCollidingBlockToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.hasFacade(Orientations.ZPos)) {
setBlockBounds(0.0F, 0.0F, 1 - facadeThickness, 1.0F, 1.0F, 1.0F);
super.addCollidingBlockToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
if (tileG.hasFacade(Orientations.ZNeg)) {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, facadeThickness);
super.addCollidingBlockToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
}
}
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos;
TileEntity tile1 = world.getBlockTileEntity(i, j, k);
TileGenericPipe tileG = (TileGenericPipe) tile1;
if (Utils.checkPipesConnections(world, tile1, i - 1, j, k))
if (Utils.checkPipesConnections(world, tile1, i - 1, j, k) || (tileG != null && tileG.hasFacade(Orientations.XNeg)))
xMin = 0.0F;
if (Utils.checkPipesConnections(world, tile1, i + 1, j, k))
if (Utils.checkPipesConnections(world, tile1, i + 1, j, k) || (tileG != null && tileG.hasFacade(Orientations.XPos)))
xMax = 1.0F;
if (Utils.checkPipesConnections(world, tile1, i, j - 1, k))
if (Utils.checkPipesConnections(world, tile1, i, j - 1, k) || (tileG != null && tileG.hasFacade(Orientations.YNeg)))
yMin = 0.0F;
if (Utils.checkPipesConnections(world, tile1, i, j + 1, k))
if (Utils.checkPipesConnections(world, tile1, i, j + 1, k) || (tileG != null && tileG.hasFacade(Orientations.YPos)))
yMax = 1.0F;
if (Utils.checkPipesConnections(world, tile1, i, j, k - 1))
if (Utils.checkPipesConnections(world, tile1, i, j, k - 1) || (tileG != null && tileG.hasFacade(Orientations.ZNeg)))
zMin = 0.0F;
if (Utils.checkPipesConnections(world, tile1, i, j, k + 1))
if (Utils.checkPipesConnections(world, tile1, i, j, k + 1) || (tileG != null && tileG.hasFacade(Orientations.ZPos)))
zMax = 1.0F;
if (tileG != null) {
if (tileG.hasFacade(Orientations.XPos) || tileG.hasFacade(Orientations.XNeg)) {
yMin = 0.0F;
yMax = 1.0F;
zMin = 0.0F;
zMax = 1.0F;
}
if (tileG.hasFacade(Orientations.YPos) || tileG.hasFacade(Orientations.YNeg)) {
xMin = 0.0F;
xMax = 1.0F;
zMin = 0.0F;
zMax = 1.0F;
}
if (tileG.hasFacade(Orientations.ZPos) || tileG.hasFacade(Orientations.ZNeg)) {
xMin = 0.0F;
xMax = 1.0F;
yMin = 0.0F;
yMax = 1.0F;
}
}
return AxisAlignedBB.getBoundingBox((double) i + xMin, (double) j + yMin, (double) k + zMin, (double) i + xMax,
(double) j + yMax, (double) k + zMax);
}
@SuppressWarnings({ "all" })
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
return getCollisionBoundingBoxFromPool(world, i, j, k);
}
@Override
public MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3 vec3d, Vec3 vec3d1) {
float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos;

View file

@ -16,6 +16,7 @@ import java.util.Random;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.Orientations;
import buildcraft.api.core.Position;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.Action;
import buildcraft.api.gates.ActionManager;
@ -26,6 +27,7 @@ import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.gates.Trigger;
import buildcraft.api.gates.TriggerParameter;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeConnection
import buildcraft.core.IDropControlInventory;
import buildcraft.core.network.TilePacketWrapper;
import buildcraft.core.triggers.ActionRedstoneOutput;
@ -131,6 +133,11 @@ public abstract class Pipe implements IPipe, IDropControlInventory {
}
public boolean isPipeConnected(TileEntity tile) {
if( tile instanceof IPipeConnection && !(tile instanceof TileGenericPipe) ){
Orientations or = Utils.get3dOrientation(new Position(this.container), new Position(tile));
if( !((IPipeConnection) tile).isPipeConnected(or) )
return false;
}
return logic.isPipeConnected(tile) && transport.isPipeConnected(tile);
}

View file

@ -41,6 +41,7 @@ import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.Packet;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ISidedInventory;
public class PipeTransportItems extends PipeTransport {
@ -145,13 +146,12 @@ public class PipeTransportItems extends PipeTransport {
if (!Utils.checkPipesConnections(entity, container))
return false;
if (entity instanceof TileGenericPipe)
if (container.pipe.transport instanceof PipeTransportItems)
return container.pipe.transport.inputOpen(o);
if (entity instanceof IPipeEntry)
return true;
else if (entity instanceof TileGenericPipe) {
TileGenericPipe pipe = (TileGenericPipe) entity;
return pipe.pipe.transport instanceof PipeTransportItems;
} else if (entity instanceof IInventory)
return ((IPipeEntry) entity).acceptItems();
if (entity instanceof IInventory)
if(Transactor.getTransactorFor(entity).add(item.getItemStack(), o.reverse(), false).stackSize > 0)
return true;
@ -437,6 +437,10 @@ public class PipeTransportItems extends PipeTransport {
@Override
public boolean isPipeConnected(TileEntity tile) {
if( tile instanceof ISidedInventory ){
Orientations or = Utils.get3dOrientation(new Position(container), new Position(tile));
return ((ISidedInventory) tile).getSizeInventorySide(or.toDirection()) > 0;
}
return tile instanceof TileGenericPipe
|| tile instanceof IPipeEntry
|| tile instanceof ISpecialInventory

View file

@ -567,7 +567,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
}
public boolean hasFacade(Orientations direction){
if (this.worldObj.isRemote) return false;
if (this.worldObj.isRemote)
return renderState.facadeMatrix.isConnected(direction);
return (this.facadeBlocks[direction.ordinal()] != 0);
}

View file

@ -20,6 +20,8 @@ import net.minecraftforge.client.ForgeHooksClient;
public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
public static final float facadeThickness = 1F / 16F;
/**
* Mirrors the array on the Y axis by calculating offsets from 0.5F
* @param targetArray
@ -156,7 +158,6 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
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];