Search in sources :

Example 1 with ItemLogisticsPipe

use of logisticspipes.items.ItemLogisticsPipe 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 ItemLogisticsPipe

use of logisticspipes.items.ItemLogisticsPipe in project LogisticsPipes by RS485.

the class LogisticsNewPipeItemRenderer method renderPipeItem.

private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
    GL11.glPushMatrix();
    // don't break other mods' guis when holding a pipe
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
    // force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
    // GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
    Tessellator tessellator = Tessellator.instance;
    GL11.glTranslatef(translateX, translateY, translateZ);
    Block block = LogisticsPipes.LogisticsPipeBlock;
    if (item.getItem() instanceof ItemLogisticsPipe) {
        ItemLogisticsPipe lItem = (ItemLogisticsPipe) item.getItem();
        int renderList = lItem.getNewPipeRenderList();
        if (renderList == -1) {
            lItem.setNewPipeRenderList(GL11.glGenLists(1));
            renderList = lItem.getNewPipeRenderList();
            GL11.glNewList(renderList, GL11.GL_COMPILE);
            tessellator.startDrawingQuads();
            generatePipeRenderList(lItem.getNewPipeIconIndex());
            tessellator.draw();
            GL11.glEndList();
        }
        GL11.glCallList(renderList);
    }
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopAttrib();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) Block(net.minecraft.block.Block) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe)

Example 3 with ItemLogisticsPipe

use of logisticspipes.items.ItemLogisticsPipe in project LogisticsPipes by RS485.

the class RenderTickHandler method renderWorldLast.

//private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
    if (LogisticsRenderPipe.config.isUseNewRenderer()) {
        if (displayPipeGhost()) {
            Minecraft mc = Minecraft.getMinecraft();
            EntityPlayer player = mc.thePlayer;
            MovingObjectPosition box = mc.objectMouseOver;
            if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
                ItemStack stack = FMLClientHandler.instance().getClient().thePlayer.inventory.mainInventory[FMLClientHandler.instance().getClient().thePlayer.inventory.currentItem];
                CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
                int i = box.blockX;
                int j = box.blockY;
                int k = box.blockZ;
                World world = player.getEntityWorld();
                int side = box.sideHit;
                Block worldBlock = world.getBlock(i, j, k);
                if (worldBlock == Blocks.snow) {
                    side = 1;
                } else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
                    if (side == 0) {
                        j--;
                    }
                    if (side == 1) {
                        j++;
                    }
                    if (side == 2) {
                        k--;
                    }
                    if (side == 3) {
                        k++;
                    }
                    if (side == 4) {
                        i--;
                    }
                    if (side == 5) {
                        i++;
                    }
                }
                double xCoord = i;
                double yCoord = j;
                double zCoord = k;
                boolean isFreeSpace = true;
                ITubeOrientation orientation = null;
                if (pipe instanceof CoreMultiBlockPipe) {
                    CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
                    DoubleCoordinates placeAt = new DoubleCoordinates(xCoord, yCoord, zCoord);
                    LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
                    globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
                    LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multipipe.getSubBlocks();
                    orientation = multipipe.getTubeOrientation(player, (int) xCoord, (int) zCoord);
                    if (orientation != null) {
                        orientation.rotatePositions(positions);
                        positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
                        globalPos.addToAll(orientation.getOffset());
                        for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
                            if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, player, stack)) {
                                TileEntity tile = player.getEntityWorld().getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
                                boolean canPlace = false;
                                if (tile instanceof LogisticsTileGenericSubMultiBlock) {
                                    if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
                                        canPlace = true;
                                    }
                                }
                                if (!canPlace) {
                                    isFreeSpace = false;
                                    break;
                                }
                            }
                        }
                    } else {
                        return;
                    }
                } else {
                    if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, i, j, k, false, side, player, stack)) {
                        isFreeSpace = false;
                    }
                }
                if (isFreeSpace) {
                    GL11.glPushMatrix();
                    double x;
                    double y;
                    double z;
                    if (orientation != null) {
                        x = xCoord + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
                        y = yCoord + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
                        z = zCoord + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
                    } else {
                        x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
                        y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
                        z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
                    }
                    GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
                    GL11.glEnable(GL11.GL_BLEND);
                    //GL11.glDepthMask(false);
                    GL11.glDisable(GL11.GL_TEXTURE_2D);
                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                    mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png"));
                    Tessellator tess = Tessellator.instance;
                    CCRenderState.reset();
                    CCRenderState.useNormals = true;
                    CCRenderState.alphaOverride = 0xff;
                    GL11.glEnable(GL11.GL_TEXTURE_2D);
                    CCRenderState.alphaOverride = 0x50;
                    CCRenderState.useNormals = true;
                    CCRenderState.hasBrightness = false;
                    CCRenderState.startDrawing();
                    pipe.getHighlightRenderer().renderHighlight(orientation);
                    tess.draw();
                    CCRenderState.alphaOverride = 0xff;
                    GL11.glDisable(GL11.GL_BLEND);
                    GL11.glDepthMask(true);
                    GL11.glPopMatrix();
                }
            }
        }
    }
}
Also used : ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) EventPriority(cpw.mods.fml.common.eventhandler.EventPriority) Blocks(net.minecraft.init.Blocks) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) LogisticsPipes(logisticspipes.LogisticsPipes) ActiveRenderInfo(net.minecraft.client.renderer.ActiveRenderInfo) RenderWorldLastEvent(net.minecraftforge.client.event.RenderWorldLastEvent) RenderTickEvent(cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) Minecraft(net.minecraft.client.Minecraft) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) ClientViewController(logisticspipes.routing.debug.ClientViewController) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsRenderPipe(logisticspipes.renderer.LogisticsRenderPipe) FMLClientHandler(cpw.mods.fml.client.FMLClientHandler) Core(tv.twitch.Core) GL11(org.lwjgl.opengl.GL11) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) CCRenderState(codechicken.lib.render.CCRenderState) World(net.minecraft.world.World) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) CoordinateUtils(network.rs485.logisticspipes.world.CoordinateUtils) Phase(cpw.mods.fml.common.gameevent.TickEvent.Phase) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Tessellator(net.minecraft.client.renderer.Tessellator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ResourceLocation(net.minecraft.util.ResourceLocation) TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectType(net.minecraft.util.MovingObjectPosition.MovingObjectType) Tessellator(net.minecraft.client.renderer.Tessellator) World(net.minecraft.world.World) TileEntity(net.minecraft.tileentity.TileEntity) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) ResourceLocation(net.minecraft.util.ResourceLocation) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Minecraft(net.minecraft.client.Minecraft) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) LPPositionSet(logisticspipes.utils.LPPositionSet) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with ItemLogisticsPipe

use of logisticspipes.items.ItemLogisticsPipe in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method registerPipe.

/* Registration ******************************************************** */
public static ItemLogisticsPipe registerPipe(Class<? extends CoreUnroutedPipe> clas) {
    ItemLogisticsPipe item = new ItemLogisticsPipe();
    item.setUnlocalizedName(clas.getSimpleName());
    GameRegistry.registerItem(item, item.getUnlocalizedName());
    LogisticsBlockGenericPipe.pipes.put(item, clas);
    CoreUnroutedPipe dummyPipe = LogisticsBlockGenericPipe.createPipe(item);
    if (dummyPipe != null) {
        item.setPipeIconIndex(dummyPipe.getIconIndexForItem(), dummyPipe.getTextureIndex());
        MainProxy.proxy.setIconProviderFromPipe(item, dummyPipe);
        item.setDummyPipe(dummyPipe);
    }
    return item;
}
Also used : ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe)

Example 5 with ItemLogisticsPipe

use of logisticspipes.items.ItemLogisticsPipe in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset) {
    super.onBlockActivated(world, x, y, z, player, side, xOffset, yOffset, zOffset);
    world.notifyBlocksOfNeighborChange(x, y, z, LogisticsPipes.LogisticsPipeBlock);
    CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(world, x, y, z);
    if (LogisticsBlockGenericPipe.isValid(pipe)) {
        ItemStack currentItem = player.getCurrentEquippedItem();
        if (currentItem == null) {
        // Fall through the end of the test
        } else if (currentItem.getItem() == Items.sign) {
            // Sign will be placed anyway, so lets show the sign gui
            return false;
        } else if (currentItem.getItem() instanceof ItemLogisticsPipe) {
            return false;
        } else if (SimpleServiceLocator.toolWrenchHandler.isWrench(currentItem.getItem())) {
            // interface callbacks for the individual pipe/logic calls
            return pipe.blockActivated(player);
        }
        if (pipe.canHoldBCParts()) {
            IBCClickResult result = SimpleServiceLocator.buildCraftProxy.handleBCClickOnPipe(world, x, y, z, player, side, xOffset, yOffset, zOffset, pipe);
            if (result.handled()) {
                return true;
            }
            if (result.blocked()) {
                return false;
            }
        }
        return pipe.blockActivated(player);
    }
    return false;
}
Also used : IBCClickResult(logisticspipes.proxy.buildcraft.subproxies.IBCClickResult) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemLogisticsPipe (logisticspipes.items.ItemLogisticsPipe)5 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)2 CoreUnroutedPipe (logisticspipes.pipes.basic.CoreUnroutedPipe)2 Block (net.minecraft.block.Block)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 ItemStack (net.minecraft.item.ItemStack)2 CCRenderState (codechicken.lib.render.CCRenderState)1 FMLClientHandler (cpw.mods.fml.client.FMLClientHandler)1 EventPriority (cpw.mods.fml.common.eventhandler.EventPriority)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Phase (cpw.mods.fml.common.gameevent.TickEvent.Phase)1 RenderTickEvent (cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent)1 LogisticsPipes (logisticspipes.LogisticsPipes)1 ITubeOrientation (logisticspipes.interfaces.ITubeOrientation)1 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)1 PipeFluidBasic (logisticspipes.pipes.PipeFluidBasic)1 PipeItemsBasicLogistics (logisticspipes.pipes.PipeItemsBasicLogistics)1 CoreMultiBlockPipe (logisticspipes.pipes.basic.CoreMultiBlockPipe)1 LogisticsTileGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)1 IBCClickResult (logisticspipes.proxy.buildcraft.subproxies.IBCClickResult)1