Search in sources :

Example 1 with PipeWire

use of buildcraft.api.transport.PipeWire in project BuildCraft by BuildCraft.

the class AdvancedFacadeRecipe method generateExampleExpansions.

@Override
public List<List<ItemStack>> generateExampleExpansions() {
    List<List<ItemStack>> list = new ArrayList<>();
    list.add(ItemFacade.allStacks);
    List<ItemStack> pipeWires = new ArrayList<>();
    for (PipeWire wire : PipeWire.values()) {
        pipeWires.add(wire.getStack());
    }
    list.add(pipeWires);
    return list;
}
Also used : PipeWire(buildcraft.api.transport.PipeWire) ItemPipeWire(buildcraft.transport.ItemPipeWire) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 2 with PipeWire

use of buildcraft.api.transport.PipeWire in project BuildCraft by BuildCraft.

the class AdvancedFacadeRecipe method craft.

@Override
public ItemStack craft(ItemStack input, List<ItemStack> expansions, boolean preview) {
    PipeWire wire = null;
    ItemStack facade = null;
    for (ItemStack stack : expansions) {
        if (wire == null && stack.getItem() instanceof ItemPipeWire) {
            wire = PipeWire.fromOrdinal(stack.getItemDamage());
            if (!preview) {
                stack.stackSize--;
            }
        } else if (facade == null && (stack.getItem() instanceof ItemFacade || stack.getItem() == BuildCraftTransport.pipeWire)) {
            facade = stack;
            if (!preview) {
                stack.stackSize--;
            }
        }
    }
    if (wire != null && facade != null) {
        ItemFacade.FacadeState[] states = ItemFacade.getFacadeStates(input);
        ItemFacade.FacadeState additionalState;
        if (facade.getItem() == BuildCraftTransport.plugItem) {
            additionalState = ItemFacade.FacadeState.createTransparent(wire);
        } else {
            additionalState = ItemFacade.getFacadeStates(facade)[0];
            additionalState = ItemFacade.FacadeState.create(additionalState.state, wire);
        }
        // if in states array exists state with the same wire just override it
        for (int i = 0; i < states.length; i++) {
            if (states[i].wire == wire) {
                states[i] = additionalState;
                return ItemFacade.getFacade(states);
            }
        }
        return ItemFacade.getFacade(JavaTools.concat(states, new ItemFacade.FacadeState[] { additionalState }));
    } else {
        return null;
    }
}
Also used : PipeWire(buildcraft.api.transport.PipeWire) ItemPipeWire(buildcraft.transport.ItemPipeWire) ItemFacade(buildcraft.transport.ItemFacade) ItemStack(net.minecraft.item.ItemStack) ItemPipeWire(buildcraft.transport.ItemPipeWire)

Example 3 with PipeWire

use of buildcraft.api.transport.PipeWire in project BuildCraft by BuildCraft.

the class Gate method readFromNBT.

public void readFromNBT(NBTTagCompound data) {
    readStatementsFromNBT(data);
    if (data.hasKey("wireState[0]")) {
        for (PipeWire wire : PipeWire.VALUES) {
            if (data.getBoolean("wireState[" + wire.ordinal() + "]")) {
                broadcastSignal |= 1 << wire.ordinal();
            }
        }
    } else {
        broadcastSignal = data.getByte("wireState");
    }
    redstoneOutput = data.getByte("redstoneOutput");
}
Also used : PipeWire(buildcraft.api.transport.PipeWire)

Example 4 with PipeWire

use of buildcraft.api.transport.PipeWire in project BuildCraft by BuildCraft.

the class ItemFacade method migrate.

private static NBTTagCompound migrate(ItemStack stack, NBTTagCompound nbt) {
    Block block = null, blockAlt = null;
    int metadata = 0, metadataAlt;
    PipeWire wire = null;
    if (nbt.hasKey("id"))
        block = Block.REGISTRY.getObjectById(nbt.getInteger("id"));
    else if (nbt.hasKey("name"))
        block = Block.REGISTRY.getObject(new ResourceLocation(nbt.getString("name")));
    if (nbt.hasKey("name_alt"))
        blockAlt = Block.REGISTRY.getObject(new ResourceLocation(nbt.getString("name_alt")));
    if (nbt.hasKey("meta"))
        metadata = nbt.getInteger("meta");
    if (nbt.hasKey("meta_alt"))
        metadataAlt = nbt.getInteger("meta_alt");
    else
        metadataAlt = stack.getItemDamage() & 0x0000F;
    if (nbt.hasKey("wire"))
        wire = PipeWire.fromOrdinal(nbt.getInteger("wire"));
    if (block != null) {
        FacadeState[] states;
        FacadeState mainState = FacadeState.create(block.getStateFromMeta(metadata));
        if (blockAlt != null && wire != null) {
            FacadeState altState = FacadeState.create(blockAlt.getStateFromMeta(metadataAlt), wire);
            states = new FacadeState[] { mainState, altState };
        } else {
            states = new FacadeState[] { mainState };
        }
        NBTTagCompound newNbt = getFacade(states).getTagCompound();
        stack.setTagCompound(newNbt);
        return newNbt;
    }
    return nbt;
}
Also used : PipeWire(buildcraft.api.transport.PipeWire) ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block) FakeBlockAccessSingleBlock(buildcraft.core.lib.world.FakeBlockAccessSingleBlock) IFluidBlock(net.minecraftforge.fluids.IFluidBlock)

Example 5 with PipeWire

use of buildcraft.api.transport.PipeWire in project BuildCraft by BuildCraft.

