Merge Power into Builder
This commit is contained in:
commit
c3d1df0c4e
46 changed files with 1279 additions and 601 deletions
BIN
buildcraft_resources/gfx/buildcraft/gui/filteredBuffer_gui.png
Normal file
BIN
buildcraft_resources/gfx/buildcraft/gui/filteredBuffer_gui.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -112,4 +112,5 @@ tile.engineIron=Combustion Engine
|
|||
tile.oilStill=Oil
|
||||
tile.spring.water=Water Spring
|
||||
tile.spring.oil=Oil Spring
|
||||
tile.oilMoving=Oil
|
||||
tile.oilMoving=Oil
|
||||
tile.filteredBufferBlock=Filtered Buffer
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 494 B |
Binary file not shown.
After Width: | Height: | Size: 315 B |
Binary file not shown.
After Width: | Height: | Size: 323 B |
Binary file not shown.
After Width: | Height: | Size: 336 B |
|
@ -299,8 +299,8 @@ public class BuildCraftBuilders {
|
|||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(templateItem, 1), new Object[]{"ppp", "pip", "ppp", Character.valueOf('i'),
|
||||
new ItemStack(Item.dyePowder, 1, 0), Character.valueOf('p'), Item.paper});
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", Character.valueOf('i'),
|
||||
new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('p'), Item.paper});
|
||||
// CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", Character.valueOf('i'),
|
||||
// new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('p'), Item.paper});
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), new Object[]{"l ", "r ", Character.valueOf('l'),
|
||||
new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('r'), Block.torchRedstoneActive});
|
||||
|
|
|
@ -30,6 +30,7 @@ import buildcraft.core.Version;
|
|||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
import buildcraft.core.triggers.BCTrigger;
|
||||
import buildcraft.transport.BlockFilteredBuffer;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.GateIconProvider;
|
||||
import buildcraft.transport.GuiHandler;
|
||||
|
@ -77,6 +78,7 @@ import buildcraft.transport.pipes.PipeStructureCobblestone;
|
|||
import buildcraft.transport.triggers.ActionEnergyPulser;
|
||||
import buildcraft.transport.triggers.ActionSignalOutput;
|
||||
import buildcraft.transport.triggers.ActionSingleEnergyPulse;
|
||||
import buildcraft.transport.triggers.TriggerFilteredBufferInventoryLevel;
|
||||
import buildcraft.transport.triggers.TriggerPipeContents;
|
||||
import buildcraft.transport.triggers.TriggerPipeContents.Kind;
|
||||
import buildcraft.transport.triggers.TriggerPipeSignal;
|
||||
|
@ -142,6 +144,7 @@ public class BuildCraftTransport {
|
|||
public static Item pipePowerDiamond;
|
||||
public static Item facadeItem;
|
||||
public static Item plugItem;
|
||||
public static BlockFilteredBuffer filteredBufferBlock;
|
||||
// public static Item pipeItemsStipes;
|
||||
public static Item pipeStructureCobblestone;
|
||||
public static int groupItemsTrigger;
|
||||
|
@ -159,6 +162,9 @@ public class BuildCraftTransport {
|
|||
public static BCTrigger triggerGreenSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_GREEN_SIGNAL_INACTIVE, false, IPipe.WireColor.Green);
|
||||
public static BCTrigger triggerYellowSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_ACTIVE, true, IPipe.WireColor.Yellow);
|
||||
public static BCTrigger triggerYellowSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_INACTIVE, false, IPipe.WireColor.Yellow);
|
||||
public static BCTrigger triggerInventoryBelow25 = new TriggerFilteredBufferInventoryLevel(DefaultProps.TRIGGER_INVENTORY_LEVEL_BELOW25, TriggerFilteredBufferInventoryLevel.State.Below25);
|
||||
public static BCTrigger triggerInventoryBelow50 = new TriggerFilteredBufferInventoryLevel(DefaultProps.TRIGGER_INVENTORY_LEVEL_BELOW50, TriggerFilteredBufferInventoryLevel.State.Below50);
|
||||
public static BCTrigger triggerInventoryBelow75 = new TriggerFilteredBufferInventoryLevel(DefaultProps.TRIGGER_INVENTORY_LEVEL_BELOW75, TriggerFilteredBufferInventoryLevel.State.Below75);
|
||||
public static BCAction actionRedSignal = new ActionSignalOutput(DefaultProps.ACTION_RED_SIGNAL, IPipe.WireColor.Red);
|
||||
public static BCAction actionBlueSignal = new ActionSignalOutput(DefaultProps.ACTION_BLUE_SIGNAL, IPipe.WireColor.Blue);
|
||||
public static BCAction actionGreenSignal = new ActionSignalOutput(DefaultProps.ACTION_GREEN_SIGNAL, IPipe.WireColor.Green);
|
||||
|
@ -349,6 +355,12 @@ public class BuildCraftTransport {
|
|||
Property pipePlugId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipePlug.id", DefaultProps.PIPE_PLUG_ID);
|
||||
plugItem = new ItemPlug(pipePlugId.getInt());
|
||||
plugItem.setUnlocalizedName("pipePlug");
|
||||
|
||||
Property filteredBufferId = BuildCraftCore.mainConfiguration.getBlock("filteredBuffer.id", DefaultProps.FILTERED_BUFFER);
|
||||
filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt());
|
||||
CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock"));
|
||||
CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer");
|
||||
|
||||
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[]{new ItemStack(pipeStructureCobblestone)}, 1000, new ItemStack(plugItem, 8)));
|
||||
|
||||
} finally {
|
||||
|
@ -412,6 +424,11 @@ public class BuildCraftTransport {
|
|||
CoreProxy.proxy.addCraftingRecipe(pipe.result, pipe.input);
|
||||
}
|
||||
}
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(filteredBufferBlock, 1),
|
||||
new Object[] { "wdw", "wcw", "wpw", Character.valueOf('w'), "plankWood", Character.valueOf('d'),
|
||||
BuildCraftTransport.pipeItemsDiamond, Character.valueOf('c'), Block.chest, Character.valueOf('p'),
|
||||
Block.pistonBase });
|
||||
}
|
||||
|
||||
@IMCCallback
|
||||
|
|
|
@ -13,7 +13,9 @@ import net.minecraft.world.World;
|
|||
|
||||
public class SafeTimeTracker {
|
||||
|
||||
private long lastMark = 0;
|
||||
private long lastMark = Long.MIN_VALUE;
|
||||
private long duration = 0;
|
||||
private boolean marked;
|
||||
|
||||
/**
|
||||
* Return true if a given delay has passed since last time marked was called successfully.
|
||||
|
@ -28,12 +30,18 @@ public class SafeTimeTracker {
|
|||
lastMark = currentTime;
|
||||
return false;
|
||||
} else if (lastMark + delay <= currentTime) {
|
||||
duration = currentTime - lastMark;
|
||||
lastMark = world.getWorldTime();
|
||||
marked = true;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public long durationOfLastDelay(){
|
||||
return marked ? duration : 0;
|
||||
}
|
||||
|
||||
public void markTime(World world) {
|
||||
lastMark = world.getWorldTime();
|
||||
|
|
|
@ -7,14 +7,15 @@
|
|||
*/
|
||||
package buildcraft.api.power;
|
||||
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public interface IPowerReceptor {
|
||||
|
||||
public PowerProvider getPowerProvider(ForgeDirection side);
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side);
|
||||
|
||||
public void doWork(PowerProvider workProvider);
|
||||
public void doWork(PowerHandler workProvider);
|
||||
|
||||
public World getWorldObj();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,30 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
|
||||
public final class PowerProvider {
|
||||
public final class PowerHandler {
|
||||
|
||||
public static enum Type {
|
||||
|
||||
ENGINE, GATE, MACHINE, PIPE, STORAGE;
|
||||
|
||||
public boolean canReceiveFromPipes() {
|
||||
switch (this) {
|
||||
case MACHINE:
|
||||
case STORAGE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean eatsEngineExcess() {
|
||||
switch (this) {
|
||||
case MACHINE:
|
||||
case STORAGE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PerditionCalculator {
|
||||
|
||||
|
@ -30,8 +53,18 @@ public final class PowerProvider {
|
|||
this.powerLoss = powerLoss;
|
||||
}
|
||||
|
||||
public float applyPerdition(PowerProvider provider, float current) {
|
||||
current -= powerLoss;
|
||||
/**
|
||||
* Apply the perdition algorithm to the current stored energy. This
|
||||
* function can only be called once per tick, but it might not be called
|
||||
* every tick. It is triggered by any manipulation of the stored energy.
|
||||
*
|
||||
* @param powerHandler the PowerHandler requesting the perdition update
|
||||
* @param current the current stored energy
|
||||
* @param ticksPassed ticks since the last time this function was called
|
||||
* @return
|
||||
*/
|
||||
public float applyPerdition(PowerHandler powerHandler, float current, long ticksPassed) {
|
||||
current -= powerLoss * ticksPassed;
|
||||
if (current < 0) {
|
||||
current = 0;
|
||||
}
|
||||
|
@ -44,56 +77,60 @@ public final class PowerProvider {
|
|||
private float maxEnergyStored;
|
||||
private float activationEnergy;
|
||||
private float energyStored = 0;
|
||||
public final boolean canAcceptPowerFromPipes;
|
||||
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
|
||||
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
|
||||
private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
|
||||
public final int[] powerSources = {0, 0, 0, 0, 0, 0};
|
||||
public final IPowerReceptor receptor;
|
||||
private PerditionCalculator perdition;
|
||||
private final PowerReceiver receiver;
|
||||
private final Type type;
|
||||
|
||||
public PowerProvider(IPowerReceptor receptor) {
|
||||
this(receptor, true);
|
||||
public PowerHandler(IPowerReceptor receptor, Type type) {
|
||||
this.receptor = receptor;
|
||||
this.type = type;
|
||||
this.receiver = new PowerReceiver();
|
||||
}
|
||||
|
||||
public PowerProvider(IPowerReceptor receptor, boolean canAcceptPowerFromPipes) {
|
||||
this.canAcceptPowerFromPipes = canAcceptPowerFromPipes;
|
||||
this.receptor = receptor;
|
||||
public PowerReceiver getPowerReceiver() {
|
||||
return receiver;
|
||||
}
|
||||
|
||||
public float getMinEnergyReceived() {
|
||||
return this.minEnergyReceived;
|
||||
return minEnergyReceived;
|
||||
}
|
||||
|
||||
public float getMaxEnergyReceived() {
|
||||
return this.maxEnergyReceived;
|
||||
return maxEnergyReceived;
|
||||
}
|
||||
|
||||
public float getMaxEnergyStored() {
|
||||
return this.maxEnergyStored;
|
||||
return maxEnergyStored;
|
||||
}
|
||||
|
||||
public float getActivationEnergy() {
|
||||
return this.activationEnergy;
|
||||
return activationEnergy;
|
||||
}
|
||||
|
||||
public float getEnergyStored() {
|
||||
return this.energyStored;
|
||||
return energyStored;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup your PowerProvider's settings.
|
||||
* Setup your PowerHandler's settings.
|
||||
*
|
||||
* @param minEnergyReceived This is the minimum about of power that will be
|
||||
* accepted by the PowerProvider. This should generally be greater than the
|
||||
* 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
|
||||
* PowerProvider. This should generally be less than 500. Too low and larger
|
||||
* 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 PowerProvider can
|
||||
* @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.
|
||||
*/
|
||||
|
@ -107,25 +144,23 @@ public final class PowerProvider {
|
|||
this.activationEnergy = activationEnergy;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
applyPerdition();
|
||||
applyWork();
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (powerSources[i] > 0) {
|
||||
powerSources[i]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void configurePowerPerdition(int powerLoss, int powerLossRegularity) {
|
||||
if (powerLoss == 0 || powerLossRegularity == 0) {
|
||||
perdition = new PerditionCalculator(0);
|
||||
return;
|
||||
}
|
||||
perdition = new PerditionCalculator((float) powerLoss / (float) powerLossRegularity * 10.0F);
|
||||
perdition = new PerditionCalculator((float) powerLoss / (float) powerLossRegularity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to define a new PerditionCalculator class to handler perdition
|
||||
* calculations.
|
||||
*
|
||||
* For example if you want exponentially increasing loss bases on amount
|
||||
* stored.
|
||||
*
|
||||
* @param perdition
|
||||
*/
|
||||
public void setPerdition(PerditionCalculator perdition) {
|
||||
this.perdition = perdition;
|
||||
}
|
||||
|
@ -136,14 +171,30 @@ public final class PowerProvider {
|
|||
return perdition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the power handler. You should call this if you can, but its not
|
||||
* required.
|
||||
*
|
||||
* If you don't call it, the possibility exists for some weirdness with the
|
||||
* perdition algorithm and work callback as its possible they will not be
|
||||
* called on every tick they otherwise would be. You should be able to
|
||||
* design around this though if you are aware of the limitations.
|
||||
*/
|
||||
public void update() {
|
||||
applyPerdition();
|
||||
applyWork();
|
||||
validateEnergy();
|
||||
}
|
||||
|
||||
private void applyPerdition() {
|
||||
if (energyStored > 0) {
|
||||
float newEnergy = getPerdition().applyPerdition(this, energyStored);
|
||||
if (perditionTracker.markTimeIfDelay(receptor.getWorldObj(), 1) && energyStored > 0) {
|
||||
float newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
||||
if (newEnergy == 0 || newEnergy < energyStored) {
|
||||
energyStored = newEnergy;
|
||||
} else {
|
||||
energyStored = DEFUALT_PERDITION.applyPerdition(this, energyStored);
|
||||
energyStored = DEFUALT_PERDITION.applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
|
||||
}
|
||||
validateEnergy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,9 +206,23 @@ public final class PowerProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateSources(ForgeDirection source) {
|
||||
if (sourcesTracker.markTimeIfDelay(receptor.getWorldObj(), 1)) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
powerSources[i] -= sourcesTracker.durationOfLastDelay();
|
||||
if (powerSources[i] < 0) {
|
||||
powerSources[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (source != null)
|
||||
powerSources[source.ordinal()] = 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract energy from the PowerProvider. You must call this even if
|
||||
* doWork() triggers.
|
||||
* Extract energy from the PowerHandler. You must call this even if doWork()
|
||||
* triggers.
|
||||
*
|
||||
* @param min
|
||||
* @param max
|
||||
|
@ -165,6 +230,8 @@ public final class PowerProvider {
|
|||
* @return amount used
|
||||
*/
|
||||
public float useEnergy(float min, float max, boolean doUse) {
|
||||
applyPerdition();
|
||||
|
||||
float result = 0;
|
||||
|
||||
if (energyStored >= min) {
|
||||
|
@ -181,6 +248,8 @@ public final class PowerProvider {
|
|||
}
|
||||
}
|
||||
|
||||
validateEnergy();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -203,46 +272,80 @@ public final class PowerProvider {
|
|||
data.setCompoundTag(tag, nbt);
|
||||
}
|
||||
|
||||
/**
|
||||
* The amount of power that this PowerProvider currently needs.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public float powerRequest() {
|
||||
return Math.min(maxEnergyReceived, maxEnergyStored - energyStored);
|
||||
}
|
||||
public final class PowerReceiver {
|
||||
|
||||
public float receiveEnergy(float quantity, ForgeDirection from) {
|
||||
return receiveEnergy(quantity, from, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add power to the Provider from an external source.
|
||||
*
|
||||
* @param quantity
|
||||
* @param from
|
||||
* @return the amount of power used
|
||||
*/
|
||||
public float receiveEnergy(float quantity, ForgeDirection from, boolean boundsCheck) {
|
||||
if (boundsCheck) {
|
||||
if (quantity < minEnergyReceived) {
|
||||
quantity = minEnergyReceived;
|
||||
} else if (quantity > maxEnergyReceived) {
|
||||
quantity = maxEnergyReceived;
|
||||
}
|
||||
private PowerReceiver() {
|
||||
}
|
||||
if (from != null)
|
||||
powerSources[from.ordinal()] = 2;
|
||||
|
||||
quantity = addEnergy(quantity);
|
||||
applyWork();
|
||||
public float getMinEnergyReceived() {
|
||||
return minEnergyReceived;
|
||||
}
|
||||
|
||||
return quantity;
|
||||
public float getMaxEnergyReceived() {
|
||||
return maxEnergyReceived;
|
||||
}
|
||||
|
||||
public float getMaxEnergyStored() {
|
||||
return maxEnergyStored;
|
||||
}
|
||||
|
||||
public float getActivationEnergy() {
|
||||
return activationEnergy;
|
||||
}
|
||||
|
||||
public float getEnergyStored() {
|
||||
return energyStored;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
PowerHandler.this.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* The amount of power that this PowerHandler currently needs.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public float powerRequest() {
|
||||
return Math.min(maxEnergyReceived, maxEnergyStored - energyStored);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add power to the PowerReceiver from an external source.
|
||||
*
|
||||
* @param quantity
|
||||
* @param from
|
||||
* @return the amount of power used
|
||||
*/
|
||||
public float receiveEnergy(Type source, final float quantity, ForgeDirection from) {
|
||||
float used = quantity;
|
||||
if (source == Type.ENGINE) {
|
||||
if (used < minEnergyReceived) {
|
||||
return 0;
|
||||
} else if (used > maxEnergyReceived) {
|
||||
used = maxEnergyReceived;
|
||||
}
|
||||
}
|
||||
|
||||
updateSources(from);
|
||||
|
||||
used = addEnergy(used);
|
||||
|
||||
applyWork();
|
||||
|
||||
if (source == Type.ENGINE && type.eatsEngineExcess()) {
|
||||
return Math.min(quantity, maxEnergyReceived);
|
||||
}
|
||||
|
||||
return used;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal use only you should NEVER call this function on a PowerProvider
|
||||
* you don't own.
|
||||
*
|
||||
* @return the amount the power changed by
|
||||
*/
|
||||
|
@ -262,20 +365,21 @@ public final class PowerProvider {
|
|||
return quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal use only you should NEVER call this function on a PowerProvider
|
||||
* you don't own.
|
||||
*/
|
||||
public void setEnergy(float quantity) {
|
||||
this.energyStored = quantity;
|
||||
if (energyStored > maxEnergyStored) {
|
||||
energyStored = maxEnergyStored;
|
||||
} else if (energyStored < 0) {
|
||||
energyStored = 0;
|
||||
}
|
||||
validateEnergy();
|
||||
}
|
||||
|
||||
public boolean isPowerSource(ForgeDirection from) {
|
||||
return powerSources[from.ordinal()] != 0;
|
||||
}
|
||||
|
||||
private void validateEnergy() {
|
||||
if (energyStored < 0) {
|
||||
energyStored = 0;
|
||||
}
|
||||
if (energyStored > maxEnergyStored) {
|
||||
energyStored = maxEnergyStored;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,7 +26,6 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
@ -44,7 +43,7 @@ public class BlockArchitect extends BlockContainer {
|
|||
public BlockArchitect(int i) {
|
||||
super(i, Material.iron);
|
||||
setHardness(0.5F);
|
||||
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
|
||||
//setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,6 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -34,7 +33,7 @@ public class BlockBlueprintLibrary extends BlockContainer {
|
|||
|
||||
public BlockBlueprintLibrary(int i) {
|
||||
super(i, Material.wood);
|
||||
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
|
||||
//setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
|
||||
setHardness(0.7F);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ public class ItemBptBluePrint extends ItemBptBase {
|
|||
|
||||
public ItemBptBluePrint(int i) {
|
||||
super(i);
|
||||
setCreativeTab(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,9 @@ import buildcraft.api.core.LaserKind;
|
|||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.DefaultProps;
|
||||
|
@ -50,7 +52,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
private BptBuilderBase bluePrintBuilder;
|
||||
public @TileNetworkData
|
||||
Box box = new Box();
|
||||
private PowerProvider powerProvider;
|
||||
private PowerHandler powerHandler;
|
||||
private LinkedList<BlockIndex> path;
|
||||
private LinkedList<EntityLaser> pathLasers;
|
||||
private EntityRobot builderRobot;
|
||||
|
@ -167,8 +169,8 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
public TileBuilder() {
|
||||
super();
|
||||
|
||||
powerProvider = new PowerProvider(this);
|
||||
powerProvider.configure(25, 25, 25, 25);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
powerHandler.configure(25, 25, 25, 25);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -261,7 +263,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
return;
|
||||
|
||||
|
@ -271,7 +273,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
if (builderRobot != null && !builderRobot.readyToBuild())
|
||||
return;
|
||||
|
||||
if (powerProvider.useEnergy(25, 25, true) < 25)
|
||||
if (powerHandler.useEnergy(25, 25, true) < 25)
|
||||
return;
|
||||
|
||||
iterateBpt();
|
||||
|
@ -281,12 +283,13 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
box.initialize(bluePrintBuilder);
|
||||
}
|
||||
|
||||
if (builderRobot == null) {
|
||||
builderRobot = new EntityRobot(worldObj, box);
|
||||
worldObj.spawnEntityInWorld(builderRobot);
|
||||
}
|
||||
if (builderRobot == null) {
|
||||
builderRobot = new EntityRobot(worldObj, box);
|
||||
worldObj.spawnEntityInWorld(builderRobot);
|
||||
}
|
||||
|
||||
box.createLasers(worldObj, LaserKind.Stripes);
|
||||
|
||||
box.createLasers(worldObj, LaserKind.Stripes);
|
||||
|
||||
// builderRobot.scheduleContruction(bluePrintBuilder.getNextBlock(worldObj, this), bluePrintBuilder.getContext());
|
||||
}
|
||||
|
@ -333,8 +336,11 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
if (bluePrintBuilder != null) {
|
||||
box.deleteLasers();
|
||||
box.reset();
|
||||
box.initialize(bluePrintBuilder);
|
||||
box.createLasers(worldObj, LaserKind.Stripes);
|
||||
|
||||
/*
|
||||
box.initialize(bluePrintBuilder);
|
||||
box.createLasers(worldObj, LaserKind.Stripes);
|
||||
*/
|
||||
}
|
||||
|
||||
if (builderRobot != null) {
|
||||
|
@ -509,8 +515,8 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -550,7 +556,6 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
// else
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ import buildcraft.api.filler.IFillerPattern;
|
|||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionReceptor;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.IMachine;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
|
@ -45,18 +47,18 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
public IFillerPattern currentPattern;
|
||||
boolean forceDone = false;
|
||||
private ItemStack contents[];
|
||||
PowerProvider powerProvider;
|
||||
private PowerHandler powerHandler;
|
||||
private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown;
|
||||
|
||||
public TileFiller() {
|
||||
contents = new ItemStack[getSizeInventory()];
|
||||
powerProvider = new PowerProvider(this);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
initPowerProvider();
|
||||
}
|
||||
|
||||
private void initPowerProvider() {
|
||||
powerProvider.configure(30, 50, 25, 100);
|
||||
powerProvider.configurePowerPerdition(1, 1);
|
||||
powerHandler.configure(30, 50, 25, 100);
|
||||
powerHandler.configurePowerPerdition(1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,20 +96,20 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
return;
|
||||
}
|
||||
|
||||
if (powerProvider.getEnergyStored() >= 25) {
|
||||
doWork(powerProvider);
|
||||
if (powerHandler.getEnergyStored() >= 25) {
|
||||
doWork(powerHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
return;
|
||||
|
||||
if (lastMode == Mode.Off)
|
||||
return;
|
||||
|
||||
if (powerProvider.useEnergy(25, 25, true) < 25)
|
||||
if (powerHandler.useEnergy(25, 25, true) < 25)
|
||||
return;
|
||||
|
||||
if (box.isInitialized() && currentPattern != null && !done) {
|
||||
|
@ -136,7 +138,7 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
}
|
||||
}
|
||||
|
||||
if (powerProvider.getEnergyStored() >= 25) {
|
||||
if (powerHandler.getEnergyStored() >= 25) {
|
||||
doWork(workProvider);
|
||||
}
|
||||
}
|
||||
|
@ -322,8 +324,8 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
|
|||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -116,6 +116,7 @@ public class DefaultProps {
|
|||
public static int OIL_MOVING_ID = 1520;
|
||||
public static int OIL_STILL_ID = 1521;
|
||||
public static int SPRING_ID = 1522;
|
||||
public static int FILTERED_BUFFER = 1523;
|
||||
|
||||
public static boolean CURRENT_CONTINUOUS = false;
|
||||
public static double PIPES_DURABILITY = 0.25D;
|
||||
|
@ -154,6 +155,9 @@ public class DefaultProps {
|
|||
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 TRIGGER_INVENTORY_LEVEL_BELOW25 = 31;
|
||||
public static int TRIGGER_INVENTORY_LEVEL_BELOW50 = 32;
|
||||
public static int TRIGGER_INVENTORY_LEVEL_BELOW75 = 33;
|
||||
|
||||
public static int ACTION_REDSTONE = 1;
|
||||
public static int ACTION_RED_SIGNAL = 2;
|
||||
|
|
|
@ -20,4 +20,5 @@ public class GuiIds {
|
|||
public static final int GATES = 51;
|
||||
public static final int PIPE_EMERALD_ITEM = 52;
|
||||
|
||||
public static final int FILTERED_BUFFER = 60;
|
||||
}
|
||||
|
|
|
@ -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.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -30,10 +28,8 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
private static Map<Class, TilePacketWrapper> updateWrappers = new HashMap<Class, TilePacketWrapper>();
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static Map<Class, TilePacketWrapper> descriptionWrappers = new HashMap<Class, TilePacketWrapper>();
|
||||
|
||||
private final TilePacketWrapper descriptionPacket;
|
||||
private final TilePacketWrapper updatePacket;
|
||||
|
||||
private boolean init = false;
|
||||
|
||||
public TileBuildCraft() {
|
||||
|
@ -59,7 +55,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
|
||||
if (this instanceof IPowerReceptor) {
|
||||
IPowerReceptor receptor = ((IPowerReceptor) this);
|
||||
receptor.getPowerProvider(null).update();
|
||||
receptor.getPowerReceiver(null).update();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +70,6 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
}
|
||||
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
public void sendNetworkUpdate() {
|
||||
|
@ -110,13 +105,10 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
|
||||
@Override
|
||||
public void postPacketHandling(PacketUpdate packet) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInvNameLocalized() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
29
common/buildcraft/core/gui/slots/SlotValidated.java
Normal file
29
common/buildcraft/core/gui/slots/SlotValidated.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) CovertJaguar, 2011 http://railcraft.info
|
||||
*
|
||||
* This code is the property of CovertJaguar
|
||||
* and may only be used with explicit written
|
||||
* permission unless otherwise specified on the
|
||||
* license page at railcraft.wikispaces.com.
|
||||
*/
|
||||
package buildcraft.core.gui.slots;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author SandGrainOne
|
||||
*/
|
||||
public class SlotValidated extends Slot {
|
||||
|
||||
public SlotValidated(IInventory inv, int id, int x, int y) {
|
||||
super(inv, id, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return inventory.isStackValidForSlot(this.getSlotIndex(), itemStack);
|
||||
}
|
||||
}
|
|
@ -87,10 +87,9 @@ public class StackHelper {
|
|||
if (oreDictionary) {
|
||||
int idBase = OreDictionary.getOreID(base);
|
||||
if (idBase >= 0) {
|
||||
int idComp = OreDictionary.getOreID(comparison);
|
||||
if (idComp >= 0) {
|
||||
if (idBase == idComp)
|
||||
return true;
|
||||
for(ItemStack itemstack : OreDictionary.getOres(idBase)) {
|
||||
if(comparison.itemID == itemstack.itemID && (itemstack.getItemDamage() == OreDictionary.WILDCARD_VALUE || comparison.getItemDamage() == itemstack.getItemDamage()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,11 @@ public class ActionTriggerIconProvider implements IIconProvider {
|
|||
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 Trigger_Inventory_Below25 = 33;
|
||||
public static final int Trigger_Inventory_Below50 = 34;
|
||||
public static final int Trigger_Inventory_Below75 = 35;
|
||||
|
||||
public static final int MAX = 33;
|
||||
public static final int MAX = 36;
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
@ -94,6 +97,9 @@ public class ActionTriggerIconProvider implements IIconProvider {
|
|||
icons[ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_yellow_inactive");
|
||||
icons[ActionTriggerIconProvider.Trigger_RedstoneInput_Active] = iconRegister.registerIcon("buildcraft:triggers/trigger_redstoneinput_active");
|
||||
icons[ActionTriggerIconProvider.Trigger_RedstoneInput_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_redstoneinput_inactive");
|
||||
icons[ActionTriggerIconProvider.Trigger_Inventory_Below25] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below25");
|
||||
icons[ActionTriggerIconProvider.Trigger_Inventory_Below50] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below50");
|
||||
icons[ActionTriggerIconProvider.Trigger_Inventory_Below75] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below75");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,9 @@ import buildcraft.api.core.Position;
|
|||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.core.TileBuffer;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
|
@ -44,7 +46,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
public static final float MAX_HEAT = 250;
|
||||
protected int progressPart = 0;
|
||||
protected boolean lastPower = false;
|
||||
protected PowerProvider provider;
|
||||
protected PowerHandler powerHandler;
|
||||
public float currentOutput = 0;
|
||||
public boolean isRedstonePowered = false;
|
||||
public TileBuffer[] tileCache;
|
||||
|
@ -61,8 +63,8 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
boolean isPumping = false; // Used for SMP synch
|
||||
|
||||
public TileEngine(int invSize) {
|
||||
provider = new PowerProvider(this, false);
|
||||
provider.configurePowerPerdition(1, 100);
|
||||
powerHandler = new PowerHandler(this, Type.ENGINE);
|
||||
powerHandler.configurePowerPerdition(1, 100);
|
||||
|
||||
inv = new SimpleInventory(invSize, "Engine", 64);
|
||||
}
|
||||
|
@ -71,7 +73,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
public void initialize() {
|
||||
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
tileCache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, true);
|
||||
provider.configure(minEnergyReceived(), maxEnergyReceived(), 1, getMaxEnergy());
|
||||
powerHandler.configure(minEnergyReceived(), maxEnergyReceived(), 1, getMaxEnergy());
|
||||
checkRedstonePower();
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +213,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
|
||||
private float getPowerToExtract() {
|
||||
TileEntity tile = tileCache[orientation.ordinal()].getTile();
|
||||
PowerProvider receptor = ((IPowerReceptor) tile).getPowerProvider(orientation.getOpposite());
|
||||
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
|
||||
return extractEnergy(receptor.getMinEnergyReceived(), receptor.getMaxEnergyReceived(), false); // Comment out for constant power
|
||||
// return extractEnergy(0, getActualOutput(), false); // Uncomment for constant power
|
||||
}
|
||||
|
@ -219,11 +221,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
private void sendPower() {
|
||||
TileEntity tile = tileCache[orientation.ordinal()].getTile();
|
||||
if (isPoweredTile(tile, orientation)) {
|
||||
PowerProvider receptor = ((IPowerReceptor) tile).getPowerProvider(orientation.getOpposite());
|
||||
PowerReceiver receptor = ((IPowerReceptor) tile).getPowerReceiver(orientation.getOpposite());
|
||||
|
||||
float extracted = getPowerToExtract();
|
||||
if (extracted > 0) {
|
||||
float needed = receptor.receiveEnergy(extracted, orientation.getOpposite(), true);
|
||||
float needed = receptor.receiveEnergy(PowerHandler.Type.ENGINE, extracted, orientation.getOpposite());
|
||||
extractEnergy(receptor.getMinEnergyReceived(), needed, true); // Comment out for constant power
|
||||
// currentOutput = extractEnergy(0, needed, true); // Uncomment for constant power
|
||||
}
|
||||
|
@ -386,16 +388,16 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
public abstract int getScaledBurnTime(int scale);
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return provider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
return;
|
||||
|
||||
addEnergy(provider.useEnergy(1, maxEnergyReceived(), true) * 0.95F);
|
||||
addEnergy(powerHandler.useEnergy(1, maxEnergyReceived(), true) * 0.95F);
|
||||
}
|
||||
|
||||
public void addEnergy(float addition) {
|
||||
|
@ -444,9 +446,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
|
||||
public boolean isPoweredTile(TileEntity tile, ForgeDirection side) {
|
||||
if (tile instanceof IPowerReceptor) {
|
||||
PowerProvider receptor = ((IPowerReceptor) tile).getPowerProvider(side.getOpposite());
|
||||
|
||||
return receptor != null;
|
||||
return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -17,7 +17,9 @@ import buildcraft.BuildCraftCore;
|
|||
import buildcraft.BuildCraftFactory;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.core.IMachine;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
|
@ -27,12 +29,12 @@ import buildcraft.core.utils.Utils;
|
|||
public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerReceptor, IPipeConnection {
|
||||
|
||||
boolean isDigging = true;
|
||||
PowerProvider powerProvider;
|
||||
private PowerHandler powerHandler;
|
||||
|
||||
public TileMiningWell() {
|
||||
powerProvider = new PowerProvider(this);
|
||||
powerProvider.configure(100, 100, 60, 1000);
|
||||
powerProvider.configurePowerPerdition(1, 1);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
powerHandler.configure(100, 100, 60, 1000);
|
||||
powerHandler.configurePowerPerdition(1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,8 +42,8 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe
|
|||
* bedrock, lava or goes below 0, it's considered done.
|
||||
*/
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
if (powerProvider.useEnergy(60, 60, true) != 60)
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (powerHandler.useEnergy(60, 60, true) != 60)
|
||||
return;
|
||||
|
||||
World world = worldObj;
|
||||
|
@ -114,8 +116,8 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe
|
|||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,9 @@ import buildcraft.BuildCraftFactory;
|
|||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.EntityBlock;
|
||||
import buildcraft.core.IMachine;
|
||||
|
@ -45,17 +47,17 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
LiquidTank tank;
|
||||
double tubeY = Double.NaN;
|
||||
int aimY = 0;
|
||||
private PowerProvider powerProvider;
|
||||
private PowerHandler powerHandler;
|
||||
|
||||
public TilePump() {
|
||||
powerProvider = new PowerProvider(this);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
initPowerProvider();
|
||||
tank = new LiquidTank(MAX_LIQUID);
|
||||
}
|
||||
|
||||
private void initPowerProvider() {
|
||||
powerProvider.configure(1, 8, 10, 100);
|
||||
powerProvider.configurePowerPerdition(1, 100);
|
||||
powerHandler.configure(1, 8, 10, 100);
|
||||
powerHandler.configurePowerPerdition(1, 100);
|
||||
}
|
||||
|
||||
// TODO, manage this by different levels (pump what's above first...)
|
||||
|
@ -87,7 +89,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
|
||||
if (tank.fill(liquidToPump, false) == liquidToPump.amount) {
|
||||
|
||||
if (powerProvider.useEnergy(10, 10, true) == 10) {
|
||||
if (powerHandler.useEnergy(10, 10, true) == 10) {
|
||||
index = getNextIndexToPump(true);
|
||||
|
||||
if (liquidToPump.itemID != Block.waterStill.blockID || BuildCraftCore.consumeWaterSources) {
|
||||
|
@ -286,7 +288,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
|
||||
tubeY = nbttagcompound.getFloat("tubeY");
|
||||
|
||||
powerProvider.readFromNBT(nbttagcompound);
|
||||
powerHandler.readFromNBT(nbttagcompound);
|
||||
initPowerProvider();
|
||||
}
|
||||
|
||||
|
@ -294,7 +296,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
powerProvider.writeToNBT(nbttagcompound);
|
||||
powerHandler.writeToNBT(nbttagcompound);
|
||||
|
||||
if (tank.getLiquid() != null) {
|
||||
nbttagcompound.setTag("tank", tank.getLiquid().writeToNBT(new NBTTagCompound()));
|
||||
|
@ -315,12 +317,12 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
35
common/buildcraft/factory/TileQuarry.java
Executable file → Normal file
35
common/buildcraft/factory/TileQuarry.java
Executable file → Normal file
|
@ -31,7 +31,8 @@ import buildcraft.api.core.IAreaProvider;
|
|||
import buildcraft.api.core.LaserKind;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.DefaultAreaProvider;
|
||||
|
@ -70,18 +71,18 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
private BlueprintBuilder blueprintBuilder;
|
||||
private ListIterator<SchematicBuilder> blueprintIterator;
|
||||
public EntityMechanicalArm arm;
|
||||
public PowerProvider powerProvider;
|
||||
public PowerHandler powerHandler;
|
||||
boolean isDigging = false;
|
||||
public static final int MAX_ENERGY = 15000;
|
||||
|
||||
public TileQuarry() {
|
||||
powerProvider = new PowerProvider(this);
|
||||
powerHandler = new PowerHandler(this, PowerHandler.Type.MACHINE);
|
||||
initPowerProvider();
|
||||
}
|
||||
|
||||
private void initPowerProvider() {
|
||||
powerProvider.configure(50, 100, 25, MAX_ENERGY);
|
||||
powerProvider.configurePowerPerdition(2, 1);
|
||||
powerHandler.configure(50, 100, 25, MAX_ENERGY);
|
||||
powerHandler.configurePowerPerdition(2, 1);
|
||||
}
|
||||
|
||||
public void createUtilsIfNeeded() {
|
||||
|
@ -146,9 +147,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
return;
|
||||
}
|
||||
if (inProcess) {
|
||||
float energyToUse = 2 + powerProvider.getEnergyStored() / 500;
|
||||
float energyToUse = 2 + powerHandler.getEnergyStored() / 500;
|
||||
|
||||
float energy = powerProvider.useEnergy(energyToUse, energyToUse, true);
|
||||
float energy = powerHandler.useEnergy(energyToUse, energyToUse, true);
|
||||
|
||||
if (energy > 0) {
|
||||
moveHead(0.1 + energy / 200F);
|
||||
|
@ -188,17 +189,15 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
}
|
||||
|
||||
protected void buildFrame() {
|
||||
|
||||
powerProvider.configure(50, 100, 25, MAX_ENERGY);
|
||||
|
||||
if (!blueprintIterator.hasNext())
|
||||
return;
|
||||
|
||||
if (powerProvider.useEnergy(25, 25, false) != 25)
|
||||
if (powerHandler.useEnergy(25, 25, false) != 25)
|
||||
return;
|
||||
|
||||
if (builder == null) {
|
||||
|
@ -209,7 +208,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
if (builder.readyToBuild()) {
|
||||
while (blueprintIterator.hasNext()) {
|
||||
if (builder.scheduleContruction(blueprintIterator.next())) {
|
||||
powerProvider.useEnergy(0, 25, true);
|
||||
powerHandler.useEnergy(0, 25, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -217,8 +216,8 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
}
|
||||
|
||||
protected void dig() {
|
||||
powerProvider.configure(100, 500, 60, MAX_ENERGY);
|
||||
if (powerProvider.useEnergy(60, 60, true) != 60)
|
||||
powerHandler.configure(100, 500, 60, MAX_ENERGY);
|
||||
if (powerHandler.useEnergy(60, 60, true) != 60)
|
||||
return;
|
||||
|
||||
if (!findTarget(true)) {
|
||||
|
@ -342,7 +341,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
powerProvider.readFromNBT(nbttagcompound);
|
||||
powerHandler.readFromNBT(nbttagcompound);
|
||||
initPowerProvider();
|
||||
|
||||
if (nbttagcompound.hasKey("box")) {
|
||||
|
@ -380,7 +379,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
powerProvider.writeToNBT(nbttagcompound);
|
||||
powerHandler.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setInteger("targetX", targetX);
|
||||
nbttagcompound.setInteger("targetY", targetY);
|
||||
|
@ -665,8 +664,8 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,9 @@ import buildcraft.BuildCraftCore;
|
|||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.recipes.RefineryRecipe;
|
||||
import buildcraft.core.IMachine;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
|
@ -43,11 +45,11 @@ public class TileRefinery extends TileBuildCraft implements ITankContainer, IPow
|
|||
private int animationStage = 0;
|
||||
SafeTimeTracker time = new SafeTimeTracker();
|
||||
SafeTimeTracker updateNetworkTime = new SafeTimeTracker();
|
||||
PowerProvider powerProvider;
|
||||
private PowerHandler powerHandler;
|
||||
private boolean isActive;
|
||||
|
||||
public TileRefinery() {
|
||||
powerProvider = new PowerProvider(this);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
initPowerProvider();
|
||||
|
||||
filters[0] = 0;
|
||||
|
@ -57,8 +59,8 @@ public class TileRefinery extends TileBuildCraft implements ITankContainer, IPow
|
|||
}
|
||||
|
||||
private void initPowerProvider() {
|
||||
powerProvider.configure(25, 100, 25, 1000);
|
||||
powerProvider.configurePowerPerdition(1, 1);
|
||||
powerHandler.configure(25, 100, 25, 1000);
|
||||
powerHandler.configurePowerPerdition(1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,12 +108,12 @@ public class TileRefinery extends TileBuildCraft implements ITankContainer, IPow
|
|||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,7 +154,7 @@ public class TileRefinery extends TileBuildCraft implements ITankContainer, IPow
|
|||
|
||||
isActive = true;
|
||||
|
||||
if (powerProvider.getEnergyStored() >= currentRecipe.energy) {
|
||||
if (powerHandler.getEnergyStored() >= currentRecipe.energy) {
|
||||
increaseAnimation();
|
||||
} else {
|
||||
decreaseAnimation();
|
||||
|
@ -161,7 +163,7 @@ public class TileRefinery extends TileBuildCraft implements ITankContainer, IPow
|
|||
if (!time.markTimeIfDelay(worldObj, currentRecipe.delay))
|
||||
return;
|
||||
|
||||
float energyUsed = powerProvider.useEnergy(currentRecipe.energy, currentRecipe.energy, true);
|
||||
float energyUsed = powerHandler.useEnergy(currentRecipe.energy, currentRecipe.energy, true);
|
||||
|
||||
if (energyUsed != 0) {
|
||||
if (consumeInput(currentRecipe.ingredient1) && consumeInput(currentRecipe.ingredient2)) {
|
||||
|
@ -250,7 +252,7 @@ public class TileRefinery extends TileBuildCraft implements ITankContainer, IPow
|
|||
animationStage = nbttagcompound.getInteger("animationStage");
|
||||
animationSpeed = nbttagcompound.getFloat("animationSpeed");
|
||||
|
||||
powerProvider.readFromNBT(nbttagcompound);
|
||||
powerHandler.readFromNBT(nbttagcompound);
|
||||
initPowerProvider();
|
||||
|
||||
filters[0] = nbttagcompound.getInteger("filters_0");
|
||||
|
@ -277,7 +279,7 @@ public class TileRefinery extends TileBuildCraft implements ITankContainer, IPow
|
|||
|
||||
nbttagcompound.setInteger("animationStage", animationStage);
|
||||
nbttagcompound.setFloat("animationSpeed", animationSpeed);
|
||||
powerProvider.writeToNBT(nbttagcompound);
|
||||
powerHandler.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setInteger("filters_0", filters[0]);
|
||||
nbttagcompound.setInteger("filters_1", filters[1]);
|
||||
|
|
|
@ -18,7 +18,9 @@ import buildcraft.api.core.SafeTimeTracker;
|
|||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionReceptor;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.EntityEnergyLaser;
|
||||
import buildcraft.core.IMachine;
|
||||
|
@ -33,22 +35,22 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
|
|||
private final SafeTimeTracker searchTracker = new SafeTimeTracker();
|
||||
private final SafeTimeTracker networkTracker = new SafeTimeTracker();
|
||||
private ILaserTarget laserTarget;
|
||||
public PowerProvider powerProvider;
|
||||
private PowerHandler powerHandler;
|
||||
private int nextNetworkUpdate = 3;
|
||||
private int nextLaserUpdate = 10;
|
||||
private int nextLaserSearch = 100;
|
||||
private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown;
|
||||
|
||||
|
||||
public TileLaser() {
|
||||
powerProvider = new PowerProvider(this);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
initPowerProvider();
|
||||
}
|
||||
|
||||
private void initPowerProvider() {
|
||||
powerProvider.configure(25, 150, 25, 1000);
|
||||
powerProvider.configurePowerPerdition(1, 1);
|
||||
powerHandler.configure(25, 150, 25, 1000);
|
||||
powerHandler.configurePowerPerdition(1, 1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
@ -57,7 +59,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
|
|||
return;
|
||||
|
||||
// Disable the laser and do nothing if no energy is available.
|
||||
if (powerProvider.getEnergyStored() == 0) {
|
||||
if (powerHandler.getEnergyStored() == 0) {
|
||||
removeLaser();
|
||||
return;
|
||||
}
|
||||
|
@ -93,7 +95,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
|
|||
}
|
||||
|
||||
// Consume power and transfer it to the table.
|
||||
float power = powerProvider.useEnergy(0, 4, true);
|
||||
float power = powerHandler.useEnergy(0, 4, true);
|
||||
laserTarget.receiveLaserEnergy(power);
|
||||
|
||||
if (laser != null) {
|
||||
|
@ -230,14 +232,13 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -251,7 +252,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
|
|||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
powerProvider.readFromNBT(nbttagcompound);
|
||||
powerHandler.readFromNBT(nbttagcompound);
|
||||
initPowerProvider();
|
||||
}
|
||||
|
||||
|
@ -259,7 +260,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
|
|||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
powerProvider.writeToNBT(nbttagcompound);
|
||||
powerHandler.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
85
common/buildcraft/transport/BlockFilteredBuffer.java
Normal file
85
common/buildcraft/transport/BlockFilteredBuffer.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
/**
|
||||
* 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
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.IItemPipe;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author SandGrainOne
|
||||
*/
|
||||
public class BlockFilteredBuffer extends BlockBuildCraft {
|
||||
|
||||
private static Icon blockTexture;
|
||||
|
||||
public BlockFilteredBuffer(int blockId) {
|
||||
super(blockId, Material.iron);
|
||||
setHardness(5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1) {
|
||||
return new TileFilteredBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer,
|
||||
int par6, float par7, float par8, float par9) {
|
||||
|
||||
super.onBlockActivated(world, x, y, z, entityplayer, par6, par7, par8, par9);
|
||||
|
||||
if (entityplayer.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entityplayer.getCurrentEquippedItem() != null) {
|
||||
if (entityplayer.getCurrentEquippedItem().getItem() instanceof IItemPipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(world)) {
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.FILTERED_BUFFER, world, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
itemList.add(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister par1IconRegister) {
|
||||
blockTexture = par1IconRegister.registerIcon("buildcraft:filteredBuffer_all");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(int i, int j) {
|
||||
return blockTexture;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -51,27 +49,26 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockGenericPipe extends BlockContainer {
|
||||
|
||||
static enum Part {
|
||||
|
||||
Pipe,
|
||||
Gate
|
||||
}
|
||||
|
||||
static class RaytraceResult {
|
||||
|
||||
RaytraceResult(Part hitPart, MovingObjectPosition movingObjectPosition) {
|
||||
this.hitPart = hitPart;
|
||||
this.movingObjectPosition = movingObjectPosition;
|
||||
}
|
||||
|
||||
public Part hitPart;
|
||||
public MovingObjectPosition movingObjectPosition;
|
||||
}
|
||||
|
||||
private static Random rand = new Random();
|
||||
|
||||
private boolean skippedFirstIconRegister;
|
||||
|
||||
/* Defined subprograms ************************************************* */
|
||||
|
||||
public BlockGenericPipe(int i) {
|
||||
super(i, Material.glass);
|
||||
|
||||
|
@ -198,31 +195,31 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
TileEntity tile1 = world.getBlockTileEntity(i, j, k);
|
||||
TileGenericPipe tileG = (TileGenericPipe) tile1;
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i - 1, j, k) || (tileG != null && tileG.hasFacade(ForgeDirection.WEST))) {
|
||||
xMin = 0.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i + 1, j, k) || (tileG != null && tileG.hasFacade(ForgeDirection.EAST))) {
|
||||
xMax = 1.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i, j - 1, k) || (tileG != null && tileG.hasFacade(ForgeDirection.DOWN))) {
|
||||
yMin = 0.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i, j + 1, k) || (tileG != null && tileG.hasFacade(ForgeDirection.UP))) {
|
||||
yMax = 1.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i, j, k - 1) || (tileG != null && tileG.hasFacade(ForgeDirection.NORTH))) {
|
||||
zMin = 0.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i, j, k + 1) || (tileG != null && tileG.hasFacade(ForgeDirection.SOUTH))) {
|
||||
zMax = 1.0F;
|
||||
}
|
||||
|
||||
if (tileG != null) {
|
||||
if (Utils.checkPipesConnections(world, tile1, i - 1, j, k) || tileG.hasFacade(ForgeDirection.WEST)) {
|
||||
xMin = 0.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i + 1, j, k) || tileG.hasFacade(ForgeDirection.EAST)) {
|
||||
xMax = 1.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i, j - 1, k) || tileG.hasFacade(ForgeDirection.DOWN)) {
|
||||
yMin = 0.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i, j + 1, k) || tileG.hasFacade(ForgeDirection.UP)) {
|
||||
yMax = 1.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i, j, k - 1) || tileG.hasFacade(ForgeDirection.NORTH)) {
|
||||
zMin = 0.0F;
|
||||
}
|
||||
|
||||
if (Utils.checkPipesConnections(world, tile1, i, j, k + 1) || tileG.hasFacade(ForgeDirection.SOUTH)) {
|
||||
zMax = 1.0F;
|
||||
}
|
||||
|
||||
if (tileG.hasFacade(ForgeDirection.EAST) || tileG.hasFacade(ForgeDirection.WEST)) {
|
||||
yMin = 0.0F;
|
||||
yMax = 1.0F;
|
||||
|
@ -263,15 +260,15 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
double pitch = Math.toRadians(entityPlayer.rotationPitch);
|
||||
double yaw = Math.toRadians(entityPlayer.rotationYaw);
|
||||
|
||||
double dirX = -Math.sin(yaw) * Math.cos(pitch);
|
||||
double dirY = -Math.sin(pitch);
|
||||
double dirZ = Math.cos(yaw) * Math.cos(pitch);
|
||||
double dirX = -Math.sin(yaw) * Math.cos(pitch);
|
||||
double dirY = -Math.sin(pitch);
|
||||
double dirZ = Math.cos(yaw) * Math.cos(pitch);
|
||||
|
||||
double reachDistance = 5;
|
||||
double reachDistance = 5;
|
||||
|
||||
if (entityPlayer instanceof EntityPlayerMP) {
|
||||
reachDistance = ((EntityPlayerMP) entityPlayer).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
if (entityPlayer instanceof EntityPlayerMP) {
|
||||
reachDistance = ((EntityPlayerMP) entityPlayer).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
|
||||
Vec3 origin = Vec3.fakePool.getVecFromPool(entityPlayer.posX, entityPlayer.posY + 1.62 - entityPlayer.yOffset, entityPlayer.posZ);
|
||||
Vec3 direction = origin.addVector(dirX * reachDistance, dirY * reachDistance, dirZ * reachDistance);
|
||||
|
@ -290,9 +287,10 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
}
|
||||
|
||||
/**
|
||||
* pipe hits along x, y, and z axis, gate (all 6 sides) [and wires+facades]
|
||||
* pipe hits along x, y, and z axis, gate (all 6 sides) [and
|
||||
* wires+facades]
|
||||
*/
|
||||
MovingObjectPosition[] hits = new MovingObjectPosition[] { null, null, null, null, null, null, null, null, null };
|
||||
MovingObjectPosition[] hits = new MovingObjectPosition[]{null, null, null, null, null, null, null, null, null};
|
||||
|
||||
boolean needAxisCheck = false;
|
||||
boolean needCenterCheck = true;
|
||||
|
@ -390,7 +388,8 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
|
||||
for (int i = 0; i < hits.length; i++) {
|
||||
MovingObjectPosition hit = hits[i];
|
||||
if (hit == null) continue;
|
||||
if (hit == null)
|
||||
continue;
|
||||
|
||||
double lengthSquared = hit.hitVec.squareDistanceTo(origin);
|
||||
|
||||
|
@ -424,24 +423,24 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
float max = Utils.pipeMaxPos - 0.05F;
|
||||
|
||||
switch (dir) {
|
||||
case DOWN:
|
||||
setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max);
|
||||
break;
|
||||
case UP:
|
||||
setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max);
|
||||
break;
|
||||
case NORTH:
|
||||
setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos);
|
||||
break;
|
||||
case SOUTH:
|
||||
setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F);
|
||||
break;
|
||||
case WEST:
|
||||
setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max);
|
||||
break;
|
||||
case EAST:
|
||||
setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max);
|
||||
break;
|
||||
case DOWN:
|
||||
setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max);
|
||||
break;
|
||||
case UP:
|
||||
setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max);
|
||||
break;
|
||||
case NORTH:
|
||||
setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos);
|
||||
break;
|
||||
case SOUTH:
|
||||
setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F);
|
||||
break;
|
||||
case WEST:
|
||||
setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max);
|
||||
break;
|
||||
case EAST:
|
||||
setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -503,6 +502,7 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public TileEntity createNewTileEntity(World var1) {
|
||||
return new TileGenericPipe();
|
||||
}
|
||||
|
@ -554,7 +554,6 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
}
|
||||
|
||||
/* Wrappers ************************************************************ */
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int l) {
|
||||
super.onNeighborBlockChange(world, x, y, z, l);
|
||||
|
@ -607,7 +606,6 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
return stripEquipment(pipe);
|
||||
|
||||
} else if (entityplayer.getCurrentEquippedItem() == null) {
|
||||
|
||||
// Fall through the end of the test
|
||||
} else if (entityplayer.getCurrentEquippedItem().itemID == Item.sign.itemID)
|
||||
// Sign will be placed anyway, so lets show the sign gui
|
||||
|
@ -694,7 +692,7 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
private boolean stripEquipment(Pipe pipe) {
|
||||
|
||||
// Try to strip wires first, starting with yellow.
|
||||
for (IPipe.WireColor color : IPipe.WireColor.values())
|
||||
for (IPipe.WireColor color : IPipe.WireColor.values()) {
|
||||
if (pipe.wireSet[color.reverse().ordinal()]) {
|
||||
if (!CoreProxy.proxy.isRenderWorld(pipe.worldObj)) {
|
||||
dropWire(color.reverse(), pipe.worldObj, pipe.xCoord, pipe.yCoord, pipe.zCoord);
|
||||
|
@ -704,6 +702,7 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
pipe.container.scheduleRenderUpdate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to strip gate next
|
||||
if (pipe.hasGate()) {
|
||||
|
@ -726,23 +725,23 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
|
||||
Item wireItem;
|
||||
switch (color) {
|
||||
case Red:
|
||||
wireItem = BuildCraftTransport.redPipeWire;
|
||||
break;
|
||||
case Blue:
|
||||
wireItem = BuildCraftTransport.bluePipeWire;
|
||||
break;
|
||||
case Green:
|
||||
wireItem = BuildCraftTransport.greenPipeWire;
|
||||
break;
|
||||
default:
|
||||
wireItem = BuildCraftTransport.yellowPipeWire;
|
||||
case Red:
|
||||
wireItem = BuildCraftTransport.redPipeWire;
|
||||
break;
|
||||
case Blue:
|
||||
wireItem = BuildCraftTransport.bluePipeWire;
|
||||
break;
|
||||
case Green:
|
||||
wireItem = BuildCraftTransport.greenPipeWire;
|
||||
break;
|
||||
default:
|
||||
wireItem = BuildCraftTransport.yellowPipeWire;
|
||||
}
|
||||
Utils.dropItems(world, new ItemStack(wireItem), i, j, k);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "all" })
|
||||
@SuppressWarnings({"all"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) {
|
||||
|
||||
|
@ -811,7 +810,7 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "all" })
|
||||
@SuppressWarnings({"all"})
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int i, int j, int k, Random random) {
|
||||
Pipe pipe = getPipe(world, i, j, k);
|
||||
|
@ -822,9 +821,7 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
}
|
||||
|
||||
/* Registration ******************************************************** */
|
||||
|
||||
public static Map<Integer, Class<? extends Pipe>> pipes = new HashMap<Integer, Class<? extends Pipe>>();
|
||||
|
||||
static long lastRemovedDate = -1;
|
||||
public static Map<BlockIndex, Pipe> pipeRemoved = new HashMap<BlockIndex, Pipe>();
|
||||
|
||||
|
@ -899,17 +896,16 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
if (!skippedFirstIconRegister){
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
if (!skippedFirstIconRegister) {
|
||||
skippedFirstIconRegister = true;
|
||||
return;
|
||||
}
|
||||
BuildCraftTransport.instance.gateIconProvider.registerIcons(iconRegister);
|
||||
BuildCraftTransport.instance.wireIconProvider.registerIcons(iconRegister);
|
||||
for (int i : pipes.keySet()){
|
||||
for (int i : pipes.keySet()) {
|
||||
Pipe dummyPipe = createPipe(i);
|
||||
if (dummyPipe != null){
|
||||
if (dummyPipe != null) {
|
||||
dummyPipe.getIconProvider().registerIcons(iconRegister);
|
||||
}
|
||||
}
|
||||
|
@ -922,102 +918,113 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Spawn a digging particle effect in the world, this is a wrapper around
|
||||
* EffectRenderer.addBlockHitEffects to allow the block more control over
|
||||
* the particles. Useful when you have entirely different texture sheets for
|
||||
* different sides/locations in the world.
|
||||
*
|
||||
* @param world The current world
|
||||
* @param target The target the player is looking at {x/y/z/side/sub}
|
||||
* @param effectRenderer A reference to the current effect renderer.
|
||||
* @return True to prevent vanilla digging particles form spawning.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addBlockHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||
int x = target.blockX;
|
||||
int y = target.blockY;
|
||||
int z = target.blockZ;
|
||||
* Spawn a digging particle effect in the world, this is a wrapper around
|
||||
* EffectRenderer.addBlockHitEffects to allow the block more control over
|
||||
* the particles. Useful when you have entirely different texture sheets for
|
||||
* different sides/locations in the world.
|
||||
*
|
||||
* @param world The current world
|
||||
* @param target The target the player is looking at {x/y/z/side/sub}
|
||||
* @param effectRenderer A reference to the current effect renderer.
|
||||
* @return True to prevent vanilla digging particles form spawning.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addBlockHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
|
||||
int x = target.blockX;
|
||||
int y = target.blockY;
|
||||
int z = target.blockZ;
|
||||
|
||||
Pipe pipe = getPipe(worldObj, x, y, z);
|
||||
if (pipe == null) return false;
|
||||
Pipe pipe = getPipe(worldObj, x, y, z);
|
||||
if (pipe == null)
|
||||
return false;
|
||||
|
||||
Icon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());
|
||||
Icon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());
|
||||
|
||||
int sideHit = target.sideHit;
|
||||
int sideHit = target.sideHit;
|
||||
|
||||
Block block = BuildCraftTransport.genericPipeBlock;
|
||||
float b = 0.1F;
|
||||
double px = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (b * 2.0F)) + b + block.getBlockBoundsMinX();
|
||||
double py = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (b * 2.0F)) + b + block.getBlockBoundsMinY();
|
||||
double pz = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (b * 2.0F)) + b + block.getBlockBoundsMinZ();
|
||||
Block block = BuildCraftTransport.genericPipeBlock;
|
||||
float b = 0.1F;
|
||||
double px = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (b * 2.0F)) + b + block.getBlockBoundsMinX();
|
||||
double py = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (b * 2.0F)) + b + block.getBlockBoundsMinY();
|
||||
double pz = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (b * 2.0F)) + b + block.getBlockBoundsMinZ();
|
||||
|
||||
if (sideHit == 0) {
|
||||
py = (double) y + block.getBlockBoundsMinY() - (double) b;
|
||||
}
|
||||
if (sideHit == 0) {
|
||||
py = (double) y + block.getBlockBoundsMinY() - (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 1) {
|
||||
py = (double) y + block.getBlockBoundsMaxY() + (double) b;
|
||||
}
|
||||
if (sideHit == 1) {
|
||||
py = (double) y + block.getBlockBoundsMaxY() + (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 2) {
|
||||
pz = (double) z + block.getBlockBoundsMinZ() - (double) b;
|
||||
}
|
||||
if (sideHit == 2) {
|
||||
pz = (double) z + block.getBlockBoundsMinZ() - (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 3) {
|
||||
pz = (double) z + block.getBlockBoundsMaxZ() + (double) b;
|
||||
}
|
||||
if (sideHit == 3) {
|
||||
pz = (double) z + block.getBlockBoundsMaxZ() + (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 4) {
|
||||
px = (double) x + block.getBlockBoundsMinX() - (double) b;
|
||||
}
|
||||
if (sideHit == 4) {
|
||||
px = (double) x + block.getBlockBoundsMinX() - (double) b;
|
||||
}
|
||||
|
||||
if (sideHit == 5) {
|
||||
px = (double) x + block.getBlockBoundsMaxX() + (double) b;
|
||||
}
|
||||
if (sideHit == 5) {
|
||||
px = (double) x + block.getBlockBoundsMaxX() + (double) b;
|
||||
}
|
||||
|
||||
EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, worldObj.getBlockMetadata(x, y, z), Minecraft.getMinecraft().renderEngine);
|
||||
EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, worldObj.getBlockMetadata(x, y, z), Minecraft.getMinecraft().renderEngine);
|
||||
fx.setParticleIcon(Minecraft.getMinecraft().renderEngine, icon);
|
||||
effectRenderer.addEffect(fx.func_70596_a(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
|
||||
return true;
|
||||
}
|
||||
effectRenderer.addEffect(fx.func_70596_a(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn particles for when the block is destroyed. Due to the nature of how
|
||||
* this is invoked, the x/y/z locations are not always guaranteed to host
|
||||
* your block. So be sure to do proper sanity checks before assuming that
|
||||
* the location is this block.
|
||||
*
|
||||
* @param world The current world
|
||||
* @param x X position to spawn the particle
|
||||
* @param y Y position to spawn the particle
|
||||
* @param z Z position to spawn the particle
|
||||
* @param meta The metadata for the block before it was destroyed.
|
||||
* @param effectRenderer A reference to the current effect renderer.
|
||||
* @return True to prevent vanilla break particles from spawning.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addBlockDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||
Pipe pipe = getPipe(worldObj, x, y, z);
|
||||
if (pipe == null) return false;
|
||||
/**
|
||||
* Spawn particles for when the block is destroyed. Due to the nature of how
|
||||
* this is invoked, the x/y/z locations are not always guaranteed to host
|
||||
* your block. So be sure to do proper sanity checks before assuming that
|
||||
* the location is this block.
|
||||
*
|
||||
* @param world The current world
|
||||
* @param x X position to spawn the particle
|
||||
* @param y Y position to spawn the particle
|
||||
* @param z Z position to spawn the particle
|
||||
* @param meta The metadata for the block before it was destroyed.
|
||||
* @param effectRenderer A reference to the current effect renderer.
|
||||
* @return True to prevent vanilla break particles from spawning.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean addBlockDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
|
||||
Pipe pipe = getPipe(worldObj, x, y, z);
|
||||
if (pipe == null)
|
||||
return false;
|
||||
|
||||
Icon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());
|
||||
Icon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());
|
||||
|
||||
byte its = 4;
|
||||
for (int i = 0; i < its; ++i) {
|
||||
for (int j = 0; j < its; ++j) {
|
||||
for (int k = 0; k < its; ++k) {
|
||||
double px = x + (i + 0.5D) / (double) its;
|
||||
double py = y + (j + 0.5D) / (double) its;
|
||||
double pz = z + (k + 0.5D) / (double) its;
|
||||
int random = rand.nextInt(6);
|
||||
EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, BuildCraftTransport.genericPipeBlock, random, meta, Minecraft.getMinecraft().renderEngine);
|
||||
byte its = 4;
|
||||
for (int i = 0; i < its; ++i) {
|
||||
for (int j = 0; j < its; ++j) {
|
||||
for (int k = 0; k < its; ++k) {
|
||||
double px = x + (i + 0.5D) / (double) its;
|
||||
double py = y + (j + 0.5D) / (double) its;
|
||||
double pz = z + (k + 0.5D) / (double) its;
|
||||
int random = rand.nextInt(6);
|
||||
EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, BuildCraftTransport.genericPipeBlock, random, meta, Minecraft.getMinecraft().renderEngine);
|
||||
fx.setParticleIcon(Minecraft.getMinecraft().renderEngine, icon);
|
||||
effectRenderer.addEffect(fx.func_70596_a(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
effectRenderer.addEffect(fx.func_70596_a(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static int facadeRenderColor = -1;
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
|
||||
if (facadeRenderColor != -1) {
|
||||
return facadeRenderColor;
|
||||
}
|
||||
return super.colorMultiplier(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package buildcraft.transport;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
||||
public class EnergyPulser {
|
||||
|
||||
|
@ -26,7 +27,7 @@ public class EnergyPulser {
|
|||
return;
|
||||
|
||||
if (!singlePulse || !hasPulsed) {
|
||||
powerReceptor.getPowerProvider(null).receiveEnergy(Math.min(1 << (pulseCount - 1), 64), ForgeDirection.WEST);
|
||||
powerReceptor.getPowerReceiver(null).receiveEnergy(Type.GATE, Math.min(1 << (pulseCount - 1), 64), ForgeDirection.WEST);
|
||||
hasPulsed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,11 @@ import net.minecraft.world.World;
|
|||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.transport.gui.ContainerDiamondPipe;
|
||||
import buildcraft.transport.gui.ContainerEmeraldPipe;
|
||||
import buildcraft.transport.gui.ContainerFilteredBuffer;
|
||||
import buildcraft.transport.gui.ContainerGateInterface;
|
||||
import buildcraft.transport.gui.GuiDiamondPipe;
|
||||
import buildcraft.transport.gui.GuiEmeraldPipe;
|
||||
import buildcraft.transport.gui.GuiFilteredBuffer;
|
||||
import buildcraft.transport.gui.GuiGateInterface;
|
||||
import buildcraft.transport.pipes.PipeLogicDiamond;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
@ -22,6 +24,12 @@ public class GuiHandler implements IGuiHandler {
|
|||
return null;
|
||||
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileFilteredBuffer) {
|
||||
TileFilteredBuffer filteredBuffer = (TileFilteredBuffer) tile;
|
||||
return new ContainerFilteredBuffer(player.inventory, filteredBuffer);
|
||||
}
|
||||
|
||||
if (!(tile instanceof TileGenericPipe))
|
||||
return null;
|
||||
|
||||
|
@ -51,6 +59,12 @@ public class GuiHandler implements IGuiHandler {
|
|||
return null;
|
||||
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileFilteredBuffer) {
|
||||
TileFilteredBuffer filteredBuffer = (TileFilteredBuffer) tile;
|
||||
return new GuiFilteredBuffer(player.inventory, filteredBuffer);
|
||||
}
|
||||
|
||||
if (!(tile instanceof TileGenericPipe))
|
||||
return null;
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ import buildcraft.BuildCraftCore;
|
|||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
@ -74,10 +75,10 @@ public class PipeTransportPower extends PipeTransport {
|
|||
|
||||
if (tile instanceof IPowerReceptor) {
|
||||
IPowerReceptor receptor = (IPowerReceptor) tile;
|
||||
PowerProvider provider = receptor.getPowerProvider(side.getOpposite());
|
||||
if (provider == null)
|
||||
PowerReceiver receiver = receptor.getPowerReceiver(side.getOpposite());
|
||||
if (receiver == null)
|
||||
return false;
|
||||
if (container.pipe instanceof PipePowerWood || provider.canAcceptPowerFromPipes)
|
||||
if (container.pipe instanceof PipePowerWood || receiver.getType().canReceiveFromPipes())
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -150,11 +151,11 @@ public class PipeTransportPower extends PipeTransport {
|
|||
internalPower[i] -= watts;
|
||||
} else if (tiles[j] instanceof IPowerReceptor) {
|
||||
IPowerReceptor pow = (IPowerReceptor) tiles[j];
|
||||
PowerProvider prov = pow.getPowerProvider(ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
|
||||
PowerReceiver prov = pow.getPowerReceiver(ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
|
||||
|
||||
if (prov != null && prov.canAcceptPowerFromPipes && prov.powerRequest() > 0) {
|
||||
if (prov != null && prov.getType().canReceiveFromPipes() && prov.powerRequest() > 0) {
|
||||
watts = (internalPower[i] / totalPowerQuery) * powerQuery[j];
|
||||
watts = prov.receiveEnergy(watts, ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
|
||||
watts = prov.receiveEnergy(Type.PIPE, watts, ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
|
||||
internalPower[i] -= watts;
|
||||
}
|
||||
}
|
||||
|
@ -187,8 +188,8 @@ public class PipeTransportPower extends PipeTransport {
|
|||
for (int i = 0; i < 6; ++i) {
|
||||
if (tiles[i] instanceof IPowerReceptor && !(tiles[i] instanceof TileGenericPipe)) {
|
||||
IPowerReceptor receptor = (IPowerReceptor) tiles[i];
|
||||
PowerProvider prov = receptor.getPowerProvider(ForgeDirection.VALID_DIRECTIONS[i].getOpposite());
|
||||
if (prov != null && prov.canAcceptPowerFromPipes) {
|
||||
PowerReceiver prov = receptor.getPowerReceiver(ForgeDirection.VALID_DIRECTIONS[i].getOpposite());
|
||||
if (prov != null && prov.getType().canReceiveFromPipes()) {
|
||||
float request = prov.powerRequest();
|
||||
|
||||
if (request > 0) {
|
||||
|
|
130
common/buildcraft/transport/TileFilteredBuffer.java
Normal file
130
common/buildcraft/transport/TileFilteredBuffer.java
Normal file
|
@ -0,0 +1,130 @@
|
|||
package buildcraft.transport;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
|
||||
public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IOverrideDefaultTriggers {
|
||||
|
||||
private final SimpleInventory inventoryFilters = new SimpleInventory(9, "FilteredBufferFilters", 1);
|
||||
private final SimpleInventory inventoryStorage = new SimpleInventory(9, "FilteredBufferStorage", 64);
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
public IInventory getFilters() {
|
||||
return inventoryFilters;
|
||||
}
|
||||
|
||||
/** IInventory Implementation **/
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventoryStorage.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotId) {
|
||||
return inventoryStorage.getStackInSlot(slotId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotId, int count) {
|
||||
return inventoryStorage.decrStackSize(slotId, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotId) {
|
||||
return inventoryStorage.getStackInSlotOnClosing(slotId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotId, ItemStack itemStack) {
|
||||
inventoryStorage.setInventorySlotContents(slotId, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName() {
|
||||
return inventoryStorage.getInvName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventoryStorage.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityPlayer) {
|
||||
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackValidForSlot(int i, ItemStack itemstack) {
|
||||
|
||||
ItemStack filterItemStack = inventoryFilters.getStackInSlot(i);
|
||||
|
||||
if ( filterItemStack == null || filterItemStack.itemID != itemstack.itemID)
|
||||
return false;
|
||||
|
||||
if (Item.itemsList[itemstack.itemID].isDamageable())
|
||||
return true;
|
||||
|
||||
if (filterItemStack.getItemDamage() == itemstack.getItemDamage())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<ITrigger> getTriggers() {
|
||||
LinkedList<ITrigger> result = new LinkedList<ITrigger>();
|
||||
|
||||
result.add(BuildCraftTransport.triggerInventoryBelow25);
|
||||
result.add(BuildCraftTransport.triggerInventoryBelow50);
|
||||
result.add(BuildCraftTransport.triggerInventoryBelow75);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
|
||||
NBTTagCompound inventoryStorageTag = (NBTTagCompound) nbtTagCompound.getTag("inventoryStorage");
|
||||
inventoryStorage.readFromNBT(inventoryStorageTag);
|
||||
NBTTagCompound inventoryFiltersTag = (NBTTagCompound) nbtTagCompound.getTag("inventoryFilters");
|
||||
inventoryFilters.readFromNBT(inventoryFiltersTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
super.writeToNBT(nbtTagCompound);
|
||||
|
||||
NBTTagCompound inventoryStorageTag = new NBTTagCompound();
|
||||
inventoryStorage.writeToNBT(inventoryStorageTag);
|
||||
nbtTagCompound.setTag("inventoryStorage", inventoryStorageTag);
|
||||
|
||||
NBTTagCompound inventoryFiltersTag = new NBTTagCompound();
|
||||
inventoryFilters.writeToNBT(inventoryFiltersTag);
|
||||
nbtTagCompound.setTag("inventoryFilters", inventoryFiltersTag);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
@ -32,7 +30,8 @@ import buildcraft.api.core.SafeTimeTracker;
|
|||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeEntry;
|
||||
|
@ -73,29 +72,22 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
pipeId = data.readInt();
|
||||
gateKind = data.readInt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private PipeRenderState renderState = new PipeRenderState();
|
||||
private CoreState coreState = new CoreState();
|
||||
private boolean deletePipe = false;
|
||||
|
||||
public TileBuffer[] tileBuffer;
|
||||
public boolean[] pipeConnectionsBuffer = new boolean[6];
|
||||
|
||||
public SafeTimeTracker networkSyncTracker = new SafeTimeTracker();
|
||||
|
||||
public Pipe pipe;
|
||||
private boolean blockNeighborChange = false;
|
||||
private boolean refreshRenderState = false;
|
||||
private boolean pipeBound = false;
|
||||
|
||||
private int[] facadeBlocks = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
||||
private int[] facadeMeta = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
||||
private boolean[] plugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
|
||||
|
||||
public TileGenericPipe() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,13 +148,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
pipe.validate();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean initialized = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(deletePipe){
|
||||
|
||||
if (deletePipe) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
|
@ -189,7 +180,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
refreshRenderState = false;
|
||||
}
|
||||
|
||||
PowerProvider provider = getPowerProvider(null);
|
||||
PowerReceiver provider = getPowerReceiver(null);
|
||||
|
||||
if (provider != null) {
|
||||
provider.update();
|
||||
|
@ -224,23 +215,23 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
renderState.wireMatrix.setWireConnected(color, direction, pipe.isWireConnectedTo(this.getTile(direction), color));
|
||||
}
|
||||
boolean lit = pipe.signalStrength[color.ordinal()] > 0;
|
||||
|
||||
switch(color){
|
||||
case Red:
|
||||
renderState.wireMatrix.setWireIndex(color, lit? WireIconProvider.Texture_Red_Lit : WireIconProvider.Texture_Red_Dark);
|
||||
break;
|
||||
case Blue:
|
||||
renderState.wireMatrix.setWireIndex(color, lit? WireIconProvider.Texture_Blue_Lit : WireIconProvider.Texture_Blue_Dark);
|
||||
break;
|
||||
case Green:
|
||||
renderState.wireMatrix.setWireIndex(color, lit? WireIconProvider.Texture_Green_Lit : WireIconProvider.Texture_Green_Dark);
|
||||
break;
|
||||
case Yellow:
|
||||
renderState.wireMatrix.setWireIndex(color, lit? WireIconProvider.Texture_Yellow_Lit : WireIconProvider.Texture_Yellow_Dark);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
switch (color) {
|
||||
case Red:
|
||||
renderState.wireMatrix.setWireIndex(color, lit ? WireIconProvider.Texture_Red_Lit : WireIconProvider.Texture_Red_Dark);
|
||||
break;
|
||||
case Blue:
|
||||
renderState.wireMatrix.setWireIndex(color, lit ? WireIconProvider.Texture_Blue_Lit : WireIconProvider.Texture_Blue_Dark);
|
||||
break;
|
||||
case Green:
|
||||
renderState.wireMatrix.setWireIndex(color, lit ? WireIconProvider.Texture_Green_Lit : WireIconProvider.Texture_Green_Dark);
|
||||
break;
|
||||
case Yellow:
|
||||
renderState.wireMatrix.setWireIndex(color, lit ? WireIconProvider.Texture_Yellow_Lit : WireIconProvider.Texture_Yellow_Dark);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,10 +246,10 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
}
|
||||
|
||||
//Plugs
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
renderState.plugMatrix.setConnected(direction, plugs[direction.ordinal()]);
|
||||
}
|
||||
|
||||
|
||||
if (renderState.isDirty()) {
|
||||
worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
renderState.clean();
|
||||
|
@ -268,8 +259,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
public void initialize(Pipe pipe) {
|
||||
|
||||
this.blockType = getBlockType();
|
||||
|
||||
if(pipe == null){
|
||||
|
||||
if (pipe == null) {
|
||||
BuildCraftCore.bcLog.log(Level.WARNING, "Pipe failed to initialize at {0},{1},{2}, deleting", new Object[]{xCoord, yCoord, zCoord});
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
return;
|
||||
|
@ -329,17 +320,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
public PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
if (BlockGenericPipe.isValid(pipe) && pipe instanceof IPowerReceptor)
|
||||
return ((IPowerReceptor) pipe).getPowerProvider(null);
|
||||
return ((IPowerReceptor) pipe).getPowerReceiver(null);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (BlockGenericPipe.isValid(pipe) && pipe instanceof IPowerReceptor) {
|
||||
((IPowerReceptor) pipe).doWork(null);
|
||||
((IPowerReceptor) pipe).doWork(workProvider);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,7 +420,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
@Override
|
||||
public void blockRemoved(ForgeDirection from) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -457,21 +447,23 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
|
||||
/**
|
||||
* Checks if this tile is connected to another tile
|
||||
*
|
||||
* @param with - The other Tile
|
||||
* @param side - The orientation to get to the other tile ('with')
|
||||
* @return true if pipes are considered connected
|
||||
*/
|
||||
|
||||
protected boolean arePipesConnected(TileEntity with, ForgeDirection side) {
|
||||
Pipe pipe1 = pipe;
|
||||
|
||||
if (hasPlug(side)) return false;
|
||||
|
||||
if (hasPlug(side))
|
||||
return false;
|
||||
|
||||
if (!BlockGenericPipe.isValid(pipe1))
|
||||
return false;
|
||||
|
||||
if (with instanceof TileGenericPipe) {
|
||||
if (((TileGenericPipe)with).hasPlug(side.getOpposite())) return false;
|
||||
if (((TileGenericPipe) with).hasPlug(side.getOpposite()))
|
||||
return false;
|
||||
Pipe pipe2 = ((TileGenericPipe) with).pipe;
|
||||
|
||||
if (!BlockGenericPipe.isValid(pipe2))
|
||||
|
@ -488,12 +480,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
if (tileBuffer != null) {
|
||||
pipeConnectionsBuffer = new boolean[6];
|
||||
|
||||
for (int i = 0; i < tileBuffer.length; ++i) {
|
||||
TileBuffer t = tileBuffer[i];
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
|
||||
TileBuffer t = tileBuffer[side.ordinal()];
|
||||
t.refresh();
|
||||
|
||||
if (t.getTile() != null) {
|
||||
pipeConnectionsBuffer[i] = arePipesConnected(t.getTile(), ForgeDirection.VALID_DIRECTIONS[i]);
|
||||
pipeConnectionsBuffer[side.ordinal()] = arePipesConnected(t.getTile(), side);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -519,11 +511,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
}
|
||||
}
|
||||
|
||||
/** ITankContainer implementation **/
|
||||
|
||||
/**
|
||||
* ITankContainer implementation *
|
||||
*/
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) {
|
||||
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof ITankContainer)
|
||||
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof ITankContainer && !hasPlug(from))
|
||||
return ((ITankContainer) pipe.transport).fill(from, resource, doFill);
|
||||
else
|
||||
return 0;
|
||||
|
@ -539,7 +532,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof ITankContainer)
|
||||
if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof ITankContainer && !hasPlug(from))
|
||||
return ((ITankContainer) pipe.transport).drain(from, maxDrain, doDrain);
|
||||
else
|
||||
return null;
|
||||
|
@ -587,8 +580,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
return renderState.facadeMatrix.getFacadeBlockId(direction) != 0;
|
||||
return (this.facadeBlocks[direction.ordinal()] != 0);
|
||||
}
|
||||
|
||||
private void dropFacadeItem(ForgeDirection direction){
|
||||
|
||||
private void dropFacadeItem(ForgeDirection direction) {
|
||||
Utils.dropItems(worldObj, ItemFacade.getStack(this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()]), this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
|
@ -604,29 +597,31 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
scheduleRenderUpdate();
|
||||
}
|
||||
|
||||
/** IPipeRenderState implementation **/
|
||||
|
||||
/**
|
||||
* IPipeRenderState implementation *
|
||||
*/
|
||||
@Override
|
||||
public PipeRenderState getRenderState() {
|
||||
return renderState;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIconProvider getPipeIcons() {
|
||||
if (pipe == null) return null;
|
||||
if (pipe == null)
|
||||
return null;
|
||||
return pipe.getIconProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClientState getStateInstance(byte stateId) {
|
||||
switch (stateId) {
|
||||
case 0:
|
||||
return coreState;
|
||||
case 1:
|
||||
return renderState;
|
||||
case 2:
|
||||
return (IClientState) pipe;
|
||||
case 0:
|
||||
return coreState;
|
||||
case 1:
|
||||
return renderState;
|
||||
case 2:
|
||||
return (IClientState) pipe;
|
||||
}
|
||||
throw new RuntimeException("Unknown state requested: " + stateId + " this is a bug!");
|
||||
}
|
||||
|
@ -637,17 +632,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
return;
|
||||
|
||||
switch (stateId) {
|
||||
case 0:
|
||||
if (pipe == null && coreState.pipeId != 0) {
|
||||
initialize(BlockGenericPipe.createPipe(coreState.pipeId));
|
||||
}
|
||||
if (pipe != null && coreState.gateKind != GateKind.None.ordinal()) {
|
||||
if (pipe.gate == null) {
|
||||
pipe.gate = new GateVanilla(pipe);
|
||||
case 0:
|
||||
if (pipe == null && coreState.pipeId != 0) {
|
||||
initialize(BlockGenericPipe.createPipe(coreState.pipeId));
|
||||
}
|
||||
pipe.gate.kind = GateKind.values()[coreState.gateKind];
|
||||
}
|
||||
break;
|
||||
if (pipe != null && coreState.gateKind != GateKind.None.ordinal()) {
|
||||
if (pipe.gate == null) {
|
||||
pipe.gate = new GateVanilla(pipe);
|
||||
}
|
||||
pipe.gate.kind = GateKind.values()[coreState.gateKind];
|
||||
}
|
||||
break;
|
||||
}
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
@ -684,12 +679,15 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
}
|
||||
|
||||
public boolean hasPlug(ForgeDirection forgeDirection) {
|
||||
if (this.worldObj.isRemote)
|
||||
return renderState.plugMatrix.isConnected(forgeDirection);
|
||||
return plugs[forgeDirection.ordinal()];
|
||||
}
|
||||
|
||||
public void removeAndDropPlug(ForgeDirection forgeDirection) {
|
||||
if (!hasPlug(forgeDirection)) return;
|
||||
|
||||
if (!hasPlug(forgeDirection))
|
||||
return;
|
||||
|
||||
plugs[forgeDirection.ordinal()] = false;
|
||||
Utils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord);
|
||||
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
|
||||
|
@ -698,8 +696,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
}
|
||||
|
||||
public boolean addPlug(ForgeDirection forgeDirection) {
|
||||
if (hasPlug(forgeDirection)) return false;
|
||||
|
||||
if (hasPlug(forgeDirection))
|
||||
return false;
|
||||
|
||||
plugs[forgeDirection.ordinal()] = true;
|
||||
worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId());
|
||||
scheduleNeighborChange(); //To force recalculation of connections
|
||||
|
|
|
@ -13,6 +13,7 @@ public class TransportProxy {
|
|||
GameRegistry.registerTileEntity(TileDummyGenericPipe.class, "net.minecraft.src.buildcraft.GenericPipe");
|
||||
GameRegistry.registerTileEntity(TileDummyGenericPipe2.class, "net.minecraft.src.buildcraft.transport.TileGenericPipe");
|
||||
GameRegistry.registerTileEntity(TileGenericPipe.class, "net.minecraft.src.buildcraft.transport.GenericPipe");
|
||||
GameRegistry.registerTileEntity(TileFilteredBuffer.class, "net.minecraft.src.buildcraft.transport.TileFilteredBuffer");
|
||||
}
|
||||
|
||||
public void registerRenderers() {
|
||||
|
|
74
common/buildcraft/transport/gui/ContainerFilteredBuffer.java
Normal file
74
common/buildcraft/transport/gui/ContainerFilteredBuffer.java
Normal file
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* 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
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.gui;
|
||||
|
||||
import buildcraft.core.gui.slots.SlotValidated;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
import buildcraft.core.gui.slots.SlotPhantom;
|
||||
import buildcraft.transport.TileFilteredBuffer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author SandGrainOne
|
||||
*/
|
||||
public class ContainerFilteredBuffer extends BuildCraftContainer {
|
||||
|
||||
private class SlotPhantomLockable extends SlotPhantom {
|
||||
|
||||
final IInventory locks;
|
||||
|
||||
public SlotPhantomLockable(IInventory storage, IInventory locks, int par2, int par3, int par4) {
|
||||
super(storage, par2, par3, par4);
|
||||
this.locks = locks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAdjust() {
|
||||
return locks.getStackInSlot(this.getSlotIndex()) == null;
|
||||
}
|
||||
}
|
||||
IInventory playerInventory;
|
||||
TileFilteredBuffer filteredBuffer;
|
||||
|
||||
public ContainerFilteredBuffer(InventoryPlayer playerInventory, TileFilteredBuffer tile) {
|
||||
super(tile.getSizeInventory());
|
||||
|
||||
this.playerInventory = playerInventory;
|
||||
this.filteredBuffer = tile;
|
||||
|
||||
IInventory filters = tile.getFilters();
|
||||
|
||||
for (int col = 0; col < 9; col++) {
|
||||
// Filtered Buffer filter slots
|
||||
addSlotToContainer(new SlotPhantomLockable(filters, tile, col, 8 + col * 18, 27));
|
||||
// Filtered Buffer inventory slots
|
||||
addSlotToContainer(new SlotValidated(tile, col, 8 + col * 18, 61));
|
||||
}
|
||||
|
||||
// Player inventory
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k1 = 0; k1 < 9; k1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 86 + l * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Player hot bar
|
||||
for (int i1 = 0; i1 < 9; i1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 144));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityPlayer) {
|
||||
return filteredBuffer.isUseableByPlayer(entityPlayer);
|
||||
}
|
||||
}
|
61
common/buildcraft/transport/gui/GuiFilteredBuffer.java
Normal file
61
common/buildcraft/transport/gui/GuiFilteredBuffer.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* 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
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.TileFilteredBuffer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author SandGrainOne
|
||||
*/
|
||||
public class GuiFilteredBuffer extends GuiContainer {
|
||||
|
||||
IInventory playerInventory;
|
||||
TileFilteredBuffer filteredBuffer;
|
||||
|
||||
public GuiFilteredBuffer(InventoryPlayer playerInventory, TileFilteredBuffer filteredBuffer) {
|
||||
super(new ContainerFilteredBuffer(playerInventory, filteredBuffer));
|
||||
|
||||
this.playerInventory = playerInventory;
|
||||
this.filteredBuffer = filteredBuffer;
|
||||
xSize = 175;
|
||||
ySize = 169;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/filteredBuffer_gui.png");
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
|
||||
|
||||
IInventory filters = filteredBuffer.getFilters();
|
||||
|
||||
for (int col = 0; col < filters.getSizeInventory(); col++) {
|
||||
if (filters.getStackInSlot(col) == null) {
|
||||
drawTexturedModalRect(cornerX + 7 + col * 18, cornerY + 60, 176, 0, 18, 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
String title = StringUtils.localize("tile.filteredBufferBlock");
|
||||
int xPos = (xSize - fontRenderer.getStringWidth(title)) / 2;
|
||||
fontRenderer.drawString(title, xPos, 10, 0x404040);
|
||||
}
|
||||
}
|
|
@ -77,11 +77,11 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISpecialInventory
|
|||
|
||||
/* ISELECTIVEINVENTORY */
|
||||
if (inventory instanceof ISelectiveInventory) {
|
||||
ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerProvider.getEnergyStored());
|
||||
ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerHandler.getEnergyStored());
|
||||
if (doRemove) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack != null) {
|
||||
powerProvider.useEnergy(stack.stackSize, stack.stackSize, true);
|
||||
powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
|
||||
}
|
||||
}
|
||||
incrementFilter();
|
||||
|
@ -90,7 +90,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISpecialInventory
|
|||
|
||||
/* ISPECIALINVENTORY */
|
||||
} else if (inventory instanceof ISpecialInventory) {
|
||||
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) powerProvider.getEnergyStored());
|
||||
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) powerHandler.getEnergyStored());
|
||||
if (stacks != null) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if(stack == null)
|
||||
|
@ -109,10 +109,10 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISpecialInventory
|
|||
}
|
||||
}
|
||||
if (doRemove) {
|
||||
stacks = ((ISpecialInventory) inventory).extractItem(true, from, (int) powerProvider.getEnergyStored());
|
||||
stacks = ((ISpecialInventory) inventory).extractItem(true, from, (int) powerHandler.getEnergyStored());
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack != null) {
|
||||
powerProvider.useEnergy(stack.stackSize, stack.stackSize, true);
|
||||
powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISpecialInventory
|
|||
}
|
||||
if (doRemove) {
|
||||
incrementFilter();
|
||||
return inventory.decrStackSize(i, (int) powerProvider.useEnergy(1, stack.stackSize, true));
|
||||
return inventory.decrStackSize(i, (int) powerHandler.useEnergy(1, stack.stackSize, true));
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@ import buildcraft.BuildCraftTransport;
|
|||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.transport.IPipedItem;
|
||||
import buildcraft.core.EntityPassiveItem;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
@ -36,7 +38,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
||||
|
||||
private PowerProvider powerProvider;
|
||||
private PowerHandler powerHandler;
|
||||
|
||||
private int[] entitiesDropped;
|
||||
private int entitiesDroppedIndex = 0;
|
||||
|
@ -50,9 +52,9 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
|||
entitiesDropped[i] = -1;
|
||||
}
|
||||
|
||||
powerProvider = new PowerProvider(this);
|
||||
powerProvider.configure(1, 64, 1, 256);
|
||||
powerProvider.configurePowerPerdition(1, 1);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
powerHandler.configure(1, 64, 1, 256);
|
||||
powerHandler.configurePowerPerdition(1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,12 +146,12 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
for (int j = 1; j < 5; ++j)
|
||||
if (trySucc(j))
|
||||
return;
|
||||
|
||||
powerProvider.useEnergy(1, 1, true);
|
||||
powerHandler.useEnergy(1, 1, true);
|
||||
}
|
||||
|
||||
private boolean trySucc(int distance) {
|
||||
|
@ -174,7 +176,7 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
|||
EntityMinecartChest cart = (EntityMinecartChest) list.get(g);
|
||||
if (!cart.isDead) {
|
||||
ItemStack stack = checkExtractGeneric(cart, true, getOpenOrientation());
|
||||
if (stack != null && powerProvider.useEnergy(1, 1, true) == 1) {
|
||||
if (stack != null && powerHandler.useEnergy(1, 1, true) == 1) {
|
||||
EntityItem entityitem = new EntityItem(worldObj, cart.posX, cart.posY + 0.3F, cart.posZ, stack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
worldObj.spawnEntityInWorld(entityitem);
|
||||
|
@ -223,7 +225,7 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
|||
|
||||
CoreProxy.proxy.obsidianPipePickup(worldObj, item, this.container);
|
||||
|
||||
float energyUsed = powerProvider.useEnergy(distance, contained.stackSize * distance, true);
|
||||
float energyUsed = powerHandler.useEnergy(distance, contained.stackSize * distance, true);
|
||||
|
||||
if (distance == 0 || energyUsed / distance == contained.stackSize) {
|
||||
stack = contained;
|
||||
|
@ -239,7 +241,7 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
|||
speed = 0.01;
|
||||
}
|
||||
} else if (entity instanceof EntityArrow) {
|
||||
powerProvider.useEnergy(distance, distance, true);
|
||||
powerHandler.useEnergy(distance, distance, true);
|
||||
stack = new ItemStack(Item.arrow, 1);
|
||||
CoreProxy.proxy.removeEntity(entity);
|
||||
}
|
||||
|
@ -276,15 +278,15 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
|||
if (item.entityId == entitiesDropped[i])
|
||||
return false;
|
||||
|
||||
return powerProvider.useEnergy(1, distance, false) >= distance;
|
||||
return powerHandler.useEnergy(1, distance, false) >= distance;
|
||||
} else if (entity instanceof EntityArrow)
|
||||
return powerProvider.useEnergy(1, distance, false) >= distance;
|
||||
return powerHandler.useEnergy(1, distance, false) >= distance;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,14 +11,15 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.inventory.ISpecialInventory;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.transport.IPipedItem;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.core.EntityPassiveItem;
|
||||
|
@ -32,16 +33,16 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class PipeItemsWood extends Pipe implements IPowerReceptor {
|
||||
|
||||
protected PowerProvider powerProvider;
|
||||
protected PowerHandler powerHandler;
|
||||
protected int standardIconIndex = PipeIconProvider.TYPE.PipeItemsWood_Standard.ordinal();
|
||||
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllWood_Solid.ordinal();
|
||||
|
||||
protected PipeItemsWood(PipeTransportItems transport, PipeLogic logic, int itemID) {
|
||||
super(transport, logic, itemID);
|
||||
|
||||
powerProvider = new PowerProvider(this, false);
|
||||
powerProvider.configure(1, 64, 1, 64);
|
||||
powerProvider.configurePowerPerdition(0, 0);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
powerHandler.configure(1, 64, 1, 64);
|
||||
powerHandler.configurePowerPerdition(0, 0);
|
||||
}
|
||||
|
||||
protected PipeItemsWood(int itemID, PipeTransportItems transport) {
|
||||
|
@ -73,17 +74,17 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
if (powerProvider.getEnergyStored() <= 0)
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (powerHandler.getEnergyStored() <= 0)
|
||||
return;
|
||||
|
||||
extractItems();
|
||||
powerProvider.setEnergy(0);
|
||||
powerHandler.setEnergy(0);
|
||||
}
|
||||
|
||||
private void extractItems() {
|
||||
|
@ -108,7 +109,7 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
|
|||
|
||||
for (ItemStack stack : extracted) {
|
||||
if (stack == null || stack.stackSize == 0) {
|
||||
powerProvider.useEnergy(1, 1, true);
|
||||
powerHandler.useEnergy(1, 1, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -132,11 +133,11 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
|
|||
|
||||
/* ISPECIALINVENTORY */
|
||||
if (inventory instanceof ISpecialInventory) {
|
||||
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(doRemove, from, (int) powerProvider.getEnergyStored());
|
||||
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(doRemove, from, (int) powerHandler.getEnergyStored());
|
||||
if (stacks != null && doRemove) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack != null) {
|
||||
powerProvider.useEnergy(stack.stackSize, stack.stackSize, true);
|
||||
powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +165,7 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
|
|||
|
||||
if (slot != null && slot.stackSize > 0 && inventory.canExtractItem(k, slot, from.ordinal())) {
|
||||
if (doRemove) {
|
||||
return inventory.decrStackSize(k, (int) powerProvider.useEnergy(1, slot.stackSize, true));
|
||||
return inventory.decrStackSize(k, (int) powerHandler.useEnergy(1, slot.stackSize, true));
|
||||
} else {
|
||||
return slot;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ import buildcraft.BuildCraftTransport;
|
|||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.core.network.TileNetworkData;
|
||||
import buildcraft.transport.Pipe;
|
||||
|
@ -32,7 +34,7 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
|
|||
public @TileNetworkData
|
||||
int liquidToExtract;
|
||||
|
||||
private PowerProvider powerProvider;
|
||||
private PowerHandler powerHandler;
|
||||
|
||||
protected int standardIconIndex = PipeIconProvider.TYPE.PipeLiquidsWood_Standard.ordinal();
|
||||
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllWood_Solid.ordinal();
|
||||
|
@ -47,17 +49,17 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
|
|||
protected PipeLiquidsWood(PipeLogic logic, int itemID) {
|
||||
super(new PipeTransportLiquids(), logic, itemID);
|
||||
|
||||
powerProvider = new PowerProvider(this, false);
|
||||
powerProvider.configure(1, 100, 1, 250);
|
||||
powerProvider.configurePowerPerdition(0, 0);
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
powerHandler.configure(1, 100, 1, 250);
|
||||
powerHandler.configurePowerPerdition(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts a random piece of item outside of a nearby chest.
|
||||
*/
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
if (powerProvider.getEnergyStored() <= 0)
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (powerHandler.getEnergyStored() <= 0)
|
||||
return;
|
||||
|
||||
World w = worldObj;
|
||||
|
@ -76,15 +78,15 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
|
|||
return;
|
||||
|
||||
if (liquidToExtract <= LiquidContainerRegistry.BUCKET_VOLUME) {
|
||||
liquidToExtract += powerProvider.useEnergy(1, 1, true) * LiquidContainerRegistry.BUCKET_VOLUME;
|
||||
liquidToExtract += powerHandler.useEnergy(1, 1, true) * LiquidContainerRegistry.BUCKET_VOLUME;
|
||||
}
|
||||
}
|
||||
powerProvider.useEnergy(1, 1, true);
|
||||
powerHandler.useEnergy(1, 1, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,9 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportPower;
|
||||
|
@ -21,7 +23,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
public class PipePowerWood extends Pipe implements IPowerReceptor {
|
||||
|
||||
private PowerProvider powerProvider;
|
||||
private PowerHandler powerHandler;
|
||||
protected int standardIconIndex = PipeIconProvider.TYPE.PipePowerWood_Standard.ordinal();
|
||||
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllWood_Solid.ordinal();
|
||||
private boolean[] powerSources = new boolean[6];
|
||||
|
@ -30,14 +32,14 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
public PipePowerWood(int itemID) {
|
||||
super(new PipeTransportPower(), new PipeLogicWood(), itemID);
|
||||
|
||||
powerProvider = new PowerProvider(this, false);
|
||||
powerHandler = new PowerHandler(this, Type.PIPE);
|
||||
initPowerProvider();
|
||||
((PipeTransportPower) transport).initFromPipe(getClass());
|
||||
}
|
||||
|
||||
private void initPowerProvider() {
|
||||
powerProvider.configure(2, 1000, 1, 1500);
|
||||
powerProvider.configurePowerPerdition(1, 10);
|
||||
powerHandler.configure(2, 1000, 1, 1500);
|
||||
powerHandler.configurePowerPerdition(1, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,13 +63,12 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PowerProvider getPowerProvider(ForgeDirection side) {
|
||||
return powerProvider;
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerProvider workProvider) {
|
||||
// TODO Auto-generated method stub
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +77,7 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
if (worldObj.isRemote)
|
||||
return;
|
||||
|
||||
if (powerProvider.getEnergyStored() <= 0)
|
||||
if (powerHandler.getEnergyStored() <= 0)
|
||||
return;
|
||||
|
||||
int sources = 0;
|
||||
|
@ -85,7 +86,7 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
powerSources[o.ordinal()] = false;
|
||||
continue;
|
||||
}
|
||||
if (powerProvider.isPowerSource(o)) {
|
||||
if (powerHandler.isPowerSource(o)) {
|
||||
powerSources[o.ordinal()] = true;
|
||||
}
|
||||
if (powerSources[o.ordinal()]) {
|
||||
|
@ -98,10 +99,10 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
|
||||
float energyToRemove;
|
||||
|
||||
if (powerProvider.getEnergyStored() > 40) {
|
||||
energyToRemove = powerProvider.getEnergyStored() / 40 + 4;
|
||||
} else if (powerProvider.getEnergyStored() > 10) {
|
||||
energyToRemove = powerProvider.getEnergyStored() / 10;
|
||||
if (powerHandler.getEnergyStored() > 40) {
|
||||
energyToRemove = powerHandler.getEnergyStored() / 40 + 4;
|
||||
} else if (powerHandler.getEnergyStored() > 10) {
|
||||
energyToRemove = powerHandler.getEnergyStored() / 10;
|
||||
} else {
|
||||
energyToRemove = 1;
|
||||
}
|
||||
|
@ -113,37 +114,37 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
|
|||
if (!powerSources[o.ordinal()])
|
||||
continue;
|
||||
|
||||
float energyUsable = powerProvider.useEnergy(0, energyToRemove, false);
|
||||
float energyUsable = powerHandler.useEnergy(0, energyToRemove, false);
|
||||
|
||||
float energySend = trans.receiveEnergy(o, energyUsable);
|
||||
if (energySend > 0) {
|
||||
powerProvider.useEnergy(0, energySend, true);
|
||||
powerHandler.useEnergy(0, energySend, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean requestsPower() {
|
||||
if (full) {
|
||||
boolean request = powerProvider.getEnergyStored() < powerProvider.getMaxEnergyStored() / 2;
|
||||
boolean request = powerHandler.getEnergyStored() < powerHandler.getMaxEnergyStored() / 2;
|
||||
if (request) {
|
||||
full = false;
|
||||
}
|
||||
return request;
|
||||
}
|
||||
full = powerProvider.getEnergyStored() >= powerProvider.getMaxEnergyStored() - 10;
|
||||
full = powerHandler.getEnergyStored() >= powerHandler.getMaxEnergyStored() - 10;
|
||||
return !full;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
powerProvider.writeToNBT(data);
|
||||
powerHandler.writeToNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
powerProvider.readFromNBT(data);
|
||||
powerHandler.readFromNBT(data);
|
||||
initPowerProvider();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,14 +13,24 @@ import buildcraft.BuildCraftTransport;
|
|||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.ItemFacade;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class FacadeItemRenderer implements IItemRenderer {
|
||||
|
||||
private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
|
||||
|
||||
|
||||
int decodedMeta = ItemFacade.getMetaData(item);
|
||||
int decodedBlockId = ItemFacade.getBlockId(item);
|
||||
|
||||
try {
|
||||
int color = Item.itemsList[decodedBlockId].getColorFromItemStack(new ItemStack(decodedBlockId, 1, decodedMeta), 0);
|
||||
float r = (float) (color >> 16 & 0xff) / 255F;
|
||||
float g = (float) (color >> 8 & 0xff) / 255F;
|
||||
float b = (float) (color & 0xff) / 255F;
|
||||
GL11.glColor4f(r, g, b, 1.0F);
|
||||
} catch (Throwable error) {
|
||||
}
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
Block block = Block.blocksList[decodedBlockId];
|
||||
|
@ -100,14 +110,14 @@ public class FacadeItemRenderer implements IItemRenderer {
|
|||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
return true;
|
||||
case EQUIPPED:
|
||||
return true;
|
||||
case INVENTORY:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case ENTITY:
|
||||
return true;
|
||||
case EQUIPPED:
|
||||
return true;
|
||||
case INVENTORY:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,19 +130,18 @@ public class FacadeItemRenderer implements IItemRenderer {
|
|||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
GL11.glScalef(0.50F, 0.50F, 0.50F);
|
||||
renderFacadeItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F);
|
||||
break;
|
||||
case EQUIPPED:
|
||||
renderFacadeItem((RenderBlocks) data[0], item, 0F, 0F, 0f);
|
||||
break;
|
||||
case INVENTORY:
|
||||
GL11.glScalef(1.1F, 1.1F, 1.1F);
|
||||
renderFacadeItem((RenderBlocks) data[0], item, -0.3f, -0.35f, -0.7f);
|
||||
break;
|
||||
default:
|
||||
case ENTITY:
|
||||
GL11.glScalef(0.50F, 0.50F, 0.50F);
|
||||
renderFacadeItem((RenderBlocks) data[0], item, -0.6F, 0f, -0.6F);
|
||||
break;
|
||||
case EQUIPPED:
|
||||
renderFacadeItem((RenderBlocks) data[0], item, 0F, 0F, 0f);
|
||||
break;
|
||||
case INVENTORY:
|
||||
GL11.glScalef(1.1F, 1.1F, 1.1F);
|
||||
renderFacadeItem((RenderBlocks) data[0], item, -0.3f, -0.35f, -0.7f);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,11 +10,14 @@ import buildcraft.api.core.IIconProvider;
|
|||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.api.transport.IPipe.WireColor;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.IPipeRenderState;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeRenderState;
|
||||
import buildcraft.transport.TransportProxy;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
|
@ -32,11 +35,11 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* Shifts the coordinates around effectivly rotating something. Zero state is DOWN then -> NORTH -> WEST Note - To obtain Pos, do a mirrorY() before
|
||||
* Shifts the coordinates around effectivly rotating something. Zero state
|
||||
* is DOWN then -> NORTH -> WEST Note - To obtain Pos, do a mirrorY() before
|
||||
* rotating
|
||||
*
|
||||
* @param targetArray
|
||||
* the array that should be rotated
|
||||
* @param targetArray the array that should be rotated
|
||||
*/
|
||||
private void rotate(float[][] targetArray) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
@ -48,8 +51,7 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param targetArray
|
||||
* the array that should be transformed
|
||||
* @param targetArray the array that should be transformed
|
||||
* @param direction
|
||||
*/
|
||||
private void transform(float[][] targetArray, ForgeDirection direction) {
|
||||
|
@ -65,8 +67,7 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
/**
|
||||
* Clones both dimensions of a float[][]
|
||||
*
|
||||
* @param source
|
||||
* the float[][] to deepClone
|
||||
* @param source the float[][] to deepClone
|
||||
* @return
|
||||
*/
|
||||
private float[][] deepClone(float[][] source) {
|
||||
|
@ -84,7 +85,8 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
|
||||
PipeRenderState state = renderState.getRenderState();
|
||||
IIconProvider icons = renderState.getPipeIcons();
|
||||
if (icons == null) return;
|
||||
if (icons == null)
|
||||
return;
|
||||
|
||||
|
||||
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
|
||||
|
@ -182,25 +184,28 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
zeroState[2][1] = 1.0F;
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (state.facadeMatrix.getFacadeBlockId(direction) != 0) {
|
||||
Block renderBlock = Block.blocksList[state.facadeMatrix.getFacadeBlockId(direction)];
|
||||
int renderMeta = state.facadeMatrix.getFacadeMetaId(direction);
|
||||
state.currentTexture = renderBlock.getIcon(direction.ordinal(), renderMeta);
|
||||
int facadeId = state.facadeMatrix.getFacadeBlockId(direction);
|
||||
if (facadeId != 0) {
|
||||
Block renderBlock = Block.blocksList[facadeId];
|
||||
int renderMeta = state.facadeMatrix.getFacadeMetaId(direction);
|
||||
state.currentTexture = renderBlock.getIcon(direction.ordinal(), renderMeta);
|
||||
|
||||
if (renderBlock.getRenderType() == 31) {
|
||||
if ((renderMeta & 12) == 4)
|
||||
{
|
||||
renderblocks.uvRotateEast = 1;
|
||||
renderblocks.uvRotateWest = 1;
|
||||
renderblocks.uvRotateTop = 1;
|
||||
renderblocks.uvRotateBottom = 1;
|
||||
}
|
||||
else if ((renderMeta & 12) == 8)
|
||||
{
|
||||
renderblocks.uvRotateSouth = 1;
|
||||
renderblocks.uvRotateNorth = 1;
|
||||
}
|
||||
}
|
||||
try {
|
||||
BlockGenericPipe.facadeRenderColor = Item.itemsList[state.facadeMatrix.getFacadeBlockId(direction)].getColorFromItemStack(new ItemStack(facadeId, 1, renderMeta), 0);
|
||||
} catch (Throwable error) {
|
||||
}
|
||||
|
||||
if (renderBlock.getRenderType() == 31) {
|
||||
if ((renderMeta & 12) == 4) {
|
||||
renderblocks.uvRotateEast = 1;
|
||||
renderblocks.uvRotateWest = 1;
|
||||
renderblocks.uvRotateTop = 1;
|
||||
renderblocks.uvRotateBottom = 1;
|
||||
} else if ((renderMeta & 12) == 8) {
|
||||
renderblocks.uvRotateSouth = 1;
|
||||
renderblocks.uvRotateNorth = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Hollow facade
|
||||
if (state.pipeConnectionMatrix.isConnected(direction)) {
|
||||
|
@ -246,15 +251,17 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (renderBlock.getRenderType() == 31) {
|
||||
renderblocks.uvRotateSouth = 0;
|
||||
renderblocks.uvRotateEast = 0;
|
||||
renderblocks.uvRotateWest = 0;
|
||||
renderblocks.uvRotateNorth = 0;
|
||||
renderblocks.uvRotateTop = 0;
|
||||
renderblocks.uvRotateBottom = 0;
|
||||
}
|
||||
if (renderBlock.getRenderType() == 31) {
|
||||
renderblocks.uvRotateSouth = 0;
|
||||
renderblocks.uvRotateEast = 0;
|
||||
renderblocks.uvRotateWest = 0;
|
||||
renderblocks.uvRotateNorth = 0;
|
||||
renderblocks.uvRotateTop = 0;
|
||||
renderblocks.uvRotateBottom = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BlockGenericPipe.facadeRenderColor = -1;
|
||||
}
|
||||
|
||||
// X START - END
|
||||
|
@ -310,14 +317,14 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
}
|
||||
|
||||
// X START - END
|
||||
zeroState[0][0] = 0.25F + 0.125F/2 + zFightOffset;
|
||||
zeroState[0][1] = 0.75F - 0.125F/2 + zFightOffset;
|
||||
zeroState[0][0] = 0.25F + 0.125F / 2 + zFightOffset;
|
||||
zeroState[0][1] = 0.75F - 0.125F / 2 + zFightOffset;
|
||||
// Y START - END
|
||||
zeroState[1][0] = 0.25F;
|
||||
zeroState[1][1] = 0.25F + 0.125F;
|
||||
// Z START - END
|
||||
zeroState[2][0] = 0.25F + 0.125F/2;
|
||||
zeroState[2][1] = 0.75F - 0.125F/2;
|
||||
zeroState[2][0] = 0.25F + 0.125F / 2;
|
||||
zeroState[2][1] = 0.75F - 0.125F / 2;
|
||||
|
||||
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe
|
||||
|
||||
|
@ -503,14 +510,13 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction){
|
||||
private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) {
|
||||
return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) == 0 && !state.plugMatrix.isConnected(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* 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
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.triggers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.core.triggers.ActionTriggerIconProvider;
|
||||
import buildcraft.core.triggers.BCTrigger;
|
||||
import buildcraft.transport.TileFilteredBuffer;
|
||||
|
||||
public class TriggerFilteredBufferInventoryLevel extends BCTrigger {
|
||||
|
||||
public enum State {
|
||||
Below25, Below50, Below75
|
||||
};
|
||||
|
||||
public State state;
|
||||
|
||||
public TriggerFilteredBufferInventoryLevel(int id, State state) {
|
||||
super(id);
|
||||
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
switch (state) {
|
||||
case Below25:
|
||||
return "Contains < 25%";
|
||||
case Below50:
|
||||
return "Contains < 50%";
|
||||
default:
|
||||
return "Contains < 75%";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) {
|
||||
if (tile instanceof TileFilteredBuffer) {
|
||||
|
||||
// A parameter is required
|
||||
if (parameter == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileFilteredBuffer filteredBuffer = (TileFilteredBuffer) tile;
|
||||
ItemStack searchStack = parameter.getItem();
|
||||
|
||||
int foundStackCount = 0;
|
||||
int foundItemCount = 0;
|
||||
|
||||
IInventory filters = filteredBuffer.getFilters();
|
||||
|
||||
for (int i = 0 ; i < filters.getSizeInventory() ; i++) {
|
||||
ItemStack filterStack = filters.getStackInSlot(i);
|
||||
|
||||
if (filterStack != null && filterStack.isItemEqual(searchStack)) {
|
||||
ItemStack foundStack = filteredBuffer.getStackInSlot(i);
|
||||
|
||||
if(foundStack != null)
|
||||
foundItemCount += foundStack.stackSize;
|
||||
|
||||
foundStackCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundStackCount > 0) {
|
||||
float percentage = (float)foundItemCount / ((float)foundStackCount * (float)searchStack.getMaxStackSize());
|
||||
|
||||
switch (state) {
|
||||
case Below25:
|
||||
return percentage < 0.25f;
|
||||
case Below50:
|
||||
return percentage < 0.5f;
|
||||
default:
|
||||
return percentage < 0.75f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconIndex() {
|
||||
switch (state) {
|
||||
case Below25:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Below25;
|
||||
case Below50:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Below50;
|
||||
default:
|
||||
return ActionTriggerIconProvider.Trigger_Inventory_Below75;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue