Search in sources :

Example 1 with PipeBlockRequestTable

use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.

the class LogisticsPipes method createPipe.

protected Item createPipe(Class<? extends CoreUnroutedPipe> clas, String descr, Side side) {
    final ItemLogisticsPipe res = LogisticsBlockGenericPipe.registerPipe(clas);
    res.setCreativeTab(LogisticsPipes.LPCreativeTab);
    res.setUnlocalizedName(clas.getSimpleName());
    final CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.createPipe(res);
    if (pipe instanceof CoreRoutedPipe) {
        postInitRun.add(() -> res.setPipeIconIndex(((CoreRoutedPipe) pipe).getTextureType(ForgeDirection.UNKNOWN).normal, ((CoreRoutedPipe) pipe).getTextureType(ForgeDirection.UNKNOWN).newTexture));
    }
    if (side.isClient()) {
        if (pipe instanceof PipeBlockRequestTable) {
            MinecraftForgeClient.registerItemRenderer(res, new LogisticsPipeItemRenderer(true));
        } else {
            MinecraftForgeClient.registerItemRenderer(res, MainProxy.proxy.getPipeItemRenderer());
        }
    }
    if (clas != PipeItemsBasicLogistics.class && CoreRoutedPipe.class.isAssignableFrom(clas)) {
        if (clas != PipeFluidBasic.class && PipeFluidBasic.class.isAssignableFrom(clas)) {
            registerShapelessResetRecipe(res, 0, LogisticsPipes.LogisticsFluidBasicPipe, 0);
        } else {
            registerShapelessResetRecipe(res, 0, LogisticsPipes.LogisticsBasicPipe, 0);
        }
    }
    return res;
}
Also used : CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) PipeItemsBasicLogistics(logisticspipes.pipes.PipeItemsBasicLogistics) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) PipeFluidBasic(logisticspipes.pipes.PipeFluidBasic) LogisticsPipeItemRenderer(logisticspipes.renderer.LogisticsPipeItemRenderer)

Example 2 with PipeBlockRequestTable

use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method addCollisionBoxesToList.

@Override
@SuppressWarnings({ "rawtypes" })
public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) {
    TileEntity tile = world.getTileEntity(i, j, k);
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
        setBlockBounds(0, 0, 0, 1, 1, 1);
        super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        return;
    }
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe != null && ((LogisticsTileGenericPipe) tile).pipe.isMultiBlock()) {
        ((CoreMultiBlockPipe) ((LogisticsTileGenericPipe) tile).pipe).addCollisionBoxesToList(arraylist, axisalignedbb);
        if (!((LogisticsTileGenericPipe) tile).pipe.actAsNormalPipe()) {
            return;
        }
    }
    setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
    super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
    if (tile instanceof LogisticsTileGenericPipe) {
        LogisticsTileGenericPipe tileG = (LogisticsTileGenericPipe) tile;
        if (tileG.isPipeConnected(ForgeDirection.WEST)) {
            setBlockBounds(0.0F, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.EAST)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, 1.0F, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.DOWN)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, 0.0F, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.UP)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, 1.0F, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.NORTH)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, 0.0F, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.SOUTH)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        float facadeThickness = LPConstants.FACADE_THICKNESS;
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.EAST)) {
            setBlockBounds(1 - facadeThickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.WEST)) {
            setBlockBounds(0.0F, 0.0F, 0.0F, facadeThickness, 1.0F, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.UP)) {
            setBlockBounds(0.0F, 1 - facadeThickness, 0.0F, 1.0F, 1.0F, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.DOWN)) {
            setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, facadeThickness, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.SOUTH)) {
            setBlockBounds(0.0F, 0.0F, 1 - facadeThickness, 1.0F, 1.0F, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.NORTH)) {
            setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, facadeThickness);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
    }
    setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable)

Example 3 with PipeBlockRequestTable

use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method collisionRayTrace.

