Search in sources :

Example 1 with RedstoneControlMode

use of crazypants.enderio.base.machine.modes.RedstoneControlMode in project EnderIO by SleepyTrousers.

the class ItemConduit method writeToNBT.

@Override
public void writeToNBT(@Nonnull NBTTagCompound nbtRoot) {
    super.writeToNBT(nbtRoot);
    for (Entry<EnumFacing, IItemFilter> entry : inputFilters.entrySet()) {
        if (entry.getValue() != null) {
            IItemFilter f = entry.getValue();
            if (!isDefault(f)) {
                NBTTagCompound itemRoot = new NBTTagCompound();
                FilterRegistry.writeFilterToNbt(f, itemRoot);
                nbtRoot.setTag("inFilts." + entry.getKey().name(), itemRoot);
            }
        }
    }
    for (Entry<EnumFacing, ItemStack> entry : functionUpgrades.entrySet()) {
        if (entry.getValue() != null) {
            ItemStack up = entry.getValue();
            NBTTagCompound itemRoot = new NBTTagCompound();
            up.writeToNBT(itemRoot);
            nbtRoot.setTag("functionUpgrades." + entry.getKey().name(), itemRoot);
        }
    }
    for (Entry<EnumFacing, IItemFilter> entry : outputFilters.entrySet()) {
        if (entry.getValue() != null) {
            IItemFilter f = entry.getValue();
            if (!isDefault(f)) {
                NBTTagCompound itemRoot = new NBTTagCompound();
                FilterRegistry.writeFilterToNbt(f, itemRoot);
                nbtRoot.setTag("outFilts." + entry.getKey().name(), itemRoot);
            }
        }
    }
    for (Entry<EnumFacing, ItemStack> entry : inputFilterUpgrades.entrySet()) {
        if (entry.getValue() != null) {
            ItemStack up = entry.getValue();
            IItemFilter filter = getInputFilter(entry.getKey());
            FilterRegistry.writeFilterToStack(filter, up);
            NBTTagCompound itemRoot = new NBTTagCompound();
            up.writeToNBT(itemRoot);
            nbtRoot.setTag("inputFilterUpgrades." + entry.getKey().name(), itemRoot);
        }
    }
    for (Entry<EnumFacing, ItemStack> entry : outputFilterUpgrades.entrySet()) {
        if (entry.getValue() != null) {
            ItemStack up = entry.getValue();
            IItemFilter filter = getOutputFilter(entry.getKey());
            FilterRegistry.writeFilterToStack(filter, up);
            NBTTagCompound itemRoot = new NBTTagCompound();
            up.writeToNBT(itemRoot);
            nbtRoot.setTag("outputFilterUpgrades." + entry.getKey().name(), itemRoot);
        }
    }
    for (Entry<EnumFacing, RedstoneControlMode> entry : extractionModes.entrySet()) {
        if (entry.getValue() != null) {
            short ord = (short) entry.getValue().ordinal();
            nbtRoot.setShort("extRM." + entry.getKey().name(), ord);
        }
    }
    for (Entry<EnumFacing, DyeColor> entry : extractionColors.entrySet()) {
        if (entry.getValue() != null) {
            short ord = (short) entry.getValue().ordinal();
            nbtRoot.setShort("extSC." + entry.getKey().name(), ord);
        }
    }
    for (Entry<EnumFacing, Boolean> entry : selfFeed.entrySet()) {
        if (entry.getValue() != null) {
            nbtRoot.setBoolean("selfFeed." + entry.getKey().name(), entry.getValue());
        }
    }
    for (Entry<EnumFacing, Boolean> entry : roundRobin.entrySet()) {
        if (entry.getValue() != null) {
            nbtRoot.setBoolean("roundRobin." + entry.getKey().name(), entry.getValue());
        }
    }
    for (Entry<EnumFacing, Integer> entry : priority.entrySet()) {
        if (entry.getValue() != null) {
            nbtRoot.setInteger("priority." + entry.getKey().name(), entry.getValue());
        }
    }
    for (Entry<EnumFacing, DyeColor> entry : inputColors.entrySet()) {
        if (entry.getValue() != null) {
            short ord = (short) entry.getValue().ordinal();
            nbtRoot.setShort("inSC." + entry.getKey().name(), ord);
        }
    }
    for (Entry<EnumFacing, DyeColor> entry : outputColors.entrySet()) {
        if (entry.getValue() != null) {
            short ord = (short) entry.getValue().ordinal();
            nbtRoot.setShort("outSC." + entry.getKey().name(), ord);
        }
    }
}
Also used : IItemFilter(crazypants.enderio.base.filter.IItemFilter) EnumFacing(net.minecraft.util.EnumFacing) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) RedstoneControlMode(crazypants.enderio.base.machine.modes.RedstoneControlMode) DyeColor(com.enderio.core.common.util.DyeColor) ItemStack(net.minecraft.item.ItemStack)

Example 2 with RedstoneControlMode

use of crazypants.enderio.base.machine.modes.RedstoneControlMode in project EnderIO by SleepyTrousers.

the class ConduitRedstoneModeControlable method setRedstoneControlMode.

@Override
public void setRedstoneControlMode(@Nonnull RedstoneControlMode mode) {
    RedstoneControlMode curMode = getRedstoneControlMode();
    con.setExtractionRedstoneMode(mode, gui.getDir());
    colorB.onGuiInit();
    colorB.setColorIndex(con.getExtractionSignalColor(gui.getDir()).ordinal());
    if (mode == RedstoneControlMode.OFF || mode == RedstoneControlMode.ON) {
        colorB.setIsVisible(true);
    } else {
        colorB.setIsVisible(false);
    }
    if (curMode != mode) {
        PacketHandler.INSTANCE.sendToServer(new PacketExtractMode(con, gui.getDir()));
    }
}
Also used : PacketExtractMode(crazypants.enderio.conduits.network.PacketExtractMode) RedstoneControlMode(crazypants.enderio.base.machine.modes.RedstoneControlMode)

Aggregations

RedstoneControlMode (crazypants.enderio.base.machine.modes.RedstoneControlMode)2 DyeColor (com.enderio.core.common.util.DyeColor)1 IItemFilter (crazypants.enderio.base.filter.IItemFilter)1 PacketExtractMode (crazypants.enderio.conduits.network.PacketExtractMode)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 EnumFacing (net.minecraft.util.EnumFacing)1