the class BuildCraftTransport method preInit.

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent evt) {
    // TODO Fluid shader rendering
    // FluidShaderManager.INSTANCE.getRenderer(null);
    new BCCreativeTab("pipes");
    if (NEPTUNE_TESTING)
        new BCCreativeTab("neptune");
    if (Loader.isModLoaded("BuildCraft|Silicon")) {
        new BCCreativeTab("gates");
    }
    try {
        BuildCraftCore.mainConfigManager.register("experimental.kinesisLossMode", "lossless", "Allowed values: lossless, absolute, percentage. Defaults to lossless.", RestartRequirement.WORLD);
        BuildCraftCore.mainConfigManager.register("experimental.kinesisCanExplode", false, "Can kinesis pipes explode when over their RF/t rating?", RestartRequirement.NONE);
        BuildCraftCore.mainConfigManager.register("general.pipes.hardness", DefaultProps.PIPES_DURABILITY, "How hard to break should a pipe be?", RestartRequirement.NONE);
        BuildCraftCore.mainConfigManager.register("general.pipes.baseFluidRate", DefaultProps.PIPES_FLUIDS_BASE_FLOW_RATE, "What should the base flow rate of a fluid pipe be?", RestartRequirement.GAME).setMinValue(1).setMaxValue(40);
        BuildCraftCore.mainConfigManager.register("debug.printFacadeList", false, "Print a list of all registered facades.", RestartRequirement.GAME);
        BuildCraftCore.mainConfigManager.register("general.pipes.facadeShowAllInCreative", true, "Should all BC facades be shown in Creative/NEI, or just a few carefully chosen ones?", RestartRequirement.GAME);
        BuildCraftCore.mainConfigManager.register("general.pipes.slimeballWaterproofRecipe", false, "Should I enable an alternate Waterproof recipe, based on slimeballs?", RestartRequirement.GAME);
        BuildCraftCore.mainConfigManager.register("power.gateCostMultiplier", 1.0D, "What should be the multiplier of all gate power costs?", RestartRequirement.GAME);
        BuildCraftCore.mainConfigManager.register("general.pipes.facadeBlacklist", new String[] { // @formatter:off
        Block.blockRegistry.getNameForObject(Blocks.end_portal_frame).toString(), Block.blockRegistry.getNameForObject(Blocks.grass).toString(), Block.blockRegistry.getNameForObject(Blocks.leaves).toString(), Block.blockRegistry.getNameForObject(Blocks.leaves2).toString(), Block.blockRegistry.getNameForObject(Blocks.lit_pumpkin).toString(), Block.blockRegistry.getNameForObject(Blocks.lit_redstone_lamp).toString(), Block.blockRegistry.getNameForObject(Blocks.mob_spawner).toString(), Block.blockRegistry.getNameForObject(Blocks.monster_egg).toString(), Block.blockRegistry.getNameForObject(Blocks.redstone_lamp).toString(), Block.blockRegistry.getNameForObject(Blocks.double_stone_slab).toString(), Block.blockRegistry.getNameForObject(Blocks.double_wooden_slab).toString(), Block.blockRegistry.getNameForObject(Blocks.sponge).toString() // @formatter:on
        }, "What block types should be blacklisted from being a facade?", RestartRequirement.GAME);
        BuildCraftCore.mainConfigManager.register("general.pipes.facadeNoLaserRecipe", false, "Should non-laser (crafting table) facade recipes be forced?", RestartRequirement.GAME);
        reloadConfig(RestartRequirement.GAME);
        if (showAllFacadesCreative) {
            new BCCreativeTab("facades");
        }
        filteredBufferBlock = new BlockFilteredBuffer();
        BCRegistry.INSTANCE.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock"), false);
        pipeWaterproof = new ItemBuildCraft();
        pipeWaterproof.setUnlocalizedName("pipeWaterproof");
        BCRegistry.INSTANCE.registerItem(pipeWaterproof, false);
        genericPipeBlock = (BlockGenericPipe) CompatHooks.INSTANCE.getBlock(BlockGenericPipe.class);
        BCRegistry.INSTANCE.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class, true);
        ItemStack andesite = new ItemStack(Blocks.stone, 1, 5);
        ItemStack diorite = new ItemStack(Blocks.stone, 1, 3);
        ItemStack granite = new ItemStack(Blocks.stone, 1, 1);
        pipeItemsWood = buildPipe(PipeItemsWood.class, "plankWood", "blockGlassColorless", "plankWood");
        pipeItemsEmerald = buildPipe(PipeItemsEmerald.class, "gemEmerald", "blockGlassColorless", "gemEmerald");
        // pipeItemsCobblestone = buildPipe(PipeItemsCobblestone.class, "cobblestone", "blockGlassColorless", "cobblestone");
        pipeItemsStone = buildPipe(PipeItemsStone.class, "stone", "blockGlassColorless", "stone");
        pipeItemsGranite = buildPipe(PipeItemsGranite.class, granite, "blockGlassColorless", granite);
        pipeItemsDiorite = buildPipe(PipeItemsDiorite.class, diorite, "blockGlassColorless", diorite);
        pipeItemsAndesite = buildPipe(PipeItemsAndesite.class, andesite, "blockGlassColorless", andesite);
        // pipeItemsQuartz = buildPipe(PipeItemsQuartz.class, "blockQuartz", "blockGlassColorless", "blockQuartz");
        pipeItemsIron = buildPipe(PipeItemsIron.class, "ingotIron", "blockGlassColorless", "ingotIron");
        pipeItemsGold = buildPipe(PipeItemsGold.class, "ingotGold", "blockGlassColorless", "ingotGold");
        pipeItemsDiamond = buildPipe(PipeItemsDiamond.class, "gemDiamond", "blockGlassColorless", "gemDiamond");
        pipeItemsObsidian = buildPipe(PipeItemsObsidian.class, Blocks.obsidian, "blockGlassColorless", Blocks.obsidian);
        // pipeItemsLapis = buildPipe(PipeItemsLapis.class, "blockLapis", "blockGlassColorless", "blockLapis");
        // pipeItemsDaizuli = buildPipe(PipeItemsDaizuli.class, "blockLapis", "blockGlassColorless", "gemDiamond");
        pipeItemsSandstone = buildPipe(PipeItemsSandstone.class, Blocks.sandstone, "blockGlassColorless", Blocks.sandstone);
        // pipeItemsVoid = buildPipe(PipeItemsVoid.class, "dyeBlack", "blockGlassColorless", "dustRedstone");
        // pipeItemsEmzuli = buildPipe(PipeItemsEmzuli.class, "blockLapis", "blockGlassColorless", "gemEmerald");
        // pipeItemsStripes = buildPipe(PipeItemsStripes.class, "gearGold", "blockGlassColorless", "gearGold");
        pipeItemsClay = buildPipe(PipeItemsClay.class, Blocks.clay, "blockGlassColorless", Blocks.clay);
        pipeFluidsWood = buildPipe(PipeFluidsWood.class, pipeWaterproof, pipeItemsWood);
        // pipeFluidsCobblestone = buildPipe(PipeFluidsCobblestone.class, pipeWaterproof, pipeItemsCobblestone);
        pipeFluidsStone = buildPipe(PipeFluidsStone.class, pipeWaterproof, pipeItemsStone);
        pipeFluidsAndesite = buildPipe(PipeFluidsAndesite.class, pipeWaterproof, pipeItemsAndesite);
        pipeFluidsDiorite = buildPipe(PipeFluidsDiorite.class, pipeWaterproof, pipeItemsDiorite);
        pipeFluidsGranite = buildPipe(PipeFluidsGranite.class, pipeWaterproof, pipeItemsGranite);
        // pipeFluidsQuartz = buildPipe(PipeFluidsQuartz.class, pipeWaterproof, pipeItemsQuartz);
        pipeFluidsIron = buildPipe(PipeFluidsIron.class, pipeWaterproof, pipeItemsIron);
        pipeFluidsGold = buildPipe(PipeFluidsGold.class, pipeWaterproof, pipeItemsGold);
        pipeFluidsEmerald = buildPipe(PipeFluidsEmerald.class, pipeWaterproof, pipeItemsEmerald);
        pipeFluidsDiamond = buildPipe(PipeFluidsDiamond.class, pipeWaterproof, pipeItemsDiamond);
        pipeFluidsSandstone = buildPipe(PipeFluidsSandstone.class, pipeWaterproof, pipeItemsSandstone);
        // pipeFluidsVoid = buildPipe(PipeFluidsVoid.class, pipeWaterproof, pipeItemsVoid);
        pipeFluidsClay = buildPipe(PipeFluidsClay.class, pipeWaterproof, pipeItemsClay);
        pipePowerWood = buildPipe(PipePowerWood.class, "dustRedstone", pipeItemsWood);
        // pipePowerCobblestone = buildPipe(PipePowerCobblestone.class, "dustRedstone", pipeItemsCobblestone);
        pipePowerStone = buildPipe(PipePowerStone.class, "dustRedstone", pipeItemsStone);
        // PIPE_QUARTZ_POWER = buildPipe(PipePowerQuartz.class, "dustRedstone", pipeItemsQuartz);
        pipePowerIron = buildPipe(PipePowerIron.class, "dustRedstone", pipeItemsIron);
        pipePowerGold = buildPipe(PipePowerGold.class, "dustRedstone", pipeItemsGold);
        pipePowerDiamond = buildPipe(PipePowerDiamond.class, "dustRedstone", pipeItemsDiamond);
        // pipePowerEmerald = buildPipe(PipePowerEmerald.class, "dustRedstone", pipeItemsEmerald);
        // PIPE_SANDSTONE_POWER = buildPipe(PipePowerSandstone.class, "dustRedstone", pipeItemsSandstone);
        pipeStructureCobblestone = buildPipe(PipeStructureCobblestone.class, Blocks.cobblestone, Blocks.gravel, Blocks.cobblestone);
        pipeWire = new ItemPipeWire();
        BCRegistry.INSTANCE.registerItem(pipeWire, false);
        PipeWire.item = pipeWire;
        pipeGate = new ItemGate();
        pipeGate.setUnlocalizedName("pipeGate");
        BCRegistry.INSTANCE.registerItem(pipeGate, false);
        facadeItem = new ItemFacade();
        facadeItem.setUnlocalizedName("pipeFacade");
        BCRegistry.INSTANCE.registerItem(facadeItem, false);
        FacadeAPI.facadeItem = facadeItem;
        plugItem = new ItemPlug();
        plugItem.setUnlocalizedName("pipePlug");
        BCRegistry.INSTANCE.registerItem(plugItem, false);
        lensItem = new ItemLens();
        lensItem.setUnlocalizedName("pipeLens");
        BCRegistry.INSTANCE.registerItem(lensItem, false);
        powerAdapterItem = new ItemPowerAdapter();
        powerAdapterItem.setUnlocalizedName("pipePowerAdapter");
        BCRegistry.INSTANCE.registerItem(powerAdapterItem, false);
        gateCopier = new ItemGateCopier();
        BCRegistry.INSTANCE.registerItem(gateCopier, false);
        for (PipeContents kind : PipeContents.values()) {
            triggerPipe[kind.ordinal()] = new TriggerPipeContents(kind);
        }
        for (PipeWire wire : PipeWire.values()) {
            triggerPipeWireActive[wire.ordinal()] = new TriggerPipeSignal(true, wire);
            triggerPipeWireInactive[wire.ordinal()] = new TriggerPipeSignal(false, wire);
            actionPipeWire[wire.ordinal()] = new ActionPipeSignal(wire);
        }
        for (Time time : TriggerClockTimer.Time.VALUES) {
            triggerTimer[time.ordinal()] = new TriggerClockTimer(time);
        }
        triggerRedstoneFader[0] = new TriggerRedstoneFaderInput(TriggerRedstoneFaderInput.Mode.LESS);
        triggerRedstoneFader[1] = new TriggerRedstoneFaderInput(TriggerRedstoneFaderInput.Mode.EQUAL);
        triggerRedstoneFader[2] = new TriggerRedstoneFaderInput(TriggerRedstoneFaderInput.Mode.GREATER);
        actionRedstoneFader = new ActionRedstoneFaderOutput();
        for (EnumDyeColor color : EnumDyeColor.values()) {
            actionPipeColor[color.ordinal()] = new ActionPipeColor(color);
        }
        for (EnumFacing direction : EnumFacing.VALUES) {
            actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(direction);
        }
        for (PowerMode limit : PowerMode.VALUES) {
            actionPowerLimiter[limit.ordinal()] = new ActionPowerLimiter(limit);
        }
        triggerLightSensorBright = new TriggerLightSensor(true);
        triggerLightSensorDark = new TriggerLightSensor(false);
    } finally {
        BuildCraftCore.mainConfiguration.save();
    }
    InterModComms.registerHandler(new IMCHandlerTransport());
    if (NEPTUNE_TESTING) {
        pipeBlock = new BlockPipe();
        /* Ideally we would use "pipeBlock" but its taken by the generic pipe. Using pipeBlockNeptune will probably
             * be fine for us though */
        pipeBlock.setUnlocalizedName("pipeBlockNeptune");
        BCRegistry.INSTANCE.registerBlock(pipeBlock, /* Register the block without registering an item - each pipe creates an item for itself. */
        null, /* Force register the pipe block- its probably a mistake for it to be disabled in the config, as you
                     * can already disable pipes indervidually. We don't mind too much about using an additional block
                     * id. */
        true);
        // Let a seperate class handle all of the pipe initialisation- there is a large amount of it to do and we
        // don't need to make this even bigger than what it already is
        TransportPipes_BC8.preInit();
    }
}
Also used : ItemBuildCraft(buildcraft.core.lib.items.ItemBuildCraft) EnumFacing(net.minecraft.util.EnumFacing) Time(buildcraft.transport.statements.TriggerClockTimer.Time) BlockPipe(buildcraft.transport.block.BlockPipe) PipeWire(buildcraft.api.transport.PipeWire) PipeContents(buildcraft.transport.statements.TriggerPipeContents.PipeContents)

Aggregations

PipeWire (buildcraft.api.transport.PipeWire)9 ItemStack (net.minecraft.item.ItemStack)3 EnumFacing (net.minecraft.util.EnumFacing)3 ItemPipeWire (buildcraft.transport.ItemPipeWire)2 ArrayList (java.util.ArrayList)2 ItemBuildCraft (buildcraft.core.lib.items.ItemBuildCraft)1 FakeBlockAccessSingleBlock (buildcraft.core.lib.world.FakeBlockAccessSingleBlock)1 ItemFacade (buildcraft.transport.ItemFacade)1 BlockPipe (buildcraft.transport.block.BlockPipe)1 Time (buildcraft.transport.statements.TriggerClockTimer.Time)1 PipeContents (buildcraft.transport.statements.TriggerPipeContents.PipeContents)1 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 Block (net.minecraft.block.Block)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 Axis (net.minecraft.util.EnumFacing.Axis)1 AxisDirection (net.minecraft.util.EnumFacing.AxisDirection)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 Vec3d (net.minecraft.util.math.Vec3d)1