your current location:首页 > news>[1.12.2] How to make the energy gradually consumed instead of deducting the energy when performing the formula created b

[1.12.2] How to make the energy gradually consumed instead of deducting the energy when performing the formula created b

2024-12-10 17:57:46|Myriagame |source:minecraft skins

There is a significant difference between the machine created by the REF and the machines of some mainstream technology modules:

When the former executes the formula, the energy will consume one -time after running the progress bar, while the latter is gradually consumed while executing.

This tutorial is inspired by fantasy technology (but in fact its script does not achieve the expected effect, the author should modify the REF itself), which gives a method to eliminate this difference to increase the integrity of the integrated package.

Overall thinking

Add an additional invisible energy buffer groove with large energy tanks such as machine energy grooves to meet the energy tanks of energy tanks and fill in the energy buffer groove per TICK. Check whether the energy in the energy buffer groove in the progress bar is equal to the need for energy needThe energy consumed and emptied the energy buffer groove.

accomplish

Energy buffer slot:

At the same time, the interactive surface is set to componentface.none () while setting the energy slot, and calling Sethidden (), Setaccess (FALSE, FALSE) function makes it invisible in the GUI and cannot interact with the energy pipeline.

like:

  .seitenergyslot (8, 2, componentFace.none (), 16000) .sethidden ()

.setaccess (false, false) .setgroup ("FAKE_ENERGY");

Detecting formula conditions:

Add a new energy consumption formula, call Setsubprocess (String) to make it different from the original formula in different processing groups; the items, fluids and other conditions are the same as the original formula, but the mining min and max set up are 0, so that the raw materials will not be consumed;Set the energy you need to consume from the energy slot to extract each Tick and output it in the buffer slot.

Due to unknown reasons, setting different treatment groups can only make two formula detecting conditions in the same Tick and cannot be implemented in the same Tick, so you need to set the world conditions: only when the energy in the buffer groove is smaller than the required energy required for one formula, this energy is executed.Special formula.This is to give the original formula for the opportunity, otherwise it will only continue to perform energy consumption formulas until the buffer groove is full or the energy slot will be continuously executed when the formula conditions are met.

Example:

 // Here is a function to encapsulate these operations for calling

Function CHAMBERENERGYTICK (Item As IINGREDIENT, FLUIDIN As IliquidStack, Time as int, Energytick as int) {{{{{{{{{{{{{{

Var EnergyUse = Mods.requious.asSemblyReCipe.create (Function (Container) {

Container.addenergyoutput ("Fake_nergy", Energytick); Energytick);

});

// Set the processing group

Energyuse = EnergyUSE.Setsubprocess ("EnergyProcessing");

// Detects raw materials

Energyuse = Energyuse.requirefluid ("Input1", Fluidin, 0, 0);

Energyuse = Energyuse.requireitem ("Input2", itemin, 0, 0);

// Set world conditions

EnergyUse = EnergyUse.requireworkdCondition ("CheckFakenergy", Function (MachineContainer) {// The first condition detection buffer energy is less than the energy required by the formula.Extraction and processing),

// Used to detect whether the energy in the energy slot meets the total energy requirements.

If (MachineContainer.Getenergy (8, 2)

MachineContainer.Getenergy (7, 1)> = Time*Energytick)

Return true;

Return false;

// The following "1" indicates that this world condition is detected every 1tick

}, 1);

EnergyUse = EnergyUse.requirenergy ("Energy", Energytick); Energytick;

// No need to add in JEI (avoid excess misleading display)

.addRecipe (Energyuse);

}

Treatment of the original formula and energy buffer groove:

The energy conditions are not extracted from the energy slot, and the buffer slot is extracted (set the MIN to the energy consumption, and the MAX is set to the maximum value of the energy slot to achieve the effect of clear the buffer groove).The reduction of energy is synchronized with progress bar).

Increase world conditions before running progress (to avoid the progress of the progress bar and find that the energy is not enough to stop there is a bit ugly): detect whether the energy groove is sufficient, if it is not enough to perform the formula.

*Note that the Jei formula is added separately.

Example:

 // Use function packaging operation to call

Function CHAMBERRECIPE (itemin as IINGREDIENT, FLUIDIN As IliquidStack, itemout as Iitemstack,

Fluidout as IliquidStack, Gasout as IliquidStack, Energytick as int, Time as int) {{

Var recipe = mods.requious.AssemblyRecipe.create (function (container) {

If (! ISNULL (itemout))

Container.addItemoutput ("Output3", itemout);

If (! Isnull (Fluidout))

Container.addfluidoutput ("Output2", FLUIDOUT);

If (! Isnull (GASOUT))

Container.addfluidoutput ("Output1", Gasout);

});

// Set the processing group

Recipe = recipe.setsubprocess ("RecipeProcessing");

Recipe = recipe.requirefluid ("input1", FLUIDIN);

Recipe = recipe.requireitem ("input2", itemin);

// Energy detection conditions

Recipe = recipe.requireworkDition ("Checkenergy", Function (MachineContainer) {

If (MachineContainer.Getenergy (7, 1)> = Time*Energytick) Return true;

Return false;

}, 1);

Recipe = recipe.requireering ("duration", time);

// Add the processing of the cushion slot after the progress bar

Recipe = recipe.requirenergy ("FAKE_ENERGY", Time*Energytick, 16000);

.addrecipe (recipe);

// Add Jei formula separately

Var recipejei = mods.requious.assemblyRecipe.create (function (container) {if (! ISNULL (itemout)))

Container.addItemoutput ("Output3", itemout);

If (! Isnull (Fluidout))

Container.addfluidoutput ("Output2", FLUIDOUT);

If (! Isnull (GASOUT))

Container.addfluidoutput ("Output1", Gasout);

});

Recipejei = recipejei.requirefluid ("input1", Fluidin);

Recipejei = recipejei.requireitem ("input2", itemin);

Recipejei = recipejei.requirenergy ("Energy", Time*Energytick);

Recipejei = recipejei.requireduration ("duration", time);

.addjeirecipe (recipejei);

// Call to generate a special formula for energy consumption

Chambernergytick (itemin, floidin, time, Energytick);

}

So far.The following is a simple call example:

 Chamberrecipe (, *600, NULL, *600, Null, 20, 70); 

Now your custom machine can be closer to the "original machine" in the technology module!