fixed style

This commit is contained in:
SpaceToad 2014-09-04 20:55:50 +02:00
parent ccaeffe763
commit 9f71fdfe0e
33 changed files with 393 additions and 230 deletions

View file

@ -8,6 +8,7 @@
*/
package buildcraft.api.power;
@Deprecated
public interface ILaserTarget {
/**

View file

@ -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);
}

View file

@ -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();
}

View file

@ -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) {

View file

@ -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;
import cpw.mods.fml.common.API;

View file

@ -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;

View file

@ -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;
@ -71,7 +72,7 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil
super.updateEntity();
RFBattery battery = this.getBattery();
if (rfPrev != battery.getEnergyStored()) {
rfPrev = battery.getEnergyStored();
rfUnchangedCycles = 0;
@ -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
@ -144,11 +146,11 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
rfPrev = getBattery().getEnergyStored();
rfUnchangedCycles = 0;
}
@Override
public double getMaxRenderDistanceSquared() {
return Double.MAX_VALUE;

View file

@ -1,27 +1,30 @@
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;
public RFBattery(int maxEnergy, int maxReceive, int maxExtract) {
this.maxEnergy = maxEnergy;
this.maxReceive = maxReceive;
this.maxExtract = maxExtract;
}
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");
this.maxEnergy = battery.getInteger("maxEnergy");
this.maxReceive = battery.getInteger("maxReceive");
this.maxExtract = battery.getInteger("maxExtract");
}
public void writeToNBT(NBTTagCompound tag) {
NBTTagCompound battery = new NBTTagCompound();
battery.setInteger("energy", this.energy);
@ -29,21 +32,35 @@ public class RFBattery implements IEnergyStorage {
battery.setInteger("maxReceive", this.maxReceive);
battery.setInteger("maxExtract", this.maxExtract);
}
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;
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
return addEnergy(0, Math.min(maxReceive, this.maxReceive), simulate);
@ -63,18 +80,18 @@ public class RFBattery implements IEnergyStorage {
public int getMaxEnergyStored() {
return maxEnergy;
}
public int getMaxEnergyReceive() {
return maxReceive;
}
public int getMaxEnergyExtract() {
return maxExtract;
}
public void setEnergy(int energy) {
this.energy = energy;
public void setEnergy(int iEnergy) {
energy = iEnergy;
if (energy < 0) {
energy = 0;
} else if (energy > maxEnergy) {

View file

@ -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;
@ -41,7 +44,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
private boolean init = false;
private String owner = "[BuildCraft]";
private RFBattery battery;
public TileBuildCraft() {
if (!updateWrappers.containsKey(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());
descriptionPacket = descriptionWrappers.get(this.getClass());
}
public String getOwner() {
return owner;
}
@ -160,41 +163,54 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
public boolean equals(Object cmp) {
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() {
return battery;
}
protected void setBattery(RFBattery battery) {
this.battery = battery;
}

View file

@ -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;
@ -61,8 +64,8 @@ public class DefaultTriggerProvider implements ITriggerProvider {
res.add(BuildCraftCore.triggerMachineActive);
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);
}

View file

@ -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;
@ -39,11 +43,11 @@ public class TriggerEnergy extends BCTrigger {
private boolean isValidEnergyHandler(IEnergyHandler handler) {
return handler.getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0;
}
private boolean isTriggeredEnergyHandler(IEnergyHandler handler) {
int energyStored = handler.getEnergyStored(ForgeDirection.UNKNOWN);
int energyMaxStored = handler.getMaxEnergyStored(ForgeDirection.UNKNOWN);
if (energyMaxStored > 0) {
if (high) {
return (energyStored / energyMaxStored) > 0.95;
@ -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;

View file

@ -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) {

View file

@ -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;
}
}

View file

@ -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,26 +267,28 @@ 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();
}
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);
extractEnergy(0.0, (double)neededRF / 10.0, true);
(int) Math.round(extracted * 10), false);
extractEnergy(0.0, neededRF / 10.0, true);
}
} else if (tile instanceof IPowerReceptor) {
PowerReceiver receptor = ((IPowerReceptor) tile)
@ -377,11 +386,14 @@ 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);
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");
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;
@ -593,7 +606,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
public void checkRedstonePower() {
isRedstonePowered = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
}
// RF support
@Override
@ -606,9 +619,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
public int extractEnergy(ForgeDirection from, int maxExtract,
boolean simulate) {
return 0;
/*if(!(from == orientation)) return 0;
int energyRF = (int)Math.round(10 * energy);
int energyExtracted = Math.min(maxExtract, energyRF);
if(!simulate) {
@ -620,9 +633,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
@Override
public int getEnergyStored(ForgeDirection from) {
if(!(from == orientation)) return 0;
return (int)Math.round(10 * energy);
if (!(from == orientation)) {
return 0;
}
return (int) Math.round(10 * energy);
}
@Override

View file

@ -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();
}

View file

@ -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);
}

View file

@ -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;
@ -96,7 +98,7 @@ public class TileEngineWood extends TileEngine {
public boolean isBurning() {
return isRedstonePowered;
}
@Override
public double getMaxEnergy() {
return 100;
@ -111,19 +113,20 @@ public class TileEngineWood extends TileEngine {
public double maxEnergyExtracted() {
return 1 + PowerHandler.PerditionCalculator.MIN_POWERLOSS;
}
// TODO: HACK
@Override
public boolean canConnectEnergy(ForgeDirection from) {
return false;
}
@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;
}
}
}

View file

@ -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));
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
@ -100,9 +103,9 @@ public class PipeTransportPower extends PipeTransport {
return true;
}
}
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,11 +211,11 @@ 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
powerConsumed = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[out].getOpposite(),
powerConsumed, false);
tilePowered = true;
@ -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,10 +280,10 @@ 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) {
requestEnergy(dir, request);
}
@ -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);
@ -297,7 +301,7 @@ public class PipeTransportPower extends PipeTransport {
}
// Sum the amount of energy requested on each side
int[] transferQuery = new int[6];
for (int i = 0; i < 6; ++i) {
@ -519,7 +523,7 @@ public class PipeTransportPower extends PipeTransport {
public int consumePower(ForgeDirection dir, int max) {
int result;
if (externalPower[dir.ordinal()] < max) {
result = externalPower[dir.ordinal()];
} else {

View file

@ -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);
}

View file

@ -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;
@ -1111,41 +1116,51 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
((IPowerReceptor) pipe).doWork(workProvider);
}
}
@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;
}
}
}

View file

@ -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);

View file

@ -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;
@ -26,7 +27,7 @@ public class PacketPowerUpdate extends PacketCoordinates {
}
@Override
public void readData(ByteBuf data) {
public void readData(ByteBuf data) {
super.readData(data);
displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
overload = data.readBoolean();
@ -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)));
}
}
}

View file

@ -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;

View file

@ -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);

View file

@ -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,9 +241,12 @@ 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();
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);
}
}
return maxReceive;
}

View file

@ -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;

View file

@ -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 {

View file

@ -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;
@ -41,12 +45,12 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
private boolean full;
private int requestedEnergy, sources;
private PowerHandler powerHandler;
public PipePowerWood(Item item) {
super(new PipeTransportPower(), item);
battery = new RFBattery(320 * 50, 320, 0);
powerHandler = new PowerHandler(this, Type.PIPE);
powerHandler.configure(0, 500, 1, 1500);
powerHandler.setPerdition(new PerditionCalculator(PerditionCalculator.MIN_POWERLOSS));
@ -86,7 +90,7 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
sources++;
}
}
if (container.getWorldObj().isRemote) {
// We only do the isRemote check now to get a list
// 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.
// That way, we can replicate BC behaviour more accurately,
// but we still need to see how well that works with constant power.
/* if (mjStored > 40) {
energyToRemove = mjStored / 40 + 4;
} else if (mjStored > 10) {
@ -117,9 +121,9 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
} else {
energyToRemove = 1;
} */
energyToRemove /= sources;
// Extract power from RF sources.
// While we send power to receivers and so does TE4,
// Extra Utilities generators (as an example) depend
@ -128,26 +132,27 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerRec
if (!powerSources[o.ordinal()]) {
continue;
}
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);
}
}
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
if (!powerSources[o.ordinal()]) {
continue;
}
int energyUsable = Math.min(battery.getEnergyStored(), energyToRemove);
if (energyUsable > 0) {
battery.setEnergy(battery.getEnergyStored() - transport.receiveEnergy(o, energyUsable));
}
}
requestedEnergy = 0;
}
@ -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);
}

View file

@ -8,7 +8,7 @@
Checkstyle-Configuration: BuildCraft
Description: none
-->
<module name="Checker">
<module name="Checker">
<property name="severity" value="error"/>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
@ -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