Search in sources :

Example 1 with LogisticsFluidContainer

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

the class LogisticsPipes method initItems.

private void initItems(Side side) {
    boolean isClient = side == Side.CLIENT;
    Object renderer = null;
    if (isClient) {
        renderer = new FluidContainerRenderer();
    }
    LogisticsPipes.LogisticsItemCard = new LogisticsItemCard();
    LogisticsPipes.LogisticsItemCard.setUnlocalizedName("logisticsItemCard");
    GameRegistry.registerItem(LogisticsPipes.LogisticsItemCard, LogisticsPipes.LogisticsItemCard.getUnlocalizedName());
    if (isClient) {
        MinecraftForgeClient.registerItemRenderer(LogisticsPipes.LogisticsItemCard, (FluidContainerRenderer) renderer);
    }
    LogisticsPipes.LogisticsRemoteOrderer = new RemoteOrderer();
    LogisticsPipes.LogisticsRemoteOrderer.setUnlocalizedName("remoteOrdererItem");
    GameRegistry.registerItem(LogisticsPipes.LogisticsRemoteOrderer, LogisticsPipes.LogisticsRemoteOrderer.getUnlocalizedName());
    ItemPipeSignCreator.registerPipeSignTypes();
    LogisticsPipes.LogisticsCraftingSignCreator = new ItemPipeSignCreator();
    LogisticsPipes.LogisticsCraftingSignCreator.setUnlocalizedName("ItemPipeSignCreator");
    GameRegistry.registerItem(LogisticsPipes.LogisticsCraftingSignCreator, LogisticsPipes.LogisticsCraftingSignCreator.getUnlocalizedName());
    int renderIndex;
    if (isClient) {
        renderIndex = RenderingRegistry.addNewArmourRendererPrefix("LogisticsHUD");
    } else {
        renderIndex = 0;
    }
    LogisticsPipes.LogisticsHUDArmor = new ItemHUDArmor(renderIndex);
    LogisticsPipes.LogisticsHUDArmor.setUnlocalizedName("logisticsHUDGlasses");
    GameRegistry.registerItem(LogisticsPipes.LogisticsHUDArmor, LogisticsPipes.LogisticsHUDArmor.getUnlocalizedName());
    LogisticsPipes.LogisticsParts = new ItemParts();
    LogisticsPipes.LogisticsParts.setUnlocalizedName("logisticsParts");
    GameRegistry.registerItem(LogisticsPipes.LogisticsParts, LogisticsPipes.LogisticsParts.getUnlocalizedName());
    SimpleServiceLocator.buildCraftProxy.registerTrigger();
    LogisticsPipes.ModuleItem = new ItemModule();
    LogisticsPipes.ModuleItem.setUnlocalizedName("itemModule");
    LogisticsPipes.ModuleItem.loadModules();
    GameRegistry.registerItem(LogisticsPipes.ModuleItem, LogisticsPipes.ModuleItem.getUnlocalizedName());
    LogisticsPipes.LogisticsItemDisk = new ItemDisk();
    LogisticsPipes.LogisticsItemDisk.setUnlocalizedName("itemDisk");
    GameRegistry.registerItem(LogisticsPipes.LogisticsItemDisk, LogisticsPipes.LogisticsItemDisk.getUnlocalizedName());
    LogisticsPipes.UpgradeItem = new ItemUpgrade();
    LogisticsPipes.UpgradeItem.setUnlocalizedName("itemUpgrade");
    LogisticsPipes.UpgradeItem.loadUpgrades();
    GameRegistry.registerItem(LogisticsPipes.UpgradeItem, LogisticsPipes.UpgradeItem.getUnlocalizedName());
    LogisticsPipes.LogisticsFluidContainer = new LogisticsFluidContainer();
    LogisticsPipes.LogisticsFluidContainer.setUnlocalizedName("logisticsFluidContainer");
    if (isClient) {
        MinecraftForgeClient.registerItemRenderer(LogisticsPipes.LogisticsFluidContainer, (FluidContainerRenderer) renderer);
    }
    GameRegistry.registerItem(LogisticsPipes.LogisticsFluidContainer, LogisticsPipes.LogisticsFluidContainer.getUnlocalizedName());
    LogisticsPipes.LogisticsBrokenItem = new LogisticsBrokenItem();
    LogisticsPipes.LogisticsBrokenItem.setUnlocalizedName("brokenItem");
    GameRegistry.registerItem(LogisticsPipes.LogisticsBrokenItem, LogisticsPipes.LogisticsBrokenItem.getUnlocalizedName());
    LogisticsPipes.LogisticsPipeControllerItem = new ItemPipeController();
    LogisticsPipes.LogisticsPipeControllerItem.setUnlocalizedName("pipeController");
    GameRegistry.registerItem(LogisticsPipes.LogisticsPipeControllerItem, LogisticsPipes.LogisticsPipeControllerItem.getUnlocalizedName());
    //Blocks
    LogisticsPipes.LogisticsSolidBlock = new LogisticsSolidBlock();
    GameRegistry.registerBlock(LogisticsPipes.LogisticsSolidBlock, LogisticsSolidBlockItem.class, "logisticsSolidBlock");
    LogisticsPipes.LogisticsPipeBlock = new LogisticsBlockGenericPipe();
    GameRegistry.registerBlock(LogisticsPipes.LogisticsPipeBlock, "logisticsPipeBlock");
    LogisticsPipes.LogisticsSubMultiBlock = new LogisticsBlockGenericSubMultiBlock();
    GameRegistry.registerBlock(LogisticsPipes.LogisticsSubMultiBlock, "logisticsSubMultiBlock");
    LogisticsChips = new ItemLogisticsChips();
    LogisticsChips.setUnlocalizedName("logisticsChips");
    GameRegistry.registerItem(LogisticsChips, LogisticsChips.getUnlocalizedName());
    registerPipes(side);
}
Also used : ItemHUDArmor(logisticspipes.items.ItemHUDArmor) FluidContainerRenderer(logisticspipes.renderer.FluidContainerRenderer) ItemUpgrade(logisticspipes.items.ItemUpgrade) ItemPipeController(logisticspipes.items.ItemPipeController) LogisticsBlockGenericPipe(logisticspipes.pipes.basic.LogisticsBlockGenericPipe) LogisticsItemCard(logisticspipes.items.LogisticsItemCard) RemoteOrderer(logisticspipes.items.RemoteOrderer) ItemDisk(logisticspipes.items.ItemDisk) LogisticsFluidContainer(logisticspipes.items.LogisticsFluidContainer) LogisticsBrokenItem(logisticspipes.items.LogisticsBrokenItem) LogisticsSolidBlock(logisticspipes.blocks.LogisticsSolidBlock) ItemPipeSignCreator(logisticspipes.items.ItemPipeSignCreator) ItemParts(logisticspipes.items.ItemParts) ItemLogisticsChips(logisticspipes.items.ItemLogisticsChips) ItemModule(logisticspipes.items.ItemModule) LogisticsBlockGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsBlockGenericSubMultiBlock)

Example 2 with LogisticsFluidContainer

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

the class LogisticsManager method assignDestinationFor.

/**
	 * Will assign a destination for a IRoutedItem based on a best sink reply
	 * recieved from other pipes.
	 * 
	 * @param item
	 *            The item that needs to be routed.
	 * @param sourceRouterID
	 *            The SimpleID of the pipe that is sending the item. (the
	 *            routedItem will cache the UUID, and that the SimpleID belongs
	 *            to the UUID will be checked when appropriate)
	 * @param excludeSource
	 *            Boolean, true means that it wont set the source as the
	 *            destination.
	 * @return IRoutedItem with a newly assigned destination
	 */
@Override
public IRoutedItem assignDestinationFor(IRoutedItem item, int sourceRouterID, boolean excludeSource) {
    //Assert: only called server side.
    //If we for some reason can't get the router we can't do anything either
    IRouter sourceRouter = SimpleServiceLocator.routerManager.getRouterUnsafe(sourceRouterID, false);
    if (sourceRouter == null) {
        return item;
    }
    //Wipe current destination
    item.clearDestination();
    BitSet routersIndex = ServerRouter.getRoutersInterestedIn(item.getItemIdentifierStack().getItem());
    // get the routing table
    List<ExitRoute> validDestinations = new ArrayList<>();
    for (int i = routersIndex.nextSetBit(0); i >= 0; i = routersIndex.nextSetBit(i + 1)) {
        IRouter r = SimpleServiceLocator.routerManager.getRouterUnsafe(i, false);
        List<ExitRoute> exits = sourceRouter.getDistanceTo(r);
        if (exits != null) {
            validDestinations.addAll(exits.stream().filter(e -> e.containsFlag(PipeRoutingConnectionType.canRouteTo)).collect(Collectors.toList()));
        }
    }
    Collections.sort(validDestinations);
    if (item.getItemIdentifierStack() != null && item.getItemIdentifierStack().makeNormalStack().getItem() instanceof LogisticsFluidContainer) {
        Pair<Integer, Integer> bestReply = SimpleServiceLocator.logisticsFluidManager.getBestReply(SimpleServiceLocator.logisticsFluidManager.getFluidFromContainer(item.getItemIdentifierStack()), sourceRouter, item.getJamList());
        if (bestReply.getValue1() != null && bestReply.getValue1() != 0) {
            item.setDestination(bestReply.getValue1());
        }
        return item;
    } else {
        Triplet<Integer, SinkReply, List<IFilter>> bestReply = getBestReply(item.getItemIdentifierStack().getItem(), sourceRouter, validDestinations, excludeSource, item.getJamList(), null, true);
        if (bestReply.getValue1() != null && bestReply.getValue1() != 0) {
            item.setDestination(bestReply.getValue1());
            if (bestReply.getValue2().isPassive) {
                if (bestReply.getValue2().isDefault) {
                    item.setTransportMode(TransportMode.Default);
                } else {
                    item.setTransportMode(TransportMode.Passive);
                }
            } else {
                item.setTransportMode(TransportMode.Active);
            }
            item.setAdditionalTargetInformation(bestReply.getValue2().addInfo);
        }
        return item;
    }
}
Also used : LogisticsFluidContainer(logisticspipes.items.LogisticsFluidContainer) IRouter(logisticspipes.routing.IRouter) SinkReply(logisticspipes.utils.SinkReply) BitSet(java.util.BitSet) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ExitRoute(logisticspipes.routing.ExitRoute)

Example 3 with LogisticsFluidContainer

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

the class FluidContainerRenderer method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if (FluidContainerRenderer.skipNext) {
        FluidContainerRenderer.skipNext = false;
        return;
    }
    GL11.glPushMatrix();
    Minecraft mc = FMLClientHandler.instance().getClient();
    if (item.getItem() instanceof LogisticsFluidContainer) {
        FluidStack liquid = SimpleServiceLocator.logisticsFluidManager.getFluidFromContainer(ItemIdentifierStack.getFromStack(item));
        if ((type != ItemRenderType.INVENTORY && type != ItemRenderType.ENTITY) || liquid == null) {
            doRenderItem(item, mc, type, data);
            GL11.glPopMatrix();
            return;
        }
        doRenderFluid(liquid, mc, type, data);
        doRenderItem(item, mc, type, data);
    } else if (item.getItem() instanceof LogisticsItemCard) {
        doRenderItem(item, mc, type, data);
        NBTTagCompound nbt = item.getTagCompound();
        if (nbt == null || !nbt.hasKey("colors")) {
            GL11.glPopMatrix();
            return;
        }
        NBTTagCompound colors = nbt.getCompoundTag("colors");
        if (colors == null) {
            GL11.glPopMatrix();
            return;
        }
        if (type == ItemRenderType.ENTITY) {
            GL11.glScaled(0.07, 0.07, 1);
            GL11.glTranslated(-3, 3.5, -0.025);
        }
        for (int i = 0; i < 6; i++) {
            int colorCode = colors.getInteger("color:" + i);
            MinecraftColor color = MinecraftColor.values()[colorCode];
            int x = i / 3;
            int y = i % 3;
            if (type == ItemRenderType.INVENTORY) {
                Gui.drawRect(x * 5 + 4, y * 3 + 3, x * 5 + 7, y * 3 + 5, color.getColorCode());
            }
            if (type == ItemRenderType.ENTITY) {
                Gui.drawRect(-x * 5 + 4, -y * 3 + 3, -x * 5 + 7, -y * 3 + 5, color.getColorCode());
                GL11.glRotatef(180, 1, 0, 0);
                Gui.drawRect(-x * 5 + 4, -y * 3 + 3, -x * 5 + 7, -y * 3 + 5, color.getColorCode());
                GL11.glRotatef(180, 1, 0, 0);
            }
        }
    }
    GL11.glPopMatrix();
}
Also used : MinecraftColor(logisticspipes.utils.MinecraftColor) LogisticsFluidContainer(logisticspipes.items.LogisticsFluidContainer) FluidStack(net.minecraftforge.fluids.FluidStack) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Minecraft(net.minecraft.client.Minecraft) LogisticsItemCard(logisticspipes.items.LogisticsItemCard)

Example 4 with LogisticsFluidContainer

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

the class LogisticsNewPipeItemBoxRenderer method doRenderItem.

public void doRenderItem(ItemStack itemstack, float light, double x, double y, double z, double boxScale, double yaw, double pitch, double yawForPitch) {
    if (LogisticsNewRenderPipe.innerTransportBox == null)
        return;
    GL11.glPushMatrix();
    if (renderList == -1) {
        renderList = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(renderList, GL11.GL_COMPILE);
        Tessellator tess = Tessellator.instance;
        tess.startDrawingQuads();
        LogisticsNewRenderPipe.innerTransportBox.render(LogisticsNewRenderPipe.innerBoxTexture);
        tess.draw();
        GL11.glEndList();
    }
    GL11.glTranslated(x, y, z);
    Minecraft.getMinecraft().getTextureManager().bindTexture(LogisticsNewPipeItemBoxRenderer.BLOCKS);
    GL11.glScaled(boxScale, boxScale, boxScale);
    GL11.glRotated(yawForPitch, 0, 1, 0);
    GL11.glRotated(pitch, 1, 0, 0);
    GL11.glRotated(-yawForPitch, 0, 1, 0);
    GL11.glRotated(yaw, 0, 1, 0);
    GL11.glTranslated(-0.5, -0.5, -0.5);
    GL11.glCallList(renderList);
    GL11.glTranslated(0.5, 0.5, 0.5);
    GL11.glRotated(-pitch, 1, 0, 0);
    GL11.glRotated(-yaw, 0, 1, 0);
    GL11.glScaled(1 / boxScale, 1 / boxScale, 1 / boxScale);
    GL11.glTranslated(-0.5, -0.5, -0.5);
    if (itemstack != null && itemstack.getItem() instanceof LogisticsFluidContainer) {
        FluidStack f = SimpleServiceLocator.logisticsFluidManager.getFluidFromContainer(ItemIdentifierStack.getFromStack(itemstack));
        if (f != null) {
            FluidContainerRenderer.skipNext = true;
            int list = getRenderListFor(f);
            GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
            GL11.glEnable(GL11.GL_CULL_FACE);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GL11.glCallList(list);
            GL11.glPopAttrib();
        }
    }
    GL11.glPopMatrix();
}
Also used : LogisticsFluidContainer(logisticspipes.items.LogisticsFluidContainer) Tessellator(net.minecraft.client.renderer.Tessellator) FluidStack(net.minecraftforge.fluids.FluidStack)

Aggregations

LogisticsFluidContainer (logisticspipes.items.LogisticsFluidContainer)4 LogisticsItemCard (logisticspipes.items.LogisticsItemCard)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 LogisticsSolidBlock (logisticspipes.blocks.LogisticsSolidBlock)1 ItemDisk (logisticspipes.items.ItemDisk)1 ItemHUDArmor (logisticspipes.items.ItemHUDArmor)1 ItemLogisticsChips (logisticspipes.items.ItemLogisticsChips)1 ItemModule (logisticspipes.items.ItemModule)1 ItemParts (logisticspipes.items.ItemParts)1 ItemPipeController (logisticspipes.items.ItemPipeController)1 ItemPipeSignCreator (logisticspipes.items.ItemPipeSignCreator)1 ItemUpgrade (logisticspipes.items.ItemUpgrade)1 LogisticsBrokenItem (logisticspipes.items.LogisticsBrokenItem)1 RemoteOrderer (logisticspipes.items.RemoteOrderer)1 LogisticsBlockGenericPipe (logisticspipes.pipes.basic.LogisticsBlockGenericPipe)1 LogisticsBlockGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsBlockGenericSubMultiBlock)1