Search in sources :

Example 21 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class PartWireFace method renderStatic.

@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    renderer.setIgnoreLighting(shouldIgnoreLighting());
    renderer.setLightingOverride(getBrightness());
    double height = (getHeight() / 16D) - 0.001;
    double width = getWidth() / 32D;
    int color = getColorMultiplier();
    ForgeDirection d1 = ForgeDirection.NORTH;
    ForgeDirection d2 = ForgeDirection.SOUTH;
    ForgeDirection d3 = ForgeDirection.WEST;
    ForgeDirection d4 = ForgeDirection.EAST;
    if (getFace() == ForgeDirection.NORTH) {
        d1 = ForgeDirection.UP;
        d2 = ForgeDirection.DOWN;
    } else if (getFace() == ForgeDirection.SOUTH) {
        d1 = ForgeDirection.DOWN;
        d2 = ForgeDirection.UP;
    } else if (getFace() == ForgeDirection.WEST) {
        d3 = ForgeDirection.UP;
        d4 = ForgeDirection.DOWN;
    } else if (getFace() == ForgeDirection.EAST) {
        d3 = ForgeDirection.DOWN;
        d4 = ForgeDirection.UP;
    } else if (getFace() == ForgeDirection.UP) {
        d3 = ForgeDirection.EAST;
        d4 = ForgeDirection.WEST;
    }
    switch(getFace()) {
        case DOWN:
            break;
        case UP:
            renderer.addTransformation(new Rotation(180, 180, 0, Vec3d.center));
            break;
        case NORTH:
            renderer.addTransformation(new Rotation(90, 90, 0, Vec3d.center));
            d1 = d1.getRotation(getFace());
            d2 = d2.getRotation(getFace());
            d3 = d3.getRotation(getFace());
            d4 = d4.getRotation(getFace());
            break;
        case SOUTH:
            renderer.addTransformation(new Rotation(-90, 90, 0, Vec3d.center));
            d1 = d1.getRotation(getFace());
            d2 = d2.getRotation(getFace());
            d3 = d3.getRotation(getFace());
            d4 = d4.getRotation(getFace());
            break;
        case WEST:
            renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
            break;
        case EAST:
            renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
            break;
        default:
            break;
    }
    boolean s1 = shouldRenderConnection(d1);
    boolean s2 = shouldRenderConnection(d2);
    boolean s3 = shouldRenderConnection(d3);
    boolean s4 = shouldRenderConnection(d4);
    renderer.setColor(color);
    // Center
    renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, 8 / 16D - width, 8 / 16D + width, height, 8 / 16D + width), getIcons(ForgeDirection.UNKNOWN));
    // Sides
    if (s4 || s3) {
        if (s3 || (!s3 && s4 && !s1 && !s2))
            renderer.renderBox(new Vec3dCube(s3 ? (extendsToCorner(d3) ? -height : 0) : 4 / 16D, 0, 8 / 16D - width, 8 / 16D - width, height, 8 / 16D + width), getIcons(ForgeDirection.WEST));
        if (s4 || (s3 && !s4 && !s1 && !s2))
            renderer.renderBox(new Vec3dCube(8 / 16D + width, 0, 8 / 16D - width, s4 ? 1 + (extendsToCorner(d4) ? height : 0) : 12 / 16D, height, 8 / 16D + width), getIcons(ForgeDirection.EAST));
        if (s1)
            renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, s1 ? (extendsToCorner(d1) ? -height : 0) : 4 / 16D, 8 / 16D + width, height, 8 / 16D - width), getIcons(ForgeDirection.NORTH));
        if (s2)
            renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, 8 / 16D + width, 8 / 16D + width, height, s2 ? 1 + (extendsToCorner(d2) ? height : 0) : 12 / 16D), getIcons(ForgeDirection.SOUTH));
    } else {
        renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, s1 ? (extendsToCorner(d1) ? -height : 0) : 4 / 16D, 8 / 16D + width, height, 8 / 16D - width), getIcons(ForgeDirection.NORTH));
        renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, 8 / 16D + width, 8 / 16D + width, height, s2 ? 1 + (extendsToCorner(d2) ? height : 0) : 12 / 16D), getIcons(ForgeDirection.SOUTH));
    }
    renderer.setIgnoreLighting(false);
    renderer.setColor(0xFFFFFF);
    return true;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Rotation(uk.co.qmunity.lib.transform.Rotation) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 22 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class BundledConnectionCache method recalculateConnections.

