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;
|
||||
|
||||
@Deprecated
|
||||
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
|
||||
* from a specific side.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IPowerEmitter {
|
||||
|
||||
public boolean canEmitPowerFrom(ForgeDirection side);
|
||||
boolean canEmitPowerFrom(ForgeDirection side);
|
||||
}
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
package buildcraft.api.power;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* This interface should be implemented by any Tile Entity that wishes to be
|
||||
* able to receive power.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IPowerReceptor {
|
||||
|
||||
/**
|
||||
|
@ -29,7 +31,7 @@ public interface IPowerReceptor {
|
|||
* @param side
|
||||
* @return
|
||||
*/
|
||||
public PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side);
|
||||
PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side);
|
||||
|
||||
/**
|
||||
* Call back from the PowerHandler that is called when the stored power
|
||||
|
@ -39,7 +41,7 @@ public interface IPowerReceptor {
|
|||
*
|
||||
* @param workProvider
|
||||
*/
|
||||
public void doWork(PowerHandler workProvider);
|
||||
void doWork(PowerHandler workProvider);
|
||||
|
||||
public World getWorld();
|
||||
World getWorld();
|
||||
}
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
*/
|
||||
package buildcraft.api.power;
|
||||
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
|
||||
/**
|
||||
* The PowerHandler is similar to FluidTank in that it holds your power and
|
||||
* allows standardized interaction between machines.
|
||||
|
@ -28,6 +30,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
* @see IPowerReceptor
|
||||
* @see IPowerEmitter
|
||||
*/
|
||||
@Deprecated
|
||||
public final class PowerHandler {
|
||||
|
||||
public static enum Type {
|
||||
|
@ -75,11 +78,12 @@ public final class PowerHandler {
|
|||
*
|
||||
* @param powerLoss power loss per tick
|
||||
*/
|
||||
public PerditionCalculator(double powerLoss) {
|
||||
if (powerLoss < MIN_POWERLOSS) {
|
||||
public PerditionCalculator(double iPowerLoss) {
|
||||
if (iPowerLoss < MIN_POWERLOSS) {
|
||||
powerLoss = iPowerLoss;
|
||||
} else {
|
||||
powerLoss = MIN_POWERLOSS;
|
||||
}
|
||||
this.powerLoss = powerLoss;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,11 +97,14 @@ public final class PowerHandler {
|
|||
* @return
|
||||
*/
|
||||
public double applyPerdition(PowerHandler powerHandler, double current, long ticksPassed) {
|
||||
current -= powerLoss * ticksPassed;
|
||||
if (current < 0) {
|
||||
current = 0;
|
||||
double result = current;
|
||||
|
||||
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_NUMERATOR = ROLLING_AVERAGE_WEIGHT - 1;
|
||||
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 maxEnergyReceived;
|
||||
private double maxEnergyStored;
|
||||
|
@ -123,8 +132,6 @@ public final class PowerHandler {
|
|||
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
|
||||
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
|
||||
private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
|
||||
public final int[] powerSources = new int[6];
|
||||
public final IPowerReceptor receptor;
|
||||
private PerditionCalculator perdition;
|
||||
private final PowerReceiver receiver;
|
||||
private final Type type;
|
||||
|
@ -167,29 +174,38 @@ public final class PowerHandler {
|
|||
/**
|
||||
* Setup your PowerHandler's settings.
|
||||
*
|
||||
* @param minEnergyReceived This is the minimum about of power that will be
|
||||
* accepted by the PowerHandler. This should generally be greater than the
|
||||
* activationEnergy if you plan to use the doWork() callback. Anything
|
||||
* greater than 1 will prevent Redstone Engines from powering this Provider.
|
||||
* @param maxEnergyReceived The maximum amount of power accepted by the
|
||||
* PowerHandler. This should generally be less than 500. Too low and larger
|
||||
* engines will overheat while trying to power the machine. Too high, and
|
||||
* the engines will never warm up. Greater values also place greater strain
|
||||
* on the power net.
|
||||
* @param activationEnergy 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.
|
||||
* @param minEnergyReceived
|
||||
* This is the minimum about of power that will be accepted by
|
||||
* the PowerHandler. This should generally be greater than the
|
||||
* activationEnergy if you plan to use the doWork() callback.
|
||||
* Anything greater than 1 will prevent Redstone Engines from
|
||||
* powering this Provider.
|
||||
* @param iMaxEnergyReceived
|
||||
* The maximum amount of power accepted by the PowerHandler. This
|
||||
* should generally be less than 500. Too low and larger engines
|
||||
* will overheat while trying to power the machine. Too high, and
|
||||
* the engines will never warm up. Greater values also place
|
||||
* greater strain on the power net.
|
||||
* @param activationEnergy
|
||||
* 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) {
|
||||
if (minEnergyReceived > maxEnergyReceived) {
|
||||
maxEnergyReceived = minEnergyReceived;
|
||||
public void configure(double iMinEnergyReceived, double iMaxEnergyReceived, double iActivationEnergy,
|
||||
double iMaxStoredEnergy) {
|
||||
|
||||
if (iMinEnergyReceived > maxEnergyReceived) {
|
||||
maxEnergyReceived = iMinEnergyReceived;
|
||||
} else {
|
||||
maxEnergyReceived = iMaxEnergyReceived;
|
||||
}
|
||||
this.minEnergyReceived = minEnergyReceived;
|
||||
this.maxEnergyReceived = maxEnergyReceived;
|
||||
this.maxEnergyStored = maxStoredEnergy;
|
||||
this.activationEnergy = activationEnergy;
|
||||
|
||||
minEnergyReceived = iMinEnergyReceived;
|
||||
maxEnergyStored = iMaxStoredEnergy;
|
||||
activationEnergy = iActivationEnergy;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,17 +233,20 @@ public final class PowerHandler {
|
|||
* For example if you want exponentially increasing loss based on amount
|
||||
* stored.
|
||||
*
|
||||
* @param perdition
|
||||
* @param iPerdition
|
||||
*/
|
||||
public void setPerdition(PerditionCalculator perdition) {
|
||||
if (perdition == null)
|
||||
public void setPerdition(PerditionCalculator iPerdition) {
|
||||
if (iPerdition == null) {
|
||||
perdition = DEFAULT_PERDITION;
|
||||
this.perdition = perdition;
|
||||
} else {
|
||||
perdition = iPerdition;
|
||||
}
|
||||
}
|
||||
|
||||
public PerditionCalculator getPerdition() {
|
||||
if (perdition == null)
|
||||
if (perdition == null) {
|
||||
return DEFAULT_PERDITION;
|
||||
}
|
||||
return perdition;
|
||||
}
|
||||
|
||||
|
@ -250,10 +269,11 @@ public final class PowerHandler {
|
|||
if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0) {
|
||||
double prev = energyStored;
|
||||
double newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
||||
if (newEnergy == 0 || newEnergy < energyStored)
|
||||
if (newEnergy == 0 || newEnergy < energyStored) {
|
||||
energyStored = newEnergy;
|
||||
else
|
||||
} else {
|
||||
energyStored = DEFAULT_PERDITION.applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
||||
}
|
||||
validateEnergy();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,8 +333,9 @@ public final class PowerHandler {
|
|||
|
||||
validateEnergy();
|
||||
|
||||
if (doUse)
|
||||
if (doUse) {
|
||||
averageUsedPower = (averageUsedPower * ROLLING_AVERAGE_NUMERATOR + result) * ROLLING_AVERAGE_DENOMINATOR;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -433,20 +455,22 @@ public final class PowerHandler {
|
|||
*
|
||||
* @return the amount the power changed by
|
||||
*/
|
||||
public double addEnergy(double quantity) {
|
||||
energyStored += quantity;
|
||||
public double addEnergy(double iQuantity) {
|
||||
energyStored += iQuantity;
|
||||
|
||||
double added = iQuantity;
|
||||
|
||||
if (energyStored > maxEnergyStored) {
|
||||
quantity -= energyStored - maxEnergyStored;
|
||||
added -= energyStored - maxEnergyStored;
|
||||
energyStored = maxEnergyStored;
|
||||
} else if (energyStored < 0) {
|
||||
quantity -= energyStored;
|
||||
added -= energyStored;
|
||||
energyStored = 0;
|
||||
}
|
||||
|
||||
applyPerdition();
|
||||
|
||||
return quantity;
|
||||
return added;
|
||||
}
|
||||
|
||||
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;
|
||||
import cpw.mods.fml.common.API;
|
|
@ -8,13 +8,16 @@
|
|||
*/
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import cofh.api.energy.IEnergyStorage;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import cofh.api.energy.IEnergyStorage;
|
||||
|
||||
import buildcraft.api.boards.RedstoneBoardRobot;
|
||||
import buildcraft.api.core.IZone;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.LinkedList;
|
|||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.api.blueprints.ITileBuilder;
|
||||
import buildcraft.api.blueprints.SchematicRegistry;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
|
@ -123,6 +124,7 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil
|
|||
buildersInAction.add(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAndLaunchBuildingItem(BuildingItem item) {
|
||||
buildersInAction.add(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) {
|
||||
return (getBattery().useEnergy(quantity, quantity, false) > 0);
|
||||
return getBattery().useEnergy(quantity, quantity, false) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package buildcraft.core;
|
||||
|
||||
import cofh.api.energy.IEnergyStorage;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import cofh.api.energy.IEnergyStorage;
|
||||
|
||||
public class RFBattery implements IEnergyStorage {
|
||||
private int energy, maxEnergy, maxReceive, maxExtract;
|
||||
|
||||
|
@ -13,7 +14,9 @@ public class RFBattery implements IEnergyStorage {
|
|||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
if(!(tag.hasKey("battery"))) return;
|
||||
if (!(tag.hasKey("battery"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound battery = tag.getCompoundTag("battery");
|
||||
this.energy = battery.getInteger("energy");
|
||||
|
@ -32,15 +35,29 @@ public class RFBattery implements IEnergyStorage {
|
|||
|
||||
public int addEnergy(int minReceive, int maxReceive, boolean simulate) {
|
||||
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;
|
||||
}
|
||||
|
||||
public int useEnergy(int minExtract, int maxExtract, boolean simulate) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -72,8 +89,8 @@ public class RFBattery implements IEnergyStorage {
|
|||
return maxExtract;
|
||||
}
|
||||
|
||||
public void setEnergy(int energy) {
|
||||
this.energy = energy;
|
||||
public void setEnergy(int iEnergy) {
|
||||
energy = iEnergy;
|
||||
|
||||
if (energy < 0) {
|
||||
energy = 0;
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -20,7 +19,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.core.network.BuildCraftPacket;
|
||||
|
@ -161,34 +164,47 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
return this == cmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return (battery != null);
|
||||
return battery != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
||||
boolean simulate) {
|
||||
if(battery != null && this.canConnectEnergy(from))
|
||||
if (battery != null && this.canConnectEnergy(from)) {
|
||||
return battery.receiveEnergy(maxReceive, simulate);
|
||||
else return 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract,
|
||||
boolean simulate) {
|
||||
if(battery != null && this.canConnectEnergy(from))
|
||||
if (battery != null && this.canConnectEnergy(from)) {
|
||||
return battery.extractEnergy(maxExtract, simulate);
|
||||
else return 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
if(battery != null && this.canConnectEnergy(from))
|
||||
if (battery != null && this.canConnectEnergy(from)) {
|
||||
return battery.getEnergyStored();
|
||||
else return 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
if(battery != null && this.canConnectEnergy(from))
|
||||
if (battery != null && this.canConnectEnergy(from)) {
|
||||
return battery.getMaxEnergyStored();
|
||||
else return 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public RFBattery getBattery() {
|
||||
|
|
|
@ -10,13 +10,16 @@ package buildcraft.core.triggers;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
|
@ -62,7 +65,7 @@ public class DefaultTriggerProvider implements ITriggerProvider {
|
|||
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.triggerEnergyLow);
|
||||
}
|
||||
|
|
|
@ -8,13 +8,17 @@
|
|||
*/
|
||||
package buildcraft.core.triggers;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.api.gates.IGate;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
@ -56,8 +60,9 @@ public class TriggerEnergy extends BCTrigger {
|
|||
@Override
|
||||
public boolean isTriggerActive(IGate gate, ITriggerParameter[] parameters) {
|
||||
if (gate.getPipe() instanceof IEnergyHandler) {
|
||||
if(isValidEnergyHandler((IEnergyHandler)gate.getPipe()))
|
||||
return isTriggeredEnergyHandler((IEnergyHandler)gate.getPipe());
|
||||
if (isValidEnergyHandler((IEnergyHandler) gate.getPipe())) {
|
||||
return isTriggeredEnergyHandler((IEnergyHandler) gate.getPipe());
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
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,
|
||||
// we can skip the isValidEnergyHandler(...) check.
|
||||
return isTriggeredEnergyHandler((IEnergyHandler)tile);
|
||||
return isTriggeredEnergyHandler((IEnergyHandler) tile);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.TreeMap;
|
|||
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.core.BlockIndex;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.core.LaserData;
|
||||
|
@ -63,7 +64,7 @@ public class TileEnergyEmitter extends TileBuildCraft {
|
|||
|
||||
if (t.data.wavePosition > t.data.renderSize) {
|
||||
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) {
|
||||
t.data.waveSize = 1F;
|
||||
|
@ -123,7 +124,8 @@ public class TileEnergyEmitter extends TileBuildCraft {
|
|||
}
|
||||
}
|
||||
} 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()) {
|
||||
if (!t.data.isVisible) {
|
||||
|
|
|
@ -10,9 +10,12 @@ package buildcraft.energy;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
@ -71,7 +74,7 @@ public class TileEnergyReceiver extends TileBuildCraft implements IPipeConnectio
|
|||
energyStored = 0;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,16 @@ package buildcraft.energy;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
|
@ -34,9 +37,8 @@ import buildcraft.core.TileBuffer;
|
|||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.energy.gui.ContainerEngine;
|
||||
|
||||
public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, IOverrideDefaultTriggers, IPipeConnection, IEnergyHandler {
|
||||
protected boolean constantPower = false;
|
||||
|
||||
public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter,
|
||||
IOverrideDefaultTriggers, IPipeConnection, IEnergyHandler {
|
||||
// Index corresponds to metadata
|
||||
public static final ResourceLocation[] BASE_TEXTURES = new ResourceLocation[]{
|
||||
new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"),
|
||||
|
@ -84,6 +86,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
@NetworkData
|
||||
public ForgeDirection orientation = ForgeDirection.UP;
|
||||
|
||||
protected boolean constantPower = false;
|
||||
protected int progressPart = 0;
|
||||
protected boolean lastPower = false;
|
||||
protected PowerHandler powerHandler;
|
||||
|
@ -239,8 +242,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
|
||||
if (progress > 0.5 && progressPart == 1) {
|
||||
progressPart = 2;
|
||||
if(!constantPower)
|
||||
if (!constantPower) {
|
||||
sendPower();
|
||||
}
|
||||
} else if (progress >= 1) {
|
||||
progress = 0;
|
||||
progressPart = 0;
|
||||
|
@ -263,10 +267,12 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
}
|
||||
|
||||
// Uncomment for constant power
|
||||
if(constantPower) {
|
||||
if (constantPower) {
|
||||
if (isRedstonePowered && isActive()) {
|
||||
sendPower();
|
||||
} else currentOutput = 0;
|
||||
} else {
|
||||
currentOutput = 0;
|
||||
}
|
||||
}
|
||||
|
||||
burn();
|
||||
|
@ -275,14 +281,14 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
private double getPowerToExtract() {
|
||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||
|
||||
if(tile instanceof IEnergyHandler) {
|
||||
IEnergyHandler handler = ((IEnergyHandler)tile);
|
||||
if (tile instanceof IEnergyHandler) {
|
||||
IEnergyHandler handler = (IEnergyHandler) tile;
|
||||
|
||||
int minEnergy = 0;
|
||||
int maxEnergy = handler.receiveEnergy(
|
||||
orientation.getOpposite(),
|
||||
(int)Math.round(this.energy * 10), true);
|
||||
return extractEnergy((double)minEnergy / 10.0, (double)maxEnergy / 10.0, false);
|
||||
(int) Math.round(this.energy * 10), true);
|
||||
return extractEnergy(minEnergy / 10.0, maxEnergy / 10.0, false);
|
||||
} else if (tile instanceof IPowerReceptor) {
|
||||
PowerReceiver receptor = ((IPowerReceptor) tile)
|
||||
.getPowerReceiver(orientation.getOpposite());
|
||||
|
@ -298,17 +304,20 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||
if (isPoweredTile(tile, orientation)) {
|
||||
double extracted = getPowerToExtract();
|
||||
if(extracted > 0) setPumping(true);
|
||||
else setPumping(false);
|
||||
if (extracted > 0) {
|
||||
setPumping(true);
|
||||
} else {
|
||||
setPumping(false);
|
||||
}
|
||||
|
||||
if (tile instanceof IEnergyHandler) {
|
||||
IEnergyHandler handler = ((IEnergyHandler) tile);
|
||||
IEnergyHandler handler = (IEnergyHandler) tile;
|
||||
if (Math.round(extracted * 10) > 0) {
|
||||
int neededRF = handler.receiveEnergy(
|
||||
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) {
|
||||
PowerReceiver receptor = ((IPowerReceptor) tile)
|
||||
|
@ -377,10 +386,13 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
TileEntity tile = getTileBuffer(o).getTile();
|
||||
|
||||
if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) {
|
||||
if((tile instanceof IPipeTile) && (((IPipeTile)tile).getPipeType() != PipeType.POWER))
|
||||
constantPower = false;
|
||||
else if(tile instanceof IEnergyHandler) constantPower = true;
|
||||
else constantPower = false;
|
||||
if ((tile instanceof IPipeTile) && (((IPipeTile) tile).getPipeType() != PipeType.POWER)) {
|
||||
constantPower = false;
|
||||
} else if (tile instanceof IEnergyHandler) {
|
||||
constantPower = true;
|
||||
} else {
|
||||
constantPower = false;
|
||||
}
|
||||
|
||||
orientation = o;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
@ -423,8 +435,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
progress = data.getFloat("progress");
|
||||
energy = data.getDouble("energy");
|
||||
heat = data.getFloat("heat");
|
||||
if(data.hasKey("constantPower"))
|
||||
if (data.hasKey("constantPower")) {
|
||||
constantPower = data.getBoolean("constantPower");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -537,7 +550,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
return false;
|
||||
} else if (tile instanceof IPowerReceptor) {
|
||||
return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null;
|
||||
} else if (tile instanceof IEnergyHandler){
|
||||
} else if (tile instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler) tile).canConnectEnergy(side.getOpposite());
|
||||
} else {
|
||||
return false;
|
||||
|
@ -620,9 +633,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
|
||||
@Override
|
||||
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
|
||||
|
|
|
@ -173,7 +173,11 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
return;
|
||||
}
|
||||
}
|
||||
if(!this.constantPower) currentOutput = currentFuel.powerPerCycle;
|
||||
|
||||
if (!this.constantPower) {
|
||||
currentOutput = currentFuel.powerPerCycle;
|
||||
}
|
||||
|
||||
addEnergy(currentFuel.powerPerCycle);
|
||||
heat += currentFuel.powerPerCycle * HEAT_PER_MJ * getBiomeTempScalar();
|
||||
}
|
||||
|
|
|
@ -77,7 +77,11 @@ public class TileEngineStone extends TileEngineWithInventory {
|
|||
burnTime--;
|
||||
|
||||
double output = getCurrentOutput();
|
||||
if(!constantPower) currentOutput = output; // Comment out for constant power
|
||||
|
||||
if (!constantPower) {
|
||||
currentOutput = output; // Comment out for constant power
|
||||
}
|
||||
|
||||
addEnergy(output);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@ package buildcraft.energy;
|
|||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
@ -121,9 +123,10 @@ public class TileEngineWood extends TileEngine {
|
|||
@Override
|
||||
protected void sendPower() {
|
||||
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();
|
||||
else // pretend we're sending out our powers
|
||||
} else { // pretend we're sending out our powers
|
||||
this.energy = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.core.CoreIconProvider;
|
||||
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.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.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.drawString(String.format("%.2f \u00B0C", engine.getHeat()), x + 22, y + 80, textColour);
|
||||
|
||||
|
@ -62,7 +65,7 @@ public abstract class GuiEngine extends GuiBuildCraft {
|
|||
|
||||
@Override
|
||||
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.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftFactory;
|
||||
import buildcraft.api.gates.IAction;
|
||||
|
@ -43,7 +45,8 @@ public class TileMiningWell extends TileBuildCraft implements IMachine {
|
|||
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) {
|
||||
return;
|
||||
|
|
|
@ -176,7 +176,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
|||
} else if (stage == Stage.IDLE) {
|
||||
dig();
|
||||
} 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)) {
|
||||
speed = 0.1 + energyToUse / 200F;
|
||||
|
@ -192,7 +192,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
|||
}
|
||||
|
||||
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)) {
|
||||
return;
|
||||
|
|
|
@ -12,10 +12,13 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
|
@ -102,7 +105,7 @@ public class PipeTransportPower extends PipeTransport {
|
|||
}
|
||||
|
||||
if (tile instanceof IEnergyHandler) {
|
||||
IEnergyHandler handler = (IEnergyHandler)tile;
|
||||
IEnergyHandler handler = (IEnergyHandler) tile;
|
||||
if (handler != null && handler.canConnectEnergy(side.getOpposite())) {
|
||||
return true;
|
||||
}
|
||||
|
@ -165,7 +168,7 @@ public class PipeTransportPower extends PipeTransport {
|
|||
// Send the power to nearby pipes who requested it
|
||||
|
||||
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
|
||||
// amount of power queried
|
||||
|
@ -194,7 +197,8 @@ public class PipeTransportPower extends PipeTransport {
|
|||
externalPower[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;
|
||||
|
||||
if (tiles[out] instanceof TileGenericPipe) {
|
||||
|
@ -207,7 +211,7 @@ public class PipeTransportPower extends PipeTransport {
|
|||
powerConsumed);
|
||||
tilePowered = true;
|
||||
} else if (tiles[out] instanceof IEnergyHandler) {
|
||||
IEnergyHandler handler = (IEnergyHandler)tiles[out];
|
||||
IEnergyHandler handler = (IEnergyHandler) tiles[out];
|
||||
|
||||
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[out].getOpposite())) {
|
||||
// Transmit power to an RF energy handler
|
||||
|
@ -222,7 +226,7 @@ public class PipeTransportPower extends PipeTransport {
|
|||
if (prov != null) {
|
||||
// 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);
|
||||
tilePowered = true;
|
||||
}
|
||||
|
@ -243,7 +247,7 @@ public class PipeTransportPower extends PipeTransport {
|
|||
|
||||
if (totalPowerConsumed > 0) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +256,7 @@ public class PipeTransportPower extends PipeTransport {
|
|||
|
||||
highestPower = 0;
|
||||
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) {
|
||||
highestPower = displayPower[i];
|
||||
|
@ -276,8 +280,8 @@ public class PipeTransportPower extends PipeTransport {
|
|||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
TileEntity tile = tiles [dir.ordinal()];
|
||||
if (tile instanceof IEnergyHandler) {
|
||||
IEnergyHandler handler = (IEnergyHandler)tile;
|
||||
if(handler.canConnectEnergy(dir.getOpposite())) {
|
||||
IEnergyHandler handler = (IEnergyHandler) tile;
|
||||
if (handler.canConnectEnergy(dir.getOpposite())) {
|
||||
int request = handler.receiveEnergy(dir.getOpposite(), this.maxPower, true);
|
||||
|
||||
if (request > 0) {
|
||||
|
@ -287,7 +291,7 @@ public class PipeTransportPower extends PipeTransport {
|
|||
} else if (!(tile instanceof TileGenericPipe && ((TileGenericPipe) tile).pipe.transport instanceof PipeTransportPower)) {
|
||||
PowerReceiver prov = getReceiverOnSide(dir);
|
||||
if (prov != null) {
|
||||
int request = (int)Math.floor(prov.powerRequest() * 10);
|
||||
int request = (int) Math.floor(prov.powerRequest() * 10);
|
||||
|
||||
if (request > 0) {
|
||||
requestEnergy(dir, request);
|
||||
|
|
|
@ -10,10 +10,13 @@ package buildcraft.transport;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
|
@ -63,7 +66,7 @@ public class PipeTriggerProvider implements ITriggerProvider {
|
|||
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.triggerEnergyLow);
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ import java.util.LinkedList;
|
|||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
@ -24,14 +24,19 @@ import net.minecraft.network.Packet;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
@ -1114,38 +1119,48 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
if(pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler)pipe).canConnectEnergy(from);
|
||||
} else return false;
|
||||
if (pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler) pipe).canConnectEnergy(from);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
||||
boolean simulate) {
|
||||
if(pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler)pipe).receiveEnergy(from, maxReceive, simulate);
|
||||
} else return 0;
|
||||
if (pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler) pipe).receiveEnergy(from, maxReceive, simulate);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract,
|
||||
boolean simulate) {
|
||||
if(pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler)pipe).extractEnergy(from, maxExtract, simulate);
|
||||
} else return 0;
|
||||
if (pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler) pipe).extractEnergy(from, maxExtract, simulate);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
if(pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler)pipe).getEnergyStored(from);
|
||||
} else return 0;
|
||||
if (pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler) pipe).getEnergyStored(from);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
if(pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler)pipe).getMaxEnergyStored(from);
|
||||
} else return 0;
|
||||
if (pipe instanceof IEnergyHandler) {
|
||||
return ((IEnergyHandler) pipe).getMaxEnergyStored(from);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,13 @@ package buildcraft.transport.gates;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.gates.GateExpansionController;
|
||||
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
|
||||
// removed. The add energy algorithm probably needs to be
|
||||
// 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;
|
||||
} else {
|
||||
gate.setPulsing(true);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
package buildcraft.transport.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import buildcraft.core.network.PacketCoordinates;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.transport.render.PipeRendererTESR;
|
||||
|
@ -40,7 +41,8 @@ public class PacketPowerUpdate extends PacketCoordinates {
|
|||
super.writeData(data);
|
||||
data.writeBoolean(overload);
|
||||
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;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
|
|
|
@ -11,7 +11,6 @@ package buildcraft.transport.pipes;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityMinecartChest;
|
||||
|
@ -20,9 +19,14 @@ import net.minecraft.init.Items;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
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);
|
||||
|
||||
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?
|
||||
|
||||
|
@ -222,7 +226,7 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IEner
|
|||
stack = contained;
|
||||
CoreProxy.proxy.removeEntity(entity);
|
||||
} 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);
|
||||
|
|
|
@ -10,7 +10,6 @@ package buildcraft.transport.pipes;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -24,7 +23,11 @@ import net.minecraft.item.ItemPotion;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.Position;
|
||||
|
@ -238,8 +241,11 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnerg
|
|||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
||||
boolean simulate) {
|
||||
if(maxReceive == 0) return 0;
|
||||
else if(simulate) return 10;
|
||||
if (maxReceive == 0) {
|
||||
return 0;
|
||||
} else if (simulate) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
ForgeDirection o = getOpenOrientation();
|
||||
|
||||
|
|
|
@ -8,16 +8,20 @@
|
|||
*/
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.Position;
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
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.api.core.IIconProvider;
|
||||
import buildcraft.core.RFBattery;
|
||||
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 {
|
||||
|
||||
|
|
|
@ -8,13 +8,17 @@
|
|||
*/
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
|
@ -131,8 +135,9 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
|||
|
||||
TileEntity tile = container.getTile(o);
|
||||
|
||||
if(tile instanceof IEnergyHandler) {
|
||||
battery.addEnergy(0, ((IEnergyHandler)tile).extractEnergy(o.getOpposite(), energyToRemove, false), false);
|
||||
if (tile instanceof IEnergyHandler) {
|
||||
battery.addEnergy(0, ((IEnergyHandler) tile).extractEnergy(o.getOpposite(), energyToRemove, false),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,10 +210,8 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
|
|||
public boolean isPowerSource(TileEntity tile, ForgeDirection from) {
|
||||
if (tile instanceof IPowerEmitter && ((IPowerEmitter) tile).canEmitPowerFrom(from.getOpposite())) {
|
||||
return true;
|
||||
} else if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).canConnectEnergy(from.getOpposite())) {
|
||||
return true;
|
||||
} 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
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/>
|
||||
</module>
|
||||
<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 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"/>
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue