Search in sources :

Example 6 with ICrafting

use of net.minecraft.inventory.ICrafting in project LogisticsPipes by RS485.

the class DummyContainer method detectAndSendChanges.

@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
    for (int i = 0; i < inventorySlots.size(); ++i) {
        if (inventorySlots.get(i) instanceof IFuzzySlot) {
            IFuzzySlot fuzzySlot = (IFuzzySlot) inventorySlots.get(i);
            BitSet set = inventoryFuzzySlotsContent.get(i);
            if (set == null) {
                set = fuzzySlot.getFuzzyFlags().getBitSet();
                MainProxy.sendToPlayerList(PacketHandler.getPacket(FuzzySlotSettingsPacket.class).setSlotNumber(fuzzySlot.getSlotId()).setFlags(set), crafters);
                inventoryFuzzySlotsContent.set(i, set);
            } else {
                BitSet setB = fuzzySlot.getFuzzyFlags().getBitSet();
                if (!set.equals(setB)) {
                    MainProxy.sendToPlayerList(PacketHandler.getPacket(FuzzySlotSettingsPacket.class).setSlotNumber(fuzzySlot.getSlotId()).setFlags(setB), crafters);
                    inventoryFuzzySlotsContent.set(i, setB);
                }
            }
        }
        ItemStack itemstack = ((Slot) inventorySlots.get(i)).getStack();
        ItemStack itemstack1 = (ItemStack) inventoryItemStacks.get(i);
        if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) {
            itemstack1 = itemstack == null ? null : itemstack.copy();
            inventoryItemStacks.set(i, itemstack1);
            for (Object crafter : crafters) {
                boolean revert = false;
                if (overrideMCAntiSend && crafter instanceof EntityPlayerMP && ((EntityPlayerMP) crafter).isChangingQuantityOnly) {
                    ((EntityPlayerMP) crafter).isChangingQuantityOnly = false;
                    revert = true;
                }
                ((ICrafting) crafter).sendSlotContents(this, i, itemstack1);
                if (revert) {
                    ((EntityPlayerMP) crafter).isChangingQuantityOnly = true;
                }
            }
        }
    }
    overrideMCAntiSend = false;
}
Also used : IFuzzySlot(logisticspipes.interfaces.IFuzzySlot) BitSet(java.util.BitSet) Slot(net.minecraft.inventory.Slot) IFuzzySlot(logisticspipes.interfaces.IFuzzySlot) ICrafting(net.minecraft.inventory.ICrafting) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) FuzzySlotSettingsPacket(logisticspipes.network.packets.gui.FuzzySlotSettingsPacket)

Example 7 with ICrafting

use of net.minecraft.inventory.ICrafting in project MineFactoryReloaded by powercrystals.

the class ContainerLiquiCrafter method detectAndSendChanges.

@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    int tankIndex = (int) (_crafter.worldObj.getWorldTime() % 9);
    ILiquidTank tank = _crafter.getTanks(ForgeDirection.UNKNOWN)[tankIndex];
    LiquidStack l = tank.getLiquid();
    for (int i = 0; i < crafters.size(); i++) {
        ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 0, tankIndex);
        if (l != null) {
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 1, l.itemID);
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 2, l.itemMeta);
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 3, l.amount);
        } else {
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 1, 0);
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 2, 0);
            ((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 3, 0);
        }
    }
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) ILiquidTank(net.minecraftforge.liquids.ILiquidTank) ICrafting(net.minecraft.inventory.ICrafting)

Example 8 with ICrafting

use of net.minecraft.inventory.ICrafting in project compactsolars by cpw.

the class ContainerCompactSolar method detectAndSendChanges.

@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    @SuppressWarnings("unchecked") List<ICrafting> crafters = this.crafters;
    for (ICrafting crafter : crafters) {
        if (theSunIsVisible != tile.theSunIsVisible || !initialized) {
            crafter.sendProgressBarUpdate(this, 0, tile.theSunIsVisible ? 1 : 0);
        }
    }
    initialized = true;
    theSunIsVisible = tile.theSunIsVisible;
}
Also used : ICrafting(net.minecraft.inventory.ICrafting)

Example 9 with ICrafting

use of net.minecraft.inventory.ICrafting in project BluePower by Qmunity.

the class ContainerCircuitDatabaseMain method detectAndSendChanges.

/**
     * Looks for changes made in the container, sends them to every listener.
     */
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    for (Object crafter : crafters) {
        ICrafting icrafting = (ICrafting) crafter;
        if (curUploadProgress != circuitDatabase.curUploadProgress) {
            icrafting.sendProgressBarUpdate(this, 0, circuitDatabase.curUploadProgress);
        }
        if (curCopyProgress != circuitDatabase.curCopyProgress) {
            icrafting.sendProgressBarUpdate(this, 1, circuitDatabase.curCopyProgress);
        }
        if (selectedShareOption != circuitDatabase.selectedShareOption) {
            icrafting.sendProgressBarUpdate(this, 2, circuitDatabase.selectedShareOption);
        }
    }
    curUploadProgress = circuitDatabase.curUploadProgress;
    curCopyProgress = circuitDatabase.curCopyProgress;
    selectedShareOption = circuitDatabase.selectedShareOption;
}
Also used : ICrafting(net.minecraft.inventory.ICrafting)

Example 10 with ICrafting

use of net.minecraft.inventory.ICrafting in project BluePower by Qmunity.

the class ContainerRegulator method detectAndSendChanges.

/**
     * Looks for changes made in the container, sends them to every listener.
     */
@Override
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    for (Object crafter : crafters) {
        ICrafting icrafting = (ICrafting) crafter;
        if (filterColor != tileRegulator.color.ordinal()) {
            icrafting.sendProgressBarUpdate(this, 0, tileRegulator.color.ordinal());
        }
        if (mode != tileRegulator.mode) {
            icrafting.sendProgressBarUpdate(this, 2, tileRegulator.mode);
        }
        if (fuzzySetting != tileRegulator.fuzzySetting) {
            icrafting.sendProgressBarUpdate(this, 3, tileRegulator.fuzzySetting);
        }
    }
    filterColor = tileRegulator.color.ordinal();
    mode = tileRegulator.mode;
    fuzzySetting = tileRegulator.fuzzySetting;
}
Also used : ICrafting(net.minecraft.inventory.ICrafting)

Aggregations

ICrafting (net.minecraft.inventory.ICrafting)12 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 MessageSyncMachineBacklog (com.bluepowermod.network.message.MessageSyncMachineBacklog)1 BitSet (java.util.BitSet)1 IFuzzySlot (logisticspipes.interfaces.IFuzzySlot)1 FuzzySlotSettingsPacket (logisticspipes.network.packets.gui.FuzzySlotSettingsPacket)1 Slot (net.minecraft.inventory.Slot)1 ItemStack (net.minecraft.item.ItemStack)1 ILiquidTank (net.minecraftforge.liquids.ILiquidTank)1 LiquidStack (net.minecraftforge.liquids.LiquidStack)1