Search in sources :

Example 1 with IFuzzySlot

use of logisticspipes.interfaces.IFuzzySlot in project LogisticsPipes by RS485.

the class DummyContainer method detectAndSendChanges.

@Override
public void detectAndSendChanges() {
    for (int i = 0; i < inventorySlots.size(); ++i) {
        if (inventorySlots.get(i) instanceof IFuzzySlot) {
            IFuzzySlot fuzzySlot = (IFuzzySlot) inventorySlots.get(i);
            BitSet slotFlags = fuzzySlot.getFuzzyFlags().copyValue();
            BitSet savedFlags = slotsFuzzyFlags.get(i);
            if (savedFlags == null || !savedFlags.equals(slotFlags)) {
                MainProxy.sendToPlayerList(PacketHandler.getPacket(FuzzySlotSettingsPacket.class).setSlotNumber(fuzzySlot.getSlotId()).setFlags(slotFlags), listeners.stream().filter(o -> o instanceof EntityPlayer).map(o -> (EntityPlayer) o));
                slotsFuzzyFlags.set(i, slotFlags);
            }
        }
        ItemStack itemstack = inventorySlots.get(i).getStack();
        ItemStack itemstack1 = inventoryItemStacks.get(i);
        if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) {
            itemstack1 = itemstack.isEmpty() ? ItemStack.EMPTY : itemstack.copy();
            inventoryItemStacks.set(i, itemstack1);
            for (IContainerListener crafter : listeners) {
                boolean revert = false;
                if (overrideMCAntiSend && crafter instanceof EntityPlayerMP && ((EntityPlayerMP) crafter).isChangingQuantityOnly) {
                    ((EntityPlayerMP) crafter).isChangingQuantityOnly = false;
                    revert = true;
                }
                crafter.sendSlotContents(this, i, itemstack1);
                if (revert) {
                    ((EntityPlayerMP) crafter).isChangingQuantityOnly = true;
                }
            }
        }
    }
    overrideMCAntiSend = false;
}
Also used : Item(net.minecraft.item.Item) LogisticsPipes(logisticspipes.LogisticsPipes) ItemModule(logisticspipes.items.ItemModule) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) MainProxy(logisticspipes.proxy.MainProxy) ArrayList(java.util.ArrayList) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IBitSet(network.rs485.logisticspipes.property.IBitSet) UpgradeManager(logisticspipes.pipes.upgrades.UpgradeManager) ItemStack(net.minecraft.item.ItemStack) FluidIdentifier(logisticspipes.utils.FluidIdentifier) IContainerListener(net.minecraft.inventory.IContainerListener) Side(net.minecraftforge.fml.relauncher.Side) ISlotUpgradeManager(logisticspipes.interfaces.ISlotUpgradeManager) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ChassisModule(logisticspipes.modules.ChassisModule) Nonnull(javax.annotation.Nonnull) ReflectionHelper(logisticspipes.utils.ReflectionHelper) FuzzySlotSettingsPacket(logisticspipes.network.packets.gui.FuzzySlotSettingsPacket) IGuiOpenControler(logisticspipes.interfaces.IGuiOpenControler) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) PacketHandler(logisticspipes.network.PacketHandler) List(java.util.List) ISlotClick(logisticspipes.interfaces.ISlotClick) ItemModuleInformationManager(logisticspipes.logisticspipes.ItemModuleInformationManager) ISlotCheck(logisticspipes.interfaces.ISlotCheck) MinecraftColor(logisticspipes.utils.MinecraftColor) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IInventory(net.minecraft.inventory.IInventory) Slot(net.minecraft.inventory.Slot) IFuzzySlot(logisticspipes.interfaces.IFuzzySlot) BitSet(java.util.BitSet) ClickType(net.minecraft.inventory.ClickType) Container(net.minecraft.inventory.Container) IFuzzySlot(logisticspipes.interfaces.IFuzzySlot) IBitSet(network.rs485.logisticspipes.property.IBitSet) BitSet(java.util.BitSet) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IContainerListener(net.minecraft.inventory.IContainerListener) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) FuzzySlotSettingsPacket(logisticspipes.network.packets.gui.FuzzySlotSettingsPacket)

Example 2 with IFuzzySlot

use of logisticspipes.interfaces.IFuzzySlot in project LogisticsPipes by RS485.

the class LogisticsBaseGuiScreen method onRenderSlot.

