fixed style
This commit is contained in:
parent
ccaeffe763
commit
9f71fdfe0e
33 changed files with 393 additions and 230 deletions
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.api.power;
|
package buildcraft.api.power;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public interface ILaserTarget {
|
public interface ILaserTarget {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
* This Tile Entity interface allows you to indicate that a block can emit power
|
* This Tile Entity interface allows you to indicate that a block can emit power
|
||||||
* from a specific side.
|
* from a specific side.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface IPowerEmitter {
|
public interface IPowerEmitter {
|
||||||
|
|
||||||
public boolean canEmitPowerFrom(ForgeDirection side);
|
boolean canEmitPowerFrom(ForgeDirection side);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
package buildcraft.api.power;
|
package buildcraft.api.power;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface should be implemented by any Tile Entity that wishes to be
|
* This interface should be implemented by any Tile Entity that wishes to be
|
||||||
* able to receive power.
|
* able to receive power.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface IPowerReceptor {
|
public interface IPowerReceptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +31,7 @@ public interface IPowerReceptor {
|
||||||
* @param side
|
* @param side
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side);
|
PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call back from the PowerHandler that is called when the stored power
|
* Call back from the PowerHandler that is called when the stored power
|
||||||
|
@ -39,7 +41,7 @@ public interface IPowerReceptor {
|
||||||
*
|
*
|
||||||
* @param workProvider
|
* @param workProvider
|
||||||
*/
|
*/
|
||||||
public void doWork(PowerHandler workProvider);
|
void doWork(PowerHandler workProvider);
|
||||||
|
|
||||||
public World getWorld();
|
World getWorld();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.api.power;
|
package buildcraft.api.power;
|
||||||
|
|
||||||
import buildcraft.api.core.SafeTimeTracker;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import buildcraft.api.core.SafeTimeTracker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The PowerHandler is similar to FluidTank in that it holds your power and
|
* The PowerHandler is similar to FluidTank in that it holds your power and
|
||||||
* allows standardized interaction between machines.
|
* allows standardized interaction between machines.
|
||||||
|
@ -28,6 +30,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
* @see IPowerReceptor
|
* @see IPowerReceptor
|
||||||
* @see IPowerEmitter
|
* @see IPowerEmitter
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public final class PowerHandler {
|
public final class PowerHandler {
|
||||||
|
|
||||||
public static enum Type {
|
public static enum Type {
|
||||||
|
@ -75,11 +78,12 @@ public final class PowerHandler {
|
||||||
*
|
*
|
||||||
* @param powerLoss power loss per tick
|
* @param powerLoss power loss per tick
|
||||||
*/
|
*/
|
||||||
public PerditionCalculator(double powerLoss) {
|
public PerditionCalculator(double iPowerLoss) {
|
||||||
if (powerLoss < MIN_POWERLOSS) {
|
if (iPowerLoss < MIN_POWERLOSS) {
|
||||||
|
powerLoss = iPowerLoss;
|
||||||
|
} else {
|
||||||
powerLoss = MIN_POWERLOSS;
|
powerLoss = MIN_POWERLOSS;
|
||||||
}
|
}
|
||||||
this.powerLoss = powerLoss;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,11 +97,14 @@ public final class PowerHandler {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public double applyPerdition(PowerHandler powerHandler, double current, long ticksPassed) {
|
public double applyPerdition(PowerHandler powerHandler, double current, long ticksPassed) {
|
||||||
current -= powerLoss * ticksPassed;
|
double result = current;
|
||||||
if (current < 0) {
|
|
||||||
current = 0;
|
result -= powerLoss * ticksPassed;
|
||||||
|
if (result < 0) {
|
||||||
|
result = 0;
|
||||||
}
|
}
|
||||||
return current;
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,6 +122,8 @@ public final class PowerHandler {
|
||||||
public static final double ROLLING_AVERAGE_WEIGHT = 100.0;
|
public static final double ROLLING_AVERAGE_WEIGHT = 100.0;
|
||||||
public static final double ROLLING_AVERAGE_NUMERATOR = ROLLING_AVERAGE_WEIGHT - 1;
|
public static final double ROLLING_AVERAGE_NUMERATOR = ROLLING_AVERAGE_WEIGHT - 1;
|
||||||
public static final double ROLLING_AVERAGE_DENOMINATOR = 1.0 / ROLLING_AVERAGE_WEIGHT;
|
public static final double ROLLING_AVERAGE_DENOMINATOR = 1.0 / ROLLING_AVERAGE_WEIGHT;
|
||||||
|
public final int[] powerSources = new int[6];
|
||||||
|
public final IPowerReceptor receptor;
|
||||||
private double minEnergyReceived;
|
private double minEnergyReceived;
|
||||||
private double maxEnergyReceived;
|
private double maxEnergyReceived;
|
||||||
private double maxEnergyStored;
|
private double maxEnergyStored;
|
||||||
|
@ -123,8 +132,6 @@ public final class PowerHandler {
|
||||||
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
|
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
|
||||||
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
|
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
|
||||||
private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
|
private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
|
||||||
public final int[] powerSources = new int[6];
|
|
||||||
public final IPowerReceptor receptor;
|
|
||||||
private PerditionCalculator perdition;
|
private PerditionCalculator perdition;
|
||||||
private final PowerReceiver receiver;
|
private final PowerReceiver receiver;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
@ -167,29 +174,38 @@ public final class PowerHandler {
|
||||||
/**
|
/**
|
||||||
* Setup your PowerHandler's settings.
|
* Setup your PowerHandler's settings.
|
||||||
*
|
*
|
||||||
* @param minEnergyReceived This is the minimum about of power that will be
|
* @param minEnergyReceived
|
||||||
* accepted by the PowerHandler. This should generally be greater than the
|
* This is the minimum about of power that will be accepted by
|
||||||
* activationEnergy if you plan to use the doWork() callback. Anything
|
* the PowerHandler. This should generally be greater than the
|
||||||
* greater than 1 will prevent Redstone Engines from powering this Provider.
|
* activationEnergy if you plan to use the doWork() callback.
|
||||||
* @param maxEnergyReceived The maximum amount of power accepted by the
|
* Anything greater than 1 will prevent Redstone Engines from
|
||||||
* PowerHandler. This should generally be less than 500. Too low and larger
|
* powering this Provider.
|
||||||
* engines will overheat while trying to power the machine. Too high, and
|
* @param iMaxEnergyReceived
|
||||||
* the engines will never warm up. Greater values also place greater strain
|
* The maximum amount of power accepted by the PowerHandler. This
|
||||||
* on the power net.
|
* should generally be less than 500. Too low and larger engines
|
||||||
* @param activationEnergy If the stored energy is greater than this value,
|
* will overheat while trying to power the machine. Too high, and
|
||||||
* the doWork() callback is called (once per tick).
|
* the engines will never warm up. Greater values also place
|
||||||
* @param maxStoredEnergy The maximum amount of power this PowerHandler can
|
* greater strain on the power net.
|
||||||
* store. Values tend to range between 100 and 5000. With 1000 and 1500
|
* @param activationEnergy
|
||||||
* being common.
|
* If the stored energy is greater than this value, the doWork()
|
||||||
|
* callback is called (once per tick).
|
||||||
|
* @param maxStoredEnergy
|
||||||
|
* The maximum amount of power this PowerHandler can store.
|
||||||
|
* Values tend to range between 100 and 5000. With 1000 and 1500
|
||||||
|
* being common.
|
||||||
*/
|
*/
|
||||||
public void configure(double minEnergyReceived, double maxEnergyReceived, double activationEnergy, double maxStoredEnergy) {
|
public void configure(double iMinEnergyReceived, double iMaxEnergyReceived, double iActivationEnergy,
|
||||||
if (minEnergyReceived > maxEnergyReceived) {
|
double iMaxStoredEnergy) {
|
||||||
maxEnergyReceived = minEnergyReceived;
|
|
||||||
|
if (iMinEnergyReceived > maxEnergyReceived) {
|
||||||
|
maxEnergyReceived = iMinEnergyReceived;
|
||||||
|
} else {
|
||||||
|
maxEnergyReceived = iMaxEnergyReceived;
|
||||||
}
|
}
|
||||||
this.minEnergyReceived = minEnergyReceived;
|
|
||||||
this.maxEnergyReceived = maxEnergyReceived;
|
minEnergyReceived = iMinEnergyReceived;
|
||||||
this.maxEnergyStored = maxStoredEnergy;
|
maxEnergyStored = iMaxStoredEnergy;
|
||||||
this.activationEnergy = activationEnergy;
|
activationEnergy = iActivationEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,17 +233,20 @@ public final class PowerHandler {
|
||||||
* For example if you want exponentially increasing loss based on amount
|
* For example if you want exponentially increasing loss based on amount
|
||||||
* stored.
|
* stored.
|
||||||
*
|
*
|
||||||
* @param perdition
|
* @param iPerdition
|
||||||
*/
|
*/
|
||||||
public void setPerdition(PerditionCalculator perdition) {
|
public void setPerdition(PerditionCalculator iPerdition) {
|
||||||
if (perdition == null)
|
if (iPerdition == null) {
|
||||||
perdition = DEFAULT_PERDITION;
|
perdition = DEFAULT_PERDITION;
|
||||||
this.perdition = perdition;
|
} else {
|
||||||
|
perdition = iPerdition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PerditionCalculator getPerdition() {
|
public PerditionCalculator getPerdition() {
|
||||||
if (perdition == null)
|
if (perdition == null) {
|
||||||
return DEFAULT_PERDITION;
|
return DEFAULT_PERDITION;
|
||||||
|
}
|
||||||
return perdition;
|
return perdition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,10 +269,11 @@ public final class PowerHandler {
|
||||||
if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0) {
|
if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0) {
|
||||||
double prev = energyStored;
|
double prev = energyStored;
|
||||||
double newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
double newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
||||||
if (newEnergy == 0 || newEnergy < energyStored)
|
if (newEnergy == 0 || newEnergy < energyStored) {
|
||||||
energyStored = newEnergy;
|
energyStored = newEnergy;
|
||||||
else
|
} else {
|
||||||
energyStored = DEFAULT_PERDITION.applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
energyStored = DEFAULT_PERDITION.applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
||||||
|
}
|
||||||
validateEnergy();
|
validateEnergy();
|
||||||
|
|
||||||
averageLostPower = (averageLostPower * ROLLING_AVERAGE_NUMERATOR + (prev - energyStored)) * ROLLING_AVERAGE_DENOMINATOR;
|
averageLostPower = (averageLostPower * ROLLING_AVERAGE_NUMERATOR + (prev - energyStored)) * ROLLING_AVERAGE_DENOMINATOR;
|
||||||
|
@ -278,8 +298,9 @@ public final class PowerHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source != null)
|
if (source != null) {
|
||||||
powerSources[source.ordinal()] = 10;
|
powerSources[source.ordinal()] = 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,8 +333,9 @@ public final class PowerHandler {
|
||||||
|
|
||||||
validateEnergy();
|
validateEnergy();
|
||||||
|
|
||||||
if (doUse)
|
if (doUse) {
|
||||||
averageUsedPower = (averageUsedPower * ROLLING_AVERAGE_NUMERATOR + result) * ROLLING_AVERAGE_DENOMINATOR;
|
averageUsedPower = (averageUsedPower * ROLLING_AVERAGE_NUMERATOR + result) * ROLLING_AVERAGE_DENOMINATOR;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -433,20 +455,22 @@ public final class PowerHandler {
|
||||||
*
|
*
|
||||||
* @return the amount the power changed by
|
* @return the amount the power changed by
|
||||||
*/
|
*/
|
||||||
public double addEnergy(double quantity) {
|
public double addEnergy(double iQuantity) {
|
||||||
energyStored += quantity;
|
energyStored += iQuantity;
|
||||||
|
|
||||||
|
double added = iQuantity;
|
||||||
|
|
||||||
if (energyStored > maxEnergyStored) {
|
if (energyStored > maxEnergyStored) {
|
||||||
quantity -= energyStored - maxEnergyStored;
|
added -= energyStored - maxEnergyStored;
|
||||||
energyStored = maxEnergyStored;
|
energyStored = maxEnergyStored;
|
||||||
} else if (energyStored < 0) {
|
} else if (energyStored < 0) {
|
||||||
quantity -= energyStored;
|
added -= energyStored;
|
||||||
energyStored = 0;
|
energyStored = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyPerdition();
|
applyPerdition();
|
||||||
|
|
||||||
return quantity;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnergy(double quantity) {
|
public void setEnergy(double quantity) {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
@API(apiVersion="1.1",owner="BuildCraftAPI|core",provides="BuildCraftAPI|power")
|
@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|power")
|
||||||
package buildcraft.api.power;
|
package buildcraft.api.power;
|
||||||
import cpw.mods.fml.common.API;
|
import cpw.mods.fml.common.API;
|
||||||
|
|
|
@ -8,13 +8,16 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.api.robots;
|
package buildcraft.api.robots;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyStorage;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyStorage;
|
||||||
|
|
||||||
import buildcraft.api.boards.RedstoneBoardRobot;
|
import buildcraft.api.boards.RedstoneBoardRobot;
|
||||||
import buildcraft.api.core.IZone;
|
import buildcraft.api.core.IZone;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import java.util.LinkedList;
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
import buildcraft.api.blueprints.ITileBuilder;
|
import buildcraft.api.blueprints.ITileBuilder;
|
||||||
import buildcraft.api.blueprints.SchematicRegistry;
|
import buildcraft.api.blueprints.SchematicRegistry;
|
||||||
import buildcraft.api.core.NetworkData;
|
import buildcraft.api.core.NetworkData;
|
||||||
|
@ -71,7 +72,7 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
RFBattery battery = this.getBattery();
|
RFBattery battery = this.getBattery();
|
||||||
|
|
||||||
if (rfPrev != battery.getEnergyStored()) {
|
if (rfPrev != battery.getEnergyStored()) {
|
||||||
rfPrev = battery.getEnergyStored();
|
rfPrev = battery.getEnergyStored();
|
||||||
rfUnchangedCycles = 0;
|
rfUnchangedCycles = 0;
|
||||||
|
@ -123,6 +124,7 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil
|
||||||
buildersInAction.add(item);
|
buildersInAction.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addAndLaunchBuildingItem(BuildingItem item) {
|
public void addAndLaunchBuildingItem(BuildingItem item) {
|
||||||
buildersInAction.add(item);
|
buildersInAction.add(item);
|
||||||
RPCHandler.rpcBroadcastWorldPlayers(worldObj, this, "launchItem", item);
|
RPCHandler.rpcBroadcastWorldPlayers(worldObj, this, "launchItem", item);
|
||||||
|
@ -133,7 +135,7 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean consumeEnergy(int quantity) {
|
public final boolean consumeEnergy(int quantity) {
|
||||||
return (getBattery().useEnergy(quantity, quantity, false) > 0);
|
return getBattery().useEnergy(quantity, quantity, false) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -144,11 +146,11 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||||
super.readFromNBT(nbttagcompound);
|
super.readFromNBT(nbttagcompound);
|
||||||
|
|
||||||
rfPrev = getBattery().getEnergyStored();
|
rfPrev = getBattery().getEnergyStored();
|
||||||
rfUnchangedCycles = 0;
|
rfUnchangedCycles = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxRenderDistanceSquared() {
|
public double getMaxRenderDistanceSquared() {
|
||||||
return Double.MAX_VALUE;
|
return Double.MAX_VALUE;
|
||||||
|
|
|
@ -1,27 +1,30 @@
|
||||||
package buildcraft.core;
|
package buildcraft.core;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyStorage;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyStorage;
|
||||||
|
|
||||||
public class RFBattery implements IEnergyStorage {
|
public class RFBattery implements IEnergyStorage {
|
||||||
private int energy, maxEnergy, maxReceive, maxExtract;
|
private int energy, maxEnergy, maxReceive, maxExtract;
|
||||||
|
|
||||||
public RFBattery(int maxEnergy, int maxReceive, int maxExtract) {
|
public RFBattery(int maxEnergy, int maxReceive, int maxExtract) {
|
||||||
this.maxEnergy = maxEnergy;
|
this.maxEnergy = maxEnergy;
|
||||||
this.maxReceive = maxReceive;
|
this.maxReceive = maxReceive;
|
||||||
this.maxExtract = maxExtract;
|
this.maxExtract = maxExtract;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound tag) {
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
if(!(tag.hasKey("battery"))) return;
|
if (!(tag.hasKey("battery"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NBTTagCompound battery = tag.getCompoundTag("battery");
|
NBTTagCompound battery = tag.getCompoundTag("battery");
|
||||||
this.energy = battery.getInteger("energy");
|
this.energy = battery.getInteger("energy");
|
||||||
this.maxEnergy = battery.getInteger("maxEnergy");
|
this.maxEnergy = battery.getInteger("maxEnergy");
|
||||||
this.maxReceive = battery.getInteger("maxReceive");
|
this.maxReceive = battery.getInteger("maxReceive");
|
||||||
this.maxExtract = battery.getInteger("maxExtract");
|
this.maxExtract = battery.getInteger("maxExtract");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound tag) {
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
NBTTagCompound battery = new NBTTagCompound();
|
NBTTagCompound battery = new NBTTagCompound();
|
||||||
battery.setInteger("energy", this.energy);
|
battery.setInteger("energy", this.energy);
|
||||||
|
@ -29,21 +32,35 @@ public class RFBattery implements IEnergyStorage {
|
||||||
battery.setInteger("maxReceive", this.maxReceive);
|
battery.setInteger("maxReceive", this.maxReceive);
|
||||||
battery.setInteger("maxExtract", this.maxExtract);
|
battery.setInteger("maxExtract", this.maxExtract);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int addEnergy(int minReceive, int maxReceive, boolean simulate) {
|
public int addEnergy(int minReceive, int maxReceive, boolean simulate) {
|
||||||
int amountReceived = Math.min(maxReceive, maxEnergy - energy);
|
int amountReceived = Math.min(maxReceive, maxEnergy - energy);
|
||||||
if (amountReceived < minReceive) return 0;
|
|
||||||
if (!simulate) energy += amountReceived;
|
if (amountReceived < minReceive) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!simulate) {
|
||||||
|
energy += amountReceived;
|
||||||
|
}
|
||||||
|
|
||||||
return amountReceived;
|
return amountReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int useEnergy(int minExtract, int maxExtract, boolean simulate) {
|
public int useEnergy(int minExtract, int maxExtract, boolean simulate) {
|
||||||
int amountExtracted = Math.min(maxExtract, energy);
|
int amountExtracted = Math.min(maxExtract, energy);
|
||||||
if (amountExtracted < minExtract) return 0;
|
|
||||||
if (!simulate) energy -= amountExtracted;
|
if (amountExtracted < minExtract) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!simulate) {
|
||||||
|
energy -= amountExtracted;
|
||||||
|
}
|
||||||
|
|
||||||
return amountExtracted;
|
return amountExtracted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||||
return addEnergy(0, Math.min(maxReceive, this.maxReceive), simulate);
|
return addEnergy(0, Math.min(maxReceive, this.maxReceive), simulate);
|
||||||
|
@ -63,18 +80,18 @@ public class RFBattery implements IEnergyStorage {
|
||||||
public int getMaxEnergyStored() {
|
public int getMaxEnergyStored() {
|
||||||
return maxEnergy;
|
return maxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxEnergyReceive() {
|
public int getMaxEnergyReceive() {
|
||||||
return maxReceive;
|
return maxReceive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxEnergyExtract() {
|
public int getMaxEnergyExtract() {
|
||||||
return maxExtract;
|
return maxExtract;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnergy(int energy) {
|
public void setEnergy(int iEnergy) {
|
||||||
this.energy = energy;
|
energy = iEnergy;
|
||||||
|
|
||||||
if (energy < 0) {
|
if (energy < 0) {
|
||||||
energy = 0;
|
energy = 0;
|
||||||
} else if (energy > maxEnergy) {
|
} else if (energy > maxEnergy) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -20,7 +19,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
import buildcraft.BuildCraftCore;
|
||||||
import buildcraft.api.power.IPowerReceptor;
|
import buildcraft.api.power.IPowerReceptor;
|
||||||
import buildcraft.core.network.BuildCraftPacket;
|
import buildcraft.core.network.BuildCraftPacket;
|
||||||
|
@ -41,7 +44,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
private String owner = "[BuildCraft]";
|
private String owner = "[BuildCraft]";
|
||||||
private RFBattery battery;
|
private RFBattery battery;
|
||||||
|
|
||||||
public TileBuildCraft() {
|
public TileBuildCraft() {
|
||||||
if (!updateWrappers.containsKey(this.getClass())) {
|
if (!updateWrappers.containsKey(this.getClass())) {
|
||||||
updateWrappers.put(this.getClass(), new TilePacketWrapper(this.getClass()));
|
updateWrappers.put(this.getClass(), new TilePacketWrapper(this.getClass()));
|
||||||
|
@ -54,7 +57,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
||||||
updatePacket = updateWrappers.get(this.getClass());
|
updatePacket = updateWrappers.get(this.getClass());
|
||||||
descriptionPacket = descriptionWrappers.get(this.getClass());
|
descriptionPacket = descriptionWrappers.get(this.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOwner() {
|
public String getOwner() {
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
@ -160,41 +163,54 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
||||||
public boolean equals(Object cmp) {
|
public boolean equals(Object cmp) {
|
||||||
return this == cmp;
|
return this == cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canConnectEnergy(ForgeDirection from) {
|
public boolean canConnectEnergy(ForgeDirection from) {
|
||||||
return (battery != null);
|
return battery != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
||||||
boolean simulate) {
|
boolean simulate) {
|
||||||
if(battery != null && this.canConnectEnergy(from))
|
if (battery != null && this.canConnectEnergy(from)) {
|
||||||
return battery.receiveEnergy(maxReceive, simulate);
|
return battery.receiveEnergy(maxReceive, simulate);
|
||||||
else return 0;
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int extractEnergy(ForgeDirection from, int maxExtract,
|
public int extractEnergy(ForgeDirection from, int maxExtract,
|
||||||
boolean simulate) {
|
boolean simulate) {
|
||||||
if(battery != null && this.canConnectEnergy(from))
|
if (battery != null && this.canConnectEnergy(from)) {
|
||||||
return battery.extractEnergy(maxExtract, simulate);
|
return battery.extractEnergy(maxExtract, simulate);
|
||||||
else return 0;
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEnergyStored(ForgeDirection from) {
|
public int getEnergyStored(ForgeDirection from) {
|
||||||
if(battery != null && this.canConnectEnergy(from))
|
if (battery != null && this.canConnectEnergy(from)) {
|
||||||
return battery.getEnergyStored();
|
return battery.getEnergyStored();
|
||||||
else return 0;
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getMaxEnergyStored(ForgeDirection from) {
|
public int getMaxEnergyStored(ForgeDirection from) {
|
||||||
if(battery != null && this.canConnectEnergy(from))
|
if (battery != null && this.canConnectEnergy(from)) {
|
||||||
return battery.getMaxEnergyStored();
|
return battery.getMaxEnergyStored();
|
||||||
else return 0;
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RFBattery getBattery() {
|
public RFBattery getBattery() {
|
||||||
return battery;
|
return battery;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setBattery(RFBattery battery) {
|
protected void setBattery(RFBattery battery) {
|
||||||
this.battery = battery;
|
this.battery = battery;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,16 @@ package buildcraft.core.triggers;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
import buildcraft.BuildCraftCore;
|
||||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||||
import buildcraft.api.gates.ITrigger;
|
import buildcraft.api.gates.ITrigger;
|
||||||
|
@ -61,8 +64,8 @@ public class DefaultTriggerProvider implements ITriggerProvider {
|
||||||
res.add(BuildCraftCore.triggerMachineActive);
|
res.add(BuildCraftCore.triggerMachineActive);
|
||||||
res.add(BuildCraftCore.triggerMachineInactive);
|
res.add(BuildCraftCore.triggerMachineInactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tile instanceof IEnergyHandler && ((IEnergyHandler)tile).getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0) {
|
if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0) {
|
||||||
res.add(BuildCraftCore.triggerEnergyHigh);
|
res.add(BuildCraftCore.triggerEnergyHigh);
|
||||||
res.add(BuildCraftCore.triggerEnergyLow);
|
res.add(BuildCraftCore.triggerEnergyLow);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,17 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.core.triggers;
|
package buildcraft.core.triggers;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
|
|
||||||
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.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.api.gates.IGate;
|
import buildcraft.api.gates.IGate;
|
||||||
import buildcraft.api.gates.ITriggerParameter;
|
import buildcraft.api.gates.ITriggerParameter;
|
||||||
import buildcraft.core.utils.StringUtils;
|
import buildcraft.core.utils.StringUtils;
|
||||||
|
@ -39,11 +43,11 @@ public class TriggerEnergy extends BCTrigger {
|
||||||
private boolean isValidEnergyHandler(IEnergyHandler handler) {
|
private boolean isValidEnergyHandler(IEnergyHandler handler) {
|
||||||
return handler.getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0;
|
return handler.getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTriggeredEnergyHandler(IEnergyHandler handler) {
|
private boolean isTriggeredEnergyHandler(IEnergyHandler handler) {
|
||||||
int energyStored = handler.getEnergyStored(ForgeDirection.UNKNOWN);
|
int energyStored = handler.getEnergyStored(ForgeDirection.UNKNOWN);
|
||||||
int energyMaxStored = handler.getMaxEnergyStored(ForgeDirection.UNKNOWN);
|
int energyMaxStored = handler.getMaxEnergyStored(ForgeDirection.UNKNOWN);
|
||||||
|
|
||||||
if (energyMaxStored > 0) {
|
if (energyMaxStored > 0) {
|
||||||
if (high) {
|
if (high) {
|
||||||
return (energyStored / energyMaxStored) > 0.95;
|
return (energyStored / energyMaxStored) > 0.95;
|
||||||
|
@ -56,8 +60,9 @@ public class TriggerEnergy extends BCTrigger {
|
||||||
@Override
|
@Override
|
||||||
public boolean isTriggerActive(IGate gate, ITriggerParameter[] parameters) {
|
public boolean isTriggerActive(IGate gate, ITriggerParameter[] parameters) {
|
||||||
if (gate.getPipe() instanceof IEnergyHandler) {
|
if (gate.getPipe() instanceof IEnergyHandler) {
|
||||||
if(isValidEnergyHandler((IEnergyHandler)gate.getPipe()))
|
if (isValidEnergyHandler((IEnergyHandler) gate.getPipe())) {
|
||||||
return isTriggeredEnergyHandler((IEnergyHandler)gate.getPipe());
|
return isTriggeredEnergyHandler((IEnergyHandler) gate.getPipe());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the pipe can't set the trigger one way or the other, then look
|
// if the pipe can't set the trigger one way or the other, then look
|
||||||
|
@ -68,10 +73,10 @@ public class TriggerEnergy extends BCTrigger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) {
|
public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) {
|
||||||
if(tile instanceof IEnergyHandler) {
|
if (tile instanceof IEnergyHandler) {
|
||||||
// Since we return false upon the trigger being invalid anyway,
|
// Since we return false upon the trigger being invalid anyway,
|
||||||
// we can skip the isValidEnergyHandler(...) check.
|
// we can skip the isValidEnergyHandler(...) check.
|
||||||
return isTriggeredEnergyHandler((IEnergyHandler)tile);
|
return isTriggeredEnergyHandler((IEnergyHandler) tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import java.util.TreeMap;
|
||||||
|
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import buildcraft.api.core.BlockIndex;
|
import buildcraft.api.core.BlockIndex;
|
||||||
import buildcraft.api.core.SafeTimeTracker;
|
import buildcraft.api.core.SafeTimeTracker;
|
||||||
import buildcraft.core.LaserData;
|
import buildcraft.core.LaserData;
|
||||||
|
@ -63,7 +64,7 @@ public class TileEnergyEmitter extends TileBuildCraft {
|
||||||
|
|
||||||
if (t.data.wavePosition > t.data.renderSize) {
|
if (t.data.wavePosition > t.data.renderSize) {
|
||||||
t.data.wavePosition = 0;
|
t.data.wavePosition = 0;
|
||||||
t.data.waveSize = (float) (getBattery().getEnergyStored() / targets.size() / 100F);
|
t.data.waveSize = getBattery().getEnergyStored() / targets.size() / 100F;
|
||||||
|
|
||||||
if (t.data.waveSize > 1) {
|
if (t.data.waveSize > 1) {
|
||||||
t.data.waveSize = 1F;
|
t.data.waveSize = 1F;
|
||||||
|
@ -123,7 +124,8 @@ public class TileEnergyEmitter extends TileBuildCraft {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int perTargetEnergy = (int)Math.floor(getBattery().useEnergy(targets.size(), targets.size() * 100, false) / targets.size());
|
int perTargetEnergy = (int) Math.floor(getBattery().useEnergy(targets.size(), targets.size() * 100, false)
|
||||||
|
/ targets.size());
|
||||||
|
|
||||||
for (Target t : targets.values()) {
|
for (Target t : targets.values()) {
|
||||||
if (!t.data.isVisible) {
|
if (!t.data.isVisible) {
|
||||||
|
|
|
@ -10,9 +10,12 @@ package buildcraft.energy;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.api.power.IPowerEmitter;
|
import buildcraft.api.power.IPowerEmitter;
|
||||||
import buildcraft.api.power.IPowerReceptor;
|
import buildcraft.api.power.IPowerReceptor;
|
||||||
import buildcraft.api.power.PowerHandler;
|
import buildcraft.api.power.PowerHandler;
|
||||||
|
@ -71,7 +74,7 @@ public class TileEnergyReceiver extends TileBuildCraft implements IPipeConnectio
|
||||||
energyStored = 0;
|
energyStored = 0;
|
||||||
}
|
}
|
||||||
} else if (tile instanceof IEnergyHandler) {
|
} else if (tile instanceof IEnergyHandler) {
|
||||||
int energyUsed = ((IEnergyHandler)tile).receiveEnergy(s.getOpposite(), energyStored, false);
|
int energyUsed = ((IEnergyHandler) tile).receiveEnergy(s.getOpposite(), energyStored, false);
|
||||||
energyStored -= energyUsed;
|
energyStored -= energyUsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,16 @@ package buildcraft.energy;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.ICrafting;
|
import net.minecraft.inventory.ICrafting;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftEnergy;
|
import buildcraft.BuildCraftEnergy;
|
||||||
import buildcraft.api.core.NetworkData;
|
import buildcraft.api.core.NetworkData;
|
||||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||||
|
@ -34,9 +37,8 @@ import buildcraft.core.TileBuffer;
|
||||||
import buildcraft.core.TileBuildCraft;
|
import buildcraft.core.TileBuildCraft;
|
||||||
import buildcraft.energy.gui.ContainerEngine;
|
import buildcraft.energy.gui.ContainerEngine;
|
||||||
|
|
||||||
public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, IOverrideDefaultTriggers, IPipeConnection, IEnergyHandler {
|
public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter,
|
||||||
protected boolean constantPower = false;
|
IOverrideDefaultTriggers, IPipeConnection, IEnergyHandler {
|
||||||
|
|
||||||
// Index corresponds to metadata
|
// Index corresponds to metadata
|
||||||
public static final ResourceLocation[] BASE_TEXTURES = new ResourceLocation[]{
|
public static final ResourceLocation[] BASE_TEXTURES = new ResourceLocation[]{
|
||||||
new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"),
|
new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"),
|
||||||
|
@ -84,6 +86,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
@NetworkData
|
@NetworkData
|
||||||
public ForgeDirection orientation = ForgeDirection.UP;
|
public ForgeDirection orientation = ForgeDirection.UP;
|
||||||
|
|
||||||
|
protected boolean constantPower = false;
|
||||||
protected int progressPart = 0;
|
protected int progressPart = 0;
|
||||||
protected boolean lastPower = false;
|
protected boolean lastPower = false;
|
||||||
protected PowerHandler powerHandler;
|
protected PowerHandler powerHandler;
|
||||||
|
@ -239,8 +242,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
|
|
||||||
if (progress > 0.5 && progressPart == 1) {
|
if (progress > 0.5 && progressPart == 1) {
|
||||||
progressPart = 2;
|
progressPart = 2;
|
||||||
if(!constantPower)
|
if (!constantPower) {
|
||||||
sendPower();
|
sendPower();
|
||||||
|
}
|
||||||
} else if (progress >= 1) {
|
} else if (progress >= 1) {
|
||||||
progress = 0;
|
progress = 0;
|
||||||
progressPart = 0;
|
progressPart = 0;
|
||||||
|
@ -263,26 +267,28 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uncomment for constant power
|
// Uncomment for constant power
|
||||||
if(constantPower) {
|
if (constantPower) {
|
||||||
if (isRedstonePowered && isActive()) {
|
if (isRedstonePowered && isActive()) {
|
||||||
sendPower();
|
sendPower();
|
||||||
} else currentOutput = 0;
|
} else {
|
||||||
|
currentOutput = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
burn();
|
burn();
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getPowerToExtract() {
|
private double getPowerToExtract() {
|
||||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||||
|
|
||||||
if(tile instanceof IEnergyHandler) {
|
if (tile instanceof IEnergyHandler) {
|
||||||
IEnergyHandler handler = ((IEnergyHandler)tile);
|
IEnergyHandler handler = (IEnergyHandler) tile;
|
||||||
|
|
||||||
int minEnergy = 0;
|
int minEnergy = 0;
|
||||||
int maxEnergy = handler.receiveEnergy(
|
int maxEnergy = handler.receiveEnergy(
|
||||||
orientation.getOpposite(),
|
orientation.getOpposite(),
|
||||||
(int)Math.round(this.energy * 10), true);
|
(int) Math.round(this.energy * 10), true);
|
||||||
return extractEnergy((double)minEnergy / 10.0, (double)maxEnergy / 10.0, false);
|
return extractEnergy(minEnergy / 10.0, maxEnergy / 10.0, false);
|
||||||
} else if (tile instanceof IPowerReceptor) {
|
} else if (tile instanceof IPowerReceptor) {
|
||||||
PowerReceiver receptor = ((IPowerReceptor) tile)
|
PowerReceiver receptor = ((IPowerReceptor) tile)
|
||||||
.getPowerReceiver(orientation.getOpposite());
|
.getPowerReceiver(orientation.getOpposite());
|
||||||
|
@ -298,17 +304,20 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||||
if (isPoweredTile(tile, orientation)) {
|
if (isPoweredTile(tile, orientation)) {
|
||||||
double extracted = getPowerToExtract();
|
double extracted = getPowerToExtract();
|
||||||
if(extracted > 0) setPumping(true);
|
if (extracted > 0) {
|
||||||
else setPumping(false);
|
setPumping(true);
|
||||||
|
} else {
|
||||||
|
setPumping(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (tile instanceof IEnergyHandler) {
|
if (tile instanceof IEnergyHandler) {
|
||||||
IEnergyHandler handler = ((IEnergyHandler) tile);
|
IEnergyHandler handler = (IEnergyHandler) tile;
|
||||||
if (Math.round(extracted * 10) > 0) {
|
if (Math.round(extracted * 10) > 0) {
|
||||||
int neededRF = handler.receiveEnergy(
|
int neededRF = handler.receiveEnergy(
|
||||||
orientation.getOpposite(),
|
orientation.getOpposite(),
|
||||||
(int)Math.round(extracted * 10), false);
|
(int) Math.round(extracted * 10), false);
|
||||||
|
|
||||||
extractEnergy(0.0, (double)neededRF / 10.0, true);
|
extractEnergy(0.0, neededRF / 10.0, true);
|
||||||
}
|
}
|
||||||
} else if (tile instanceof IPowerReceptor) {
|
} else if (tile instanceof IPowerReceptor) {
|
||||||
PowerReceiver receptor = ((IPowerReceptor) tile)
|
PowerReceiver receptor = ((IPowerReceptor) tile)
|
||||||
|
@ -377,11 +386,14 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
TileEntity tile = getTileBuffer(o).getTile();
|
TileEntity tile = getTileBuffer(o).getTile();
|
||||||
|
|
||||||
if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) {
|
if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) {
|
||||||
if((tile instanceof IPipeTile) && (((IPipeTile)tile).getPipeType() != PipeType.POWER))
|
if ((tile instanceof IPipeTile) && (((IPipeTile) tile).getPipeType() != PipeType.POWER)) {
|
||||||
constantPower = false;
|
constantPower = false;
|
||||||
else if(tile instanceof IEnergyHandler) constantPower = true;
|
} else if (tile instanceof IEnergyHandler) {
|
||||||
else constantPower = false;
|
constantPower = true;
|
||||||
|
} else {
|
||||||
|
constantPower = false;
|
||||||
|
}
|
||||||
|
|
||||||
orientation = o;
|
orientation = o;
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||||
|
@ -423,8 +435,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
progress = data.getFloat("progress");
|
progress = data.getFloat("progress");
|
||||||
energy = data.getDouble("energy");
|
energy = data.getDouble("energy");
|
||||||
heat = data.getFloat("heat");
|
heat = data.getFloat("heat");
|
||||||
if(data.hasKey("constantPower"))
|
if (data.hasKey("constantPower")) {
|
||||||
constantPower = data.getBoolean("constantPower");
|
constantPower = data.getBoolean("constantPower");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -537,7 +550,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
return false;
|
return false;
|
||||||
} else if (tile instanceof IPowerReceptor) {
|
} else if (tile instanceof IPowerReceptor) {
|
||||||
return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null;
|
return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null;
|
||||||
} else if (tile instanceof IEnergyHandler){
|
} else if (tile instanceof IEnergyHandler) {
|
||||||
return ((IEnergyHandler) tile).canConnectEnergy(side.getOpposite());
|
return ((IEnergyHandler) tile).canConnectEnergy(side.getOpposite());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -593,7 +606,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
public void checkRedstonePower() {
|
public void checkRedstonePower() {
|
||||||
isRedstonePowered = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
isRedstonePowered = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RF support
|
// RF support
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -606,9 +619,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
public int extractEnergy(ForgeDirection from, int maxExtract,
|
public int extractEnergy(ForgeDirection from, int maxExtract,
|
||||||
boolean simulate) {
|
boolean simulate) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*if(!(from == orientation)) return 0;
|
/*if(!(from == orientation)) return 0;
|
||||||
|
|
||||||
int energyRF = (int)Math.round(10 * energy);
|
int energyRF = (int)Math.round(10 * energy);
|
||||||
int energyExtracted = Math.min(maxExtract, energyRF);
|
int energyExtracted = Math.min(maxExtract, energyRF);
|
||||||
if(!simulate) {
|
if(!simulate) {
|
||||||
|
@ -620,9 +633,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyStored(ForgeDirection from) {
|
public int getEnergyStored(ForgeDirection from) {
|
||||||
if(!(from == orientation)) return 0;
|
if (!(from == orientation)) {
|
||||||
|
return 0;
|
||||||
return (int)Math.round(10 * energy);
|
}
|
||||||
|
|
||||||
|
return (int) Math.round(10 * energy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -173,7 +173,11 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!this.constantPower) currentOutput = currentFuel.powerPerCycle;
|
|
||||||
|
if (!this.constantPower) {
|
||||||
|
currentOutput = currentFuel.powerPerCycle;
|
||||||
|
}
|
||||||
|
|
||||||
addEnergy(currentFuel.powerPerCycle);
|
addEnergy(currentFuel.powerPerCycle);
|
||||||
heat += currentFuel.powerPerCycle * HEAT_PER_MJ * getBiomeTempScalar();
|
heat += currentFuel.powerPerCycle * HEAT_PER_MJ * getBiomeTempScalar();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,11 @@ public class TileEngineStone extends TileEngineWithInventory {
|
||||||
burnTime--;
|
burnTime--;
|
||||||
|
|
||||||
double output = getCurrentOutput();
|
double output = getCurrentOutput();
|
||||||
if(!constantPower) currentOutput = output; // Comment out for constant power
|
|
||||||
|
if (!constantPower) {
|
||||||
|
currentOutput = output; // Comment out for constant power
|
||||||
|
}
|
||||||
|
|
||||||
addEnergy(output);
|
addEnergy(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@ package buildcraft.energy;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import buildcraft.api.power.PowerHandler;
|
import buildcraft.api.power.PowerHandler;
|
||||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||||
import buildcraft.transport.TileGenericPipe;
|
import buildcraft.transport.TileGenericPipe;
|
||||||
|
@ -96,7 +98,7 @@ public class TileEngineWood extends TileEngine {
|
||||||
public boolean isBurning() {
|
public boolean isBurning() {
|
||||||
return isRedstonePowered;
|
return isRedstonePowered;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxEnergy() {
|
public double getMaxEnergy() {
|
||||||
return 100;
|
return 100;
|
||||||
|
@ -111,19 +113,20 @@ public class TileEngineWood extends TileEngine {
|
||||||
public double maxEnergyExtracted() {
|
public double maxEnergyExtracted() {
|
||||||
return 1 + PowerHandler.PerditionCalculator.MIN_POWERLOSS;
|
return 1 + PowerHandler.PerditionCalculator.MIN_POWERLOSS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: HACK
|
// TODO: HACK
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnectEnergy(ForgeDirection from) {
|
public boolean canConnectEnergy(ForgeDirection from) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void sendPower() {
|
protected void sendPower() {
|
||||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||||
if(tile instanceof TileGenericPipe && ((TileGenericPipe)tile).getPipeType() != PipeType.POWER)
|
if (tile instanceof TileGenericPipe && ((TileGenericPipe) tile).getPipeType() != PipeType.POWER) {
|
||||||
super.sendPower();
|
super.sendPower();
|
||||||
else // pretend we're sending out our powers
|
} else { // pretend we're sending out our powers
|
||||||
this.energy = 0.0;
|
this.energy = 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
import buildcraft.BuildCraftCore;
|
||||||
import buildcraft.core.CoreIconProvider;
|
import buildcraft.core.CoreIconProvider;
|
||||||
import buildcraft.core.gui.BuildCraftContainer;
|
import buildcraft.core.gui.BuildCraftContainer;
|
||||||
|
@ -52,9 +53,11 @@ public abstract class GuiEngine extends GuiBuildCraft {
|
||||||
|
|
||||||
fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour);
|
fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour);
|
||||||
fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.currentOutput") + ":", x + 22, y + 20, subheaderColour);
|
fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.currentOutput") + ":", x + 22, y + 20, subheaderColour);
|
||||||
fontRendererObj.drawString(String.format("%d RF/t", (int)Math.round(engine.getCurrentOutput() * 10)), x + 22, y + 32, textColour);
|
fontRendererObj.drawString(String.format("%d RF/t", (int) Math.round(engine.getCurrentOutput() * 10)),
|
||||||
|
x + 22, y + 32, textColour);
|
||||||
fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour);
|
fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour);
|
||||||
fontRendererObj.drawString(String.format("%d RF", (int)Math.round(engine.getEnergyStored() * 10)), x + 22, y + 56, textColour);
|
fontRendererObj.drawString(String.format("%d RF", (int) Math.round(engine.getEnergyStored() * 10)), x + 22,
|
||||||
|
y + 56, textColour);
|
||||||
fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.heat") + ":", x + 22, y + 68, subheaderColour);
|
fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.heat") + ":", x + 22, y + 68, subheaderColour);
|
||||||
fontRendererObj.drawString(String.format("%.2f \u00B0C", engine.getHeat()), x + 22, y + 80, textColour);
|
fontRendererObj.drawString(String.format("%.2f \u00B0C", engine.getHeat()), x + 22, y + 80, textColour);
|
||||||
|
|
||||||
|
@ -62,7 +65,7 @@ public abstract class GuiEngine extends GuiBuildCraft {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTooltip() {
|
public String getTooltip() {
|
||||||
return String.format("%d RF/t", (int)Math.round(engine.getCurrentOutput() * 10));
|
return String.format("%d RF/t", (int) Math.round(engine.getCurrentOutput() * 10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@ import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
import buildcraft.BuildCraftCore;
|
||||||
import buildcraft.BuildCraftFactory;
|
import buildcraft.BuildCraftFactory;
|
||||||
import buildcraft.api.gates.IAction;
|
import buildcraft.api.gates.IAction;
|
||||||
|
@ -43,7 +45,8 @@ public class TileMiningWell extends TileBuildCraft implements IMachine {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int miningCost = (int)Math.ceil(BuildCraftFactory.MINING_RF_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier);
|
int miningCost = (int) Math.ceil(BuildCraftFactory.MINING_RF_COST_PER_BLOCK
|
||||||
|
* BuildCraftFactory.miningMultiplier);
|
||||||
|
|
||||||
if (getBattery().useEnergy(miningCost, miningCost, false) == 0) {
|
if (getBattery().useEnergy(miningCost, miningCost, false) == 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
||||||
} else if (stage == Stage.IDLE) {
|
} else if (stage == Stage.IDLE) {
|
||||||
dig();
|
dig();
|
||||||
} else if (stage == Stage.DIGGING) {
|
} else if (stage == Stage.DIGGING) {
|
||||||
int energyToUse = 20 + (int)Math.round(getBattery().getEnergyStored() / 500);
|
int energyToUse = 20 + Math.round(getBattery().getEnergyStored() / 500);
|
||||||
|
|
||||||
if (this.consumeEnergy(energyToUse)) {
|
if (this.consumeEnergy(energyToUse)) {
|
||||||
speed = 0.1 + energyToUse / 200F;
|
speed = 0.1 + energyToUse / 200F;
|
||||||
|
@ -192,7 +192,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void dig() {
|
protected void dig() {
|
||||||
int rf = (int)Math.ceil(BuildCraftFactory.MINING_RF_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier);
|
int rf = (int) Math.ceil(BuildCraftFactory.MINING_RF_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier);
|
||||||
|
|
||||||
if (!consumeEnergy(rf)) {
|
if (!consumeEnergy(rf)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -12,10 +12,13 @@ import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
import buildcraft.BuildCraftCore;
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.SafeTimeTracker;
|
import buildcraft.api.core.SafeTimeTracker;
|
||||||
|
@ -100,9 +103,9 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tile instanceof IEnergyHandler) {
|
if (tile instanceof IEnergyHandler) {
|
||||||
IEnergyHandler handler = (IEnergyHandler)tile;
|
IEnergyHandler handler = (IEnergyHandler) tile;
|
||||||
if (handler != null && handler.canConnectEnergy(side.getOpposite())) {
|
if (handler != null && handler.canConnectEnergy(side.getOpposite())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +168,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
// Send the power to nearby pipes who requested it
|
// Send the power to nearby pipes who requested it
|
||||||
|
|
||||||
System.arraycopy(displayPower, 0, prevDisplayPower, 0, 6);
|
System.arraycopy(displayPower, 0, prevDisplayPower, 0, 6);
|
||||||
Arrays.fill(displayPower, (short)0);
|
Arrays.fill(displayPower, (short) 0);
|
||||||
|
|
||||||
// STEP 1 - computes the total amount of power contained and total
|
// STEP 1 - computes the total amount of power contained and total
|
||||||
// amount of power queried
|
// amount of power queried
|
||||||
|
@ -194,7 +197,8 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
externalPower[out] = 0;
|
externalPower[out] = 0;
|
||||||
|
|
||||||
if (powerQuery[out] > 0 && internalPower[out] == 0) {
|
if (powerQuery[out] > 0 && internalPower[out] == 0) {
|
||||||
int powerConsumed = (int)Math.floor((double)(powerQuery[out] * totalPowerContained) / totalPowerQuery);
|
int powerConsumed = (int) Math.floor((double) (powerQuery[out] * totalPowerContained)
|
||||||
|
/ totalPowerQuery);
|
||||||
boolean tilePowered = false;
|
boolean tilePowered = false;
|
||||||
|
|
||||||
if (tiles[out] instanceof TileGenericPipe) {
|
if (tiles[out] instanceof TileGenericPipe) {
|
||||||
|
@ -207,11 +211,11 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
powerConsumed);
|
powerConsumed);
|
||||||
tilePowered = true;
|
tilePowered = true;
|
||||||
} else if (tiles[out] instanceof IEnergyHandler) {
|
} else if (tiles[out] instanceof IEnergyHandler) {
|
||||||
IEnergyHandler handler = (IEnergyHandler)tiles[out];
|
IEnergyHandler handler = (IEnergyHandler) tiles[out];
|
||||||
|
|
||||||
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[out].getOpposite())) {
|
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[out].getOpposite())) {
|
||||||
// Transmit power to an RF energy handler
|
// Transmit power to an RF energy handler
|
||||||
|
|
||||||
powerConsumed = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[out].getOpposite(),
|
powerConsumed = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[out].getOpposite(),
|
||||||
powerConsumed, false);
|
powerConsumed, false);
|
||||||
tilePowered = true;
|
tilePowered = true;
|
||||||
|
@ -222,7 +226,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
if (prov != null) {
|
if (prov != null) {
|
||||||
// Transmit power to the legacy power framework
|
// Transmit power to the legacy power framework
|
||||||
|
|
||||||
powerConsumed = (int)Math.ceil(prov.receiveEnergy(Type.PIPE, (double)powerConsumed / 10.0,
|
powerConsumed = (int) Math.ceil(prov.receiveEnergy(Type.PIPE, powerConsumed / 10.0,
|
||||||
ForgeDirection.VALID_DIRECTIONS[out].getOpposite()) * 10);
|
ForgeDirection.VALID_DIRECTIONS[out].getOpposite()) * 10);
|
||||||
tilePowered = true;
|
tilePowered = true;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +247,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
|
|
||||||
if (totalPowerConsumed > 0) {
|
if (totalPowerConsumed > 0) {
|
||||||
for (int in = 0; in < 6; ++in) {
|
for (int in = 0; in < 6; ++in) {
|
||||||
int powerConsumed = (int)Math.floor(internalPower[in] / totalPowerContained * totalPowerConsumed);
|
int powerConsumed = (int) Math.floor(internalPower[in] / totalPowerContained * totalPowerConsumed);
|
||||||
displayPower[in] += powerConsumed;
|
displayPower[in] += powerConsumed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,7 +256,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
|
|
||||||
highestPower = 0;
|
highestPower = 0;
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
displayPower[i] = (short)((prevDisplayPower[i] * (DISPLAY_SMOOTHING - 1.0F) + displayPower[i]) / DISPLAY_SMOOTHING);
|
displayPower[i] = (short) ((prevDisplayPower[i] * (DISPLAY_SMOOTHING - 1.0F) + displayPower[i]) / DISPLAY_SMOOTHING);
|
||||||
|
|
||||||
if (displayPower[i] > highestPower) {
|
if (displayPower[i] > highestPower) {
|
||||||
highestPower = displayPower[i];
|
highestPower = displayPower[i];
|
||||||
|
@ -276,10 +280,10 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
TileEntity tile = tiles [dir.ordinal()];
|
TileEntity tile = tiles [dir.ordinal()];
|
||||||
if (tile instanceof IEnergyHandler) {
|
if (tile instanceof IEnergyHandler) {
|
||||||
IEnergyHandler handler = (IEnergyHandler)tile;
|
IEnergyHandler handler = (IEnergyHandler) tile;
|
||||||
if(handler.canConnectEnergy(dir.getOpposite())) {
|
if (handler.canConnectEnergy(dir.getOpposite())) {
|
||||||
int request = handler.receiveEnergy(dir.getOpposite(), this.maxPower, true);
|
int request = handler.receiveEnergy(dir.getOpposite(), this.maxPower, true);
|
||||||
|
|
||||||
if (request > 0) {
|
if (request > 0) {
|
||||||
requestEnergy(dir, request);
|
requestEnergy(dir, request);
|
||||||
}
|
}
|
||||||
|
@ -287,7 +291,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
} else if (!(tile instanceof TileGenericPipe && ((TileGenericPipe) tile).pipe.transport instanceof PipeTransportPower)) {
|
} else if (!(tile instanceof TileGenericPipe && ((TileGenericPipe) tile).pipe.transport instanceof PipeTransportPower)) {
|
||||||
PowerReceiver prov = getReceiverOnSide(dir);
|
PowerReceiver prov = getReceiverOnSide(dir);
|
||||||
if (prov != null) {
|
if (prov != null) {
|
||||||
int request = (int)Math.floor(prov.powerRequest() * 10);
|
int request = (int) Math.floor(prov.powerRequest() * 10);
|
||||||
|
|
||||||
if (request > 0) {
|
if (request > 0) {
|
||||||
requestEnergy(dir, request);
|
requestEnergy(dir, request);
|
||||||
|
@ -297,7 +301,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sum the amount of energy requested on each side
|
// Sum the amount of energy requested on each side
|
||||||
|
|
||||||
int[] transferQuery = new int[6];
|
int[] transferQuery = new int[6];
|
||||||
|
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
@ -519,7 +523,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
|
|
||||||
public int consumePower(ForgeDirection dir, int max) {
|
public int consumePower(ForgeDirection dir, int max) {
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (externalPower[dir.ordinal()] < max) {
|
if (externalPower[dir.ordinal()] < max) {
|
||||||
result = externalPower[dir.ordinal()];
|
result = externalPower[dir.ordinal()];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,10 +10,13 @@ package buildcraft.transport;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
import buildcraft.BuildCraftCore;
|
||||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||||
import buildcraft.api.gates.ITrigger;
|
import buildcraft.api.gates.ITrigger;
|
||||||
|
@ -63,7 +66,7 @@ public class PipeTriggerProvider implements ITriggerProvider {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tile instanceof IEnergyHandler && ((IEnergyHandler)tile).getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0) {
|
if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0) {
|
||||||
result.add(BuildCraftCore.triggerEnergyHigh);
|
result.add(BuildCraftCore.triggerEnergyHigh);
|
||||||
result.add(BuildCraftCore.triggerEnergyLow);
|
result.add(BuildCraftCore.triggerEnergyLow);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ import java.util.LinkedList;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
@ -24,14 +24,19 @@ import net.minecraft.network.Packet;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
|
|
||||||
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.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
import buildcraft.BuildCraftCore;
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.BCLog;
|
import buildcraft.api.core.BCLog;
|
||||||
|
@ -1111,41 +1116,51 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
||||||
((IPowerReceptor) pipe).doWork(workProvider);
|
((IPowerReceptor) pipe).doWork(workProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnectEnergy(ForgeDirection from) {
|
public boolean canConnectEnergy(ForgeDirection from) {
|
||||||
if(pipe instanceof IEnergyHandler) {
|
if (pipe instanceof IEnergyHandler) {
|
||||||
return ((IEnergyHandler)pipe).canConnectEnergy(from);
|
return ((IEnergyHandler) pipe).canConnectEnergy(from);
|
||||||
} else return false;
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
||||||
boolean simulate) {
|
boolean simulate) {
|
||||||
if(pipe instanceof IEnergyHandler) {
|
if (pipe instanceof IEnergyHandler) {
|
||||||
return ((IEnergyHandler)pipe).receiveEnergy(from, maxReceive, simulate);
|
return ((IEnergyHandler) pipe).receiveEnergy(from, maxReceive, simulate);
|
||||||
} else return 0;
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int extractEnergy(ForgeDirection from, int maxExtract,
|
public int extractEnergy(ForgeDirection from, int maxExtract,
|
||||||
boolean simulate) {
|
boolean simulate) {
|
||||||
if(pipe instanceof IEnergyHandler) {
|
if (pipe instanceof IEnergyHandler) {
|
||||||
return ((IEnergyHandler)pipe).extractEnergy(from, maxExtract, simulate);
|
return ((IEnergyHandler) pipe).extractEnergy(from, maxExtract, simulate);
|
||||||
} else return 0;
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyStored(ForgeDirection from) {
|
public int getEnergyStored(ForgeDirection from) {
|
||||||
if(pipe instanceof IEnergyHandler) {
|
if (pipe instanceof IEnergyHandler) {
|
||||||
return ((IEnergyHandler)pipe).getEnergyStored(from);
|
return ((IEnergyHandler) pipe).getEnergyStored(from);
|
||||||
} else return 0;
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxEnergyStored(ForgeDirection from) {
|
public int getMaxEnergyStored(ForgeDirection from) {
|
||||||
if(pipe instanceof IEnergyHandler) {
|
if (pipe instanceof IEnergyHandler) {
|
||||||
return ((IEnergyHandler)pipe).getMaxEnergyStored(from);
|
return ((IEnergyHandler) pipe).getMaxEnergyStored(from);
|
||||||
} else return 0;
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,13 @@ package buildcraft.transport.gates;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.gates.GateExpansionController;
|
import buildcraft.api.gates.GateExpansionController;
|
||||||
import buildcraft.api.gates.IAction;
|
import buildcraft.api.gates.IAction;
|
||||||
|
@ -100,7 +103,8 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
|
||||||
// TODO: (1 - 1) is coming from pulse count, which has been
|
// TODO: (1 - 1) is coming from pulse count, which has been
|
||||||
// removed. The add energy algorithm probably needs to be
|
// removed. The add energy algorithm probably needs to be
|
||||||
// reviewed altogether.
|
// reviewed altogether.
|
||||||
((IEnergyHandler)pipeTile).receiveEnergy(ForgeDirection.UNKNOWN, Math.min(1 << (1 - 1), 64) * 10, false);
|
((IEnergyHandler) pipeTile).receiveEnergy(ForgeDirection.UNKNOWN, Math.min(1 << (1 - 1), 64) * 10,
|
||||||
|
false);
|
||||||
hasPulsed = true;
|
hasPulsed = true;
|
||||||
} else {
|
} else {
|
||||||
gate.setPulsing(true);
|
gate.setPulsing(true);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
package buildcraft.transport.network;
|
package buildcraft.transport.network;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import buildcraft.core.network.PacketCoordinates;
|
import buildcraft.core.network.PacketCoordinates;
|
||||||
import buildcraft.core.network.PacketIds;
|
import buildcraft.core.network.PacketIds;
|
||||||
import buildcraft.transport.render.PipeRendererTESR;
|
import buildcraft.transport.render.PipeRendererTESR;
|
||||||
|
@ -26,7 +27,7 @@ public class PacketPowerUpdate extends PacketCoordinates {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readData(ByteBuf data) {
|
public void readData(ByteBuf data) {
|
||||||
super.readData(data);
|
super.readData(data);
|
||||||
displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
|
displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
|
||||||
overload = data.readBoolean();
|
overload = data.readBoolean();
|
||||||
|
@ -40,7 +41,8 @@ public class PacketPowerUpdate extends PacketCoordinates {
|
||||||
super.writeData(data);
|
super.writeData(data);
|
||||||
data.writeBoolean(overload);
|
data.writeBoolean(overload);
|
||||||
for (short element : displayPower) {
|
for (short element : displayPower) {
|
||||||
data.writeByte(Math.min(PipeRendererTESR.POWER_STAGES, (int)Math.ceil(element * PipeRendererTESR.DISPLAY_MULTIPLIER)));
|
data.writeByte(Math.min(PipeRendererTESR.POWER_STAGES,
|
||||||
|
(int) Math.ceil(element * PipeRendererTESR.DISPLAY_MULTIPLIER)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,20 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.transport.pipes;
|
package buildcraft.transport.pipes;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
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.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.api.core.NetworkData;
|
import buildcraft.api.core.NetworkData;
|
||||||
|
|
|
@ -11,7 +11,6 @@ package buildcraft.transport.pipes;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.item.EntityMinecartChest;
|
import net.minecraft.entity.item.EntityMinecartChest;
|
||||||
|
@ -20,9 +19,14 @@ import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
|
||||||
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.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -214,7 +218,7 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IEner
|
||||||
|
|
||||||
CoreProxy.proxy.obsidianPipePickup(container.getWorldObj(), item, this.container);
|
CoreProxy.proxy.obsidianPipePickup(container.getWorldObj(), item, this.container);
|
||||||
|
|
||||||
int energyUsed = (int)Math.min(10 * contained.stackSize * distance, battery.getEnergyStored());
|
int energyUsed = Math.min(10 * contained.stackSize * distance, battery.getEnergyStored());
|
||||||
|
|
||||||
// TODO: Why is energyUsed never used here?
|
// TODO: Why is energyUsed never used here?
|
||||||
|
|
||||||
|
@ -222,7 +226,7 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IEner
|
||||||
stack = contained;
|
stack = contained;
|
||||||
CoreProxy.proxy.removeEntity(entity);
|
CoreProxy.proxy.removeEntity(entity);
|
||||||
} else {
|
} else {
|
||||||
stack = contained.splitStack((int) (energyUsed / distance));
|
stack = contained.splitStack(energyUsed / distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
speed = Math.sqrt(item.motionX * item.motionX + item.motionY * item.motionY + item.motionZ * item.motionZ);
|
speed = Math.sqrt(item.motionX * item.motionX + item.motionY * item.motionY + item.motionZ * item.motionZ);
|
||||||
|
|
|
@ -10,7 +10,6 @@ package buildcraft.transport.pipes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockLeavesBase;
|
import net.minecraft.block.BlockLeavesBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -24,7 +23,11 @@ import net.minecraft.item.ItemPotion;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -238,9 +241,12 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnerg
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
||||||
boolean simulate) {
|
boolean simulate) {
|
||||||
if(maxReceive == 0) return 0;
|
if (maxReceive == 0) {
|
||||||
else if(simulate) return 10;
|
return 0;
|
||||||
|
} else if (simulate) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
ForgeDirection o = getOpenOrientation();
|
ForgeDirection o = getOpenOrientation();
|
||||||
|
|
||||||
if (o != ForgeDirection.UNKNOWN) {
|
if (o != ForgeDirection.UNKNOWN) {
|
||||||
|
@ -270,7 +276,7 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnerg
|
||||||
getWorld().setBlockToAir((int) p.x, (int) p.y, (int) p.z);
|
getWorld().setBlockToAir((int) p.x, (int) p.y, (int) p.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return maxReceive;
|
return maxReceive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,16 +8,20 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.transport.pipes;
|
package buildcraft.transport.pipes;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
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.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
package buildcraft.transport.pipes;
|
package buildcraft.transport.pipes;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.core.RFBattery;
|
import buildcraft.core.RFBattery;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
|
|
||||||
public class PipePowerEmerald extends PipePowerWood {
|
public class PipePowerEmerald extends PipePowerWood {
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,17 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.transport.pipes;
|
package buildcraft.transport.pipes;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyHandler;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
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.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.api.power.IPowerEmitter;
|
import buildcraft.api.power.IPowerEmitter;
|
||||||
|
@ -41,12 +45,12 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
||||||
private boolean full;
|
private boolean full;
|
||||||
private int requestedEnergy, sources;
|
private int requestedEnergy, sources;
|
||||||
private PowerHandler powerHandler;
|
private PowerHandler powerHandler;
|
||||||
|
|
||||||
public PipePowerWood(Item item) {
|
public PipePowerWood(Item item) {
|
||||||
super(new PipeTransportPower(), item);
|
super(new PipeTransportPower(), item);
|
||||||
|
|
||||||
battery = new RFBattery(320 * 50, 320, 0);
|
battery = new RFBattery(320 * 50, 320, 0);
|
||||||
|
|
||||||
powerHandler = new PowerHandler(this, Type.PIPE);
|
powerHandler = new PowerHandler(this, Type.PIPE);
|
||||||
powerHandler.configure(0, 500, 1, 1500);
|
powerHandler.configure(0, 500, 1, 1500);
|
||||||
powerHandler.setPerdition(new PerditionCalculator(PerditionCalculator.MIN_POWERLOSS));
|
powerHandler.setPerdition(new PerditionCalculator(PerditionCalculator.MIN_POWERLOSS));
|
||||||
|
@ -86,7 +90,7 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
||||||
sources++;
|
sources++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container.getWorldObj().isRemote) {
|
if (container.getWorldObj().isRemote) {
|
||||||
// We only do the isRemote check now to get a list
|
// We only do the isRemote check now to get a list
|
||||||
// of power sources for client-side rendering.
|
// of power sources for client-side rendering.
|
||||||
|
@ -109,7 +113,7 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
||||||
// and used in receiveEnergy and extractEnergy.
|
// and used in receiveEnergy and extractEnergy.
|
||||||
// That way, we can replicate BC behaviour more accurately,
|
// That way, we can replicate BC behaviour more accurately,
|
||||||
// but we still need to see how well that works with constant power.
|
// but we still need to see how well that works with constant power.
|
||||||
|
|
||||||
/* if (mjStored > 40) {
|
/* if (mjStored > 40) {
|
||||||
energyToRemove = mjStored / 40 + 4;
|
energyToRemove = mjStored / 40 + 4;
|
||||||
} else if (mjStored > 10) {
|
} else if (mjStored > 10) {
|
||||||
|
@ -117,9 +121,9 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
||||||
} else {
|
} else {
|
||||||
energyToRemove = 1;
|
energyToRemove = 1;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
energyToRemove /= sources;
|
energyToRemove /= sources;
|
||||||
|
|
||||||
// Extract power from RF sources.
|
// Extract power from RF sources.
|
||||||
// While we send power to receivers and so does TE4,
|
// While we send power to receivers and so does TE4,
|
||||||
// Extra Utilities generators (as an example) depend
|
// Extra Utilities generators (as an example) depend
|
||||||
|
@ -128,26 +132,27 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
||||||
if (!powerSources[o.ordinal()]) {
|
if (!powerSources[o.ordinal()]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity tile = container.getTile(o);
|
TileEntity tile = container.getTile(o);
|
||||||
|
|
||||||
if(tile instanceof IEnergyHandler) {
|
if (tile instanceof IEnergyHandler) {
|
||||||
battery.addEnergy(0, ((IEnergyHandler)tile).extractEnergy(o.getOpposite(), energyToRemove, false), false);
|
battery.addEnergy(0, ((IEnergyHandler) tile).extractEnergy(o.getOpposite(), energyToRemove, false),
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
if (!powerSources[o.ordinal()]) {
|
if (!powerSources[o.ordinal()]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int energyUsable = Math.min(battery.getEnergyStored(), energyToRemove);
|
int energyUsable = Math.min(battery.getEnergyStored(), energyToRemove);
|
||||||
|
|
||||||
if (energyUsable > 0) {
|
if (energyUsable > 0) {
|
||||||
battery.setEnergy(battery.getEnergyStored() - transport.receiveEnergy(o, energyUsable));
|
battery.setEnergy(battery.getEnergyStored() - transport.receiveEnergy(o, energyUsable));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requestedEnergy = 0;
|
requestedEnergy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,10 +210,8 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
||||||
public boolean isPowerSource(TileEntity tile, ForgeDirection from) {
|
public boolean isPowerSource(TileEntity tile, ForgeDirection from) {
|
||||||
if (tile instanceof IPowerEmitter && ((IPowerEmitter) tile).canEmitPowerFrom(from.getOpposite())) {
|
if (tile instanceof IPowerEmitter && ((IPowerEmitter) tile).canEmitPowerFrom(from.getOpposite())) {
|
||||||
return true;
|
return true;
|
||||||
} else if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).canConnectEnergy(from.getOpposite())) {
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return tile instanceof IEnergyHandler && ((IEnergyHandler) tile).canConnectEnergy(from.getOpposite());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +222,7 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doWork(PowerHandler workProvider) {
|
public void doWork(PowerHandler workProvider) {
|
||||||
battery.addEnergy(0, (int)Math.round(this.powerHandler.getEnergyStored() * 10), true);
|
battery.addEnergy(0, (int) Math.round(this.powerHandler.getEnergyStored() * 10), true);
|
||||||
this.powerHandler.setEnergy(0.0);
|
this.powerHandler.setEnergy(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
Checkstyle-Configuration: BuildCraft
|
Checkstyle-Configuration: BuildCraft
|
||||||
Description: none
|
Description: none
|
||||||
-->
|
-->
|
||||||
<module name="Checker">
|
<module name="Checker">
|
||||||
<property name="severity" value="error"/>
|
<property name="severity" value="error"/>
|
||||||
<module name="SuppressionCommentFilter">
|
<module name="SuppressionCommentFilter">
|
||||||
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
|
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/>
|
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="ImportOrder">
|
<module name="ImportOrder">
|
||||||
<property name="groups" value="java,com,org,io,joptsimple,net.minecraft,cpw,net.minecraftforge,buildcraft"/>
|
<property name="groups" value="java,com,org,io,joptsimple,net.minecraft,cpw,net.minecraftforge,cofh,buildcraft"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="WhitespaceAround">
|
<module name="WhitespaceAround">
|
||||||
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND,WILDCARD_TYPE"/>
|
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND,WILDCARD_TYPE"/>
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue