Search in sources :

Example 81 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class HeatBehaviourLiquidTransition method transformSourceBlock.

protected void transformSourceBlock(Block turningBlockSource, Block turningBlockFlowing) {
    if (FluidUtils.isSourceBlock(getWorld(), getX(), getY(), getZ())) {
        getWorld().setBlock(getX(), getY(), getZ(), turningBlockSource);
        onLiquidTransition(getX(), getY(), getZ());
    } else {
        Set<ChunkPosition> traversed = new HashSet<ChunkPosition>();
        Stack<ChunkPosition> pending = new Stack<ChunkPosition>();
        pending.push(new ChunkPosition(getX(), getY(), getZ()));
        while (!pending.isEmpty()) {
            ChunkPosition pos = pending.pop();
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                ChunkPosition newPos = new ChunkPosition(pos.chunkPosX + d.offsetX, pos.chunkPosY + d.offsetY, pos.chunkPosZ + d.offsetZ);
                Block checkingBlock = getWorld().getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
                if ((checkingBlock == getBlock() || getBlock() == Blocks.flowing_water && checkingBlock == Blocks.water || getBlock() == Blocks.flowing_lava && checkingBlock == Blocks.lava) && traversed.add(newPos)) {
                    if (FluidUtils.isSourceBlock(getWorld(), newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ)) {
                        getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockSource);
                        onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
                        return;
                    } else {
                        getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockFlowing);
                        onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
                        pending.push(newPos);
                    }
                }
            }
        }
    }
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) HashSet(java.util.HashSet) Stack(java.util.Stack)

Example 82 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class ModuleRegulatorTube method getMaxDispersion.

@Override
public int getMaxDispersion() {
    IAirHandler connectedHandler = null;
    for (Pair<ForgeDirection, IAirHandler> entry : pressureTube.getAirHandler().getConnectedPneumatics()) {
        if (entry.getKey().equals(dir)) {
            connectedHandler = entry.getValue();
            break;
        }
    }
    if (connectedHandler == null)
        return 0;
    int maxDispersion = (int) ((getThreshold() - connectedHandler.getPressure(ForgeDirection.UNKNOWN)) * connectedHandler.getVolume());
    if (maxDispersion < 0)
        return 0;
    return maxDispersion;
}
Also used : IAirHandler(pneumaticCraft.api.tileentity.IAirHandler) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 83 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoorBase method shouldSideBeRendered.

@Override
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
    ForgeDirection d = ForgeDirection.getOrientation(side);
    TileEntityPneumaticDoorBase te = (TileEntityPneumaticDoorBase) world.getTileEntity(x - d.offsetX, y - d.offsetY, z - d.offsetZ);
    ItemStack camoStack = te.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
    if (camoStack != null && camoStack.getItem() instanceof ItemBlock) {
        Block block = ((ItemBlock) camoStack.getItem()).field_150939_a;
        if (PneumaticCraftUtils.isRenderIDCamo(block.getRenderType())) {
            return true;
        }
    }
    return false;
}
Also used : TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 84 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class BlockPressureTube method canConnectRedstone.

/**
     * Determine if this block can make a redstone connection on the side provided,
     * Useful to control which sides are inputs and outputs for redstone wires.
     *
     * Side:
     *  -1: UP
     *   0: NORTH
     *   1: EAST
     *   2: SOUTH
     *   3: WEST
     *
     * @param world The current world
     * @param x X Position
     * @param y Y Position
     * @param z Z Position
     * @param side The side that is trying to make the connection
     * @return True to make the connection
     */
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
    if (side < 0 || side > 3)
        return false;
    TileEntityPressureTube tube = (TileEntityPressureTube) world.getTileEntity(x, y, z);
    ForgeDirection d = ForgeDirection.NORTH;
    for (int i = 0; i < side; i++) {
        d = d.getRotation(ForgeDirection.UP);
    }
    side = d.ordinal();
    for (int i = 0; i < 6; i++) {
        if (tube.modules[i] != null) {
            if ((side ^ 1) == i || i != side && tube.modules[i].isInline()) {
                //if we are on the same side, or when we have an 'in line' module that is not on the opposite side.
                if (tube.modules[i] instanceof TubeModuleRedstoneEmitting)
                    return true;
            }
        }
    }
    return false;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) TileEntityPressureTube(pneumaticCraft.common.tileentity.TileEntityPressureTube) TubeModuleRedstoneEmitting(pneumaticCraft.common.block.tubes.TubeModuleRedstoneEmitting)

Example 85 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class SemiBlockRequester method amountRequested.

@Override
public int amountRequested(FluidStack stack) {
    int totalRequestingAmount = getTotalRequestedAmount(stack);
    if (totalRequestingAmount > 0) {
        TileEntity te = getTileEntity();
        if (te instanceof IFluidHandler) {
            int count = 0;
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                FluidTankInfo[] infos = ((IFluidHandler) te).getTankInfo(d);
                if (infos != null) {
                    for (FluidTankInfo info : infos) {
                        if (info.fluid != null && info.fluid.getFluid() == stack.getFluid()) {
                            count += info.fluid.amount;
                        }
                    }
                    if (count > 0)
                        break;
                }
            }
            count += getIncomingFluid(stack.getFluid());
            int requested = Math.max(0, Math.min(stack.amount, totalRequestingAmount - count));
            return requested;
        }
    }
    return 0;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Aggregations

ForgeDirection (net.minecraftforge.common.util.ForgeDirection)242 TileEntity (net.minecraft.tileentity.TileEntity)80 ItemStack (net.minecraft.item.ItemStack)47 ArrayList (java.util.ArrayList)29 Block (net.minecraft.block.Block)28 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)24 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)21 IInventory (net.minecraft.inventory.IInventory)19 FluidStack (net.minecraftforge.fluids.FluidStack)18 SideOnly (cpw.mods.fml.relauncher.SideOnly)17 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)17 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)17 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)16 HashMap (java.util.HashMap)12 Pair (logisticspipes.utils.tuples.Pair)11 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)10 World (net.minecraft.world.World)10 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)9 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)9 List (java.util.List)8