Fix Pipe Raytracing + Improve Pipe interactions

Closes #1246

Its now much easier and more consistent to remove specific addons from a
pipe. Sneak-click with a gate to remove a gate, sneak-click with a
Yellow Wire to remove a Yellow Wire, etc...

Plugs can now be placed easily and simply on any side of the pipe in any
configuration.

Selection Box now highlights the part of the pipe you are pointing at.
This commit is contained in:
CovertJaguar 2013-10-11 19:16:57 -07:00
parent 9cb53f9405
commit 99fca02856
31 changed files with 763 additions and 543 deletions

View file

@ -313,28 +313,28 @@ public class BuildCraftTransport {
// 1, 0), Block.glass, new ItemStack(Item.dyePowder, 1, 11)); // 1, 0), Block.glass, new ItemStack(Item.dyePowder, 1, 11));
Property redPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "redPipeWire.id", DefaultProps.RED_PIPE_WIRE); Property redPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "redPipeWire.id", DefaultProps.RED_PIPE_WIRE);
redPipeWire = new ItemBuildCraft(redPipeWireId.getInt()); redPipeWire = new ItemBuildCraft(redPipeWireId.getInt()).setPassSneakClick(true);
redPipeWire.setUnlocalizedName("redPipeWire"); redPipeWire.setUnlocalizedName("redPipeWire");
LanguageRegistry.addName(redPipeWire, "Red Pipe Wire"); LanguageRegistry.addName(redPipeWire, "Red Pipe Wire");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 1), new ItemStack(Item.redstone, 1), AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 1), new ItemStack(Item.redstone, 1),
new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(redPipeWire, 8))); new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(redPipeWire, 8)));
Property bluePipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bluePipeWire.id", DefaultProps.BLUE_PIPE_WIRE); Property bluePipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bluePipeWire.id", DefaultProps.BLUE_PIPE_WIRE);
bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()); bluePipeWire = new ItemBuildCraft(bluePipeWireId.getInt()).setPassSneakClick(true);
bluePipeWire.setUnlocalizedName("bluePipeWire"); bluePipeWire.setUnlocalizedName("bluePipeWire");
LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire"); LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 4), new ItemStack(Item.redstone, 1), AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 4), new ItemStack(Item.redstone, 1),
new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(bluePipeWire, 8))); new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(bluePipeWire, 8)));
Property greenPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "greenPipeWire.id", DefaultProps.GREEN_PIPE_WIRE); Property greenPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "greenPipeWire.id", DefaultProps.GREEN_PIPE_WIRE);
greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()); greenPipeWire = new ItemBuildCraft(greenPipeWireId.getInt()).setPassSneakClick(true);
greenPipeWire.setUnlocalizedName("greenPipeWire"); greenPipeWire.setUnlocalizedName("greenPipeWire");
LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire"); LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 2), new ItemStack(Item.redstone, 1), AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 2), new ItemStack(Item.redstone, 1),
new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(greenPipeWire, 8))); new ItemStack(Item.ingotIron, 1)}, 500, new ItemStack(greenPipeWire, 8)));
Property yellowPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "yellowPipeWire.id", DefaultProps.YELLOW_PIPE_WIRE); Property yellowPipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "yellowPipeWire.id", DefaultProps.YELLOW_PIPE_WIRE);
yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()); yellowPipeWire = new ItemBuildCraft(yellowPipeWireId.getInt()).setPassSneakClick(true);
yellowPipeWire.setUnlocalizedName("yellowPipeWire"); yellowPipeWire.setUnlocalizedName("yellowPipeWire");
LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire"); LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire");
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 11), new ItemStack(Item.redstone, 1), AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(Item.dyePowder, 1, 11), new ItemStack(Item.redstone, 1),

View file

@ -0,0 +1,19 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* 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 buildcraft.core;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class CoreConstants {
public static final float PIPE_MIN_POS = 0.25F;
public static final float PIPE_MAX_POS = 0.75F;
}

View file