@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
    TileEntity tile = world.getTileEntity(x, y, z);
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
        setBlockBoundsBasedOnState(world, x, y, z);
        origin = origin.addVector((-x), (-y), (-z));
        direction = direction.addVector((-x), (-y), (-z));
        this.setBlockBounds(0, 0, 0, 1, 1, 1);
        Vec3 vec32 = origin.getIntermediateWithXValue(direction, minX);
        Vec3 vec33 = origin.getIntermediateWithXValue(direction, maxX);
        Vec3 vec34 = origin.getIntermediateWithYValue(direction, minY);
        Vec3 vec35 = origin.getIntermediateWithYValue(direction, maxY);
        Vec3 vec36 = origin.getIntermediateWithZValue(direction, minZ);
        Vec3 vec37 = origin.getIntermediateWithZValue(direction, maxZ);
        if (!isVecInsideYZBounds(vec32)) {
            vec32 = null;
        }
        if (!isVecInsideYZBounds(vec33)) {
            vec33 = null;
        }
        if (!isVecInsideXZBounds(vec34)) {
            vec34 = null;
        }
        if (!isVecInsideXZBounds(vec35)) {
            vec35 = null;
        }
        if (!isVecInsideXYBounds(vec36)) {
            vec36 = null;
        }
        if (!isVecInsideXYBounds(vec37)) {
            vec37 = null;
        }
        Vec3 vec38 = null;
        if (vec32 != null && (vec38 == null || origin.squareDistanceTo(vec32) < origin.squareDistanceTo(vec38))) {
            vec38 = vec32;
        }
        if (vec33 != null && (vec38 == null || origin.squareDistanceTo(vec33) < origin.squareDistanceTo(vec38))) {
            vec38 = vec33;
        }
        if (vec34 != null && (vec38 == null || origin.squareDistanceTo(vec34) < origin.squareDistanceTo(vec38))) {
            vec38 = vec34;
        }
        if (vec35 != null && (vec38 == null || origin.squareDistanceTo(vec35) < origin.squareDistanceTo(vec38))) {
            vec38 = vec35;
        }
        if (vec36 != null && (vec38 == null || origin.squareDistanceTo(vec36) < origin.squareDistanceTo(vec38))) {
            vec38 = vec36;
        }
        if (vec37 != null && (vec38 == null || origin.squareDistanceTo(vec37) < origin.squareDistanceTo(vec38))) {
            vec38 = vec37;
        }
        if (vec38 == null) {
            return null;
        } else {
            byte b0 = -1;
            if (vec38 == vec32) {
                b0 = 4;
            }
            if (vec38 == vec33) {
                b0 = 5;
            }
            if (vec38 == vec34) {
                b0 = 0;
            }
            if (vec38 == vec35) {
                b0 = 1;
            }
            if (vec38 == vec36) {
                b0 = 2;
            }
            if (vec38 == vec37) {
                b0 = 3;
            }
            return new MovingObjectPosition(x, y, z, b0, vec38.addVector(x, y, z));
        }
    }
    RaytraceResult raytraceResult = doRayTrace(world, x, y, z, origin, direction);
    if (raytraceResult == null) {
        return null;
    } else {
        return raytraceResult.movingObjectPosition;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) Vec3(net.minecraft.util.Vec3)

Example 4 with PipeBlockRequestTable

use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.

the class LogisticsPipeWorldRenderer method renderPipe.

public static boolean renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, LogisticsBlockGenericPipe block, LogisticsTileGenericPipe pipe, int x, int y, int z) {
    if (pipe.pipe instanceof PipeBlockRequestTable) {
        if (LogisticsPipeWorldRenderer.renderPass != 0) {
            return false;
        }
        PipeRenderState state = pipe.renderState;
        IIconProvider icons = pipe.getPipeIcons();
        if (icons == null) {
            return false;
        }
        state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
        block.setRenderAllSides();
        block.setBlockBounds(0, 0, 0, 1, 1, 1);
        renderblocks.setRenderBoundsFromBlock(block);
        renderblocks.renderStandardBlock(block, x, y, z);
        return true;
    }
    // Here to prevent Minecraft from crashing when nothing renders on render pass zero
    // This is likely a bug, and has been submitted as an issue to the Forge team
    renderblocks.setRenderBounds(0, 0, 0, 0, 0, 0);
    renderblocks.renderStandardBlock(Blocks.stone, x, y, z);
    renderblocks.setRenderBoundsFromBlock(block);
    PipeRenderState state = pipe.renderState;
    IIconProvider icons = pipe.getPipeIcons();
    if (icons == null) {
        return false;
    }
    if (LogisticsPipeWorldRenderer.renderPass == 0) {
        int connectivity = state.pipeConnectionMatrix.getMask();
        float[] dim = new float[6];
        if (!pipe.isOpaque()) {
            // render the unconnected pipe faces of the center block (if any)
            if (connectivity != 0x3f) {
                // note: 0x3f = 0x111111 = all sides
                LogisticsPipeWorldRenderer.resetToCenterDimensions(dim);
                state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
                LogisticsPipeWorldRenderer.renderTwoWayBlock(renderblocks, block, x, y, z, dim, connectivity ^ 0x3f);
            }
            // render the connecting pipe faces
            for (int dir = 0; dir < 6; dir++) {
                int mask = 1 << dir;
                if ((connectivity & mask) == 0) {
                    // no connection towards dir
                    continue;
                }
                // center piece offsets
                LogisticsPipeWorldRenderer.resetToCenterDimensions(dim);
                // extend block towards dir as it's connected to there
                dim[dir / 2] = dir % 2 == 0 ? 0 : LPConstants.BC_PIPE_MAX_POS;
                dim[dir / 2 + 3] = dir % 2 == 0 ? LPConstants.BC_PIPE_MIN_POS : 1;
                // the mask points to all faces perpendicular to dir, i.e. dirs 0+1 -> mask 111100, 1+2 -> 110011, 3+5 -> 001111
                int renderMask = (3 << (dir / 2 * 2)) ^ 0x3f;
                //workaround for 1.6 texture weirdness, rotate texture for N/S/E/W connections
                renderblocks.uvRotateEast = renderblocks.uvRotateNorth = renderblocks.uvRotateWest = renderblocks.uvRotateSouth = (dir < 2) ? 0 : 1;
                // render sub block
                state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.VALID_DIRECTIONS[dir]));
                LogisticsPipeWorldRenderer.renderTwoWayBlock(renderblocks, block, x, y, z, dim, renderMask);
                renderblocks.uvRotateEast = renderblocks.uvRotateNorth = renderblocks.uvRotateWest = renderblocks.uvRotateSouth = 0;
            }
        } else {
            // render the unconnected pipe faces of the center block (if any)
            if (connectivity != 0x3f) {
                // note: 0x3f = 0x111111 = all sides
                LogisticsPipeWorldRenderer.resetToCenterDimensions(dim);
                //Render opaque Layer
                state.currentTexture = icons.getIcon(Textures.LOGISTICSPIPE_OPAQUE_TEXTURE.normal);
                LogisticsPipeWorldRenderer.renderOneWayBlock(renderblocks, block, x, y, z, dim, connectivity ^ 0x3f);
                //Render Pipe Texture
                state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
                LogisticsPipeWorldRenderer.renderOneWayBlock(renderblocks, block, x, y, z, dim, connectivity ^ 0x3f);
            }
            // render the connecting pipe faces
            for (int dir = 0; dir < 6; dir++) {
                int mask = 1 << dir;
                if ((connectivity & mask) == 0) {
                    // no connection towards dir
                    continue;
                }
                // center piece offsets
                LogisticsPipeWorldRenderer.resetToCenterDimensions(dim);
                // extend block towards dir as it's connected to there
                dim[dir / 2] = dir % 2 == 0 ? 0 : LPConstants.BC_PIPE_MAX_POS;
                dim[dir / 2 + 3] = dir % 2 == 0 ? LPConstants.BC_PIPE_MIN_POS : 1;
                // the mask points to all faces perpendicular to dir, i.e. dirs 0+1 -> mask 111100, 1+2 -> 110011, 3+5 -> 001111
                int renderMask = (3 << (dir / 2 * 2)) ^ 0x3f;
                //workaround for 1.6 texture weirdness, rotate texture for N/S/E/W connections
                renderblocks.uvRotateEast = renderblocks.uvRotateNorth = renderblocks.uvRotateWest = renderblocks.uvRotateSouth = (dir < 2) ? 0 : 1;
                //Render opaque Layer
                state.currentTexture = icons.getIcon(Textures.LOGISTICSPIPE_OPAQUE_TEXTURE.normal);
                LogisticsPipeWorldRenderer.renderOneWayBlock(renderblocks, block, x, y, z, dim, 0x3f);
                // render sub block
                state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.VALID_DIRECTIONS[dir]));
                LogisticsPipeWorldRenderer.renderOneWayBlock(renderblocks, block, x, y, z, dim, renderMask);
                renderblocks.uvRotateEast = renderblocks.uvRotateNorth = renderblocks.uvRotateWest = renderblocks.uvRotateSouth = 0;
            }
        }
    }
    renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        if (pipe.tilePart.hasPipePluggable(dir)) {
            IBCPipePluggable p = pipe.tilePart.getBCPipePluggable(dir);
            p.renderPluggable(renderblocks, dir, LogisticsPipeWorldRenderer.renderPass, x, y, z);
        }
    }
    return true;
}
Also used : PipeRenderState(logisticspipes.renderer.state.PipeRenderState) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IBCPipePluggable(logisticspipes.proxy.buildcraft.subproxies.IBCPipePluggable)

Example 5 with PipeBlockRequestTable

use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.

the class CraftingSetType method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    TileEntity table = this.getTileAs(player.getEntityWorld(), TileEntity.class);
    if (table instanceof LogisticsCraftingTableTileEntity) {
        ((LogisticsCraftingTableTileEntity) table).targetType = targetType;
        ((LogisticsCraftingTableTileEntity) table).cacheRecipe();
    } else if (table instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) table).pipe instanceof PipeBlockRequestTable) {
        ((PipeBlockRequestTable) ((LogisticsTileGenericPipe) table).pipe).targetType = targetType;
        ((PipeBlockRequestTable) ((LogisticsTileGenericPipe) table).pipe).cacheRecipe();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)

Aggregations

PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)18 TileEntity (net.minecraft.tileentity.TileEntity)11 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)7 Nonnull (javax.annotation.Nonnull)4 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)4 PipeRenderState (logisticspipes.renderer.state.PipeRenderState)4 EnumFacing (net.minecraft.util.EnumFacing)4 ArrayList (java.util.ArrayList)3 ItemLogisticsPipe (logisticspipes.items.ItemLogisticsPipe)3 PipeFluidBasic (logisticspipes.pipes.PipeFluidBasic)3 PipeItemsRequestLogisticsMk2 (logisticspipes.pipes.PipeItemsRequestLogisticsMk2)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 BlockPos (net.minecraft.util.math.BlockPos)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Map (java.util.Map)2 Function (java.util.function.Function)2 Nullable (javax.annotation.Nullable)2 LPBlocks (logisticspipes.LPBlocks)2