parent
3c84c34bd9
commit
daf79abda5
3 changed files with 164 additions and 8 deletions
|
@ -36,6 +36,7 @@ import java.util.HashSet;
|
|||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -59,7 +60,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
private TileBuffer[] tileBuffer = null;
|
||||
private SafeTimeTracker timer = new SafeTimeTracker();
|
||||
private int tick = Utils.RANDOM.nextInt();
|
||||
private int numFluidBlocksFound = 0;
|
||||
private int numFluidBlocksFound = 0;
|
||||
|
||||
public TilePump() {
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
|
@ -82,8 +83,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
pushToConsumers();
|
||||
|
||||
if (tube.posY - aimY > 0.01) {
|
||||
|
@ -124,7 +125,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
if (isPumpableFluid(xCoord, y, zCoord)) {
|
||||
aimY = y;
|
||||
return;
|
||||
} else if (!worldObj.isAirBlock(xCoord, y, zCoord)) {
|
||||
} else if (isBlocked(xCoord, y, zCoord)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -133,8 +134,13 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isBlocked(int x, int y, int z) {
|
||||
Material mat = worldObj.getBlockMaterial(x, y, z);
|
||||
return mat.blocksMovement();
|
||||
}
|
||||
|
||||
private void pushToConsumers() {
|
||||
if(tileBuffer == null)
|
||||
if (tileBuffer == null)
|
||||
tileBuffer = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false);
|
||||
FluidUtils.pushFluidToConsumers(tank, 400, tileBuffer);
|
||||
}
|
||||
|
@ -232,7 +238,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
queueForPumping(index.x - 1, index.y, index.z, visitedBlocks, fluidsFound, pumpingFluid);
|
||||
queueForPumping(index.x, index.y, index.z + 1, visitedBlocks, fluidsFound, pumpingFluid);
|
||||
queueForPumping(index.x, index.y, index.z - 1, visitedBlocks, fluidsFound, pumpingFluid);
|
||||
|
||||
|
||||
if (pumpingFluid == FluidRegistry.WATER && !BuildCraftCore.consumeWaterSources && numFluidBlocksFound >= 9)
|
||||
return;
|
||||
|
||||
|
@ -265,6 +271,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
return false;
|
||||
if (!isFluidAllowed(fluid))
|
||||
return false;
|
||||
if (tank.getAcceptedFluid() != null && tank.getAcceptedFluid() != fluid)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -315,11 +323,11 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
|
|||
@Override
|
||||
public boolean isActive() {
|
||||
BlockIndex next = getNextIndexToPump(false);
|
||||
|
||||
|
||||
if (next != null) {
|
||||
return isPumpableFluid(next.x, next.y, next.z);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
107
common/buildcraft/transport/pipes/PipePowerIron.java
Normal file
107
common/buildcraft/transport/pipes/PipePowerIron.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* BuildCraft is open-source. It is distributed under the terms of the
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile or
|
||||
* run the code. It does *NOT* grant the right to redistribute this software or
|
||||
* its modifications in any form, binary or source, except if expressively
|
||||
* granted by the copyright holder.
|
||||
*/
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportPower;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipePowerIron extends Pipe<PipeTransportPower> {
|
||||
|
||||
public static enum PowerMode {
|
||||
|
||||
M2(2), M4(4), M8(8), M16(16), M32(32), M64(64), M128(128);
|
||||
public static final PowerMode[] VALUES = values();
|
||||
private final int maxPower;
|
||||
|
||||
private PowerMode(int max) {
|
||||
this.maxPower = max;
|
||||
}
|
||||
|
||||
public PowerMode getNext() {
|
||||
PowerMode next = VALUES[(ordinal() + 1) % (VALUES.length - 1)];
|
||||
return next;
|
||||
}
|
||||
|
||||
public PowerMode getPrevious() {
|
||||
PowerMode previous = VALUES[(ordinal() + VALUES.length - 2) % (VALUES.length - 1)];
|
||||
return previous;
|
||||
}
|
||||
|
||||
public static PowerMode fromId(int id) {
|
||||
if (id < 0 || id >= VALUES.length) {
|
||||
return M128;
|
||||
}
|
||||
return VALUES[id];
|
||||
}
|
||||
}
|
||||
|
||||
public PipePowerIron(int itemID) {
|
||||
super(new PipeTransportPower(), itemID);
|
||||
transport.initFromPipe(getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconIndex(ForgeDirection direction) {
|
||||
if (container == null)
|
||||
return PipeIconProvider.TYPE.PipePowerIronM128.ordinal();
|
||||
return PipeIconProvider.TYPE.PipePowerIronM2.ordinal() + container.getBlockMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer player) {
|
||||
Item equipped = player.getCurrentEquippedItem() != null ? player.getCurrentEquippedItem().getItem() : null;
|
||||
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, container.xCoord, container.yCoord, container.zCoord)) {
|
||||
if (player.isSneaking()) {
|
||||
setMode(getMode().getPrevious());
|
||||
} else {
|
||||
setMode(getMode().getNext());
|
||||
}
|
||||
player.addChatMessage(String.format(StringUtils.localize("chat.pipe.power.iron.mode"), getMode().maxPower));
|
||||
|
||||
((IToolWrench) equipped).wrenchUsed(player, container.xCoord, container.yCoord, container.zCoord);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
transport.maxPower = getMode().maxPower;
|
||||
}
|
||||
|
||||
public PowerMode getMode() {
|
||||
return PowerMode.fromId(container.getBlockMetadata());
|
||||
}
|
||||
|
||||
public void setMode(PowerMode mode) {
|
||||
if (mode.ordinal() != container.getBlockMetadata()) {
|
||||
container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, mode.ordinal(), 3);
|
||||
container.scheduleRenderUpdate();
|
||||
container.markBlockForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIconProvider getIconProvider() {
|
||||
return BuildCraftTransport.instance.pipeIconProvider;
|
||||
}
|
||||
}
|
41
common/buildcraft/transport/triggers/ActionPowerLimiter.java
Normal file
41
common/buildcraft/transport/triggers/ActionPowerLimiter.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* 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 buildcraft.core.triggers.BCAction;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class ActionPipeDirection extends BCAction {
|
||||
|
||||
private Icon icon;
|
||||
public final ForgeDirection direction;
|
||||
|
||||
public ActionPipeDirection(int id, ForgeDirection direction) {
|
||||
super(id, "buildcraft.pipe.dir." + direction.name().toLowerCase(Locale.ENGLISH));
|
||||
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return direction.name().substring(0, 1) + direction.name().substring(1).toLowerCase(Locale.ENGLISH) + " Pipe Direction";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:triggers/trigger_dir_" + direction.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue