use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class ActionWrapper method getPossible.
@Override
public ActionWrapper[] getPossible() {
IStatement[] possible = delegate.getPossible();
boolean andSides = sourcePart != EnumPipePart.CENTER;
List<ActionWrapper> list = new ArrayList<>(possible.length + 5);
for (int i = 0; i < possible.length; i++) {
list.add(wrap(possible[i], sourcePart.face));
}
if (andSides) {
EnumPipePart part = sourcePart;
for (int j = 0; j < 5; j++) {
int i = j + possible.length;
part = part.next();
ActionWrapper action = wrap(delegate, part.face);
if (true) {
// TODO: Check the gui container to see if this is a valid action!
list.add(action);
}
}
}
return list.toArray(new ActionWrapper[0]);
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class PipeItemsStripes method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
if (container.getWorld().isRemote) {
return;
}
if (battery.getEnergyStored() >= 10) {
EnumPipePart o = actionDir;
if (o == EnumPipePart.CENTER) {
o = EnumPipePart.fromFacing(getOpenOrientation());
}
if (o != EnumPipePart.CENTER) {
Vec3d vec = Utils.convert(container.getPos()).add(Utils.convert(o.face));
BlockPos veci = Utils.convertFloor(vec);
if (!BlockUtil.isUnbreakableBlock(getWorld(), Utils.convertFloor(vec))) {
IBlockState state = getWorld().getBlockState(Utils.convertFloor(vec));
Block block = state.getBlock();
if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
return;
}
ItemStack stack = new ItemStack(block, 1, block.getMetaFromState(state));
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(), veci).get();
if (battery.useEnergy(10, 10, false) != 10) {
return;
}
for (IStripesHandler handler : PipeManager.stripesHandlers) {
if (handler.getType() == StripesHandlerType.BLOCK_BREAK && handler.shouldHandle(stack)) {
if (handler.handle(getWorld(), veci, o.face, stack, player, this)) {
return;
}
}
}
List<ItemStack> stacks = block.getDrops(getWorld(), veci, state, 0);
if (stacks != null) {
for (ItemStack s : stacks) {
if (s != null) {
sendItem(s, o.opposite().face);
}
}
}
getWorld().setBlockToAir(veci);
}
}
return;
}
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class PipeLogicWood method switchSource.
private void switchSource() {
int meta = pipe.container.getBlockMetadata();
EnumPipePart oldFacing = EnumPipePart.fromMeta(meta);
EnumPipePart newFacing = oldFacing.next();
if (oldFacing == EnumPipePart.CENTER) {
oldFacing = oldFacing.next();
}
boolean first = true;
while (oldFacing != newFacing || first) {
first = false;
if (setSource(newFacing)) {
return;
}
newFacing = newFacing.next();
}
setSource(EnumPipePart.CENTER);
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class PipeFlowFluids method writeToNbt.
@Override
public NBTTagCompound writeToNbt() {
NBTTagCompound nbt = super.writeToNbt();
if (currentFluid != null) {
NBTTagCompound fluidTag = new NBTTagCompound();
currentFluid.writeToNBT(fluidTag);
nbt.setTag("fluid", fluidTag);
for (EnumPipePart part : EnumPipePart.VALUES) {
int direction = part.getIndex();
NBTTagCompound subTag = new NBTTagCompound();
sections.get(part).writeToNbt(subTag);
nbt.setTag("tank[" + direction + "]", subTag);
}
}
return nbt;
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class PipeFlowFluids method onTick.
@Override
public void onTick() {
World world = pipe.getHolder().getPipeWorld();
if (world.isRemote) {
for (EnumPipePart part : EnumPipePart.VALUES) {
sections.get(part).tickClient();
}
return;
}
if (currentFluid != null) {
// int timeSlot = (int) (world.getTotalWorldTime() % currentDelay);
int totalFluid = 0;
boolean canOutput = false;
for (EnumPipePart part : EnumPipePart.VALUES) {
Section section = sections.get(part);
section.currentTime = (section.currentTime + 1) % currentDelay;
section.advanceForMovement();
totalFluid += section.amount;
if (section.getCurrentDirection().canOutput()) {
canOutput = true;
}
}
if (totalFluid == 0) {
setFluid(null);
} else {
if (canOutput) {
moveFromPipe();
}
moveFromCenter();
moveToCenter();
}
// tick cooldowns
for (EnumPipePart part : EnumPipePart.VALUES) {
Section section = sections.get(part);
if (section.ticksInDirection > 0) {
section.ticksInDirection--;
} else if (section.ticksInDirection < 0) {
section.ticksInDirection++;
}
}
}
boolean send = false;
for (EnumPipePart part : EnumPipePart.VALUES) {
Section section = sections.get(part);
if (section.amount != section.lastSentAmount) {
send = true;
break;
} else {
Dir should = Dir.get(section.ticksInDirection);
if (section.lastSentDirection != should) {
send = true;
break;
}
}
}
if (send && tracker.markTimeIfDelay(world)) {
// send a net update
sendPayload(NET_FLUID_AMOUNTS);
}
}
Aggregations