Merge branch 'master' of github.com:BuildCraft/BuildCraft
This commit is contained in:
commit
01c4767727
20 changed files with 201 additions and 83 deletions
README.mdbuild.xml
buildcraft_resources
lang/buildcraft
mods/buildcraft/textures/items/triggers
common/buildcraft
|
@ -13,7 +13,8 @@ a problem that might have fixed been already. Such things makes for very grumpy
|
|||
less time coding and more time doing stuff that makes them less grumpy.
|
||||
|
||||
#### Frequently reported
|
||||
java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue
|
||||
* java.lang.AbstractMethodError - Incompatibility between BC/Forge/Mod using BC API. Usually not a BC issue
|
||||
* Render issue (Quarry causes flickering) - Try without optifine, if it still flickers, report it
|
||||
|
||||
### Compiling and packaging Buildcraft
|
||||
1. Ensure that `Apache Ant` (found [here](http://ant.apache.org/)) and `Git` (found [here](http://git-scm.com/)) are installed correctly on your system.
|
||||
|
|
14
build.xml
14
build.xml
|
@ -143,8 +143,10 @@
|
|||
|
||||
<target name="compile" depends="initialize-version,setup,copy-src">
|
||||
|
||||
<delete dir="${classes.dir}"/>
|
||||
<mkdir dir="${classes.dir}"/>
|
||||
<delete includeemptydirs="true">
|
||||
<fileset dir="${classes.dir}" includes="**/*"/>
|
||||
</delete>
|
||||
|
||||
<!-- Recompile -->
|
||||
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
|
||||
|
@ -202,9 +204,15 @@
|
|||
<!-- Package the compiled files -->
|
||||
<target name="package" depends="reobf">
|
||||
|
||||
<delete dir="${jar.dir}"/>
|
||||
<mkdir dir="${jar.dir}"/>
|
||||
<jar destfile="${jar.dir}/${buildcraft.name}-${mc.version}-${project.version.full}.jar" basedir="${classes.dir}"/>
|
||||
<delete includeemptydirs="true">
|
||||
<fileset dir="${jar.dir}" includes="**/*"/>
|
||||
</delete>
|
||||
<condition property="jar.file.name" value="${jar.dir}/${buildcraft.name}-${mc.version}-${project.version.full}.jar" else="${jar.dir}/${buildcraft.name}-universal-${mc.version}-${project.version.full}.jar">
|
||||
<isset property="forge-long-name"/>
|
||||
</condition>
|
||||
|
||||
<jar destfile="${jar.file.name}" basedir="${classes.dir}"/>
|
||||
<copy todir="${jar.dir}/changelog">
|
||||
<fileset dir="${resources.dir}/changelog">
|
||||
<include name="*" />
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# Master language file
|
||||
|
||||
gate.pipe.empty=Pipe Empty
|
||||
gate.pipe.containsItems=Items Traversing
|
||||
gate.pipe.containsLiquids=Liquid Traversing
|
||||
gate.pipe.containsEnergy=Power Traversing
|
||||
gate.pipe.requestsEnergy=Power Requested
|
||||
gate.pipe.tooMuchEnergy=Power Overloaded
|
||||
gui.building.resources=Building Resources
|
||||
gui.del=Del
|
||||
gui.filling.resources=Filling Resources
|
||||
|
|
Binary file not shown.
After ![]() (image error) Size: 250 B |
Binary file not shown.
After ![]() (image error) Size: 249 B |
|
@ -148,7 +148,9 @@ public class BuildCraftTransport {
|
|||
public static BCTrigger triggerPipeEmpty = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_EMPTY, Kind.Empty);
|
||||
public static BCTrigger triggerPipeItems = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_ITEMS, Kind.ContainsItems);
|
||||
public static BCTrigger triggerPipeLiquids = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_LIQUIDS, Kind.ContainsLiquids);
|
||||
public static BCTrigger triggerPipeEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_ENERGY, Kind.ContainsEnergy);
|
||||
public static BCTrigger triggerPipeContainsEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_CONTAINS_ENERGY, Kind.ContainsEnergy);
|
||||
public static BCTrigger triggerPipeRequestsEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_REQUESTS_ENERGY, Kind.RequestsEnergy);
|
||||
public static BCTrigger triggerPipeTooMuchEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_TOO_MUCH_ENERGY, Kind.TooMuchEnergy);
|
||||
public static BCTrigger triggerRedSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_ACTIVE, true, IPipe.WireColor.Red);
|
||||
public static BCTrigger triggerRedSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_INACTIVE, false, IPipe.WireColor.Red);
|
||||
public static BCTrigger triggerBlueSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_BLUE_SIGNAL_ACTIVE, true, IPipe.WireColor.Blue);
|
||||
|
|
|
@ -24,7 +24,7 @@ public abstract class PowerProvider implements IPowerProvider {
|
|||
protected float energyStored = 0;
|
||||
|
||||
protected int powerLoss = 1;
|
||||
protected int powerLossRegularity = 100;
|
||||
protected int powerLossRegularity = 1;
|
||||
|
||||
public SafeTimeTracker timeTracker = new SafeTimeTracker();
|
||||
public SafeTimeTracker energyLossTracker = new SafeTimeTracker();
|
||||
|
|
|
@ -139,7 +139,7 @@ public class DefaultProps {
|
|||
public static int TRIGGER_PIPE_EMPTY = 13;
|
||||
public static int TRIGGER_PIPE_ITEMS = 14;
|
||||
public static int TRIGGER_PIPE_LIQUIDS = 15;
|
||||
public static int TRIGGER_PIPE_ENERGY = 16;
|
||||
public static int TRIGGER_PIPE_CONTAINS_ENERGY = 16;
|
||||
public static int TRIGGER_RED_SIGNAL_ACTIVE = 17;
|
||||
public static int TRIGGER_RED_SIGNAL_INACTIVE = 18;
|
||||
public static int TRIGGER_BLUE_SIGNAL_ACTIVE = 19;
|
||||
|
@ -152,6 +152,8 @@ public class DefaultProps {
|
|||
public static int TRIGGER_GREEN_ENGINE_HEAT = 26;
|
||||
public static int TRIGGER_YELLOW_ENGINE_HEAT = 27;
|
||||
public static int TRIGGER_RED_ENGINE_HEAT = 28;
|
||||
public static int TRIGGER_PIPE_REQUESTS_ENERGY = 29;
|
||||
public static int TRIGGER_PIPE_TOO_MUCH_ENERGY = 30;
|
||||
|
||||
public static int ACTION_REDSTONE = 1;
|
||||
public static int ACTION_RED_SIGNAL = 2;
|
||||
|
|
|
@ -71,7 +71,7 @@ public class StackHelper {
|
|||
|
||||
/* ITEM COMPARISONS */
|
||||
/**
|
||||
* Determines whether the given itemstacks should be considered equivalent
|
||||
* Determines whether the given ItemStack should be considered equivalent
|
||||
* for crafting purposes.
|
||||
*
|
||||
* @param base The stack to compare to.
|
||||
|
@ -81,7 +81,7 @@ public class StackHelper {
|
|||
* base.
|
||||
*/
|
||||
public boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean oreDictionary) {
|
||||
if (isMatchingItem(base, comparison))
|
||||
if (isMatchingItem(base, comparison, true, false))
|
||||
return true;
|
||||
|
||||
if (oreDictionary) {
|
||||
|
@ -99,26 +99,54 @@ public class StackHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compares item id, damage and NBT. Accepts wildcard damage in the base
|
||||
* ItemStack. Ignores damage entirely if the item doesn't have subtypes.
|
||||
* Compares item id, damage and NBT. Accepts wildcard damage. Ignores damage
|
||||
* entirely if the item doesn't have subtypes.
|
||||
*
|
||||
* @param base The stack to compare to.
|
||||
* @param comparison The stack to compare.
|
||||
* @return true if id, damage and NBT match.
|
||||
*/
|
||||
public boolean isMatchingItem(ItemStack base, ItemStack comparison) {
|
||||
if (base == null || comparison == null)
|
||||
return false;
|
||||
return isMatchingItem(base, comparison, true, true);
|
||||
}
|
||||
|
||||
if (base.itemID != comparison.itemID)
|
||||
/**
|
||||
* Compares item id, and optionally damage and NBT. Accepts wildcard damage.
|
||||
* Ignores damage entirely if the item doesn't have subtypes.
|
||||
*
|
||||
* @param a ItemStack
|
||||
* @param b ItemStack
|
||||
* @param matchDamage
|
||||
* @param matchNBT
|
||||
* @return true if matches
|
||||
*/
|
||||
public static boolean isMatchingItem(final ItemStack a, final ItemStack b, final boolean matchDamage, final boolean matchNBT) {
|
||||
if (a == null || b == null) {
|
||||
return false;
|
||||
|
||||
if (base.getItem().getHasSubtypes()) {
|
||||
if (base.getItemDamage() != OreDictionary.WILDCARD_VALUE)
|
||||
if (base.getItemDamage() != comparison.getItemDamage())
|
||||
return false;
|
||||
}
|
||||
if (a.itemID != b.itemID) {
|
||||
return false;
|
||||
}
|
||||
if (matchDamage && a.getHasSubtypes()) {
|
||||
if (!isWildcard(a) && !isWildcard(b)) {
|
||||
if (a.getItemDamage() != b.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matchNBT) {
|
||||
if (a.stackTagCompound != null && !a.stackTagCompound.equals(b.stackTagCompound)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return ItemStack.areItemStackTagsEqual(base, comparison);
|
||||
public static boolean isWildcard(ItemStack stack) {
|
||||
return isWildcard(stack.getItemDamage());
|
||||
}
|
||||
|
||||
public static boolean isWildcard(int damage) {
|
||||
return damage == -1 || damage == OreDictionary.WILDCARD_VALUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,10 @@ public class ActionTriggerIconProvider implements IIconProvider {
|
|||
public static final int Trigger_PipeSignal_Yellow_Inactive = 28;
|
||||
public static final int Trigger_RedstoneInput_Active = 29;
|
||||
public static final int Trigger_RedstoneInput_Inactive = 30;
|
||||
public static final int Trigger_PipeContents_RequestsEnergy = 31;
|
||||
public static final int Trigger_PipeContents_TooMuchEnergy = 32;
|
||||
|
||||
public static final int MAX = 31;
|
||||
public static final int MAX = 33;
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
@ -80,6 +82,8 @@ public class ActionTriggerIconProvider implements IIconProvider {
|
|||
icons[ActionTriggerIconProvider.Trigger_PipeContents_ContainsItems] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_containsitems");
|
||||
icons[ActionTriggerIconProvider.Trigger_PipeContents_ContainsLiquid] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_containsliquid");
|
||||
icons[ActionTriggerIconProvider.Trigger_PipeContents_ContainsEnergy] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_containsenergy");
|
||||
icons[ActionTriggerIconProvider.Trigger_PipeContents_RequestsEnergy] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_requestsenergy");
|
||||
icons[ActionTriggerIconProvider.Trigger_PipeContents_TooMuchEnergy] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_toomuchenergy");
|
||||
icons[ActionTriggerIconProvider.Trigger_PipeSignal_Red_Active] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_red_active");
|
||||
icons[ActionTriggerIconProvider.Trigger_PipeSignal_Red_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_red_inactive");
|
||||
icons[ActionTriggerIconProvider.Trigger_PipeSignal_Blue_Active] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_blue_active");
|
||||
|
|
|
@ -62,6 +62,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
|
|||
|
||||
public TileEngine() {
|
||||
provider = PowerFramework.currentFramework.createPowerProvider();
|
||||
provider.configurePowerPerdition(1, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -63,7 +63,7 @@ public class BlockQuarry extends BlockMachineRoot {
|
|||
if (j == 0 && i == 3)
|
||||
return textureFront;
|
||||
|
||||
if (i == j)
|
||||
if (i == j && i>1) // Front can't be top or bottom.
|
||||
return textureFront;
|
||||
|
||||
switch (i) {
|
||||
|
|
|
@ -31,7 +31,7 @@ public class TileMiningWell extends TileMachine implements IMachine, IPowerRecep
|
|||
|
||||
public TileMiningWell() {
|
||||
powerProvider = PowerFramework.currentFramework.createPowerProvider();
|
||||
powerProvider.configure(50, 1, 25, 25, 1000);
|
||||
powerProvider.configure(50, 100, 100, 60, 1000);
|
||||
powerProvider.configurePowerPerdition(1, 1);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class TileMiningWell extends TileMachine implements IMachine, IPowerRecep
|
|||
*/
|
||||
@Override
|
||||
public void doWork() {
|
||||
if (powerProvider.useEnergy(25, 25, true) < 25)
|
||||
if (powerProvider.useEnergy(60, 60, true) != 60)
|
||||
return;
|
||||
|
||||
World world = worldObj;
|
||||
|
@ -52,7 +52,7 @@ public class TileMiningWell extends TileMachine implements IMachine, IPowerRecep
|
|||
depth = depth - 1;
|
||||
}
|
||||
|
||||
if (depth < 0 || !BlockUtil.canChangeBlock(world, xCoord, depth, zCoord)) {
|
||||
if (depth < 1 || !BlockUtil.canChangeBlock(world, xCoord, depth, zCoord)) {
|
||||
isDigging = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public class TilePump extends TileMachine implements IMachine, IPowerReceptor, I
|
|||
|
||||
private void initPowerProvider() {
|
||||
powerProvider.configure(20, 1, 8, 10, 100);
|
||||
powerProvider.configurePowerPerdition(1, 100);
|
||||
}
|
||||
|
||||
// TODO, manage this by different levels (pump what's above first...)
|
||||
|
|
|
@ -78,7 +78,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
|
|||
}
|
||||
|
||||
private void initPowerProvider() {
|
||||
powerProvider.configure(20, 25, 100, 25, MAX_ENERGY);
|
||||
powerProvider.configure(20, 50, 100, 25, MAX_ENERGY);
|
||||
powerProvider.configurePowerPerdition(2, 1);
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
|
|||
|
||||
protected void buildFrame() {
|
||||
|
||||
powerProvider.configure(20, 25, 100, 25, MAX_ENERGY);
|
||||
powerProvider.configure(20, 50, 100, 25, MAX_ENERGY);
|
||||
if (powerProvider.useEnergy(25, 25, true) != 25)
|
||||
return;
|
||||
|
||||
|
@ -211,7 +211,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
|
|||
}
|
||||
|
||||
protected void dig() {
|
||||
powerProvider.configure(20, 30, 500, 50, MAX_ENERGY);
|
||||
powerProvider.configure(20, 100, 500, 60, MAX_ENERGY);
|
||||
if (powerProvider.useEnergy(60, 60, true) != 60)
|
||||
return;
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ public class EnergyPulser {
|
|||
}
|
||||
|
||||
public void update() {
|
||||
if (!isActive && hasPulsed)
|
||||
hasPulsed = false;
|
||||
|
||||
if (powerReceptor == null || !isActive || tick++ % 10 != 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -140,14 +140,15 @@ public class PipeTransportPower extends PipeTransport {
|
|||
watts = nearbyTransport.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(), watts);
|
||||
internalPower[i] -= watts;
|
||||
} else if (tiles[j] instanceof IPowerReceptor) {
|
||||
watts = (internalPower[i] / totalPowerQuery * powerQuery[j]);
|
||||
IPowerReceptor pow = (IPowerReceptor) tiles[j];
|
||||
if (pow.powerRequest(ForgeDirection.VALID_DIRECTIONS[j].getOpposite()) > 0) {
|
||||
watts = (internalPower[i] / totalPowerQuery * powerQuery[j]);
|
||||
IPowerProvider prov = pow.getPowerProvider();
|
||||
|
||||
IPowerProvider prov = pow.getPowerProvider();
|
||||
|
||||
if (prov != null) {
|
||||
prov.receiveEnergy((float) watts, ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
|
||||
internalPower[i] -= watts;
|
||||
if (prov != null) {
|
||||
prov.receiveEnergy((float) watts, ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
|
||||
internalPower[i] -= watts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,12 +234,16 @@ public class PipeTransportPower extends PipeTransport {
|
|||
}
|
||||
|
||||
packet.displayPower = clientDisplayPower;
|
||||
packet.overload = overload >= OVERLOAD_TICKS;
|
||||
packet.overload = isOverloaded();
|
||||
CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isOverloaded() {
|
||||
return overload >= OVERLOAD_TICKS;
|
||||
}
|
||||
|
||||
public void step() {
|
||||
if (currentDate != worldObj.getWorldTime()) {
|
||||
currentDate = worldObj.getWorldTime();
|
||||
|
|
|
@ -9,6 +9,7 @@ import buildcraft.api.gates.IOverrideDefaultTriggers;
|
|||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.ITriggerProvider;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.transport.pipes.PipePowerWood;
|
||||
|
||||
public class PipeTriggerProvider implements ITriggerProvider {
|
||||
|
||||
|
@ -30,7 +31,11 @@ public class PipeTriggerProvider implements ITriggerProvider {
|
|||
result.add(BuildCraftTransport.triggerPipeItems);
|
||||
} else if (pipe.transport instanceof PipeTransportPower) {
|
||||
result.add(BuildCraftTransport.triggerPipeEmpty);
|
||||
result.add(BuildCraftTransport.triggerPipeEnergy);
|
||||
result.add(BuildCraftTransport.triggerPipeContainsEnergy);
|
||||
result.add(BuildCraftTransport.triggerPipeTooMuchEnergy);
|
||||
if (pipe instanceof PipePowerWood) {
|
||||
result.add(BuildCraftTransport.triggerPipeRequestsEnergy);
|
||||
}
|
||||
} else if (pipe.transport instanceof PipeTransportLiquids) {
|
||||
result.add(BuildCraftTransport.triggerPipeEmpty);
|
||||
result.add(BuildCraftTransport.triggerPipeLiquids);
|
||||
|
@ -43,5 +48,4 @@ public class PipeTriggerProvider implements ITriggerProvider {
|
|||
public LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity tile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,26 +13,35 @@ import buildcraft.api.core.IIconProvider;
|
|||
import buildcraft.api.power.IPowerProvider;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerFramework;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportPower;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PipePowerWood extends Pipe implements IPowerReceptor {
|
||||
|
||||
private IPowerProvider powerProvider;
|
||||
protected int standardIconIndex = PipeIconProvider.PipePowerWood_Standard;
|
||||
protected int solidIconIndex = PipeIconProvider.PipeAllWood_Solid;
|
||||
private int[] powerSources = new int[6];
|
||||
private boolean[] powerSources = new boolean[6];
|
||||
private boolean full;
|
||||
|
||||
public PipePowerWood(int itemID) {
|
||||
super(new PipeTransportPower(), new PipeLogicWood(), itemID);
|
||||
|
||||
powerProvider = PowerFramework.currentFramework.createPowerProvider();
|
||||
initPowerProvider();
|
||||
((PipeTransportPower) transport).initFromPipe(getClass());
|
||||
}
|
||||
|
||||
private void initPowerProvider() {
|
||||
powerProvider.configure(50, 2, 1000, 1, 1500);
|
||||
powerProvider.configurePowerPerdition(1, 10);
|
||||
((PipeTransportPower) transport).initFromPipe(getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,26 +85,26 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
if (worldObj.isRemote)
|
||||
return;
|
||||
|
||||
if (powerProvider.getEnergyStored() <= 0)
|
||||
return;
|
||||
|
||||
int sources = 0;
|
||||
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (!container.isPipeConnected(o)) {
|
||||
powerSources[o.ordinal()] = 0;
|
||||
powerSources[o.ordinal()] = false;
|
||||
continue;
|
||||
}
|
||||
if (powerSources[o.ordinal()] > 0) {
|
||||
powerSources[o.ordinal()]--;
|
||||
}
|
||||
if (powerProvider.isPowerSource(o)) {
|
||||
powerSources[o.ordinal()] = 40;
|
||||
powerSources[o.ordinal()] = true;
|
||||
}
|
||||
if (powerSources[o.ordinal()] > 0) {
|
||||
if (powerSources[o.ordinal()]) {
|
||||
sources++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sources <= 0)
|
||||
return;
|
||||
|
||||
|
||||
float energyToRemove;
|
||||
|
||||
if (powerProvider.getEnergyStored() > 40) {
|
||||
|
@ -110,7 +119,7 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
PipeTransportPower trans = (PipeTransportPower) transport;
|
||||
|
||||
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (powerSources[o.ordinal()] <= 0)
|
||||
if (!powerSources[o.ordinal()])
|
||||
continue;
|
||||
|
||||
float energyUsable = powerProvider.useEnergy(1, energyToRemove, false);
|
||||
|
@ -122,8 +131,33 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean requestsPower() {
|
||||
if (full) {
|
||||
boolean request = powerProvider.getEnergyStored() < powerProvider.getMaxEnergyStored() / 2;
|
||||
if (request) {
|
||||
full = false;
|
||||
}
|
||||
return request;
|
||||
}
|
||||
full = powerProvider.getEnergyStored() >= powerProvider.getMaxEnergyStored() - 10;
|
||||
return !full;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int powerRequest(ForgeDirection from) {
|
||||
return getPowerProvider().getMaxEnergyReceived();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
powerProvider.writeToNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
PowerFramework.currentFramework.loadPowerProvider(this, data);
|
||||
initPowerProvider();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.triggers;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -16,19 +14,21 @@ import net.minecraftforge.liquids.LiquidStack;
|
|||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.core.triggers.ActionTriggerIconProvider;
|
||||
import buildcraft.core.triggers.BCTrigger;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.EntityData;
|
||||
import buildcraft.transport.ITriggerPipe;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.PipeTransportLiquids;
|
||||
import buildcraft.transport.PipeTransportPower;
|
||||
import buildcraft.transport.pipes.PipePowerWood;
|
||||
|
||||
public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
|
||||
|
||||
public enum Kind {
|
||||
Empty, ContainsItems, ContainsLiquids, ContainsEnergy
|
||||
};
|
||||
|
||||
Empty, ContainsItems, ContainsLiquids, ContainsEnergy, RequestsEnergy, TooMuchEnergy
|
||||
};
|
||||
Kind kind;
|
||||
|
||||
public TriggerPipeContents(int id, Kind kind) {
|
||||
|
@ -39,11 +39,11 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
|
|||
@Override
|
||||
public boolean hasParameter() {
|
||||
switch (kind) {
|
||||
case ContainsItems:
|
||||
case ContainsLiquids:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case ContainsItems:
|
||||
case ContainsLiquids:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,18 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
|
|||
public String getDescription() {
|
||||
|
||||
switch (kind) {
|
||||
case Empty:
|
||||
return "Pipe Empty";
|
||||
case ContainsItems:
|
||||
return "Items Traversing";
|
||||
case ContainsLiquids:
|
||||
return "Liquid Traversing";
|
||||
case ContainsEnergy:
|
||||
return "Power Traversing";
|
||||
case Empty:
|
||||
return StringUtils.localize("gate.pipe.empty");
|
||||
case ContainsItems:
|
||||
return StringUtils.localize("gate.pipe.containsItems");
|
||||
case ContainsLiquids:
|
||||
return StringUtils.localize("gate.pipe.containsLiquids");
|
||||
case ContainsEnergy:
|
||||
return StringUtils.localize("gate.pipe.containsEnergy");
|
||||
case RequestsEnergy:
|
||||
return StringUtils.localize("gate.pipe.requestsEnergy");
|
||||
case TooMuchEnergy:
|
||||
return StringUtils.localize("gate.pipe.tooMuchEnergy");
|
||||
}
|
||||
|
||||
return "";
|
||||
|
@ -73,10 +77,11 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
|
|||
return transportItems.travelingEntities.isEmpty();
|
||||
else if (kind == Kind.ContainsItems)
|
||||
if (parameter != null && parameter.getItem() != null) {
|
||||
for (EntityData data : transportItems.travelingEntities.values())
|
||||
for (EntityData data : transportItems.travelingEntities.values()) {
|
||||
if (data.item.getItemStack().itemID == parameter.getItem().itemID
|
||||
&& data.item.getItemStack().getItemDamage() == parameter.getItem().getItemDamage())
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
return !transportItems.travelingEntities.isEmpty();
|
||||
} else if (pipe.transport instanceof PipeTransportLiquids) {
|
||||
|
@ -89,34 +94,44 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
|
|||
}
|
||||
|
||||
if (kind == Kind.Empty) {
|
||||
for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN))
|
||||
for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN)) {
|
||||
if (b.getLiquid() != null && b.getLiquid().amount != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN))
|
||||
for (ILiquidTank b : transportLiquids.getTanks(ForgeDirection.UNKNOWN)) {
|
||||
if (b.getLiquid() != null && b.getLiquid().amount != 0)
|
||||
if (searchedLiquid == null || searchedLiquid.isLiquidEqual(b.getLiquid()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} else if (pipe.transport instanceof PipeTransportPower) {
|
||||
PipeTransportPower transportPower = (PipeTransportPower) pipe.transport;
|
||||
|
||||
if (kind == Kind.Empty) {
|
||||
for (double s : transportPower.displayPower)
|
||||
if (s > 0)
|
||||
return false;
|
||||
switch (kind) {
|
||||
case Empty:
|
||||
for (double s : transportPower.displayPower) {
|
||||
if (s > 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
for (double s : transportPower.displayPower)
|
||||
if (s > 0)
|
||||
return true;
|
||||
return true;
|
||||
case ContainsEnergy:
|
||||
for (double s : transportPower.displayPower) {
|
||||
if (s > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
case RequestsEnergy:
|
||||
PipePowerWood wood = (PipePowerWood) pipe;
|
||||
return wood.requestsPower();
|
||||
case TooMuchEnergy:
|
||||
return transportPower.isOverloaded();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,9 +148,13 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
|
|||
case ContainsLiquids:
|
||||
return ActionTriggerIconProvider.Trigger_PipeContents_ContainsLiquid;
|
||||
case ContainsEnergy:
|
||||
default:
|
||||
return ActionTriggerIconProvider.Trigger_PipeContents_ContainsEnergy;
|
||||
|
||||
case RequestsEnergy:
|
||||
return ActionTriggerIconProvider.Trigger_PipeContents_RequestsEnergy;
|
||||
case TooMuchEnergy:
|
||||
default:
|
||||
return ActionTriggerIconProvider.Trigger_PipeContents_TooMuchEnergy;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue