Search in sources :

Example 11 with FluidIdentifier

use of logisticspipes.utils.FluidIdentifier in project LogisticsPipes by RS485.

the class ClientProxy method openFluidSelectGui.

@Override
public void openFluidSelectGui(final int slotId) {
    if (Minecraft.getMinecraft().currentScreen instanceof LogisticsBaseGuiScreen) {
        final List<ItemIdentifierStack> list = new ArrayList<>();
        for (FluidIdentifier fluid : FluidIdentifier.all()) {
            if (fluid == null) {
                continue;
            }
            list.add(fluid.getItemIdentifier().makeStack(1));
        }
        SelectItemOutOfList subGui = new SelectItemOutOfList(list, slot -> MainProxy.sendPacketToServer(PacketHandler.getPacket(DummyContainerSlotClick.class).setSlotId(slotId).setStack(list.get(slot).makeNormalStack()).setButton(0)));
        LogisticsBaseGuiScreen gui = (LogisticsBaseGuiScreen) Minecraft.getMinecraft().currentScreen;
        if (!gui.hasSubGui()) {
            gui.setSubGui(subGui);
        } else {
            SubGuiScreen nextGui = gui.getSubGui();
            while (nextGui.hasSubGui()) {
                nextGui = nextGui.getSubGui();
            }
            nextGui.setSubGui(subGui);
        }
    } else {
        throw new UnsupportedOperationException(String.valueOf(Minecraft.getMinecraft().currentScreen));
    }
}
Also used : LogisticsBaseGuiScreen(logisticspipes.utils.gui.LogisticsBaseGuiScreen) SelectItemOutOfList(logisticspipes.gui.popup.SelectItemOutOfList) ArrayList(java.util.ArrayList) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) FluidIdentifier(logisticspipes.utils.FluidIdentifier) DummyContainerSlotClick(logisticspipes.network.packets.gui.DummyContainerSlotClick) SubGuiScreen(logisticspipes.utils.gui.SubGuiScreen)

Example 12 with FluidIdentifier

use of logisticspipes.utils.FluidIdentifier in project LogisticsPipes by RS485.

the class LogisticsNewPipeItemBoxRenderer method getRenderListFor.

private int getRenderListFor(FluidStack fluid) {
    FluidIdentifier ident = FluidIdentifier.get(fluid);
    int[] array = LogisticsNewPipeItemBoxRenderer.renderLists.get(fluid);
    if (array == null) {
        array = new int[LogisticsNewPipeItemBoxRenderer.RENDER_SIZE];
        LogisticsNewPipeItemBoxRenderer.renderLists.put(ident, array);
    }
    int pos = Math.min((int) (((Math.min(fluid.amount, 5000) * 1.0F) * LogisticsNewPipeItemBoxRenderer.RENDER_SIZE) / 5000), LogisticsNewPipeItemBoxRenderer.RENDER_SIZE - 1);
    if (array[pos] != 0) {
        return array[pos];
    }
    RenderInfo block = new RenderInfo();
    block.baseBlock = fluid.getFluid().getBlock();
    block.texture = fluid.getFluid().getStillIcon();
    float ratio = pos * 1.0F / (LogisticsNewPipeItemBoxRenderer.RENDER_SIZE - 1);
    // CENTER HORIZONTAL
    array[pos] = GLAllocation.generateDisplayLists(1);
    GL11.glNewList(array[pos], 4864);
    block.minX = 0.32;
    block.maxX = 0.68;
    block.minY = 0.32;
    block.maxY = 0.32 + (0.68 - 0.32) * ratio;
    block.minZ = 0.32;
    block.maxZ = 0.68;
    CustomBlockRenderer.INSTANCE.renderBlock(block, Minecraft.getMinecraft().theWorld, 0, 0, 0, false, true);
    GL11.glEndList();
    return array[pos];
}
Also used : FluidIdentifier(logisticspipes.utils.FluidIdentifier) RenderInfo(logisticspipes.renderer.CustomBlockRenderer.RenderInfo)

Example 13 with FluidIdentifier

use of logisticspipes.utils.FluidIdentifier in project LogisticsPipes by RS485.

the class DummyContainer method handleDummyClick.

public void handleDummyClick(Slot slot, int slotId, ItemStack currentlyEquippedStack, int mouseButton, int isShift, EntityPlayer entityplayer) {
    if (slot instanceof FluidSlot) {
        if (currentlyEquippedStack != null) {
            FluidStack liquidId = FluidContainerRegistry.getFluidForFilledItem(currentlyEquippedStack);
            if (liquidId != null) {
                FluidIdentifier ident = FluidIdentifier.get(liquidId);
                if (mouseButton == 0) {
                    if (ident == null) {
                        slot.putStack(null);
                    } else {
                        slot.putStack(ident.getItemIdentifier().unsafeMakeNormalStack(1));
                    }
                } else {
                    slot.putStack(null);
                }
                return;
            }
            FluidIdentifier ident = FluidIdentifier.get(currentlyEquippedStack);
            if (ident != null) {
                if (mouseButton == 0) {
                    slot.putStack(ident.getItemIdentifier().unsafeMakeNormalStack(1));
                } else {
                    slot.putStack(null);
                }
                return;
            }
        }
        FluidIdentifier ident = null;
        if (slot.getStack() != null) {
            ident = FluidIdentifier.get(ItemIdentifier.get(slot.getStack()));
        }
        if (ident == null) {
            if (MainProxy.isClient(entityplayer.getEntityWorld())) {
                MainProxy.proxy.openFluidSelectGui(slotId);
            }
        }
        slot.putStack(null);
        return;
    }
    if (slot instanceof ColorSlot) {
        MinecraftColor equipped = MinecraftColor.getColor(currentlyEquippedStack);
        MinecraftColor color = MinecraftColor.getColor(slot.getStack());
        if (MinecraftColor.BLANK.equals(equipped)) {
            if (mouseButton == 0) {
                color = color.getNext();
            } else if (mouseButton == 1) {
                color = color.getPrev();
            } else {
                color = MinecraftColor.BLANK;
            }
            slot.putStack(color.getItemStack());
        } else {
            if (mouseButton == 1) {
                slot.putStack(MinecraftColor.BLANK.getItemStack());
            } else {
                slot.putStack(equipped.getItemStack());
            }
        }
        if (entityplayer instanceof EntityPlayerMP && MainProxy.isServer(entityplayer.worldObj)) {
            ((EntityPlayerMP) entityplayer).sendSlotContents(this, slotId, slot.getStack());
        }
        return;
    }
    if (slot instanceof DummySlot) {
        ((DummySlot) slot).setRedirectCall(true);
    }
    if (currentlyEquippedStack == null) {
        if (slot.getStack() != null && mouseButton == 1) {
            ItemStack tstack = slot.getStack();
            if (isShift == 1) {
                tstack.stackSize = Math.min(slot.getSlotStackLimit(), tstack.stackSize * 2);
            } else {
                tstack.stackSize /= 2;
                if (tstack.stackSize <= 0) {
                    tstack = null;
                }
            }
            slot.putStack(tstack);
        } else {
            slot.putStack(null);
        }
        if (slot instanceof DummySlot) {
            ((DummySlot) slot).setRedirectCall(false);
        }
        return;
    }
    if (!slot.getHasStack()) {
        ItemStack tstack = currentlyEquippedStack.copy();
        if (mouseButton == 1) {
            tstack.stackSize = 1;
        }
        if (tstack.stackSize > slot.getSlotStackLimit()) {
            tstack.stackSize = slot.getSlotStackLimit();
        }
        slot.putStack(tstack);
        if (slot instanceof DummySlot) {
            ((DummySlot) slot).setRedirectCall(false);
        }
        return;
    }
    ItemIdentifier currentItem = ItemIdentifier.get(currentlyEquippedStack);
    ItemIdentifier slotItem = ItemIdentifier.get(slot.getStack());
    if (currentItem.equals(slotItem)) {
        ItemStack tstack = slot.getStack();
        // Do manual shift-checking to play nice with NEI
        int counter = isShift == 1 ? 10 : 1;
        if (mouseButton == 1) {
            if (tstack.stackSize + counter <= slot.getSlotStackLimit()) {
                tstack.stackSize += counter;
            } else {
                tstack.stackSize = slot.getSlotStackLimit();
            }
            slot.putStack(tstack);
        } else if (mouseButton == 0) {
            tstack.stackSize -= counter;
            if (tstack.stackSize <= 0) {
                tstack = null;
            }
            slot.putStack(tstack);
        }
        if (slot instanceof DummySlot) {
            ((DummySlot) slot).setRedirectCall(false);
        }
        return;
    }
    ItemStack tstack = currentlyEquippedStack.copy();
    if (tstack.stackSize > slot.getSlotStackLimit()) {
        tstack.stackSize = slot.getSlotStackLimit();
    }
    slot.putStack(tstack);
    if (slot instanceof DummySlot) {
        ((DummySlot) slot).setRedirectCall(false);
    }
    return;
}
Also used : MinecraftColor(logisticspipes.utils.MinecraftColor) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) FluidStack(net.minecraftforge.fluids.FluidStack) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) FluidIdentifier(logisticspipes.utils.FluidIdentifier) ItemStack(net.minecraft.item.ItemStack)

Aggregations

FluidIdentifier (logisticspipes.utils.FluidIdentifier)13 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)7 FluidStack (net.minecraftforge.fluids.FluidStack)7 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)7 HashMap (java.util.HashMap)6 FluidTankInfo (net.minecraftforge.fluids.FluidTankInfo)6 TileEntity (net.minecraft.tileentity.TileEntity)5 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)4 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 LogisticsPipes (logisticspipes.LogisticsPipes)3 ISpecialTankAccessHandler (logisticspipes.interfaces.ISpecialTankAccessHandler)3 ISpecialTankHandler (logisticspipes.interfaces.ISpecialTankHandler)3 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)3 ItemStack (net.minecraft.item.ItemStack)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 TreeSet (java.util.TreeSet)2 GuiIDs (logisticspipes.network.GuiIDs)2 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)2 MainProxy (logisticspipes.proxy.MainProxy)2