Search in sources :

Example 1 with CoreUnroutedPipe

use of logisticspipes.pipes.basic.CoreUnroutedPipe 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 CoreUnroutedPipe

use of logisticspipes.pipes.basic.CoreUnroutedPipe in project LogisticsPipes by RS485.

the class RemoteOrderer method getPipe.

public static PipeItemsRemoteOrdererLogistics getPipe(@Nonnull ItemStack stack) {
    if (stack.isEmpty() || !stack.hasTagCompound()) {
        return null;
    }
    final NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound());
    if (!tag.hasKey("connectedPipe-x") || !tag.hasKey("connectedPipe-y") || !tag.hasKey("connectedPipe-z")) {
        return null;
    }
    if (!tag.hasKey("connectedPipe-world-dim")) {
        return null;
    }
    int dim = tag.getInteger("connectedPipe-world-dim");
    World world = DimensionManager.getWorld(dim);
    if (world == null) {
        return null;
    }
    TileEntity tile = world.getTileEntity(new BlockPos(tag.getInteger("connectedPipe-x"), tag.getInteger("connectedPipe-y"), tag.getInteger("connectedPipe-z")));
    if (!(tile instanceof LogisticsTileGenericPipe)) {
        return null;
    }
    CoreUnroutedPipe pipe = ((LogisticsTileGenericPipe) tile).pipe;
    if (pipe instanceof PipeItemsRemoteOrdererLogistics) {
        return (PipeItemsRemoteOrdererLogistics) pipe;
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) PipeItemsRemoteOrdererLogistics(logisticspipes.pipes.PipeItemsRemoteOrdererLogistics)

Example 3 with CoreUnroutedPipe

use of logisticspipes.pipes.basic.CoreUnroutedPipe in project LogisticsPipes by RS485.

the class ItemModule method onItemUse.

@Override
@Nonnull
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (MainProxy.isServer(player.world)) {
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof LogisticsTileGenericPipe) {
            if (player.getDisplayName().getUnformattedText().equals("ComputerCraft")) {
                // Allow turtle to place modules in pipes.
                CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(world, pos);
                if (LogisticsBlockGenericPipe.isValid(pipe)) {
                    pipe.blockActivated(player);
                }
            }
            return EnumActionResult.PASS;
        }
        openConfigGui(player.inventory.getCurrentItem(), player, world);
    }
    return EnumActionResult.PASS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) Nonnull(javax.annotation.Nonnull)

Example 4 with CoreUnroutedPipe

use of logisticspipes.pipes.basic.CoreUnroutedPipe in project LogisticsPipes by RS485.

the class RenderTickHandler method renderWorldLast.

// private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
    // if (LogisticsRenderPipe.config.isUseNewRenderer()) {
    if (displayPipeGhost()) {
        Minecraft mc = Minecraft.getMinecraft();
        EntityPlayer player = mc.player;
        RayTraceResult box = mc.objectMouseOver;
        if (box != null && box.typeOfHit == RayTraceResult.Type.BLOCK) {
            ItemStack stack = FMLClientHandler.instance().getClient().player.inventory.mainInventory.get(FMLClientHandler.instance().getClient().player.inventory.currentItem);
            CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
            World world = player.getEntityWorld();
            EnumFacing side = box.sideHit;
            BlockPos bPos = box.getBlockPos();
            Block block = world.getBlockState(bPos).getBlock();
            if (block == Blocks.SNOW_LAYER && block.isReplaceable(world, bPos)) {
                side = EnumFacing.UP;
            } else if (!block.isReplaceable(world, bPos)) {
                bPos = bPos.offset(side);
            }
            boolean isFreeSpace = true;
            ITubeOrientation orientation = null;
            if (pipe instanceof CoreMultiBlockPipe) {
                CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
                DoubleCoordinates placeAt = new DoubleCoordinates(bPos);
                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, bPos.getX(), bPos.getZ());
                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().mayPlace(LPBlocks.pipe, pos.getBlockPos(), false, side, player)) {
                            TileEntity tile = player.getEntityWorld().getTileEntity(pos.getBlockPos());
                            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().mayPlace(LPBlocks.pipe, bPos, false, side, player)) {
                    isFreeSpace = false;
                }
            }
            if (isFreeSpace) {
                GlStateManager.pushMatrix();
                double x;
                double y;
                double z;
                if (orientation != null) {
                    x = bPos.getX() + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.getPartialTicks());
                    y = bPos.getY() + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.getPartialTicks());
                    z = bPos.getZ() + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.getPartialTicks());
                } else {
                    x = bPos.getX() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.getPartialTicks());
                    y = bPos.getY() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.getPartialTicks());
                    z = bPos.getZ() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.getPartialTicks());
                }
                GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
                GlStateManager.enableBlend();
                // GL11.glDepthMask(false);
                GlStateManager.disableTexture2D();
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/white.png"));
                SimpleServiceLocator.cclProxy.getRenderState().reset();
                SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
                GlStateManager.enableTexture2D();
                SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0x50);
                SimpleServiceLocator.cclProxy.getRenderState().startDrawing(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
                pipe.getHighlightRenderer().renderHighlight(orientation);
                SimpleServiceLocator.cclProxy.getRenderState().draw();
                SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
                GlStateManager.disableBlend();
                GlStateManager.depthMask(true);
                GlStateManager.popMatrix();
            }
        }
    }
// }
}
Also used : ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) RenderTickEvent(net.minecraftforge.fml.common.gameevent.TickEvent.RenderTickEvent) Blocks(net.minecraft.init.Blocks) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) ActiveRenderInfo(net.minecraft.client.renderer.ActiveRenderInfo) RenderWorldLastEvent(net.minecraftforge.client.event.RenderWorldLastEvent) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) ClientViewController(logisticspipes.routing.debug.ClientViewController) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) GL11(org.lwjgl.opengl.GL11) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) World(net.minecraft.world.World) GlStateManager(net.minecraft.client.renderer.GlStateManager) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) EventPriority(net.minecraftforge.fml.common.eventhandler.EventPriority) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) LPBlocks(logisticspipes.LPBlocks) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Phase(net.minecraftforge.fml.common.gameevent.TickEvent.Phase) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) World(net.minecraft.world.World) TileEntity(net.minecraft.tileentity.TileEntity) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) ResourceLocation(net.minecraft.util.ResourceLocation) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) BlockPos(net.minecraft.util.math.BlockPos) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) RayTraceResult(net.minecraft.util.math.RayTraceResult) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Minecraft(net.minecraft.client.Minecraft) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) 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(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with CoreUnroutedPipe

use of logisticspipes.pipes.basic.CoreUnroutedPipe in project LogisticsPipes by RS485.

the class LogisticsPipes method registerPipe.

protected void registerPipe(IForgeRegistry<Item> registry, String name, Function<Item, ? extends CoreUnroutedPipe> constructor) {
    final ItemLogisticsPipe res = LogisticsBlockGenericPipe.registerPipe(registry, name, constructor);
    final CoreUnroutedPipe pipe = Objects.requireNonNull(LogisticsBlockGenericPipe.createPipe(res), "created a null pipe from " + res.toString());
    if (pipe instanceof CoreRoutedPipe) {
        postInitRun.add(() -> res.setPipeIconIndex(((CoreRoutedPipe) pipe).getTextureType(null).normal, ((CoreRoutedPipe) pipe).getTextureType(null).newTexture));
    }
    if (pipe.getClass() != PipeItemsBasicLogistics.class && CoreRoutedPipe.class.isAssignableFrom(pipe.getClass())) {
        if (pipe.getClass() != PipeFluidBasic.class && PipeFluidBasic.class.isAssignableFrom(pipe.getClass())) {
            resetRecipeList.add(() -> new Pair<>(res, LPItems.pipeFluidBasic));
        } else if (pipe.getClass() != PipeBlockRequestTable.class) {
            resetRecipeList.add(() -> new Pair<>(res, LPItems.pipeBasic));
        }
    }
}
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) Pair(logisticspipes.utils.tuples.Pair)

Aggregations

CoreUnroutedPipe (logisticspipes.pipes.basic.CoreUnroutedPipe)9 TileEntity (net.minecraft.tileentity.TileEntity)6 ItemStack (net.minecraft.item.ItemStack)4 World (net.minecraft.world.World)4 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)4 ITubeOrientation (logisticspipes.interfaces.ITubeOrientation)3 ItemLogisticsPipe (logisticspipes.items.ItemLogisticsPipe)3 CoreMultiBlockPipe (logisticspipes.pipes.basic.CoreMultiBlockPipe)3 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)3 LogisticsTileGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)3 LPPositionSet (logisticspipes.utils.LPPositionSet)3 Block (net.minecraft.block.Block)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 BlockPos (net.minecraft.util.math.BlockPos)3 Nonnull (javax.annotation.Nonnull)2 LPBlocks (logisticspipes.LPBlocks)2 LogisticsPipes (logisticspipes.LogisticsPipes)2 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)2 PipeFluidBasic (logisticspipes.pipes.PipeFluidBasic)2 PipeItemsBasicLogistics (logisticspipes.pipes.PipeItemsBasicLogistics)2