private void onRenderSlot(Slot slot) {
    if (slot instanceof IFuzzySlot) {
        final IBitSet set = ((IFuzzySlot) slot).getFuzzyFlags();
        int x1 = slot.xPos;
        int y1 = slot.yPos;
        GL11.glDisable(GL11.GL_LIGHTING);
        final boolean useOreDict = FuzzyUtil.INSTANCE.get(set, FuzzyFlag.USE_ORE_DICT);
        if (useOreDict) {
            Gui.drawRect(x1 + 8, y1 - 1, x1 + 17, y1, 0xFFFF4040);
            Gui.drawRect(x1 + 16, y1, x1 + 17, y1 + 8, 0xFFFF4040);
        }
        final boolean ignoreDamage = FuzzyUtil.INSTANCE.get(set, FuzzyFlag.IGNORE_DAMAGE);
        if (ignoreDamage) {
            Gui.drawRect(x1 - 1, y1 - 1, x1 + 8, y1, 0xFF40FF40);
            Gui.drawRect(x1 - 1, y1, x1, y1 + 8, 0xFF40FF40);
        }
        final boolean ignoreNBT = FuzzyUtil.INSTANCE.get(set, FuzzyFlag.IGNORE_NBT);
        if (ignoreNBT) {
            Gui.drawRect(x1 - 1, y1 + 16, x1 + 8, y1 + 17, 0xFF4040FF);
            Gui.drawRect(x1 - 1, y1 + 8, x1, y1 + 17, 0xFF4040FF);
        }
        final boolean useOreCategory = FuzzyUtil.INSTANCE.get(set, FuzzyFlag.USE_ORE_CATEGORY);
        if (useOreCategory) {
            Gui.drawRect(x1 + 8, y1 + 16, x1 + 17, y1 + 17, 0xFF7F7F40);
            Gui.drawRect(x1 + 16, y1 + 8, x1 + 17, y1 + 17, 0xFF7F7F40);
        }
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glEnable(GL11.GL_LIGHTING);
        final boolean mouseOver = this.isMouseOverSlot(slot, currentDrawScreenMouseX, currentDrawScreenMouseY);
        if (mouseOver) {
            if (fuzzySlot == slot) {
                fuzzySlotGuiHoverTime++;
                if (fuzzySlotGuiHoverTime >= 10) {
                    fuzzySlotActiveGui = true;
                }
            } else {
                fuzzySlot = (IFuzzySlot) slot;
                fuzzySlotGuiHoverTime = 0;
                fuzzySlotActiveGui = false;
            }
        }
        if (fuzzySlotActiveGui && fuzzySlot == slot) {
            if (!mouseOver) {
                // Check within FuzzyGui
                if (!isPointInRegion(slot.xPos, slot.yPos + 16, 60, 52, currentDrawScreenMouseX, currentDrawScreenMouseY)) {
                    fuzzySlotActiveGui = false;
                    fuzzySlot = null;
                }
            }
            final int posX = slot.xPos + guiLeft;
            final int posY = slot.yPos + 17 + guiTop;
            renderAtTheEnd.add(() -> {
                GL11.glDisable(GL11.GL_DEPTH_TEST);
                GL11.glDisable(GL11.GL_LIGHTING);
                GuiGraphics.drawGuiBackGround(mc, posX, posY, posX + 61, posY + 47, zLevel, true, true, true, true, true);
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                final String PREFIX = "gui.crafting.";
                mc.fontRenderer.drawString(TextUtil.translate(PREFIX + "OreDict"), posX + 5, posY + 5, (useOreDict ? 0xFF4040 : 0x404040));
                mc.fontRenderer.drawString(TextUtil.translate(PREFIX + "IgnDamage"), posX + 5, posY + 15, (ignoreDamage ? 0x40FF40 : 0x404040));
                mc.fontRenderer.drawString(TextUtil.translate(PREFIX + "IgnNBT"), posX + 5, posY + 25, (ignoreNBT ? 0x4040FF : 0x404040));
                mc.fontRenderer.drawString(TextUtil.translate(PREFIX + "OrePrefix"), posX + 5, posY + 35, (useOreCategory ? 0x7F7F40 : 0x404040));
                GL11.glEnable(GL11.GL_LIGHTING);
                GL11.glEnable(GL11.GL_DEPTH_TEST);
            });
        }
    }
}
Also used : IFuzzySlot(logisticspipes.interfaces.IFuzzySlot) IBitSet(network.rs485.logisticspipes.property.IBitSet)

Aggregations

IFuzzySlot (logisticspipes.interfaces.IFuzzySlot)2 IBitSet (network.rs485.logisticspipes.property.IBitSet)2 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 List (java.util.List)1 Nonnull (javax.annotation.Nonnull)1 LogisticsPipes (logisticspipes.LogisticsPipes)1 IGuiOpenControler (logisticspipes.interfaces.IGuiOpenControler)1 ISlotCheck (logisticspipes.interfaces.ISlotCheck)1 ISlotClick (logisticspipes.interfaces.ISlotClick)1 ISlotUpgradeManager (logisticspipes.interfaces.ISlotUpgradeManager)1 ItemModule (logisticspipes.items.ItemModule)1 ItemModuleInformationManager (logisticspipes.logisticspipes.ItemModuleInformationManager)1 ChassisModule (logisticspipes.modules.ChassisModule)1 PacketHandler (logisticspipes.network.PacketHandler)1 FuzzySlotSettingsPacket (logisticspipes.network.packets.gui.FuzzySlotSettingsPacket)1 PipeLogisticsChassis (logisticspipes.pipes.PipeLogisticsChassis)1 UpgradeManager (logisticspipes.pipes.upgrades.UpgradeManager)1 MainProxy (logisticspipes.proxy.MainProxy)1 FluidIdentifier (logisticspipes.utils.FluidIdentifier)1