@ -1,12 +1,10 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.core; package buildcraft.core;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
@ -15,10 +13,13 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemBuildCraft extends Item { public class ItemBuildCraft extends Item {
private String iconName; private String iconName;
private boolean passSneakClick = false;
public ItemBuildCraft(int i) { public ItemBuildCraft(int i) {
super(i); super(i);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
@ -36,9 +37,18 @@ public class ItemBuildCraft extends Item {
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) public void registerIcons(IconRegister par1IconRegister) {
{ this.itemIcon = par1IconRegister.registerIcon("buildcraft:" + iconName);
this.itemIcon = par1IconRegister.registerIcon("buildcraft:" + iconName); }
}
public Item setPassSneakClick(boolean passClick) {
this.passSneakClick = passClick;
return this;
}
@Override
public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) {
return passSneakClick;
}
} }

View file

@ -1,6 +1,7 @@
package buildcraft.core.render; package buildcraft.core.render;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.core.CoreConstants;
import buildcraft.core.IInventoryRenderer; import buildcraft.core.IInventoryRenderer;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
@ -57,7 +58,7 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
} else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) { } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
Tessellator tessellator = Tessellator.instance; Tessellator tessellator = Tessellator.instance;
block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
renderer.setRenderBoundsFromBlock(block); renderer.setRenderBoundsFromBlock(block);
block.setBlockBoundsForItemRender(); block.setBlockBoundsForItemRender();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
@ -116,8 +117,8 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
/* LEGACY PIPE RENDERING and quarry frames! */ /* LEGACY PIPE RENDERING and quarry frames! */
private void legacyPipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l) { private void legacyPipeRender(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l) {
float minSize = Utils.pipeMinPos; float minSize = CoreConstants.PIPE_MIN_POS;
float maxSize = Utils.pipeMaxPos; float maxSize = CoreConstants.PIPE_MAX_POS;
block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize); block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
renderblocks.setRenderBoundsFromBlock(block); renderblocks.setRenderBoundsFromBlock(block);

View file

@ -0,0 +1,73 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* 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 buildcraft.core.utils;
import net.minecraftforge.common.ForgeDirection;
/**
*
* @author Krapht
*/
public class MatrixTranformations {
/**
* Mirrors the array on the Y axis by calculating offsets from 0.5F
*
* @param targetArray
*/
public static 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 effectively rotating something. Zero state
* is DOWN then -> NORTH -> WEST Note - To obtain Position, do a mirrorY() before
* rotating
*
* @param targetArray the array that should be rotated
*/
public static 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
*/
public static void transform(float[][] targetArray, ForgeDirection 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
*/
public static float[][] deepClone(float[][] source) {
float[][] target = source.clone();
for (int i = 0; i < target.length; i++) {
target[i] = source[i].clone();
}
return target;
}
}

View file

@ -47,9 +47,6 @@ import net.minecraftforge.common.ForgeDirection;
public class Utils { public class Utils {
public static final Random RANDOM = new Random(); public static final Random RANDOM = new Random();
public static final float pipeMinPos = 0.25F;
public static final float pipeMaxPos = 0.75F;
public static float pipeNormalSpeed = 0.01F;
private static final List<ForgeDirection> directions = new ArrayList<ForgeDirection>(Arrays.asList(ForgeDirection.VALID_DIRECTIONS)); private static final List<ForgeDirection> directions = new ArrayList<ForgeDirection>(Arrays.asList(ForgeDirection.VALID_DIRECTIONS));
/* IINVENTORY HELPERS */ /* IINVENTORY HELPERS */
@ -80,14 +77,6 @@ public class Utils {
} }
/**
* Depending on the kind of item in the pipe, set the floor at a different
* level to optimize graphical aspect.
*/
public static float getPipeFloorOf(ItemStack item) {
return pipeMinPos;
}
public static ForgeDirection get2dOrientation(Position pos1, Position pos2) { public static ForgeDirection get2dOrientation(Position pos1, Position pos2) {
double Dx = pos1.x - pos2.x; double Dx = pos1.x - pos2.x;
double Dz = pos1.z - pos2.z; double Dz = pos1.z - pos2.z;
@ -338,7 +327,7 @@ public class Utils {
if (tile instanceof IInventory && !CoreProxy.proxy.isRenderWorld(world)) { if (tile instanceof IInventory && !CoreProxy.proxy.isRenderWorld(world)) {
if (!(tile instanceof IDropControlInventory) || ((IDropControlInventory) tile).doDrop()) { if (!(tile instanceof IDropControlInventory) || ((IDropControlInventory) tile).doDrop()) {
InvUtils.dropItems(world, (IInventory) tile, i, j, k); InvUtils.dropItems(world, (IInventory) tile, i, j, k);
InvUtils.wipeInventory((IInventory)tile); InvUtils.wipeInventory((IInventory) tile);
} }
} }

View file

@ -10,6 +10,7 @@
package buildcraft.factory; package buildcraft.factory;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.core.CoreConstants;
import buildcraft.core.IFramePipeConnection; import buildcraft.core.IFramePipeConnection;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -69,7 +70,7 @@ public class BlockFrame extends Block implements IFramePipeConnection {
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { public AxisAlignedBB getCollisionBoundingBoxFromPool(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; float xMin = CoreConstants.PIPE_MIN_POS, xMax = CoreConstants.PIPE_MAX_POS, yMin = CoreConstants.PIPE_MIN_POS, yMax = CoreConstants.PIPE_MAX_POS, zMin = CoreConstants.PIPE_MIN_POS, zMax = CoreConstants.PIPE_MAX_POS;
if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) { if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) {
xMin = 0.0F; xMin = 0.0F;
@ -107,36 +108,36 @@ public class BlockFrame extends Block implements IFramePipeConnection {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) { public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) { if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) {
setBlockBounds(0.0F, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (Utils.checkLegacyPipesConnections(world, i, j, k, i + 1, j, k)) { if (Utils.checkLegacyPipesConnections(world, i, j, k, i + 1, j, k)) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, 1.0F, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 1.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j - 1, k)) { if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j - 1, k)) {
setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j + 1, k)) { if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j + 1, k)) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j, k - 1)) { if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j, k - 1)) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, 0.0F, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j, k + 1)) { if (Utils.checkLegacyPipesConnections(world, i, j, k, i, j, k + 1)) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, 1.0F); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, 1.0F);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
@ -145,7 +146,7 @@ public class BlockFrame extends Block implements IFramePipeConnection {
@Override @Override
public MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3 vec3d, Vec3 vec3d1) { 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; float xMin = CoreConstants.PIPE_MIN_POS, xMax = CoreConstants.PIPE_MAX_POS, yMin = CoreConstants.PIPE_MIN_POS, yMax = CoreConstants.PIPE_MAX_POS, zMin = CoreConstants.PIPE_MIN_POS, zMax = CoreConstants.PIPE_MAX_POS;
if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) { if (Utils.checkLegacyPipesConnections(world, i, j, k, i - 1, j, k)) {
xMin = 0.0F; xMin = 0.0F;

View file

@ -9,8 +9,8 @@
package buildcraft.factory; package buildcraft.factory;
import buildcraft.core.CoreConstants;
import buildcraft.core.IFramePipeConnection; import buildcraft.core.IFramePipeConnection;
import buildcraft.core.utils.Utils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList; import java.util.ArrayList;
@ -26,13 +26,13 @@ public class BlockPlainPipe extends Block implements IFramePipeConnection {
public BlockPlainPipe(int i) { public BlockPlainPipe(int i) {
super(i, Material.glass); super(i, Material.glass);
minX = Utils.pipeMinPos; minX = CoreConstants.PIPE_MIN_POS;
minY = 0.0; minY = 0.0;
minZ = Utils.pipeMinPos; minZ = CoreConstants.PIPE_MIN_POS;
maxX = Utils.pipeMaxPos; maxX = CoreConstants.PIPE_MAX_POS;
maxY = 1.0; maxY = 1.0;
maxZ = Utils.pipeMaxPos; maxZ = CoreConstants.PIPE_MAX_POS;
} }
@Override @Override

View file

@ -16,6 +16,7 @@ import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type; import buildcraft.api.power.PowerHandler.Type;
import buildcraft.core.BlockIndex; import buildcraft.core.BlockIndex;
import buildcraft.core.CoreConstants;
import buildcraft.core.EntityBlock; import buildcraft.core.EntityBlock;
import buildcraft.core.IMachine; import buildcraft.core.IMachine;
import buildcraft.core.TileBuffer; import buildcraft.core.TileBuffer;
@ -370,11 +371,11 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
private void setTubePosition() { private void setTubePosition() {
if (tube != null) { if (tube != null) {
tube.iSize = Utils.pipeMaxPos - Utils.pipeMinPos; tube.iSize = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
tube.kSize = Utils.pipeMaxPos - Utils.pipeMinPos; tube.kSize = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
tube.jSize = yCoord - tube.posY; tube.jSize = yCoord - tube.posY;
tube.setPosition(xCoord + Utils.pipeMinPos, tubeY, zCoord + Utils.pipeMinPos); tube.setPosition(xCoord + CoreConstants.PIPE_MIN_POS, tubeY, zCoord + CoreConstants.PIPE_MIN_POS);
} }
} }

View file

@ -11,7 +11,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -33,6 +32,7 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.core.Box; import buildcraft.core.Box;
import buildcraft.core.CoreConstants;
import buildcraft.core.DefaultAreaProvider; import buildcraft.core.DefaultAreaProvider;
import buildcraft.core.EntityRobot; import buildcraft.core.EntityRobot;
import buildcraft.core.IBuilderInventory; import buildcraft.core.IBuilderInventory;
@ -128,9 +128,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
private void createArm() { private void createArm() {
worldObj.spawnEntityInWorld(new EntityMechanicalArm(worldObj, box.xMin + Utils.pipeMaxPos, yCoord + bluePrintBuilder.bluePrint.sizeY - 1 worldObj.spawnEntityInWorld(new EntityMechanicalArm(worldObj, box.xMin + CoreConstants.PIPE_MAX_POS, yCoord + bluePrintBuilder.bluePrint.sizeY - 1
+ Utils.pipeMinPos, box.zMin + Utils.pipeMaxPos, bluePrintBuilder.bluePrint.sizeX - 2 + Utils.pipeMinPos * 2, bluePrintBuilder.bluePrint.sizeZ + CoreConstants.PIPE_MIN_POS, box.zMin + CoreConstants.PIPE_MAX_POS, bluePrintBuilder.bluePrint.sizeX - 2 + CoreConstants.PIPE_MIN_POS * 2, bluePrintBuilder.bluePrint.sizeZ
- 2 + Utils.pipeMinPos * 2, this)); - 2 + CoreConstants.PIPE_MIN_POS * 2, this));
} }
// Callback from the arm once it's created // Callback from the arm once it's created

View file

@ -9,7 +9,7 @@
package buildcraft.silicon; package buildcraft.silicon;
import buildcraft.core.utils.Utils; import buildcraft.core.CoreConstants;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
@ -121,7 +121,7 @@ public class SiliconRenderBlock implements ISimpleBlockRenderingHandler {
@Override @Override
public void renderInventoryBlock(Block block, int i, int j, RenderBlocks renderblocks) { public void renderInventoryBlock(Block block, int i, int j, RenderBlocks renderblocks) {
block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1, 4F / 16F, 1); block.setBlockBounds(0.0F, 0.0F, 0.0F, 1, 4F / 16F, 1);

View file

@ -40,30 +40,45 @@ import buildcraft.api.tools.IToolWrench;
import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.ISolidSideTile; import buildcraft.api.transport.ISolidSideTile;
import buildcraft.core.BlockIndex; import buildcraft.core.BlockIndex;
import buildcraft.core.CoreConstants;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import buildcraft.transport.render.PipeRendererWorld; import buildcraft.core.utils.MatrixTranformations;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.Arrays;
import net.minecraft.client.Minecraft;
public class BlockGenericPipe extends BlockContainer { public class BlockGenericPipe extends BlockContainer {
static enum Part { static enum Part {
Pipe, Pipe,
Gate Gate,
Facade,
Plug
} }
static class RaytraceResult { static class RaytraceResult {
RaytraceResult(Part hitPart, MovingObjectPosition movingObjectPosition) { RaytraceResult(Part hitPart, MovingObjectPosition movingObjectPosition, AxisAlignedBB boundingBox, ForgeDirection side) {
this.hitPart = hitPart; this.hitPart = hitPart;
this.movingObjectPosition = movingObjectPosition; this.movingObjectPosition = movingObjectPosition;
this.boundingBox = boundingBox;
this.sideHit = side;
}
public final Part hitPart;
public final MovingObjectPosition movingObjectPosition;
public final AxisAlignedBB boundingBox;
public final ForgeDirection sideHit;
@Override
public String toString() {
return String.format("RayTraceResult: %s, %s", hitPart == null ? "null" : hitPart.name(), boundingBox == null ? "null" : boundingBox.toString());
} }
public Part hitPart;
public MovingObjectPosition movingObjectPosition;
} }
private static final ForgeDirection[] DIR_VALUES = ForgeDirection.values();
private static Random rand = new Random(); private static Random rand = new Random();
private boolean skippedFirstIconRegister; private boolean skippedFirstIconRegister;
private char renderAxis = 'a'; private char renderAxis = 'a';
@ -130,7 +145,7 @@ public class BlockGenericPipe extends BlockContainer {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) { public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
TileEntity tile1 = world.getBlockTileEntity(i, j, k); TileEntity tile1 = world.getBlockTileEntity(i, j, k);
@ -138,36 +153,36 @@ public class BlockGenericPipe extends BlockContainer {
TileGenericPipe tileG = (TileGenericPipe) tile1; TileGenericPipe tileG = (TileGenericPipe) tile1;
if (tileG.isPipeConnected(ForgeDirection.WEST)) { if (tileG.isPipeConnected(ForgeDirection.WEST)) {
setBlockBounds(0.0F, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (tileG.isPipeConnected(ForgeDirection.EAST)) { if (tileG.isPipeConnected(ForgeDirection.EAST)) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, 1.0F, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 1.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (tileG.isPipeConnected(ForgeDirection.DOWN)) { if (tileG.isPipeConnected(ForgeDirection.DOWN)) {
setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (tileG.isPipeConnected(ForgeDirection.UP)) { if (tileG.isPipeConnected(ForgeDirection.UP)) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (tileG.isPipeConnected(ForgeDirection.NORTH)) { if (tileG.isPipeConnected(ForgeDirection.NORTH)) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, 0.0F, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
if (tileG.isPipeConnected(ForgeDirection.SOUTH)) { if (tileG.isPipeConnected(ForgeDirection.SOUTH)) {
setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, 1.0F); setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, 1.0F);
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
} }
float facadeThickness = PipeRendererWorld.facadeThickness; float facadeThickness = TransportConstants.FACADE_THICKNESS;
if (tileG.hasFacade(ForgeDirection.EAST)) { if (tileG.hasFacade(ForgeDirection.EAST)) {
setBlockBounds(1 - facadeThickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); setBlockBounds(1 - facadeThickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
@ -202,61 +217,29 @@ public class BlockGenericPipe extends BlockContainer {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
} }
@SideOnly(Side.CLIENT)
@Override @Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) { public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos; RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, Minecraft.getMinecraft().thePlayer);
TileEntity tile1 = world.getBlockTileEntity(i, j, k); if (rayTraceResult != null && rayTraceResult.boundingBox != null) {
AxisAlignedBB box = rayTraceResult.boundingBox;
if (tile1 instanceof TileGenericPipe) { switch (rayTraceResult.hitPart) {
TileGenericPipe tileG = (TileGenericPipe) tile1; case Gate:
if (tileG.isPipeConnected(ForgeDirection.WEST) || tileG.hasFacade(ForgeDirection.WEST)) { case Plug: {
xMin = 0.0F; float scale = 0.001F;
} box = box.expand(scale, scale, scale);
break;
if (tileG.isPipeConnected(ForgeDirection.EAST) || tileG.hasFacade(ForgeDirection.EAST)) { }
xMax = 1.0F; case Pipe: {
} float scale = 0.08F;
box = box.expand(scale, scale, scale);
if (tileG.isPipeConnected(ForgeDirection.DOWN) || tileG.hasFacade(ForgeDirection.DOWN)) { break;
yMin = 0.0F; }
}
if (tileG.isPipeConnected(ForgeDirection.UP) || tileG.hasFacade(ForgeDirection.UP)) {
yMax = 1.0F;
}
if (tileG.isPipeConnected(ForgeDirection.NORTH) || tileG.hasFacade(ForgeDirection.NORTH)) {
zMin = 0.0F;
}
if (tileG.isPipeConnected(ForgeDirection.SOUTH) || tileG.hasFacade(ForgeDirection.SOUTH)) {
zMax = 1.0F;
}
if (tileG.hasFacade(ForgeDirection.EAST) || tileG.hasFacade(ForgeDirection.WEST)) {
yMin = 0.0F;
yMax = 1.0F;
zMin = 0.0F;
zMax = 1.0F;
}
if (tileG.hasFacade(ForgeDirection.UP) || tileG.hasFacade(ForgeDirection.DOWN)) {
xMin = 0.0F;
xMax = 1.0F;
zMin = 0.0F;
zMax = 1.0F;
}
if (tileG.hasFacade(ForgeDirection.SOUTH) || tileG.hasFacade(ForgeDirection.NORTH)) {
xMin = 0.0F;
xMax = 1.0F;
yMin = 0.0F;
yMax = 1.0F;
} }
return box.getOffsetBoundingBox(x, y, z);
} }
return super.getSelectedBoundingBoxFromPool(world, x, y, z).expand(-0.85F, -0.85F, -0.85F);
return AxisAlignedBB.getBoundingBox((double) i + xMin, (double) j + yMin, (double) k + zMin, (double) i + xMax, (double) j + yMax, (double) k + zMax);
} }
@Override @Override
@ -291,8 +274,6 @@ public class BlockGenericPipe extends BlockContainer {
} }
private RaytraceResult doRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) { private RaytraceResult doRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
float xMin = Utils.pipeMinPos, xMax = Utils.pipeMaxPos, yMin = Utils.pipeMinPos, yMax = Utils.pipeMaxPos, zMin = Utils.pipeMinPos, zMax = Utils.pipeMaxPos;
TileEntity pipeTileEntity = world.getBlockTileEntity(x, y, z); TileEntity pipeTileEntity = world.getBlockTileEntity(x, y, z);
TileGenericPipe tileG = null; TileGenericPipe tileG = null;
@ -311,96 +292,60 @@ public class BlockGenericPipe extends BlockContainer {
* pipe hits along x, y, and z axis, gate (all 6 sides) [and * pipe hits along x, y, and z axis, gate (all 6 sides) [and
* wires+facades] * wires+facades]
*/ */
MovingObjectPosition[] hits = new MovingObjectPosition[9]; MovingObjectPosition[] hits = new MovingObjectPosition[25];
AxisAlignedBB[] boxes = new AxisAlignedBB[25];
ForgeDirection[] sideHit = new ForgeDirection[25];
Arrays.fill(sideHit, ForgeDirection.UNKNOWN);
boolean needAxisCheck = false; // pipe
boolean needCenterCheck = true;
// check along the x axis for (ForgeDirection side : DIR_VALUES) {
if (side == ForgeDirection.UNKNOWN || tileG.isPipeConnected(side)) {
if (tileG.isPipeConnected(ForgeDirection.WEST)) { AxisAlignedBB bb = getPipeBoundingBox(side);
xMin = 0.0F; setBlockBounds(bb);
needAxisCheck = true; boxes[side.ordinal()] = bb;
} hits[side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction);
sideHit[side.ordinal()] = side;
if (tileG.isPipeConnected(ForgeDirection.WEST)) { }
xMax = 1.0F;
needAxisCheck = true;
}
if (needAxisCheck) {
setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
hits[0] = super.collisionRayTrace(world, x, y, z, origin, direction);
xMin = Utils.pipeMinPos;
xMax = Utils.pipeMaxPos;
needAxisCheck = false;
needCenterCheck = false; // center already checked through this axis
}
// check along the y axis
if (tileG.isPipeConnected(ForgeDirection.DOWN)) {
yMin = 0.0F;
needAxisCheck = true;
}
if (tileG.isPipeConnected(ForgeDirection.UP)) {
yMax = 1.0F;
needAxisCheck = true;
}
if (needAxisCheck) {
setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
hits[1] = super.collisionRayTrace(world, x, y, z, origin, direction);
yMin = Utils.pipeMinPos;
yMax = Utils.pipeMaxPos;
needAxisCheck = false;
needCenterCheck = false; // center already checked through this axis
}
// check along the z axis
if (tileG.isPipeConnected(ForgeDirection.NORTH)) {
zMin = 0.0F;
needAxisCheck = true;
}
if (tileG.isPipeConnected(ForgeDirection.SOUTH)) {
zMax = 1.0F;
needAxisCheck = true;
}
if (needAxisCheck) {
setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
hits[2] = super.collisionRayTrace(world, x, y, z, origin, direction);
zMin = Utils.pipeMinPos;
zMax = Utils.pipeMaxPos;
needAxisCheck = false;
needCenterCheck = false; // center already checked through this axis
}
// check center (only if no axis were checked/the pipe has no connections)
if (needCenterCheck) {
setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
hits[0] = super.collisionRayTrace(world, x, y, z, origin, direction);
} }
// gates // gates
if (pipe.hasGate()) { for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
for (int side = 0; side < 6; side++) { if (pipe.hasGate(side)) {
setBlockBoundsToGate(ForgeDirection.VALID_DIRECTIONS[side]); AxisAlignedBB bb = getGateBoundingBox(side);
setBlockBounds(bb);
hits[3 + side] = super.collisionRayTrace(world, x, y, z, origin, direction); boxes[7 + side.ordinal()] = bb;
hits[7 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction);
sideHit[7 + side.ordinal()] = side;
} }
} }
// TODO: check wires, facades // facades
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
if (tileG.hasFacade(side)) {
AxisAlignedBB bb = getFacadeBoundingBox(side);
setBlockBounds(bb);
boxes[13 + side.ordinal()] = bb;
hits[13 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction);
sideHit[13 + side.ordinal()] = side;
}
}
// plugs
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
if (tileG.hasPlug(side)) {
AxisAlignedBB bb = getPlugBoundingBox(side);
setBlockBounds(bb);
boxes[19 + side.ordinal()] = bb;
hits[19 + side.ordinal()] = super.collisionRayTrace(world, x, y, z, origin, direction);
sideHit[19 + side.ordinal()] = side;
}
}
// TODO: check wires
// get closest hit // get closest hit
@ -429,41 +374,96 @@ public class BlockGenericPipe extends BlockContainer {
} else { } else {
Part hitPart; Part hitPart;
if (minIndex < 3) { if (minIndex < 7) {
hitPart = Part.Pipe; hitPart = Part.Pipe;
} else { } else if (minIndex < 13) {
hitPart = Part.Gate; hitPart = Part.Gate;
} else if (minIndex < 19) {
hitPart = Part.Facade;
} else {
hitPart = Part.Plug;
} }
return new RaytraceResult(hitPart, hits[minIndex]); return new RaytraceResult(hitPart, hits[minIndex], boxes[minIndex], sideHit[minIndex]);
} }
} }
private void setBlockBoundsToGate(ForgeDirection dir) { private void setBlockBounds(AxisAlignedBB bb) {
float min = Utils.pipeMinPos + 0.05F; setBlockBounds((float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ);
float max = Utils.pipeMaxPos - 0.05F; }
switch (dir) { private AxisAlignedBB getGateBoundingBox(ForgeDirection side) {
case DOWN: float min = CoreConstants.PIPE_MIN_POS + 0.05F;
setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max); float max = CoreConstants.PIPE_MAX_POS - 0.05F;
break;
case UP: float[][] bounds = new float[3][2];
setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max); // X START - END
break; bounds[0][0] = min;
case NORTH: bounds[0][1] = max;
setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos); // Y START - END
break; bounds[1][0] = CoreConstants.PIPE_MIN_POS - 0.10F;
case SOUTH: bounds[1][1] = CoreConstants.PIPE_MIN_POS;
setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F); // Z START - END
break; bounds[2][0] = min;
case WEST: bounds[2][1] = max;
setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max);
break; MatrixTranformations.transform(bounds, side);
default: return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
case EAST: }
setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max);
break; private AxisAlignedBB getFacadeBoundingBox(ForgeDirection side) {
float[][] bounds = new float[3][2];
// X START - END
bounds[0][0] = 0.0F;
bounds[0][1] = 1.0F;
// Y START - END
bounds[1][0] = 0.0F;
bounds[1][1] = TransportConstants.FACADE_THICKNESS;
// Z START - END
bounds[2][0] = 0.0F;
bounds[2][1] = 1.0F;
MatrixTranformations.transform(bounds, side);
return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
}
private AxisAlignedBB getPlugBoundingBox(ForgeDirection side) {
float[][] bounds = new float[3][2];
// X START - END
bounds[0][0] = 0.25F;
bounds[0][1] = 0.75F;
// Y START - END
bounds[1][0] = 0.125F;
bounds[1][1] = 0.251F;
// Z START - END
bounds[2][0] = 0.25F;
bounds[2][1] = 0.75F;
MatrixTranformations.transform(bounds, side);
return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
}
private AxisAlignedBB getPipeBoundingBox(ForgeDirection side) {
float min = CoreConstants.PIPE_MIN_POS;
float max = CoreConstants.PIPE_MAX_POS;
if (side == ForgeDirection.UNKNOWN) {
return AxisAlignedBB.getAABBPool().getAABB(min, min, min, max, max, max);
} }
float[][] bounds = new float[3][2];
// X START - END
bounds[0][0] = min;
bounds[0][1] = max;
// Y START - END
bounds[1][0] = 0;
bounds[1][1] = min;
// Z START - END
bounds[2][0] = min;
bounds[2][1] = max;
MatrixTranformations.transform(bounds, side);
return AxisAlignedBB.getAABBPool().getAABB(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
} }
public static void removePipe(Pipe pipe) { public static void removePipe(Pipe pipe) {
@ -619,91 +619,65 @@ public class BlockGenericPipe extends BlockContainer {
Pipe pipe = getPipe(world, x, y, z); Pipe pipe = getPipe(world, x, y, z);
if (isValid(pipe)) { if (isValid(pipe)) {
ItemStack currentItem = player.getCurrentEquippedItem();
// / Right click while sneaking without wrench to strip equipment // Right click while sneaking with empty hand to strip equipment
// from the pipe. // from the pipe.
if (player.isSneaking() if (player.isSneaking() && currentItem == null) {
&& (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof IToolWrench))) { if (stripEquipment(world, x, y, z, player, pipe))
return true;
if (pipe.hasGate() || pipe.isWired()) } else if (currentItem == null) {
return stripEquipment(pipe);
} else if (player.getCurrentEquippedItem() == null) {
// Fall through the end of the test // Fall through the end of the test
} else if (player.getCurrentEquippedItem().itemID == Item.sign.itemID) } else if (currentItem.itemID == Item.sign.itemID)
// Sign will be placed anyway, so lets show the sign gui // Sign will be placed anyway, so lets show the sign gui
return false; return false;
else if (player.getCurrentEquippedItem().getItem() instanceof ItemPipe) else if (currentItem.getItem() instanceof ItemPipe)
return false; return false;
else if (player.getCurrentEquippedItem().getItem() instanceof IToolWrench) else if (currentItem.getItem() instanceof IToolWrench)
// Only check the instance at this point. Call the IToolWrench // Only check the instance at this point. Call the IToolWrench
// interface callbacks for the individual pipe/logic calls // interface callbacks for the individual pipe/logic calls
return pipe.blockActivated(player); return pipe.blockActivated(player);
else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.redPipeWire) { else if (currentItem.getItem() == BuildCraftTransport.redPipeWire) {
if (!pipe.wireSet[IPipe.WireColor.Red.ordinal()]) { if (addOrStripWire(player, pipe, IPipe.WireColor.Red)) {
pipe.wireSet[IPipe.WireColor.Red.ordinal()] = true;
if (!player.capabilities.isCreativeMode) {
player.getCurrentEquippedItem().splitStack(1);
}
pipe.signalStrength[IPipe.WireColor.Red.ordinal()] = 0;
pipe.container.scheduleNeighborChange();
return true; return true;
} }
} else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.bluePipeWire) { } else if (currentItem.getItem() == BuildCraftTransport.bluePipeWire) {
if (!pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) { if (addOrStripWire(player, pipe, IPipe.WireColor.Blue)) {
pipe.wireSet[IPipe.WireColor.Blue.ordinal()] = true;
if (!player.capabilities.isCreativeMode) {
player.getCurrentEquippedItem().splitStack(1);
}
pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] = 0;
pipe.container.scheduleNeighborChange();
return true; return true;
} }
} else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.greenPipeWire) { } else if (currentItem.getItem() == BuildCraftTransport.greenPipeWire) {
if (!pipe.wireSet[IPipe.WireColor.Green.ordinal()]) { if (addOrStripWire(player, pipe, IPipe.WireColor.Green)) {
pipe.wireSet[IPipe.WireColor.Green.ordinal()] = true;
if (!player.capabilities.isCreativeMode) {
player.getCurrentEquippedItem().splitStack(1);
}
pipe.signalStrength[IPipe.WireColor.Green.ordinal()] = 0;
pipe.container.scheduleNeighborChange();
return true; return true;
} }
} else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.yellowPipeWire) { } else if (currentItem.getItem() == BuildCraftTransport.yellowPipeWire) {
if (!pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) { if (addOrStripWire(player, pipe, IPipe.WireColor.Yellow)) {
pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] = true;
if (!player.capabilities.isCreativeMode) {
player.getCurrentEquippedItem().splitStack(1);
}
pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] = 0;
pipe.container.scheduleNeighborChange();
return true; return true;
} }
} else if (player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGate.itemID } else if (currentItem.getItem() instanceof ItemGate) {
|| player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGateAutarchic.itemID) if (addOrStripGate(world, x, y, z, player, pipe)) {
if (!pipe.hasGate()) { return true;
}
pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem()); } else if (currentItem.getItem() instanceof ItemPlug) {
if (!player.capabilities.isCreativeMode) { if (addOrStripPlug(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) {
player.getCurrentEquippedItem().splitStack(1); return true;
} }
pipe.container.scheduleRenderUpdate(); } else if (currentItem.getItem() instanceof ItemFacade)
if (addOrStripFacade(world, x, y, z, player, ForgeDirection.getOrientation(side), pipe)) {
return true; return true;
} }
boolean openGateGui = false; boolean clickedOnGate = false;
if (pipe.hasGate()) { if (pipe.hasGate()) {
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) { if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) {
openGateGui = true; clickedOnGate = true;
} }
} }
if (openGateGui) { if (clickedOnGate) {
pipe.gate.openGui(player); pipe.gate.openGui(player);
return true; return true;
} else } else
return pipe.blockActivated(player); return pipe.blockActivated(player);
@ -712,22 +686,32 @@ public class BlockGenericPipe extends BlockContainer {
return false; return false;
} }
private boolean stripEquipment(Pipe pipe) { private boolean addOrStripGate(World world, int x, int y, int z, EntityPlayer player, Pipe pipe) {
if (addGate(player, pipe))
// Try to strip wires first, starting with yellow. return true;
for (IPipe.WireColor color : IPipe.WireColor.values()) { if (player.isSneaking()) {
if (pipe.wireSet[color.reverse().ordinal()]) { RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) {
dropWire(color.reverse(), pipe); if (stripGate(pipe))
} return true;
pipe.wireSet[color.reverse().ordinal()] = false;
// pipe.worldObj.markBlockNeedsUpdate(pipe.xCoord, pipe.yCoord, pipe.zCoord);
pipe.container.scheduleRenderUpdate();
return true;
} }
} }
return false;
}
// Try to strip gate next private boolean addGate(EntityPlayer player, Pipe pipe) {
if (!pipe.hasGate()) {
pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem());
if (!player.capabilities.isCreativeMode) {
player.getCurrentEquippedItem().splitStack(1);
}
pipe.container.scheduleRenderUpdate();
return true;
}
return false;
}
private boolean stripGate(Pipe pipe) {
if (pipe.hasGate()) { if (pipe.hasGate()) {
if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
pipe.gate.dropGate(); pipe.gate.dropGate();
@ -735,10 +719,116 @@ public class BlockGenericPipe extends BlockContainer {
pipe.resetGate(); pipe.resetGate();
return true; return true;
} }
return false; return false;
} }
private boolean addOrStripWire(EntityPlayer player, Pipe pipe, IPipe.WireColor color) {
if (addWire(pipe, color)) {
if (!player.capabilities.isCreativeMode) {
player.getCurrentEquippedItem().splitStack(1);
}
return true;
}
return player.isSneaking() && stripWire(pipe, color);
}
private boolean addWire(Pipe pipe, IPipe.WireColor color) {
if (!pipe.wireSet[color.ordinal()]) {
pipe.wireSet[color.ordinal()] = true;
pipe.signalStrength[color.ordinal()] = 0;
pipe.container.scheduleNeighborChange();
return true;
}
return false;
}
private boolean stripWire(Pipe pipe, IPipe.WireColor color) {
if (pipe.wireSet[color.ordinal()]) {
if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
dropWire(color, pipe);
}
pipe.wireSet[color.ordinal()] = false;
pipe.container.scheduleRenderUpdate();
return true;
}
return false;
}
private boolean addOrStripFacade(World world, int x, int y, int z, EntityPlayer player, ForgeDirection side, Pipe pipe) {
if (player.isSneaking()) {
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) {
if (stripFacade(pipe, rayTraceResult.sideHit))
return true;
}
}
if (addFacade(player, pipe, side))
return true;
return false;
}
private boolean addFacade(EntityPlayer player, Pipe pipe, ForgeDirection side) {
ItemStack stack = player.getCurrentEquippedItem();
if (pipe.container.addFacade(side, ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) {
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
return true;
}
return false;
}
private boolean stripFacade(Pipe pipe, ForgeDirection side) {
return pipe.container.dropFacade(side);
}
private boolean addOrStripPlug(World world, int x, int y, int z, EntityPlayer player, ForgeDirection side, Pipe pipe) {
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
if (player.isSneaking()) {
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Plug) {
if (stripPlug(pipe, rayTraceResult.sideHit))
return true;
}
}
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Pipe) {
if (addPlug(player, pipe, rayTraceResult.sideHit != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side))
return true;
}
return false;
}
private boolean addPlug(EntityPlayer player, Pipe pipe, ForgeDirection side) {
ItemStack stack = player.getCurrentEquippedItem();
if (pipe.container.addPlug(side)) {
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
return true;
}
return false;
}
private boolean stripPlug(Pipe pipe, ForgeDirection side) {
return pipe.container.removeAndDropPlug(side);
}
private boolean stripEquipment(World world, int x, int y, int z, EntityPlayer player, Pipe pipe) {
// Try to strip facades first
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Facade) {
if (stripFacade(pipe, rayTraceResult.sideHit))
return true;
}
// Try to strip wires second, starting with yellow.
for (IPipe.WireColor color : IPipe.WireColor.values()) {
if (stripWire(pipe, color))
return true;
}
return stripGate(pipe);
}
/** /**
* Drops a pipe wire item of the passed color. * Drops a pipe wire item of the passed color.
* *

View file

@ -71,30 +71,30 @@ public class ItemFacade extends ItemBuildCraft {
} }
} }
@Override // @Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { // public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (worldObj.isRemote) // if (worldObj.isRemote)
return false; // return false;
TileEntity tile = worldObj.getBlockTileEntity(x, y, z); // TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
if (!(tile instanceof TileGenericPipe)) // if (!(tile instanceof TileGenericPipe))
return false; // return false;
TileGenericPipe pipeTile = (TileGenericPipe) tile; // TileGenericPipe pipeTile = (TileGenericPipe) tile;
//
if (player.isSneaking()) { // Strip facade // if (player.isSneaking()) { // Strip facade
if (!pipeTile.hasFacade(ForgeDirection.VALID_DIRECTIONS[side])) // if (!pipeTile.hasFacade(ForgeDirection.VALID_DIRECTIONS[side]))
return false; // return false;
pipeTile.dropFacade(ForgeDirection.VALID_DIRECTIONS[side]); // pipeTile.dropFacade(ForgeDirection.VALID_DIRECTIONS[side]);
return true; // return true;
} else { // } else {
if (((TileGenericPipe) tile).addFacade(ForgeDirection.values()[side], ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) { // if (((TileGenericPipe) tile).addFacade(ForgeDirection.values()[side], ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) {
if (!player.capabilities.isCreativeMode) { // if (!player.capabilities.isCreativeMode) {
stack.stackSize--; // stack.stackSize--;
} // }
return true; // return true;
} // }
return false; // return false;
} // }
} // }
public static void initialize() { public static void initialize() {
for (Field f : Block.class.getDeclaredFields()) { for (Field f : Block.class.getDeclaredFields()) {

View file

@ -46,6 +46,7 @@ public class ItemGate extends ItemBuildCraft {
setHasSubtypes(true); setHasSubtypes(true);
setMaxDamage(0); setMaxDamage(0);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft); setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setPassSneakClick(true);
} }
@SuppressWarnings({ "all" }) @SuppressWarnings({ "all" })

View file

@ -23,30 +23,30 @@ public class ItemPlug extends ItemBuildCraft {
return "item.PipePlug"; return "item.PipePlug";
} }
@Override // @Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { // public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (worldObj.isRemote) // if (worldObj.isRemote)
return false; // return false;
TileEntity tile = worldObj.getBlockTileEntity(x, y, z); // TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
if (!(tile instanceof TileGenericPipe)) // if (!(tile instanceof TileGenericPipe))
return false; // return false;
TileGenericPipe pipeTile = (TileGenericPipe) tile; // TileGenericPipe pipeTile = (TileGenericPipe) tile;
//
if (player.isSneaking()) { // Strip plug // if (player.isSneaking()) { // Strip plug
if (!pipeTile.hasPlug(ForgeDirection.VALID_DIRECTIONS[side])) // if (!pipeTile.hasPlug(ForgeDirection.VALID_DIRECTIONS[side]))
return false; // return false;
pipeTile.removeAndDropPlug(ForgeDirection.VALID_DIRECTIONS[side]); // pipeTile.removeAndDropPlug(ForgeDirection.VALID_DIRECTIONS[side]);
return true; // return true;
} else { // } else {
if (((TileGenericPipe) tile).addPlug(ForgeDirection.VALID_DIRECTIONS[side])){ // if (((TileGenericPipe) tile).addPlug(ForgeDirection.VALID_DIRECTIONS[side])){
if (!player.capabilities.isCreativeMode) { // if (!player.capabilities.isCreativeMode) {
stack.stackSize--; // stack.stackSize--;
} // }
return true; // return true;
} // }
return false; // return false;
} // }
} // }
@Override @Override
public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z ) { public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z ) {

View file

@ -365,6 +365,30 @@ public abstract class Pipe<T extends PipeTransport> implements IPipe, IDropContr
return gate != null; return gate != null;
} }
public boolean hasGate(ForgeDirection side) {
if (!hasGate())
return false;
if (container.hasFacade(side))
return false;
if (container.hasPlug(side))
return false;
int connections = 0;
ForgeDirection targetOrientation = ForgeDirection.UNKNOWN;
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
if (container.isPipeConnected(o)) {
connections++;
if (connections == 1)
targetOrientation = o;
}
}
if (connections > 1 || connections == 0)
return true;
return targetOrientation.getOpposite() != side;
}
protected void notifyBlocksOfNeighborChange(ForgeDirection side) { protected void notifyBlocksOfNeighborChange(ForgeDirection side) {
container.worldObj.notifyBlocksOfNeighborChange(container.xCoord + side.offsetX, container.yCoord + side.offsetY, container.zCoord + side.offsetZ, BuildCraftTransport.genericPipeBlock.blockID); container.worldObj.notifyBlocksOfNeighborChange(container.xCoord + side.offsetX, container.yCoord + side.offsetY, container.zCoord + side.offsetZ, BuildCraftTransport.genericPipeBlock.blockID);
} }

View file

@ -19,10 +19,10 @@ import buildcraft.core.inventory.Transactor;
import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketIds;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.BlockUtil;
import buildcraft.core.utils.Utils;
import buildcraft.transport.network.PacketPipeTransportContent; import buildcraft.transport.network.PacketPipeTransportContent;
import buildcraft.transport.network.PacketPipeTransportNBT; import buildcraft.transport.network.PacketPipeTransportNBT;
import buildcraft.transport.network.PacketSimpleId; import buildcraft.transport.network.PacketSimpleId;
import buildcraft.transport.utils.TransportUtils;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.ForwardingSet; import com.google.common.collect.ForwardingSet;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
@ -134,12 +134,12 @@ public class PipeTransportItems extends PipeTransport {
public void defaultReajustSpeed(TravelingItem item) { public void defaultReajustSpeed(TravelingItem item) {
float speed = item.getSpeed(); float speed = item.getSpeed();
if (speed > Utils.pipeNormalSpeed) { if (speed > TransportConstants.PIPE_NORMAL_SPEED) {
speed -= Utils.pipeNormalSpeed; speed -= TransportConstants.PIPE_NORMAL_SPEED;
} }
if (speed < Utils.pipeNormalSpeed) { if (speed < TransportConstants.PIPE_NORMAL_SPEED) {
speed = Utils.pipeNormalSpeed; speed = TransportConstants.PIPE_NORMAL_SPEED;
} }
item.setSpeed(speed); item.setSpeed(speed);
@ -159,7 +159,7 @@ public class PipeTransportItems extends PipeTransport {
z = Math.min(z, container.zCoord + 0.99); z = Math.min(z, container.zCoord + 0.99);
if (item.input != ForgeDirection.UP && item.input != ForgeDirection.DOWN) { if (item.input != ForgeDirection.UP && item.input != ForgeDirection.DOWN) {
y = container.yCoord + Utils.getPipeFloorOf(item.getItemStack()); y = container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack());
} }
item.setPosition(x, y, z); item.setPosition(x, y, z);
@ -338,7 +338,7 @@ public class PipeTransportItems extends PipeTransport {
item.toCenter = false; item.toCenter = false;
// Reajusting to the middle // Reajusting to the middle
item.setPosition(container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(item.getItemStack()), container.zCoord + 0.5); item.setPosition(container.xCoord + 0.5, container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()), container.zCoord + 0.5);
if (item.output == ForgeDirection.UNKNOWN) { if (item.output == ForgeDirection.UNKNOWN) {
if (travelHook != null) { if (travelHook != null) {
@ -421,7 +421,7 @@ public class PipeTransportItems extends PipeTransport {
protected boolean middleReached(TravelingItem item) { protected boolean middleReached(TravelingItem item) {
float middleLimit = item.getSpeed() * 1.01F; float middleLimit = item.getSpeed() * 1.01F;
return (Math.abs(container.xCoord + 0.5 - item.xCoord) < middleLimit && Math.abs(container.yCoord + Utils.getPipeFloorOf(item.getItemStack()) - item.yCoord) < middleLimit && Math return (Math.abs(container.xCoord + 0.5 - item.xCoord) < middleLimit && Math.abs(container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()) - item.yCoord) < middleLimit && Math
.abs(container.zCoord + 0.5 - item.zCoord) < middleLimit); .abs(container.zCoord + 0.5 - item.zCoord) < middleLimit);
} }

View file

@ -570,6 +570,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
} }
public boolean hasFacade(ForgeDirection direction) { public boolean hasFacade(ForgeDirection direction) {
if (direction == null || direction == ForgeDirection.UNKNOWN)
return false;
if (this.worldObj.isRemote) if (this.worldObj.isRemote)
return renderState.facadeMatrix.getFacadeBlockId(direction) != 0; return renderState.facadeMatrix.getFacadeBlockId(direction) != 0;
return (this.facadeBlocks[direction.ordinal()] != 0); return (this.facadeBlocks[direction.ordinal()] != 0);
@ -579,16 +581,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
InvUtils.dropItems(worldObj, ItemFacade.getStack(this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()]), this.xCoord, this.yCoord, this.zCoord); InvUtils.dropItems(worldObj, ItemFacade.getStack(this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()]), this.xCoord, this.yCoord, this.zCoord);
} }
public void dropFacade(ForgeDirection direction) { public boolean dropFacade(ForgeDirection direction) {
if (this.worldObj.isRemote)
return;
if (!hasFacade(direction)) if (!hasFacade(direction))
return; return false;
dropFacadeItem(direction); if (!worldObj.isRemote) {
this.facadeBlocks[direction.ordinal()] = 0; dropFacadeItem(direction);
this.facadeMeta[direction.ordinal()] = 0; this.facadeBlocks[direction.ordinal()] = 0;
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); this.facadeMeta[direction.ordinal()] = 0;
scheduleRenderUpdate(); worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
scheduleRenderUpdate();
}
return true;
} }
/** /**
@ -677,15 +680,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
return plugs[side.ordinal()]; return plugs[side.ordinal()];
} }
public void removeAndDropPlug(ForgeDirection side) { public boolean removeAndDropPlug(ForgeDirection side) {
if (!hasPlug(side)) if (!hasPlug(side))
return; return false;
if (!worldObj.isRemote) {
plugs[side.ordinal()] = false; plugs[side.ordinal()] = false;
InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord); InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord);
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
scheduleNeighborChange(); //To force recalculation of connections scheduleNeighborChange(); //To force recalculation of connections
scheduleRenderUpdate(); scheduleRenderUpdate();
}
return true;
} }
public boolean addPlug(ForgeDirection forgeDirection) { public boolean addPlug(ForgeDirection forgeDirection) {
@ -714,7 +719,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
public boolean isUseableByPlayer(EntityPlayer player) { public boolean isUseableByPlayer(EntityPlayer player) {
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this;
} }
@Override @Override
public void writeGuiData(DataOutputStream data) throws IOException { public void writeGuiData(DataOutputStream data) throws IOException {
if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler) if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler)

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* 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 buildcraft.transport;
import net.minecraft.item.ItemStack;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class TransportConstants {
public static final float FACADE_THICKNESS = 1F / 16F;
public static final float PIPE_NORMAL_SPEED = 0.01F;
}

View file

@ -14,12 +14,12 @@ import buildcraft.api.gates.IAction;
import buildcraft.api.tools.IToolWrench; import buildcraft.api.tools.IToolWrench;
import buildcraft.core.network.TileNetworkData; import buildcraft.core.network.TileNetworkData;
import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.EnumColor;
import buildcraft.core.utils.Utils;
import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TileGenericPipe; import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem; import buildcraft.transport.TravelingItem;
import buildcraft.transport.triggers.ActionPipeColor; import buildcraft.transport.triggers.ActionPipeColor;
import buildcraft.transport.triggers.ActionPipeDirection; import buildcraft.transport.triggers.ActionPipeDirection;
@ -140,12 +140,12 @@ public class PipeItemsDaizuli extends Pipe<PipeTransportItems> implements IPipeT
@Override @Override
public void readjustSpeed(TravelingItem item) { public void readjustSpeed(TravelingItem item) {
if (item.getSpeed() > Utils.pipeNormalSpeed) if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED)
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F); item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F);
if (item.getSpeed() < Utils.pipeNormalSpeed) if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED)
item.setSpeed(Utils.pipeNormalSpeed); item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
} }
@Override @Override

View file

@ -10,11 +10,11 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.Position; import buildcraft.api.core.Position;
import buildcraft.core.utils.Utils;
import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem; import buildcraft.transport.TravelingItem;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -50,6 +50,6 @@ public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook {
@Override @Override
public void readjustSpeed(TravelingItem item) { public void readjustSpeed(TravelingItem item) {
item.setSpeed(Math.min(Math.max(Utils.pipeNormalSpeed, item.getSpeed()) * 2f, Utils.pipeNormalSpeed * 20F)); item.setSpeed(Math.min(Math.max(TransportConstants.PIPE_NORMAL_SPEED, item.getSpeed()) * 2f, TransportConstants.PIPE_NORMAL_SPEED * 20F));
} }
} }

View file

@ -13,12 +13,12 @@ import buildcraft.api.core.Position;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.tools.IToolWrench; import buildcraft.api.tools.IToolWrench;
import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.EnumColor;
import buildcraft.core.utils.Utils;
import buildcraft.transport.IItemTravelingHook; import buildcraft.transport.IItemTravelingHook;
import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem; import buildcraft.transport.TravelingItem;
import buildcraft.transport.triggers.ActionPipeColor; import buildcraft.transport.triggers.ActionPipeColor;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -96,12 +96,12 @@ public class PipeItemsLapis extends Pipe<PipeTransportItems> implements IItemTra
@Override @Override
public void readjustSpeed(TravelingItem item) { public void readjustSpeed(TravelingItem item) {
if (item.getSpeed() > Utils.pipeNormalSpeed) { if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F); item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F);
} }
if (item.getSpeed() < Utils.pipeNormalSpeed) { if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(Utils.pipeNormalSpeed); item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
} }
} }

View file

@ -19,10 +19,10 @@ import buildcraft.core.inventory.Transactor;
import buildcraft.core.inventory.filters.StackFilter; import buildcraft.core.inventory.filters.StackFilter;
import buildcraft.transport.TravelingItem; import buildcraft.transport.TravelingItem;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.utils.TransportUtils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.util.Arrays; import java.util.Arrays;
@ -226,7 +226,7 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IPowe
CoreProxy.proxy.removeEntity(entity); CoreProxy.proxy.removeEntity(entity);
} }
TravelingItem passive = new TravelingItem(container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(stack), container.zCoord + 0.5, stack); TravelingItem passive = new TravelingItem(container.xCoord + 0.5, container.yCoord + TransportUtils.getPipeFloorOf(stack), container.zCoord + 0.5, stack);
passive.setSpeed((float) speed); passive.setSpeed((float) speed);

View file

@ -10,11 +10,11 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.Position; import buildcraft.api.core.Position;
import buildcraft.core.utils.Utils;
import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem; import buildcraft.transport.TravelingItem;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -41,12 +41,12 @@ public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook {
@Override @Override
public void readjustSpeed(TravelingItem item) { public void readjustSpeed(TravelingItem item) {
if (item.getSpeed() > Utils.pipeNormalSpeed) { if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F); item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F);
} }
if (item.getSpeed() < Utils.pipeNormalSpeed) { if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(Utils.pipeNormalSpeed); item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
} }
} }

View file

@ -10,11 +10,11 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.Position; import buildcraft.api.core.Position;
import buildcraft.core.utils.Utils;
import buildcraft.transport.IPipeTransportItemsHook; import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem; import buildcraft.transport.TravelingItem;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -40,12 +40,12 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
@Override @Override
public void readjustSpeed(TravelingItem item) { public void readjustSpeed(TravelingItem item) {
if (item.getSpeed() > Utils.pipeNormalSpeed) { if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 2.0F); item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 2.0F);
} }
if (item.getSpeed() < Utils.pipeNormalSpeed) { if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(Utils.pipeNormalSpeed); item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
} }
} }

View file

@ -1,7 +1,7 @@
package buildcraft.transport.render; package buildcraft.transport.render;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.core.utils.Utils; import buildcraft.core.CoreConstants;
import buildcraft.transport.ItemFacade; import buildcraft.transport.ItemFacade;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -11,6 +11,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.IItemRenderer;
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class FacadeItemRenderer implements IItemRenderer { public class FacadeItemRenderer implements IItemRenderer {
@ -72,7 +73,7 @@ public class FacadeItemRenderer implements IItemRenderer {
block = BuildCraftTransport.genericPipeBlock; block = BuildCraftTransport.genericPipeBlock;
Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe
block.setBlockBounds(Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos - 1F / 16F); block.setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS - 1F / 16F);
block.setBlockBoundsForItemRender(); block.setBlockBoundsForItemRender();
render.setRenderBoundsFromBlock(block); render.setRenderBoundsFromBlock(block);
GL11.glTranslatef(translateX, translateY, translateZ + 0.25F); GL11.glTranslatef(translateX, translateY, translateZ + 0.25F);
@ -112,6 +113,8 @@ public class FacadeItemRenderer implements IItemRenderer {
return true; return true;
case EQUIPPED: case EQUIPPED:
return true; return true;
case EQUIPPED_FIRST_PERSON:
return true;
case INVENTORY: case INVENTORY:
return true; return true;
default: default:
@ -133,6 +136,7 @@ public class FacadeItemRenderer implements IItemRenderer {
renderFacadeItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F); renderFacadeItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F);
break; break;
case EQUIPPED: case EQUIPPED:
case EQUIPPED_FIRST_PERSON:
renderFacadeItem((RenderBlocks) data[0], item, 0F, 0F, 0f); renderFacadeItem((RenderBlocks) data[0], item, 0F, 0F, 0f);
break; break;
case INVENTORY: case INVENTORY:

View file

@ -1,7 +1,7 @@
package buildcraft.transport.render; package buildcraft.transport.render;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.core.utils.Utils; import buildcraft.core.CoreConstants;
import buildcraft.transport.ItemPipe; import buildcraft.transport.ItemPipe;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -27,7 +27,7 @@ public class PipeItemRenderer implements IItemRenderer {
if (icon == null) if (icon == null)
icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
block.setBlockBounds(Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
block.setBlockBoundsForItemRender(); block.setBlockBoundsForItemRender();
render.setRenderBoundsFromBlock(block); render.setRenderBoundsFromBlock(block);

View file

@ -12,11 +12,11 @@ import buildcraft.BuildCraftCore.RenderMode;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipe.WireColor; import buildcraft.api.transport.IPipe.WireColor;
import buildcraft.core.CoreConstants;
import buildcraft.core.render.FluidRenderer; import buildcraft.core.render.FluidRenderer;
import buildcraft.core.render.RenderEntityBlock; import buildcraft.core.render.RenderEntityBlock;
import buildcraft.core.render.RenderEntityBlock.RenderInfo; import buildcraft.core.render.RenderEntityBlock.RenderInfo;
import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.EnumColor;
import buildcraft.core.utils.Utils;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeRenderState; import buildcraft.transport.PipeRenderState;
@ -98,7 +98,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
} }
block.texture = fluid.getStillIcon(); block.texture = fluid.getStillIcon();
float size = Utils.pipeMaxPos - Utils.pipeMinPos; float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
// render size // render size
@ -111,12 +111,12 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
GL11.glNewList(d.sideHorizontal[s], 4864 /* GL_COMPILE */); GL11.glNewList(d.sideHorizontal[s], 4864 /* GL_COMPILE */);
block.minX = 0.0F; block.minX = 0.0F;
block.minZ = Utils.pipeMinPos + 0.01F; block.minZ = CoreConstants.PIPE_MIN_POS + 0.01F;
block.maxX = block.minX + size / 2F + 0.01F; block.maxX = block.minX + size / 2F + 0.01F;
block.maxZ = block.minZ + size - 0.02F; block.maxZ = block.minZ + size - 0.02F;
block.minY = Utils.pipeMinPos + 0.01F; block.minY = CoreConstants.PIPE_MIN_POS + 0.01F;
block.maxY = block.minY + (size - 0.02F) * ratio; block.maxY = block.minY + (size - 0.02F) * ratio;
RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true);
@ -128,7 +128,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
d.sideVertical[s] = GLAllocation.generateDisplayLists(1); d.sideVertical[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(d.sideVertical[s], 4864 /* GL_COMPILE */); GL11.glNewList(d.sideVertical[s], 4864 /* GL_COMPILE */);
block.minY = Utils.pipeMaxPos - 0.01; block.minY = CoreConstants.PIPE_MAX_POS - 0.01;
block.maxY = 1; block.maxY = 1;
block.minX = 0.5 - (size / 2 - 0.01) * ratio; block.minX = 0.5 - (size / 2 - 0.01) * ratio;
@ -146,13 +146,13 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
d.centerHorizontal[s] = GLAllocation.generateDisplayLists(1); d.centerHorizontal[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(d.centerHorizontal[s], 4864 /* GL_COMPILE */); GL11.glNewList(d.centerHorizontal[s], 4864 /* GL_COMPILE */);
block.minX = Utils.pipeMinPos + 0.01; block.minX = CoreConstants.PIPE_MIN_POS + 0.01;
block.minZ = Utils.pipeMinPos + 0.01; block.minZ = CoreConstants.PIPE_MIN_POS + 0.01;
block.maxX = block.minX + size - 0.02; block.maxX = block.minX + size - 0.02;
block.maxZ = block.minZ + size - 0.02; block.maxZ = block.minZ + size - 0.02;
block.minY = Utils.pipeMinPos + 0.01; block.minY = CoreConstants.PIPE_MIN_POS + 0.01;
block.maxY = block.minY + (size - 0.02F) * ratio; block.maxY = block.minY + (size - 0.02F) * ratio;
RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true);
@ -164,8 +164,8 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
d.centerVertical[s] = GLAllocation.generateDisplayLists(1); d.centerVertical[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(d.centerVertical[s], 4864 /* GL_COMPILE */); GL11.glNewList(d.centerVertical[s], 4864 /* GL_COMPILE */);
block.minY = Utils.pipeMinPos + 0.01; block.minY = CoreConstants.PIPE_MIN_POS + 0.01;
block.maxY = Utils.pipeMaxPos - 0.01; block.maxY = CoreConstants.PIPE_MAX_POS - 0.01;
block.minX = 0.5 - (size / 2 - 0.02) * ratio; block.minX = 0.5 - (size / 2 - 0.02) * ratio;
block.maxX = 0.5 + (size / 2 - 0.02) * ratio; block.maxX = 0.5 + (size / 2 - 0.02) * ratio;
@ -192,7 +192,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
RenderInfo block = new RenderInfo(); RenderInfo block = new RenderInfo();
block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Normal.ordinal()); block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Normal.ordinal());
float size = Utils.pipeMaxPos - Utils.pipeMinPos; float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
for (int s = 0; s < POWER_STAGES; ++s) { for (int s = 0; s < POWER_STAGES; ++s) {
displayPowerList[s] = GLAllocation.generateDisplayLists(1); displayPowerList[s] = GLAllocation.generateDisplayLists(1);
@ -218,7 +218,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Overload.ordinal()); block.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Power_Overload.ordinal());
size = Utils.pipeMaxPos - Utils.pipeMinPos; size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS;
for (int s = 0; s < POWER_STAGES; ++s) { for (int s = 0; s < POWER_STAGES; ++s) {
displayPowerListOverload[s] = GLAllocation.generateDisplayLists(1); displayPowerListOverload[s] = GLAllocation.generateDisplayLists(1);
@ -273,19 +273,19 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
PipeRenderState state = pipe.getRenderState(); PipeRenderState state = pipe.getRenderState();
if (state.wireMatrix.hasWire(WireColor.Red)) { if (state.wireMatrix.hasWire(WireColor.Red)) {
pipeWireRender(pipe, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, IPipe.WireColor.Red, x, y, z); pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, IPipe.WireColor.Red, x, y, z);
} }
if (state.wireMatrix.hasWire(WireColor.Blue)) { if (state.wireMatrix.hasWire(WireColor.Blue)) {
pipeWireRender(pipe, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos, IPipe.WireColor.Blue, x, y, z); pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, IPipe.WireColor.Blue, x, y, z);
} }
if (state.wireMatrix.hasWire(WireColor.Green)) { if (state.wireMatrix.hasWire(WireColor.Green)) {
pipeWireRender(pipe, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMinPos, IPipe.WireColor.Green, x, y, z); pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, IPipe.WireColor.Green, x, y, z);
} }
if (state.wireMatrix.hasWire(WireColor.Yellow)) { if (state.wireMatrix.hasWire(WireColor.Yellow)) {
pipeWireRender(pipe, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, IPipe.WireColor.Yellow, x, y, z); pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, IPipe.WireColor.Yellow, x, y, z);
} }
if (state.hasGate()) { if (state.hasGate()) {
@ -297,13 +297,13 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
PipeRenderState state = pipe.getRenderState(); PipeRenderState state = pipe.getRenderState();
float minX = Utils.pipeMinPos; float minX = CoreConstants.PIPE_MIN_POS;
float minY = Utils.pipeMinPos; float minY = CoreConstants.PIPE_MIN_POS;
float minZ = Utils.pipeMinPos; float minZ = CoreConstants.PIPE_MIN_POS;
float maxX = Utils.pipeMaxPos; float maxX = CoreConstants.PIPE_MAX_POS;
float maxY = Utils.pipeMaxPos; float maxY = CoreConstants.PIPE_MAX_POS;
float maxZ = Utils.pipeMaxPos; float maxZ = CoreConstants.PIPE_MAX_POS;
boolean foundX = false, foundY = false, foundZ = false; boolean foundX = false, foundY = false, foundZ = false;
@ -340,43 +340,43 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
boolean center = false; boolean center = false;
if (minX == 0 && maxX != 1 && (foundY || foundZ)) if (minX == 0 && maxX != 1 && (foundY || foundZ))
if (cx == Utils.pipeMinPos) { if (cx == CoreConstants.PIPE_MIN_POS) {
maxX = Utils.pipeMinPos; maxX = CoreConstants.PIPE_MIN_POS;
} else { } else {
center = true; center = true;
} }
if (minX != 0 && maxX == 1 && (foundY || foundZ)) if (minX != 0 && maxX == 1 && (foundY || foundZ))
if (cx == Utils.pipeMaxPos) { if (cx == CoreConstants.PIPE_MAX_POS) {
minX = Utils.pipeMaxPos; minX = CoreConstants.PIPE_MAX_POS;
} else { } else {
center = true; center = true;
} }
if (minY == 0 && maxY != 1 && (foundX || foundZ)) if (minY == 0 && maxY != 1 && (foundX || foundZ))
if (cy == Utils.pipeMinPos) { if (cy == CoreConstants.PIPE_MIN_POS) {
maxY = Utils.pipeMinPos; maxY = CoreConstants.PIPE_MIN_POS;
} else { } else {
center = true; center = true;
} }
if (minY != 0 && maxY == 1 && (foundX || foundZ)) if (minY != 0 && maxY == 1 && (foundX || foundZ))
if (cy == Utils.pipeMaxPos) { if (cy == CoreConstants.PIPE_MAX_POS) {
minY = Utils.pipeMaxPos; minY = CoreConstants.PIPE_MAX_POS;
} else { } else {
center = true; center = true;
} }
if (minZ == 0 && maxZ != 1 && (foundX || foundY)) if (minZ == 0 && maxZ != 1 && (foundX || foundY))
if (cz == Utils.pipeMinPos) { if (cz == CoreConstants.PIPE_MIN_POS) {
maxZ = Utils.pipeMinPos; maxZ = CoreConstants.PIPE_MIN_POS;
} else { } else {
center = true; center = true;
} }
if (minZ != 0 && maxZ == 1 && (foundX || foundY)) if (minZ != 0 && maxZ == 1 && (foundX || foundY))
if (cz == Utils.pipeMaxPos) { if (cz == CoreConstants.PIPE_MAX_POS) {
minZ = Utils.pipeMaxPos; minZ = CoreConstants.PIPE_MAX_POS;
} else { } else {
center = true; center = true;
} }
@ -389,10 +389,16 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_CULL_FACE);
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
GL11.glColor3f(1, 1, 1); GL11.glColor3f(1, 1, 1);
GL11.glTranslatef((float) x, (float) y, (float) z); GL11.glTranslatef((float) x, (float) y, (float) z);
float scale = 1.001f;
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
bindTexture(TextureMap.locationBlocksTexture); bindTexture(TextureMap.locationBlocksTexture);
RenderInfo box = new RenderInfo(); RenderInfo box = new RenderInfo();
@ -400,36 +406,36 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
// Z render // Z render
if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) { if (minZ != CoreConstants.PIPE_MIN_POS || maxZ != CoreConstants.PIPE_MAX_POS || !found) {
box.setBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ, cx == Utils.pipeMinPos ? cx box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, minZ, cx == CoreConstants.PIPE_MIN_POS ? cx
: cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ); : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, maxZ);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
// X render // X render
if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) { if (minX != CoreConstants.PIPE_MIN_POS || maxX != CoreConstants.PIPE_MAX_POS || !found) {
box.setBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX, cy == Utils.pipeMinPos ? cy box.setBounds(minX, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, maxX, cy == CoreConstants.PIPE_MIN_POS ? cy
: cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F); : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
// Y render // Y render
if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) { if (minY != CoreConstants.PIPE_MIN_POS || maxY != CoreConstants.PIPE_MAX_POS || !found) {
box.setBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, minY, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx
: cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F); : cx + 0.05F, maxY, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
if (center || !found) { if (center || !found) {
box.setBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? 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); cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
RenderHelper.enableStandardItemLighting(); RenderHelper.enableStandardItemLighting();
GL11.glPopAttrib(); GL11.glPopAttrib();
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@ -442,7 +448,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_CULL_FACE);
// GL11.glDisable(GL11.GL_TEXTURE_2D); // GL11.glDisable(GL11.GL_TEXTURE_2D);
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
GL11.glColor3f(1, 1, 1); GL11.glColor3f(1, 1, 1);
GL11.glTranslatef((float) x, (float) y, (float) z); GL11.glTranslatef((float) x, (float) y, (float) z);
@ -450,42 +456,42 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
PipeRenderState state = pipe.getRenderState(); PipeRenderState state = pipe.getRenderState();
float min = Utils.pipeMinPos + 0.05F; float min = CoreConstants.PIPE_MIN_POS + 0.05F;
float max = Utils.pipeMaxPos - 0.05F; float max = CoreConstants.PIPE_MAX_POS - 0.05F;
RenderInfo box = new RenderInfo(); RenderInfo box = new RenderInfo();
box.texture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex()); box.texture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex());
if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) { if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) {
box.setBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos + 0.001F, max, max); box.setBounds(CoreConstants.PIPE_MIN_POS - 0.10F, min, min, CoreConstants.PIPE_MIN_POS + 0.001F, max, max);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) { if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) {
box.setBounds(Utils.pipeMaxPos + 0.001F, min, min, Utils.pipeMaxPos + 0.10F, max, max); box.setBounds(CoreConstants.PIPE_MAX_POS + 0.001F, min, min, CoreConstants.PIPE_MAX_POS + 0.10F, max, max);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) { if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) {
box.setBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos + 0.001F, max); box.setBounds(min, CoreConstants.PIPE_MIN_POS - 0.10F, min, max, CoreConstants.PIPE_MIN_POS + 0.001F, max);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) { if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) {
box.setBounds(min, Utils.pipeMaxPos + 0.001F, min, max, Utils.pipeMaxPos + 0.10F, max); box.setBounds(min, CoreConstants.PIPE_MAX_POS + 0.001F, min, max, CoreConstants.PIPE_MAX_POS + 0.10F, max);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) { if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) {
box.setBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos + 0.001F); box.setBounds(min, min, CoreConstants.PIPE_MIN_POS - 0.10F, max, max, CoreConstants.PIPE_MIN_POS + 0.001F);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) { if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) {
box.setBounds(min, min, Utils.pipeMaxPos + 0.001F, max, max, Utils.pipeMaxPos + 0.10F); box.setBounds(min, min, CoreConstants.PIPE_MAX_POS + 0.001F, max, max, CoreConstants.PIPE_MAX_POS + 0.10F);
RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true);
} }
RenderHelper.enableStandardItemLighting(); RenderHelper.enableStandardItemLighting();
GL11.glPopAttrib(); GL11.glPopAttrib();

View file

@ -2,12 +2,14 @@ package buildcraft.transport.render;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IIconProvider;
import buildcraft.core.utils.Utils; import buildcraft.core.CoreConstants;
import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.IPipeRenderState; import buildcraft.transport.IPipeRenderState;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeRenderState; import buildcraft.transport.PipeRenderState;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TransportProxy; import buildcraft.transport.TransportProxy;
import buildcraft.core.utils.MatrixTranformations;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
@ -20,62 +22,8 @@ import net.minecraftforge.common.ForgeDirection;
public class PipeRendererWorld implements ISimpleBlockRenderingHandler { public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
public static final float facadeThickness = 1F / 16F;
/**
* 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 DOWN then -> NORTH -> WEST 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, ForgeDirection 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;
}
private void renderAllFaceExeptAxe(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int x, int y, int z, char axe) { private void renderAllFaceExeptAxe(RenderBlocks renderblocks, BlockGenericPipe block, Icon icon, int x, int y, int z, char axe) {
float minX = (float) renderblocks.renderMinX; float minX = (float) renderblocks.renderMinX;
@ -121,8 +69,8 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, IPipeRenderState renderState, int x, int y, int z) { public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, IPipeRenderState renderState, int x, int y, int z) {
float minSize = Utils.pipeMinPos; float minSize = CoreConstants.PIPE_MIN_POS;
float maxSize = Utils.pipeMaxPos; float maxSize = CoreConstants.PIPE_MAX_POS;
PipeRenderState state = renderState.getRenderState(); PipeRenderState state = renderState.getRenderState();
IIconProvider icons = renderState.getPipeIcons(); IIconProvider icons = renderState.getPipeIcons();
@ -210,7 +158,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
zeroState[0][1] = 1.0F + zFightOffset / 2; zeroState[0][1] = 1.0F + zFightOffset / 2;
// Y START - END // Y START - END
zeroState[1][0] = 0.0F - zFightOffset; zeroState[1][0] = 0.0F - zFightOffset;
zeroState[1][1] = facadeThickness; zeroState[1][1] = TransportConstants.FACADE_THICKNESS;
// Z START - END // Z START - END
zeroState[2][0] = 0.0F; zeroState[2][0] = 0.0F;
zeroState[2][1] = 1.0F; zeroState[2][1] = 1.0F;
@ -241,39 +189,39 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
// Hollow facade // Hollow facade
if (state.pipeConnectionMatrix.isConnected(direction)) { if (state.pipeConnectionMatrix.isConnected(direction)) {
float[][] rotated = deepClone(zeroState); float[][] rotated = MatrixTranformations.deepClone(zeroState);
rotated[2][0] = 0.0F; rotated[2][0] = 0.0F;
rotated[2][1] = Utils.pipeMinPos - zFightOffset; rotated[2][1] = CoreConstants.PIPE_MIN_POS - zFightOffset;
rotated[1][0] -= zFightOffset / 2; rotated[1][0] -= zFightOffset / 2;
transform(rotated, direction); MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z); renderblocks.renderStandardBlock(block, x, y, z);
rotated = deepClone(zeroState); rotated = MatrixTranformations.deepClone(zeroState);
rotated[2][0] = Utils.pipeMaxPos + zFightOffset; rotated[2][0] = CoreConstants.PIPE_MAX_POS + zFightOffset;
rotated[1][0] -= zFightOffset / 2; rotated[1][0] -= zFightOffset / 2;
transform(rotated, direction); MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z); renderblocks.renderStandardBlock(block, x, y, z);
rotated = deepClone(zeroState); rotated = MatrixTranformations.deepClone(zeroState);
rotated[0][0] = 0.0F; rotated[0][0] = 0.0F;
rotated[0][1] = Utils.pipeMinPos - zFightOffset; rotated[0][1] = CoreConstants.PIPE_MIN_POS - zFightOffset;
rotated[1][1] -= zFightOffset; rotated[1][1] -= zFightOffset;
transform(rotated, direction); MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z); renderblocks.renderStandardBlock(block, x, y, z);
rotated = deepClone(zeroState); rotated = MatrixTranformations.deepClone(zeroState);
rotated[0][0] = Utils.pipeMaxPos + zFightOffset; rotated[0][0] = CoreConstants.PIPE_MAX_POS + zFightOffset;
rotated[0][1] = 1F; rotated[0][1] = 1F;
rotated[1][1] -= zFightOffset; rotated[1][1] -= zFightOffset;
transform(rotated, direction); MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z); renderblocks.renderStandardBlock(block, x, y, z);
} else { // Solid facade } else { // Solid facade
float[][] rotated = deepClone(zeroState); float[][] rotated = MatrixTranformations.deepClone(zeroState);
transform(rotated, direction); MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z); renderblocks.renderStandardBlock(block, x, y, z);
} }
@ -292,21 +240,21 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
} }
// X START - END // X START - END
zeroState[0][0] = Utils.pipeMinPos; zeroState[0][0] = CoreConstants.PIPE_MIN_POS;
zeroState[0][1] = Utils.pipeMaxPos; zeroState[0][1] = CoreConstants.PIPE_MAX_POS;
// Y START - END // Y START - END
zeroState[1][0] = facadeThickness; zeroState[1][0] = TransportConstants.FACADE_THICKNESS;
zeroState[1][1] = Utils.pipeMinPos; zeroState[1][1] = CoreConstants.PIPE_MIN_POS;
// Z START - END // Z START - END
zeroState[2][0] = Utils.pipeMinPos; zeroState[2][0] = CoreConstants.PIPE_MIN_POS;
zeroState[2][1] = Utils.pipeMaxPos; zeroState[2][1] = CoreConstants.PIPE_MAX_POS;
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) { if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) {
float[][] rotated = deepClone(zeroState); float[][] rotated = MatrixTranformations.deepClone(zeroState);
transform(rotated, direction); MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z); renderblocks.renderStandardBlock(block, x, y, z);
@ -333,8 +281,8 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (state.plugMatrix.isConnected(direction)) { if (state.plugMatrix.isConnected(direction)) {
float[][] rotated = deepClone(zeroState); float[][] rotated = MatrixTranformations.deepClone(zeroState);
transform(rotated, direction); MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z); renderblocks.renderStandardBlock(block, x, y, z);
@ -355,8 +303,8 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (state.plugMatrix.isConnected(direction)) { if (state.plugMatrix.isConnected(direction)) {
float[][] rotated = deepClone(zeroState); float[][] rotated = MatrixTranformations.deepClone(zeroState);
transform(rotated, direction); MatrixTranformations.transform(rotated, direction);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(block, x, y, z); renderblocks.renderStandardBlock(block, x, y, z);

View file

@ -11,7 +11,7 @@
*/ */
package buildcraft.transport.render; package buildcraft.transport.render;
import buildcraft.core.utils.Utils; import buildcraft.transport.utils.TransportUtils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntityFX;
@ -42,7 +42,7 @@ public class TileEntityPickupFX extends EntityFX
this.entityToPickUp = par2Entity; this.entityToPickUp = par2Entity;
this.entityPickingUp = par3Entity; this.entityPickingUp = par3Entity;
this.maxAge = 3; this.maxAge = 3;
this.yOffs = Utils.getPipeFloorOf(par2Entity.getEntityItem()); this.yOffs = TransportUtils.getPipeFloorOf(par2Entity.getEntityItem());
} }
@Override @Override

View file

@ -0,0 +1,27 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* 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 buildcraft.transport.utils;
import buildcraft.core.CoreConstants;
import net.minecraft.item.ItemStack;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class TransportUtils {
/**
* Depending on the kind of item in the pipe, set the floor at a different
* level to optimize graphical aspect.
*/
public static float getPipeFloorOf(ItemStack item) {
return CoreConstants.PIPE_MIN_POS;
}
}