Wooden Power Pipes now add power to themselves...
...instead of their neighbor. The result being that they are constrained by the new limits and that they actually render the power flow in themselves. Wooden Pipes are set with a input cap of 32 MJ/t, buffed from the previous effective limit of 29 MJ/t. Note that this also effectively adds a 32 MJ/t pipe that can be used for limiting flows.
This commit is contained in:
parent
e18031d223
commit
a0f57c57ca
3 changed files with 54 additions and 45 deletions
|
@ -39,15 +39,18 @@ public class TileHopper extends TileBuildCraft implements IInventory {
|
|||
|
||||
TileEntity tile = this.worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
|
||||
if (tile == null) return;
|
||||
if (tile == null)
|
||||
return;
|
||||
|
||||
ITransactor transactor = Transactor.getTransactorFor(tile);
|
||||
|
||||
if (transactor == null) return;
|
||||
if (transactor == null)
|
||||
return;
|
||||
|
||||
for(int internalSlot = 0; internalSlot < _inventory.getSizeInventory(); internalSlot++) {
|
||||
for (int internalSlot = 0; internalSlot < _inventory.getSizeInventory(); internalSlot++) {
|
||||
ItemStack stackInSlot = _inventory.getStackInSlot(internalSlot);
|
||||
if(stackInSlot == null) continue;
|
||||
if (stackInSlot == null)
|
||||
continue;
|
||||
|
||||
ItemStack clonedStack = stackInSlot.copy().splitStack(1);
|
||||
if (transactor.add(clonedStack, ForgeDirection.UP, true).stackSize > 0) {
|
||||
|
@ -57,8 +60,9 @@ public class TileHopper extends TileBuildCraft implements IInventory {
|
|||
}
|
||||
}
|
||||
|
||||
/** IInventory Implementation **/
|
||||
|
||||
/**
|
||||
* IInventory Implementation *
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return _inventory.getSizeInventory();
|
||||
|
@ -96,7 +100,7 @@ public class TileHopper extends TileBuildCraft implements IInventory {
|
|||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityPlayer) {
|
||||
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this;
|
||||
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,12 +9,10 @@
|
|||
|
||||
package buildcraft.transport;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
|
@ -27,7 +25,6 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
|
@ -45,12 +42,8 @@ import buildcraft.transport.Gate.GateConditional;
|
|||
import buildcraft.transport.pipes.PipeLogic;
|
||||
import buildcraft.transport.triggers.ActionSignalOutput;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multiset;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
|
|
@ -7,18 +7,15 @@
|
|||
*/
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.power.IPowerProvider;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerFramework;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportPower;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -27,13 +24,15 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
private IPowerProvider powerProvider;
|
||||
protected int standardIconIndex = PipeIconProvider.PipePowerWood_Standard;
|
||||
protected int solidIconIndex = PipeIconProvider.PipeAllWood_Solid;
|
||||
private int[] powerSources = new int[6];
|
||||
|
||||
public PipePowerWood(int itemID) {
|
||||
super(new PipeTransportPower(), new PipeLogicWood(), itemID);
|
||||
|
||||
powerProvider = PowerFramework.currentFramework.createPowerProvider();
|
||||
powerProvider.configure(50, 2, 1000, 1, 1000);
|
||||
powerProvider.configure(50, 2, 1000, 1, 1500);
|
||||
powerProvider.configurePowerPerdition(1, 10);
|
||||
((PipeTransportPower) transport).maxPower = 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,16 +76,25 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
if (worldObj.isRemote)
|
||||
return;
|
||||
|
||||
int sources = 0;
|
||||
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (Utils.checkPipesConnections(container, container.getTile(o))) {
|
||||
TileEntity tile = container.getTile(o);
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
if (((TileGenericPipe) tile).pipe == null) {
|
||||
continue; // Null pointer protection
|
||||
if (!container.isPipeConnected(o)) {
|
||||
powerSources[o.ordinal()] = 0;
|
||||
continue;
|
||||
}
|
||||
if (powerSources[o.ordinal()] > 0) {
|
||||
powerSources[o.ordinal()]--;
|
||||
}
|
||||
if (powerProvider.isPowerSource(o)) {
|
||||
powerSources[o.ordinal()] = 40;
|
||||
}
|
||||
if (powerSources[o.ordinal()] > 0) {
|
||||
sources++;
|
||||
}
|
||||
}
|
||||
|
||||
PipeTransportPower trans = (PipeTransportPower) ((TileGenericPipe) tile).pipe.transport;
|
||||
if (sources <= 0)
|
||||
return;
|
||||
|
||||
float energyToRemove;
|
||||
|
||||
|
@ -97,18 +105,22 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
} else {
|
||||
energyToRemove = 1;
|
||||
}
|
||||
energyToRemove /= (float) sources;
|
||||
|
||||
PipeTransportPower trans = (PipeTransportPower) transport;
|
||||
|
||||
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (powerSources[o.ordinal()] <= 0)
|
||||
continue;
|
||||
|
||||
float energyUsable = powerProvider.useEnergy(1, energyToRemove, false);
|
||||
|
||||
float energySend = Math.min(energyUsable, ((PipeTransportPower) transport).powerQuery[o.ordinal()]);
|
||||
float energySend = (float) trans.receiveEnergy(o, energyUsable);
|
||||
if (energySend > 0) {
|
||||
trans.receiveEnergy(o.getOpposite(), energySend);
|
||||
powerProvider.useEnergy(1, energySend, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int powerRequest(ForgeDirection from) {
|
||||
|
|
Loading…
Reference in a new issue