Power Pipe rework

Explosions are gone, loss over distance is gone.

Added two new Power pipes, Cobble and Diamond.

All pipes have much smaller max throughput:
Cobble = 8 MJ/t
Stone = 16 MJ/t
Gold = 64 MJ/t
Diamond = 256 MJ/t

The power display will turn red if a pipe has hit its max capacity. You
can use smaller pipes to throttle certain parts of your power net.

Machines are more lossy now to make up for the lossless pipes. Expect
low power draws even when idle.

Also added on/off Gate action support to lasers and ACTs.
This commit is contained in:
CovertJaguar 2013-06-12 02:35:15 -07:00
parent 6dd4287945
commit 8f7292ec06
27 changed files with 372 additions and 283 deletions

View file

@ -64,8 +64,10 @@ item.PipeLiquidsIron=Iron Waterproof Pipe
item.PipeLiquidsGold=Golden Waterproof Pipe
item.PipeLiquidsEmerald=Emerald Waterproof Pipe
item.PipePowerWood=Wooden Conductive Pipe
item.PipePowerCobblestone=Cobblestone Conductive Pipe
item.PipePowerStone=Stone Conductive Pipe
item.PipePowerGold=Golden Conductive Pipe
item.PipePowerDiamond=Diamond Conductive Pipe
item.PipeItemsStripes=Stripes Transport Pipe
item.PipeStructureCobblestone=Cobblestone Structure Pipe
item.PipeItemsVoid=Void Transport Pipe

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

View file

@ -67,6 +67,8 @@ import buildcraft.transport.pipes.PipeLiquidsSandstone;
import buildcraft.transport.pipes.PipeLiquidsStone;
import buildcraft.transport.pipes.PipeLiquidsVoid;
import buildcraft.transport.pipes.PipeLiquidsWood;
import buildcraft.transport.pipes.PipePowerCobblestone;
import buildcraft.transport.pipes.PipePowerDiamond;
import buildcraft.transport.pipes.PipePowerGold;
import buildcraft.transport.pipes.PipePowerStone;
import buildcraft.transport.pipes.PipePowerWood;
@ -103,7 +105,6 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
public class BuildCraftTransport {
public static BlockGenericPipe genericPipeBlock;
public static boolean usePipeLoss;
public static int maxItemsInPipes;
public static float pipeDurability;
@ -136,8 +137,10 @@ public class BuildCraftTransport {
public static Item pipeLiquidsEmerald;
public static Item pipePowerWood;
public static Item pipePowerCobblestone;
public static Item pipePowerStone;
public static Item pipePowerGold;
public static Item pipePowerDiamond;
public static Item facadeItem;
public static Item plugItem;
@ -223,10 +226,6 @@ public class BuildCraftTransport {
@PreInit
public void preInitialize(FMLPreInitializationEvent evt) {
try {
Property pipeLoss = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "power.usePipeLoss", DefaultProps.USE_PIPELOSS);
pipeLoss.comment = "Set to false to turn off energy loss over distance on all power pipes";
usePipeLoss = pipeLoss.getBoolean(DefaultProps.USE_PIPELOSS);
Property durability = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pipes.durability", DefaultProps.PIPES_DURABILITY);
durability.comment = "How long a pipe will take to break";
pipeDurability = (float) durability.getDouble(DefaultProps.PIPES_DURABILITY);
@ -293,8 +292,10 @@ public class BuildCraftTransport {
pipeLiquidsEmerald = createPipe(DefaultProps.PIPE_LIQUIDS_EMERALD_ID, PipeLiquidsEmerald.class, "Emerald Waterproof Pipe", pipeWaterproof, pipeItemsEmerald, null);
pipePowerWood = createPipe(DefaultProps.PIPE_POWER_WOOD_ID, PipePowerWood.class, "Wooden Conductive Pipe", Item.redstone, pipeItemsWood, null);
pipePowerCobblestone = createPipe(DefaultProps.PIPE_POWER_COBBLESTONE_ID, PipePowerCobblestone.class, "Cobblestone Conductive Pipe", Item.redstone, pipeItemsCobblestone, null);
pipePowerStone = createPipe(DefaultProps.PIPE_POWER_STONE_ID, PipePowerStone.class, "Stone Conductive Pipe", Item.redstone, pipeItemsStone, null);
pipePowerGold = createPipe(DefaultProps.PIPE_POWER_GOLD_ID, PipePowerGold.class, "Golden Conductive Pipe", Item.redstone, pipeItemsGold, null);
pipePowerDiamond = createPipe(DefaultProps.PIPE_POWER_DIAMOND_ID, PipePowerDiamond.class, "Diamond Conductive Pipe", Item.redstone, pipeItemsDiamond, null);
pipeStructureCobblestone = createPipe(DefaultProps.PIPE_STRUCTURE_COBBLESTONE_ID, PipeStructureCobblestone.class, "Cobblestone Structure Pipe", Block.gravel, pipeItemsCobblestone, null);

View file

@ -23,6 +23,7 @@ import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftBuilders;
import buildcraft.api.core.LaserKind;
import buildcraft.api.core.Position;
import buildcraft.api.gates.IAction;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerFramework;
@ -639,7 +640,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
}
@Override
public boolean allowActions() {
public boolean allowAction(IAction action) {
return false;
}
}

View file

@ -23,19 +23,17 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerFramework;
import buildcraft.core.Box;
import buildcraft.core.IMachine;
import buildcraft.core.TileBuildCraft;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.TileNetworkData;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.ActionMachineControl;
import buildcraft.core.triggers.ActionMachineControl.Mode;
import buildcraft.core.utils.Utils;
import buildcraft.factory.TileMachine;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowerReceptor, IMachine, IActionReceptor {
public class TileFiller extends TileMachine implements ISidedInventory, IPowerReceptor, IMachine, IActionReceptor {
private static int[] SLOTS_GRID = Utils.createSlotArray(0, 9);
private static int[] SLOTS_INPUT = Utils.createSlotArray(9, 27);
@ -54,8 +52,12 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
public TileFiller() {
contents = new ItemStack[getSizeInventory()];
powerProvider = PowerFramework.currentFramework.createPowerProvider();
initPowerProvider();
}
private void initPowerProvider() {
powerProvider.configure(20, 25, 50, 25, 100);
powerProvider.configurePowerPerdition(25, 40);
powerProvider.configurePowerPerdition(1, 1);
}
@Override
@ -353,14 +355,6 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
public void closeChest() {
}
@Override
public int powerRequest(ForgeDirection from) {
if (isActive())
return powerProvider.getMaxEnergyReceived();
else
return 0;
}
@Override
public void actionActivated(IAction action) {
if (action == BuildCraftCore.actionOn) {
@ -373,14 +367,15 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
}
@Override
public boolean allowActions() {
public boolean allowAction(IAction action) {
return true;
}
@Override
public boolean isStackValidForSlot(int slot, ItemStack stack) {
if (slot < 9) {
if(getStackInSlot(slot) != null) return false;
if (getStackInSlot(slot) != null)
return false;
return stack.itemID == Block.brick.blockID || stack.itemID == Block.glass.blockID;
}
return true;

View file

@ -116,7 +116,6 @@ public class DefaultProps {
public static boolean CURRENT_CONTINUOUS = false;
public static double PIPES_DURABILITY = 0.25D;
public static boolean FILLER_DESTROY = false;
public static boolean USE_PIPELOSS = true;
public static int TRIGGER_REDSTONE_ACTIVE = 1;
public static int TRIGGER_REDSTONE_INACTIVE = 2;

View file

@ -9,6 +9,8 @@
package buildcraft.core;
import buildcraft.api.gates.IAction;
public interface IMachine {
public boolean isActive();
@ -17,6 +19,6 @@ public interface IMachine {
public boolean manageSolids();
public boolean allowActions();
public boolean allowAction(IAction action);
}

View file

@ -8,6 +8,8 @@ import buildcraft.BuildCraftCore;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionProvider;
import buildcraft.core.IMachine;
import cpw.mods.fml.common.FMLLog;
import java.util.logging.Level;
public class DefaultActionProvider implements IActionProvider {
@ -17,13 +19,20 @@ public class DefaultActionProvider implements IActionProvider {
res.add(BuildCraftCore.actionRedstone);
if (tile instanceof IMachine && ((IMachine) tile).allowActions()) {
res.add(BuildCraftCore.actionOn);
res.add(BuildCraftCore.actionOff);
res.add(BuildCraftCore.actionLoop);
try {
if (tile instanceof IMachine) {
IMachine machine = (IMachine) tile;
if (machine.allowAction(BuildCraftCore.actionOn))
res.add(BuildCraftCore.actionOn);
if (machine.allowAction(BuildCraftCore.actionOff))
res.add(BuildCraftCore.actionOff);
if (machine.allowAction(BuildCraftCore.actionLoop))
res.add(BuildCraftCore.actionLoop);
}
} catch (Throwable error) {
FMLLog.log("Buildcraft", Level.SEVERE, "Outdated API detected, please update your mods!");
}
return res;
}
}

View file

@ -1,14 +1,13 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* 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.factory;
import buildcraft.api.power.IPowerProvider;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.core.IMachine;
@ -18,11 +17,8 @@ public abstract class TileMachine extends TileBuildCraft implements IMachine, IP
@Override
public int powerRequest(ForgeDirection from) {
if (isActive())
return (int) Math.ceil(Math.min(getPowerProvider().getMaxEnergyReceived(), getPowerProvider().getMaxEnergyStored()
- getPowerProvider().getEnergyStored()));
else
return 0;
IPowerProvider p = getPowerProvider();
float needed = p.getMaxEnergyStored() - p.getEnergyStored();
return (int) Math.ceil(Math.min(p.getMaxEnergyReceived(), needed));
}
}

View file

@ -17,6 +17,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftFactory;
import buildcraft.api.gates.IAction;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerFramework;
@ -34,6 +35,7 @@ public class TileMiningWell extends TileMachine implements IMachine, IPowerRecep
public TileMiningWell() {
powerProvider = PowerFramework.currentFramework.createPowerProvider();
powerProvider.configure(50, 1, 25, 25, 1000);
powerProvider.configurePowerPerdition(1, 1);
}
/**
@ -131,7 +133,7 @@ public class TileMiningWell extends TileMachine implements IMachine, IPowerRecep
}
@Override
public boolean allowActions() {
public boolean allowAction(IAction action) {
return false;
}
}

View file

@ -1,12 +1,10 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* 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.factory;
import java.util.HashSet;
@ -27,6 +25,7 @@ import net.minecraftforge.liquids.LiquidTank;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftFactory;
import buildcraft.api.core.Position;
import buildcraft.api.gates.IAction;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerFramework;
@ -41,25 +40,24 @@ import buildcraft.core.utils.Utils;
public class TilePump extends TileMachine implements IMachine, IPowerReceptor, ITankContainer {
public static int MAX_LIQUID = LiquidContainerRegistry.BUCKET_VOLUME;
EntityBlock tube;
private TreeMap<Integer, LinkedList<BlockIndex>> blocksToPump = new TreeMap<Integer, LinkedList<BlockIndex>>();
LiquidTank tank;
double tubeY = Double.NaN;
int aimY = 0;
private IPowerProvider powerProvider;
public TilePump() {
powerProvider = PowerFramework.currentFramework.createPowerProvider();
powerProvider.configure(20, 1, 10, 10, 100);
initPowerProvider();
tank = new LiquidTank(MAX_LIQUID);
}
// TODO, manage this by different levels (pump what's above first...)
private void initPowerProvider() {
powerProvider.configure(20, 1, 8, 10, 100);
}
// TODO, manage this by different levels (pump what's above first...)
@Override
public void updateEntity() {
super.updateEntity();
@ -144,7 +142,7 @@ public class TilePump extends TileMachine implements IMachine, IPowerReceptor, I
@Override
public void initialize() {
tube = FactoryProxy.proxy.newPumpTube(worldObj);
tube = FactoryProxy.proxy.newPumpTube(worldObj);
if (!Double.isNaN(tubeY)) {
tube.posY = tubeY;
@ -233,7 +231,7 @@ public class TilePump extends TileMachine implements IMachine, IPowerReceptor, I
addToPumpIfLiquid(new BlockIndex(index.i, index.j + 1, index.k), markedBlocks, lastFound, pumpList, liquidId);
if(System.currentTimeMillis() > timeoutTime)
if (System.currentTimeMillis() > timeoutTime)
return;
}
}
@ -264,11 +262,11 @@ public class TilePump extends TileMachine implements IMachine, IPowerReceptor, I
}
private boolean isLiquid(BlockIndex index) {
if(index == null)
if (index == null)
return false;
LiquidStack liquid = Utils.liquidFromBlockId(worldObj.getBlockId(index.i, index.j, index.k));
if(liquid == null)
if (liquid == null)
return false;
return BuildCraftFactory.pumpDimensionList.isLiquidAllowed(liquid, worldObj.provider.dimensionId);
@ -288,8 +286,7 @@ public class TilePump extends TileMachine implements IMachine, IPowerReceptor, I
tubeY = nbttagcompound.getFloat("tubeY");
PowerFramework.currentFramework.loadPowerProvider(this, nbttagcompound);
powerProvider.configure(20, 1, 10, 10, 100);
initPowerProvider();
}
@Override
@ -405,12 +402,11 @@ public class TilePump extends TileMachine implements IMachine, IPowerReceptor, I
}
@Override
public boolean allowActions() {
public boolean allowAction(IAction action) {
return false;
}
// ITankContainer implementation.
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) {
// not acceptable
@ -438,7 +434,7 @@ public class TilePump extends TileMachine implements IMachine, IPowerReceptor, I
@Override
public ILiquidTank[] getTanks(ForgeDirection direction) {
return new ILiquidTank[] { tank };
return new ILiquidTank[]{tank};
}
@Override

View file

@ -1,12 +1,10 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* 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.factory;
import java.util.LinkedList;
@ -28,6 +26,7 @@ import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftFactory;
import buildcraft.api.core.IAreaProvider;
import buildcraft.api.core.LaserKind;
import buildcraft.api.gates.IAction;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerFramework;
@ -53,6 +52,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, IPipeConnection, IBuilderInventory {
public @TileNetworkData
Box box = new Box();
public @TileNetworkData
@ -65,21 +65,21 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
double speed = 0.03;
public @TileNetworkData
boolean builderDone = false;
public EntityRobot builder;
BptBuilderBase bluePrintBuilder;
public EntityMechanicalArm arm;
public IPowerProvider powerProvider;
boolean isDigging = false;
public static final int MAX_ENERGY = 15000;
public TileQuarry() {
powerProvider = PowerFramework.currentFramework.createPowerProvider();
initPowerProvider();
}
private void initPowerProvider() {
powerProvider.configure(20, 25, 100, 25, MAX_ENERGY);
powerProvider.configurePowerPerdition(2, 1);
}
public void createUtilsIfNeeded() {
@ -113,7 +113,6 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
isDigging = true;
}
}
private boolean loadDefaultBoundaries = false;
private boolean movingHorizontally;
private boolean movingVertically;
@ -233,7 +232,6 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
int[] target = getTarget();
headTrajectory = Math.atan2(target[2] - head[2], target[0] - head[0]);
}
private final LinkedList<int[]> visitList = Lists.newLinkedList();
public boolean findTarget(boolean doSet) {
@ -323,7 +321,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
if (!BlockUtil.canChangeBlock(blockID, worldObj, bx, by, bz)) {
blockedColumns[searchX][searchZ] = true;
} else if (!BlockUtil.isSoftBlock(blockID, worldObj, bx, by, bz)) {
visitList.add(new int[] { bx, by, bz });
visitList.add(new int[]{bx, by, bz});
}
// Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this
if (visitList.size() > bluePrintBuilder.bluePrint.sizeZ * bluePrintBuilder.bluePrint.sizeX * 2)
@ -339,6 +337,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
super.readFromNBT(nbttagcompound);
PowerFramework.currentFramework.loadPowerProvider(this, nbttagcompound);
initPowerProvider();
if (nbttagcompound.hasKey("box")) {
box.initialize(nbttagcompound.getCompoundTag("box"));
@ -518,7 +517,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
if (placedBy != null && CoreProxy.proxy.isSimulating(worldObj)) {
PacketDispatcher.sendPacketToPlayer(
new Packet3Chat(String.format("[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available",
xCoord, yCoord, zCoord)), (Player) placedBy);
xCoord, yCoord, zCoord)), (Player) placedBy);
}
sendNetworkUpdate();
return;
@ -547,7 +546,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
if (placedBy != null) {
PacketDispatcher.sendPacketToPlayer(
new Packet3Chat(String.format("Quarry size is outside of chunkloading bounds or too small %d %d (%d)", xSize, zSize,
chunkTicket.getMaxChunkListDepth())), (Player) placedBy);
chunkTicket.getMaxChunkListDepth())), (Player) placedBy);
}
a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10);
@ -571,23 +570,23 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
ForgeDirection o = ForgeDirection.values()[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)].getOpposite();
switch (o) {
case EAST:
xMin = xCoord + 1;
zMin = zCoord - 4 - 1;
break;
case WEST:
xMin = xCoord - 9 - 2;
zMin = zCoord - 4 - 1;
break;
case SOUTH:
xMin = xCoord - 4 - 1;
zMin = zCoord + 1;
break;
case NORTH:
default:
xMin = xCoord - 4 - 1;
zMin = zCoord - 9 - 2;
break;
case EAST:
xMin = xCoord + 1;
zMin = zCoord - 4 - 1;
break;
case WEST:
xMin = xCoord - 9 - 2;
zMin = zCoord - 4 - 1;
break;
case SOUTH:
xMin = xCoord - 4 - 1;
zMin = zCoord + 1;
break;
case NORTH:
default:
xMin = xCoord - 4 - 1;
zMin = zCoord - 9 - 2;
break;
}
box.initialize(xMin, yCoord, zMin, xMin + xSize - 1, yCoord + ySize - 1, zMin + zSize - 1);
@ -710,7 +709,6 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
}
@Override
@ -727,7 +725,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
public int getInventoryStackLimit() {
return 0;
}
@Override
public boolean isStackValidForSlot(int i, ItemStack itemstack) {
return false;
@ -752,7 +750,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
}
@Override
public boolean allowActions() {
public boolean allowAction(IAction action) {
return false;
}
@ -815,11 +813,11 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
}
private double[] getHead() {
return new double[] { headPosX, headPosY, headPosZ };
return new double[]{headPosX, headPosY, headPosZ};
}
private int[] getTarget() {
return new int[] { targetX, targetY, targetZ };
return new int[]{targetX, targetY, targetZ};
}
private void setTarget(int x, int y, int z) {
@ -853,5 +851,4 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
}
sendNetworkUpdate();
}
}

View file

@ -1,12 +1,10 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* 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.factory;
import net.minecraft.entity.player.EntityPlayer;
@ -23,6 +21,7 @@ import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.IAction;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerFramework;
@ -36,26 +35,19 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
private int[] filters = new int[2];
private int[] filtersMeta = new int[2];
public static int LIQUID_PER_SLOT = LiquidContainerRegistry.BUCKET_VOLUME * 4;
public LiquidTank ingredient1 = new LiquidTank(LIQUID_PER_SLOT);
public LiquidTank ingredient2 = new LiquidTank(LIQUID_PER_SLOT);
public LiquidTank result = new LiquidTank(LIQUID_PER_SLOT);
public float animationSpeed = 1;
private int animationStage = 0;
SafeTimeTracker time = new SafeTimeTracker();
SafeTimeTracker updateNetworkTime = new SafeTimeTracker();
IPowerProvider powerProvider;
private boolean isActive;
public TileRefinery() {
powerProvider = PowerFramework.currentFramework.createPowerProvider();
powerProvider.configure(20, 25, 100, 25, 1000);
filters[0] = 0;
filters[1] = 0;
@ -63,6 +55,11 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
filtersMeta[1] = 0;
}
private void initPowerProvider() {
powerProvider.configure(20, 25, 100, 25, 1000);
powerProvider.configurePowerPerdition(1, 1);
}
@Override
public int getSizeInventory() {
return 0;
@ -80,7 +77,6 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
}
@Override
@ -92,7 +88,7 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
public int getInventoryStackLimit() {
return 0;
}
@Override
public boolean isStackValidForSlot(int i, ItemStack itemstack) {
return false;
@ -120,7 +116,6 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
@Override
public void doWork() {
}
@Override
@ -260,7 +255,7 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
animationSpeed = nbttagcompound.getFloat("animationSpeed");
PowerFramework.currentFramework.loadPowerProvider(this, nbttagcompound);
powerProvider.configure(20, 25, 100, 25, 1000);
initPowerProvider();
filters[0] = nbttagcompound.getInteger("filters_0");
filters[1] = nbttagcompound.getInteger("filters_1");
@ -365,25 +360,25 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
}
@Override
public boolean allowActions() {
public boolean allowAction(IAction action) {
return false;
}
/* SMP GUI */
public void getGUINetworkData(int i, int j) {
switch (i) {
case 0:
filters[0] = j;
break;
case 1:
filters[1] = j;
break;
case 2:
filtersMeta[0] = j;
break;
case 3:
filtersMeta[1] = j;
break;
case 0:
filters[0] = j;
break;
case 1:
filters[1] = j;
break;
case 2:
filtersMeta[0] = j;
break;
case 3:
filtersMeta[1] = j;
break;
}
}
@ -449,7 +444,7 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
@Override
public ILiquidTank[] getTanks(ForgeDirection direction) {
return new ILiquidTank[] { ingredient1, ingredient2, result };
return new ILiquidTank[]{ingredient1, ingredient2, result};
}
@Override
@ -501,7 +496,6 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
}
// Network
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(9, 1, 0);

View file

@ -1,5 +1,8 @@
package buildcraft.silicon;
import buildcraft.BuildCraftCore;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionReceptor;
import java.util.Arrays;
import java.util.List;
@ -23,12 +26,13 @@ import buildcraft.core.network.PacketSlotChange;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.CraftingHelper;
import buildcraft.core.inventory.SimpleInventory;
import buildcraft.core.triggers.ActionMachineControl;
import buildcraft.core.utils.Utils;
import com.google.common.collect.Lists;
import net.minecraftforge.common.ForgeDirection;
public class TileAdvancedCraftingTable extends TileEntity implements IInventory, ILaserTarget, IMachine {
public class TileAdvancedCraftingTable extends TileEntity implements IInventory, ILaserTarget, IMachine, IActionReceptor {
private final class InternalInventoryCraftingContainer extends Container {
@ -139,6 +143,7 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
private int recentEnergyAverage;
private InternalPlayer internalPlayer;
private IRecipe currentRecipe;
private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown;
@Override
public int getSizeInventory() {
@ -295,6 +300,9 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
if (!CoreProxy.proxy.isSimulating(worldObj)) {
return;
}
if (lastMode == ActionMachineControl.Mode.Off) {
return;
}
updateCraftingResults();
tick++;
tick = tick % recentEnergy.length;
@ -393,7 +401,7 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
@Override
public boolean hasCurrentWork() {
return craftable;
return craftable && lastMode != ActionMachineControl.Mode.Off;
}
@Override
@ -433,8 +441,8 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
}
@Override
public boolean allowActions() {
return true;
public boolean allowAction(IAction action) {
return action == BuildCraftCore.actionOn || action == BuildCraftCore.actionOff;
}
public void getGUINetworkData(int id, int data) {
@ -479,4 +487,13 @@ public class TileAdvancedCraftingTable extends TileEntity implements IInventory,
public boolean isStackValidForSlot(int slot, ItemStack stack) {
return true;
}
@Override
public void actionActivated(IAction action) {
if (action == BuildCraftCore.actionOn) {
lastMode = ActionMachineControl.Mode.On;
} else if (action == BuildCraftCore.actionOff) {
lastMode = ActionMachineControl.Mode.Off;
}
}
}

View file

@ -1,5 +1,6 @@
package buildcraft.silicon;
import buildcraft.api.gates.IAction;
import java.util.LinkedList;
import net.minecraft.entity.item.EntityItem;
@ -458,7 +459,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
@Override
public boolean allowActions() {
public boolean allowAction(IAction action) {
return false;
}

View file

@ -1,14 +1,13 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* 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.silicon;
import buildcraft.BuildCraftCore;
import java.util.LinkedList;
import net.minecraft.nbt.NBTTagCompound;
@ -16,37 +15,43 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.core.Position;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionReceptor;
import buildcraft.api.power.IPowerProvider;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerFramework;
import buildcraft.core.BlockIndex;
import buildcraft.core.EntityEnergyLaser;
import buildcraft.core.TileBuildCraft;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.ActionMachineControl;
import buildcraft.factory.TileMachine;
public class TileLaser extends TileBuildCraft implements IPowerReceptor {
public class TileLaser extends TileMachine implements IPowerReceptor, IActionReceptor {
private EntityEnergyLaser laser = null;
private final SafeTimeTracker laserTickTracker = new SafeTimeTracker();
private final SafeTimeTracker searchTracker = new SafeTimeTracker();
private final SafeTimeTracker networkTracker = new SafeTimeTracker();
private ILaserTarget laserTarget;
public IPowerProvider powerProvider;
private int nextNetworkUpdate = 3;
private int nextLaserUpdate = 10;
private int nextLaserSearch = 100;
private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown;
public TileLaser() {
powerProvider = PowerFramework.currentFramework.createPowerProvider();
powerProvider.configure(20, 25, 25, 25, 1000);
initPowerProvider();
}
private void initPowerProvider() {
powerProvider.configure(20, 25, 25, 25, 1000);
powerProvider.configurePowerPerdition(1, 1);
}
@Override
public void updateEntity() {
super.updateEntity();
if (!CoreProxy.proxy.isSimulating(worldObj))
return;
@ -57,6 +62,12 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor {
return;
}
// If a gate disabled us, remove laser and do nothing.
if (lastMode == ActionMachineControl.Mode.Off) {
removeLaser();
return;
}
// Check for available tables if none is linked to this laser.
if (!isValidTable())
if (canFindTable()) {
@ -65,10 +76,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor {
// If we still don't have a valid table or the existing has
// become invalid, we disable the laser and do nothing.
// Also bleed some energy from the provider which will result that a
// laser will eventually run out of power and stop searching
if (!isValidTable()) {
powerProvider.useEnergy(0F, 0.1F, true);
removeLaser();
return;
}
@ -122,25 +130,25 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor {
int maxZ = zCoord + 5;
switch (ForgeDirection.values()[meta]) {
case WEST:
maxX = xCoord;
break;
case EAST:
minX = xCoord;
break;
case DOWN:
maxY = yCoord;
break;
case UP:
minY = yCoord;
break;
case NORTH:
maxZ = zCoord;
break;
default:
case SOUTH:
minZ = zCoord;
break;
case WEST:
maxX = xCoord;
break;
case EAST:
minX = xCoord;
break;
case DOWN:
maxY = yCoord;
break;
case UP:
minY = yCoord;
break;
case NORTH:
maxZ = zCoord;
break;
default:
case SOUTH:
minZ = zCoord;
break;
}
LinkedList<BlockIndex> targets = new LinkedList<BlockIndex>();
@ -182,25 +190,25 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor {
switch (ForgeDirection.values()[meta]) {
case WEST:
px = -0.3;
break;
case EAST:
px = 0.3;
break;
case DOWN:
py = -0.3;
break;
case UP:
py = 0.3;
break;
case NORTH:
pz = -0.3;
break;
case SOUTH:
default:
pz = 0.3;
break;
case WEST:
px = -0.3;
break;
case EAST:
px = 0.3;
break;
case DOWN:
py = -0.3;
break;
case UP:
py = 0.3;
break;
case NORTH:
pz = -0.3;
break;
case SOUTH:
default:
pz = 0.3;
break;
}
Position head = new Position(xCoord + 0.5 + px, yCoord + 0.5 + py, zCoord + 0.5 + pz);
@ -236,27 +244,19 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor {
public void doWork() {
}
@Override
public int powerRequest(ForgeDirection from) {
if (powerProvider.getEnergyStored() < 200 || laser != null)
return 25;
else
return 0;
}
@Override
public void sendNetworkUpdate() {
if (networkTracker.markTimeIfDelay(worldObj, nextNetworkUpdate)) {
super.sendNetworkUpdate();
}
};
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
PowerFramework.currentFramework.loadPowerProvider(this, nbttagcompound);
powerProvider.configure(20, 25, 25, 25, 1000);
initPowerProvider();
}
@Override
@ -272,4 +272,32 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor {
removeLaser();
}
@Override
public boolean isActive() {
return laser != null;
}
@Override
public boolean manageLiquids() {
return false;
}
@Override
public boolean manageSolids() {
return false;
}
@Override
public boolean allowAction(IAction action) {
return action == BuildCraftCore.actionOn || action == BuildCraftCore.actionOff;
}
@Override
public void actionActivated(IAction action) {
if (action == BuildCraftCore.actionOn) {
lastMode = ActionMachineControl.Mode.On;
} else if (action == BuildCraftCore.actionOff) {
lastMode = ActionMachineControl.Mode.Off;
}
}
}

View file

@ -45,7 +45,11 @@ public class PipeIconProvider implements IIconProvider {
public static final int Stripes = 33;
public static final int MAX = 34;
public static final int PipePowerCobblestone = 34;
public static final int PipePowerDiamond = 35;
public static final int MAX = 36;
@SideOnly(Side.CLIENT)
private Icon[] _icons;
@ -99,12 +103,14 @@ public class PipeIconProvider implements IIconProvider {
_icons[PipeIconProvider.PipeLiquidsStone] = iconRegister.registerIcon("buildcraft:pipeLiquidsStone");
_icons[PipeIconProvider.PipeLiquidsVoid] = iconRegister.registerIcon("buildcraft:pipeLiquidsVoid");
_icons[PipeIconProvider.PipePowerDiamond] = iconRegister.registerIcon("buildcraft:pipePowerDiamond");
_icons[PipeIconProvider.PipePowerGold] = iconRegister.registerIcon("buildcraft:pipePowerGold");
_icons[PipeIconProvider.PipePowerStone] = iconRegister.registerIcon("buildcraft:pipePowerStone");
_icons[PipeIconProvider.PipePowerWood_Standard] = iconRegister.registerIcon("buildcraft:pipePowerWood_standard");
_icons[PipeIconProvider.PipePowerCobblestone] = iconRegister.registerIcon("buildcraft:pipePowerCobblestone");
_icons[PipeIconProvider.PipePowerWood_Standard] = iconRegister.registerIcon("buildcraft:pipePowerWood_standard");
_icons[PipeIconProvider.Power_Normal] = iconRegister.registerIcon("buildcraft:texture_cyan");
_icons[PipeIconProvider.Power_Overload] = iconRegister.registerIcon("buildcraft:texture_red_dark");
_icons[PipeIconProvider.Power_Overload] = iconRegister.registerIcon("buildcraft:texture_red_lit");
_icons[PipeIconProvider.Stripes] = iconRegister.registerIcon("buildcraft:pipeStripes");
}

View file

@ -1,21 +1,16 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* 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 java.util.Arrays;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.power.IPowerProvider;
@ -28,33 +23,25 @@ import buildcraft.transport.network.PacketPowerUpdate;
public class PipeTransportPower extends PipeTransport {
private static final int MAX_POWER_INTERNAL = 10000;
private static final int OVERLOAD_LIMIT = 7500;
private static final short MAX_DISPLAY = 100;
private static final float DISPLAY_POWER_FACTOR = 0.1f;
private static final double DISPLAY_SMOOTHING = 5.0;
private boolean needsInit = true;
private TileEntity[] tiles = new TileEntity[6];
public short[] displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
public double[] displayPower = new double[6];
public short[] clientDisplayPower = new short[6];
public boolean overload;
public int[] powerQuery = new int[6];
public int[] nextPowerQuery = new int[6];
public long currentDate;
public double[] internalPower = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
public double[] internalNextPower = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
public double powerResistance = 0.05;
public double[] internalPower = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
public double[] internalNextPower = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
public int maxPower = 8;
public PipeTransportPower() {
for (int i = 0; i < 6; ++i) {
powerQuery[i] = 0;
}
}
SafeTimeTracker tracker = new SafeTimeTracker();
@Override
@ -103,7 +90,7 @@ public class PipeTransportPower extends PipeTransport {
// Send the power to nearby pipes who requested it
Arrays.fill(displayPower, (short) 0);
double highestPower = 0;
for (int i = 0; i < 6; ++i) {
if (internalPower[i] > 0) {
@ -117,6 +104,9 @@ public class PipeTransportPower extends PipeTransport {
}
double totalWatt = internalPower[i];
if (totalWatt > highestPower) {
highestPower = totalWatt;
}
for (int j = 0; j < 6; ++j) {
if (j != i && powerQuery[j] > 0) {
@ -129,8 +119,8 @@ public class PipeTransportPower extends PipeTransport {
nearbyTransport.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(), watts);
displayPower[j] += (short) (watts * DISPLAY_POWER_FACTOR + .9999);
displayPower[i] += (short) (watts * DISPLAY_POWER_FACTOR + .9999);
displayPower[j] = (displayPower[j] * (DISPLAY_SMOOTHING - 1.0) + watts) / DISPLAY_SMOOTHING;
displayPower[i] = (displayPower[i] * (DISPLAY_SMOOTHING - 1.0) + watts) / DISPLAY_SMOOTHING;
internalPower[i] -= watts;
} else if (tiles[j] instanceof IPowerReceptor) {
@ -141,8 +131,8 @@ public class PipeTransportPower extends PipeTransport {
if (prov != null) {
prov.receiveEnergy((float) watts, ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
displayPower[j] += (short) (watts * DISPLAY_POWER_FACTOR + .9999);
displayPower[i] += (short) (watts * DISPLAY_POWER_FACTOR + .9999);
displayPower[j] = (displayPower[j] * (DISPLAY_SMOOTHING - 1.0) + watts) / DISPLAY_SMOOTHING;
displayPower[i] = (displayPower[i] * (DISPLAY_SMOOTHING - 1.0) + watts) / DISPLAY_SMOOTHING;
internalPower[i] -= watts;
}
@ -152,15 +142,7 @@ public class PipeTransportPower extends PipeTransport {
}
}
double highestPower = 0;
for (int i = 0; i < 6; i++) {
if (internalPower[i] > highestPower) {
highestPower = internalPower[i];
}
displayPower[i] = (short) Math.max(displayPower[i], Math.ceil(internalPower[i] * DISPLAY_POWER_FACTOR));
displayPower[i] = (short) Math.min(displayPower[i], MAX_DISPLAY);
}
overload = highestPower > OVERLOAD_LIMIT;
overload = highestPower > maxPower * 0.9;
// Compute the tiles requesting energy that are not pipes
@ -177,7 +159,7 @@ public class PipeTransportPower extends PipeTransport {
// Sum the amount of energy requested on each side
int transferQuery[] = { 0, 0, 0, 0, 0, 0 };
int transferQuery[] = {0, 0, 0, 0, 0, 0};
for (int i = 0; i < 6; ++i) {
transferQuery[i] = 0;
@ -212,7 +194,13 @@ public class PipeTransportPower extends PipeTransport {
if (tracker.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) {
PacketPowerUpdate packet = new PacketPowerUpdate(xCoord, yCoord, zCoord);
packet.displayPower = displayPower;
double displayFactor = MAX_DISPLAY / 256.0;
for (int i = 0; i < clientDisplayPower.length; i++) {
clientDisplayPower[i] = (short) (displayPower[i] * displayFactor + .9999);
}
packet.displayPower = clientDisplayPower;
packet.overload = overload;
CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST);
}
@ -224,11 +212,10 @@ public class PipeTransportPower extends PipeTransport {
currentDate = worldObj.getWorldTime();
powerQuery = nextPowerQuery;
nextPowerQuery = new int[] { 0, 0, 0, 0, 0, 0 };
nextPowerQuery = new int[]{0, 0, 0, 0, 0, 0};
double[] next = Arrays.copyOf(internalPower, 6);
internalPower = internalNextPower;
internalNextPower = next;
internalNextPower = new double[6];
for (int i = 0; i < nextPowerQuery.length; i++) {
if (powerQuery[i] == 0.0d && internalNextPower[i] > 0) {
internalNextPower[i] -= 1;
@ -242,15 +229,10 @@ public class PipeTransportPower extends PipeTransport {
if (this.container.pipe instanceof IPipeTransportPowerHook) {
((IPipeTransportPowerHook) this.container.pipe).receiveEnergy(from, val);
} else {
if (BuildCraftTransport.usePipeLoss) {
internalNextPower[from.ordinal()] += val * (1 - powerResistance);
} else {
internalNextPower[from.ordinal()] += val;
}
internalNextPower[from.ordinal()] += val;
if (internalNextPower[from.ordinal()] >= MAX_POWER_INTERNAL) {
worldObj.createExplosion(null, xCoord, yCoord, zCoord, 3, false);
worldObj.setBlock(xCoord, yCoord, zCoord, 0);
if (internalNextPower[from.ordinal()] >= maxPower) {
internalNextPower[from.ordinal()] = maxPower;
}
}
}
@ -301,12 +283,11 @@ public class PipeTransportPower extends PipeTransport {
/**
* Client-side handler for receiving power updates from the server;
*
*
* @param packetPower
*/
public void handlePowerPacket(PacketPowerUpdate packetPower) {
displayPower = packetPower.displayPower;
clientDisplayPower = packetPower.displayPower;
overload = packetPower.overload;
}
}

View file

@ -45,8 +45,10 @@ public class TransportProxyClient extends TransportProxy {
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeLiquidsEmerald.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerWood.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerCobblestone.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerStone.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerGold.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerDiamond.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeStructureCobblestone.itemID, pipeItemRenderer);
// MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStipes.shiftedIndex, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsVoid.itemID, pipeItemRenderer);

View file

@ -0,0 +1,37 @@
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile
* or run the code. It does *NOT* grant the right to redistribute this software
* or its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
*/
package buildcraft.transport.pipes;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportPower;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PipePowerCobblestone extends Pipe {
public PipePowerCobblestone(int itemID) {
super(new PipeTransportPower(), new PipeLogicStone(), itemID);
}
@Override
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return BuildCraftTransport.instance.pipeIconProvider;
}
@Override
public int getIconIndex(ForgeDirection direction) {
return PipeIconProvider.PipePowerCobblestone;
}
}

View file

@ -0,0 +1,39 @@
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile
* or run the code. It does *NOT* grant the right to redistribute this software
* or its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
*/
package buildcraft.transport.pipes;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportPower;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PipePowerDiamond extends Pipe {
public PipePowerDiamond(int itemID) {
super(new PipeTransportPower(), new PipeLogicGold(), itemID);
((PipeTransportPower) transport).maxPower = 256;
}
@Override
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return BuildCraftTransport.instance.pipeIconProvider;
}
@Override
public int getIconIndex(ForgeDirection direction) {
return PipeIconProvider.PipePowerDiamond;
}
}

View file

@ -22,7 +22,7 @@ public class PipePowerGold extends Pipe {
public PipePowerGold(int itemID) {
super(new PipeTransportPower(), new PipeLogicGold(), itemID);
((PipeTransportPower) transport).powerResistance = 0.005;
((PipeTransportPower) transport).maxPower = 64;
}
@Override

View file

@ -21,6 +21,8 @@ public class PipePowerStone extends Pipe {
public PipePowerStone(int itemID) {
super(new PipeTransportPower(), new PipeLogicStone(), itemID);
((PipeTransportPower) transport).maxPower = 16;
}
@Override

View file

@ -1,11 +1,10 @@
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile
* or run the code. It does *NOT* grant the right to redistribute this software
* or its modifications in any form, binary or source, except if expressively
* BuildCraft Open Source License. It grants rights to read, modify, compile or
* run the code. It does *NOT* grant the right to redistribute this software or
* its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
*/
package buildcraft.transport.pipes;
import net.minecraft.tileentity.TileEntity;
@ -25,22 +24,16 @@ import cpw.mods.fml.relauncher.SideOnly;
public class PipePowerWood extends Pipe implements IPowerReceptor {
private static final int MAX_OVERHEAT_TICKS = 100;
private IPowerProvider powerProvider;
protected int standardIconIndex = PipeIconProvider.PipePowerWood_Standard;
protected int solidIconIndex = PipeIconProvider.PipeAllWood_Solid;
private int overheatTicks;
public PipePowerWood(int itemID) {
super(new PipeTransportPower(), new PipeLogicWood(), itemID);
powerProvider = PowerFramework.currentFramework.createPowerProvider();
powerProvider.configure(50, 2, 1000, 1, 1000);
powerProvider.configurePowerPerdition(1, 100);
powerProvider.configurePowerPerdition(1, 10);
}
@Override
@ -70,15 +63,12 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
@Override
public IPowerProvider getPowerProvider() {
if (overheatTicks > 0)
return null;
return powerProvider;
}
@Override
public void doWork() {
// TODO Auto-generated method stub
}
@Override
@ -87,12 +77,6 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
if (worldObj.isRemote)
return;
if (powerProvider.getEnergyStored() == powerProvider.getMaxEnergyStored()) {
overheatTicks += overheatTicks < MAX_OVERHEAT_TICKS ? 1 : 0;
} else {
overheatTicks -= overheatTicks > 0 ? 1 : 0;
}
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
if (Utils.checkPipesConnections(container, container.getTile(o))) {
TileEntity tile = container.getTile(o);
@ -116,9 +100,8 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
float energyUsable = powerProvider.useEnergy(1, energyToRemove, false);
float energySend = Math.min(energyUsable, ((PipeTransportPower)transport).powerQuery[o.ordinal()]);
if(energySend > 0)
{
float energySend = Math.min(energyUsable, ((PipeTransportPower) transport).powerQuery[o.ordinal()]);
if (energySend > 0) {
trans.receiveEnergy(o.getOpposite(), energySend);
powerProvider.useEnergy(1, energySend, true);
}
@ -131,5 +114,4 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
public int powerRequest(ForgeDirection from) {
return getPowerProvider().getMaxEnergyReceived();
}
}

View file

@ -292,8 +292,8 @@ public class RenderPipe extends TileEntitySpecialRenderer {
GL11.glRotatef(angleZ[i], 0, 0, 1);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
if (pow.displayPower[i] >= 1.0) {
short stage = pow.displayPower[i];
if (pow.clientDisplayPower[i] >= 1.0) {
short stage = pow.clientDisplayPower[i];
if (stage < displayList.length) {
GL11.glCallList(displayList[stage]);

View file

@ -106,14 +106,14 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
PipeTransportPower transportPower = (PipeTransportPower) pipe.transport;
if (kind == Kind.Empty) {
for (short s : transportPower.displayPower)
if (s != 0)
for (double s : transportPower.displayPower)
if (s > 0)
return false;
return true;
} else {
for (short s : transportPower.displayPower)
if (s != 0)
for (double s : transportPower.displayPower)
if (s > 0)
return true;
return false;