@SuppressWarnings("unchecked")
@Override
public void recalculateConnections() {
    if (dev.getWorld().isRemote)
        return;
    IBundledDevice self = getSelf();
    for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        boolean wasConnected = connections[d.ordinal()] != null;
        BundledConnection con = RedConnectionHelper.getBundledNeighbor(self, d);
        if (con != null) {
            if (!wasConnected || connections[d.ordinal()].getB() != con.getB() || connections[d.ordinal()].getSideB() != con.getSideB() || connections[d.ordinal()].getType() != con.getType()) {
                onConnect(con.getSideA(), con.getB(), con.getSideB(), con.getType());
                ((IConnectionCache<IBundledDevice>) con.getB().getBundledConnectionCache()).onConnect(con.getSideB(), con.getA(), con.getSideA(), con.getType());
                IConnection<IBundledDevice> con2 = (IConnection<IBundledDevice>) con.getB().getBundledConnectionCache().getConnectionOnSide(con.getSideB());
                con = connections[d.ordinal()];
                if (con == null)
                    return;
                con.setComplementaryConnection(con2);
                con2.setComplementaryConnection(con);
            }
        } else if (wasConnected) {
            con = connections[d.ordinal()];
            if (con != null) {
                onDisconnect(con.getSideA());
                con.getB().getBundledConnectionCache().onDisconnect(con.getSideB());
            }
        }
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IConnection(com.bluepowermod.api.connect.IConnection) IConnectionCache(com.bluepowermod.api.connect.IConnectionCache) IBundledDevice(com.bluepowermod.api.wire.redstone.IBundledDevice)

Example 23 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class TileSortingMachine method triggerSorting.

private void triggerSorting() {
    if (isBufferEmpty()) {
        ForgeDirection dir = getOutputDirection().getOpposite();
        // might need opposite
        TileEntity inputTE = getTileCache(dir);
        if (inputTE instanceof IInventory) {
            IInventory inputInv = (IInventory) inputTE;
            int[] accessibleSlots;
            if (inputInv instanceof ISidedInventory) {
                accessibleSlots = ((ISidedInventory) inputInv).getAccessibleSlotsFromSide(dir.getOpposite().ordinal());
            } else {
                accessibleSlots = new int[inputInv.getSizeInventory()];
                for (int i = 0; i < accessibleSlots.length; i++) accessibleSlots[i] = i;
            }
            for (int slot : accessibleSlots) {
                ItemStack stack = inputInv.getStackInSlot(slot);
                if (stack != null && IOHelper.canExtractItemFromInventory(inputInv, stack, slot, dir.getOpposite().ordinal())) {
                    if (tryProcessItem(stack, false)) {
                        if (stack.stackSize == 0)
                            inputInv.setInventorySlotContents(slot, null);
                        return;
                    }
                }
            }
            if (sortMode == SortMode.ANYSTACK_SEQUENTIAL) {
                for (int i = curColumn; i < inventory.length; i += 8) {
                    ItemStack filterStack = inventory[i];
                    if (filterStack != null) {
                        ItemStack extractedStack = IOHelper.extract(inputTE, dir.getOpposite(), filterStack, true, false);
                        if (extractedStack != null) {
                            addItemToOutputBuffer(extractedStack.copy(), colors[curColumn]);
                            gotoNextNonEmptyColumn();
                            break;
                        }
                    }
                }
            } else if (sortMode == SortMode.ALLSTACK_SEQUENTIAL) {
                if (matchAndProcessColumn(inputInv, accessibleSlots, curColumn)) {
                    gotoNextNonEmptyColumn();
                }
            } else if (sortMode == SortMode.RANDOM_ALLSTACKS) {
                for (int i = 0; i < 8; i++) {
                    if (matchAndProcessColumn(inputInv, accessibleSlots, i)) {
                        break;
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) ISidedInventory(net.minecraft.inventory.ISidedInventory) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ItemStack(net.minecraft.item.ItemStack)

Example 24 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class TileTransposer method redstoneChanged.

@Override
protected void redstoneChanged(boolean newValue) {
    super.redstoneChanged(newValue);
    ForgeDirection direction = getFacingDirection();
    if (!worldObj.isRemote && isBufferEmpty() && newValue) {
        if (worldObj.isAirBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ)) {
            suckItems();
        } else {
            pullItem();
        }
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 25 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class TileTransposer method pullItem.

protected void pullItem() {
    ForgeDirection dir = getOutputDirection().getOpposite();
    TileEntity inputTE = getTileCache(dir);
    ItemStack extractedStack = IOHelper.extractOneItem(inputTE, dir.getOpposite());
    if (extractedStack != null)
        addItemToOutputBuffer(extractedStack);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ItemStack(net.minecraft.item.ItemStack)

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