NBT processing instance can be separated by stacking items [ID] dynamic combination/integrated dynamics

As we all know, the recipes of blood magic alchemy tables and prison furnaces are many and mixed. Its automation potential is imperative, but some formulas contain duplicate items, such as this:

If the normal distribution will inevitably lead to stacking, why not solve it?

In fact, there are long -term solutions in the station. The use of AE2's name pressure printing can solve the problem more elegantly, but the work efficiency problem of the pressing device when this method is large in synthetic demand cannot be ignored.So if you have integrated motivation in your integration package, you may consider some more efficient solutions.

Notice:

1. The special solution to this problem is simpler and elegant from Langran's inverted method. This is an instance tutorial on NBT extraction

2. If you have the conditions to use the NBT extractor, most of the steps of this tutorial will become simpler

3. This tutorial requires you to understand the basic use of integrated power, otherwise you may be difficult to understand the following content ...

The easiest solution

First of all, the easiest is that there are four materials inside the prison furnace, which accepts side input, so we can just arrange four items output ports on its four sides, pointing to the four materials:

The above figure shows the GUI of one of the output ports of the items. The value of the variable card is 0, which means that it points to the No. 0 grid in the prison furnace, and the other three output ports are 1,2,3, respectively.

For the alchemy table, its side can interact with the internal 6 material grids, and the alchemy table occupies two squares, so there are just 6 sides, so we can make it:

Simple and rude, but effective.

But maybe you think, what should be good if the alchemy table only covers the area?This item output thief is difficult to do, can it save a province (what you say is your DJ2) ...

I don't like this solution very much. It is neither universal nor exquisite. Integrated motivation is a powerful module. It can definitely do more than that.

More elegant solution?

Use the item container to read the refinery table and open its GUI, you will find that the total number of items, the number of grooves, and the number of slots installed with items:

The number of slots 6 means that this item container reader of the alchemy table can read the contents of 6 slots. They represent the 6 materials inside the alchemy table, which are numbered 0,1,2,3 respectively., 4,5.

Now paying attention to the number of slots containing items, the value 0 means that all the 6 materials grooves in this alchemy table are empty. At this time, we should put the items on the No. 0 material slot;After entering the items, then this value will become 1. At this time, we should put the items to the No. 1 material slot; if there are n slots put the items, this value will become N. At this time, we should get to NPut the items in the slot.

It is not difficult to find that the value of the number of slots installed with items is that we will put the target slot number of the item next, so we only need to use a variable card to take out this value, and then use it as the output of the item output.The parameters of the position "position" can be:

Note: You need to click the additional number on the right side of the "output item to the specified location", and set the "item transmission rate" to 1:

The above is obviously a better solution, but there are still two problems in this solution:

1. For the furnace of the prison fire, it cannot be used as the law. If you read it with an item container reader, you will find that there are 6 grids on the side instead of 4, because the product grid and soul stone grid are also included in the product grid and soul stone grid.Inside, it is still not possible to follow the above approach. The solution will be attached at the end of this tutorial. If you think that the above solution can solve all your problems after reading the tutorial, then you can directly refer to that solution.

2. Consider the following formula:

The bucket here will leave an empty bucket after use. Imagine that in the alchemy table, there is an empty bucket left in the alchemy table, and the other 0,3,4,5 grid is empty.The number of items is 2, but there is an empty barrel in the No. 2 grid, so the machine will be stuck.

You realized this, so you made an empty barrel export device and kept taking out the empty barrel from the material grid, so the two empty barrels were taken out in order. When the empty bucket of the No. 1 slot was removed,The items were put in the No. 1 and No. 1 slot, and the empty barrels of the No. 2 slot were taken out. The number of grooves equipped with items was 1, but the No. 1 grid had been put into the item, so the machine was stuck again.

The reason for this situation is that the number of grooves equipped with items can only indicate the serial number of the first empty slot in strict order in order., Will cause the machine to get stuck.As a result, what we need to realize is to read the serial number of the first empty slot in the real sense.

The final solution

What we need to do is to read the information of each raw material slot → find out the first empty raw material slot → put a raw material into this raw material slot.

The first step is to read the information of each raw material slot. This is very simple. The reader reader can remit the grid information it can read into a list:

Come to the second step and find out the first empty raw material slot. The first thing that comes to mind is obviously to achieve a method of setting the first element in the list in the list, but unfortunately, the integrated power does not provide this without providing this wayThe operator.But don't forget, when the information customized by the reader cannot meet your needs, we also have a block reader. It can read the NBT information of the block. We can find all kinds of what we want in NBT we wantthing.Below is the NBT information of a alchemy table and its GUI content (digital representative slot number under the slot): It is not difficult to find that under the "ITEMS" key, it is a list.The value of the "slot" key under each item is the slot number where the item is located.

Then we only need to take out the value of the "SLOT" key below each item to remit into a list. In the above example, [0,1,2,4,5,6], record it as a, and write another list B B.= [0,1,2,3,4,5,114514], just find out all the numbers that have not appeared in A in B and remit into a list C (in this example, C = [3,114514])Then the first element of the list C is the serial number of the first empty raw material groove we are looking for. When the raw material slot is not empty, the first element of C will be 114514. There is no corresponding raw material slot under this serial number.So you don't enter the raw material.

There are ideas, and the next time is programming time.

First take the NBT of the alchemy table in the meter reader, and then write a string constant volume of "Items", and substitute it into NBT.List_tag (NBT data: NBT list) computing symbol.List of items under:

Each value of this list is a NBT. We want to extract the values ​​of the "Slot" key in these NBTs. First of all, you need to customize an input NBT → output the integer value operator under the "slot" key in the NBT tag.The following is a specific step (variable names are pure personal habits, and are designed to facilitate expression. You can use any name you like):

1. Name the NBT list in the picture above to name "NBT_LIST"

2. Extract NBT.INTEGER (NBT data: integer) operator, and name it "NBT2int"

3. Ins the "NBT2INT" into the FLIP computing symbol, take out the new operator and name it "nbt2int_flipped"

4. Write a string constant with "slot", and name it "" slot ""

5. Replace "NBT2int_flipped" and "Slot" "into the Apply (one yuan execution) computing symbol, remove the new computing symbol and name it" Pick_slot ", which is the custom operator we want.

Then, the "pick_slot" and "nbt_list" are substituted into the MAP (traversed mapping) computing symbols, the returned list is taken out and named "slot_list". We get a list of "slot" key value of each item.

Next, write a integer list with the content of [0,1,2,3,4,5,114514] and name it "NUM_LIST", and then you needThe steps are as follows:

1. Remove the contains (list containing) operators and name it "contains"

2. Replace "contains" and "slot_list" into the Apply (one yuan execution) computing symbols, remove the new operator and name it "in_slot_list"

3. Take it out! (Logic non -) operators, and named "NOT"

4. Put "in_slot_list" and "NOT" in turn. (Pipe) operator, take out the new operator and name it "not_in_slot_list"

5. Put "not_in_slot_list" and "NUM_LIST" into the Filter (filter) operator, take out the returned list and name it "Empty_slots". At this point, we take out the serial number of the material slot all of all the vacant grooves in the alchemy table:

Finally, the "EMPTY_SLOTS" is substituted into the Head (first) operator, removed the returned variables and named it "first_empty_slot", and we completed our mission.

Put the "first_empty_slot" into the output item of the output port of the item to the specified location option, and click the plus number of this line to change the item transmission rate to 1. Do not forget to continuously export the bucket.When we are distributed, we have completed an exquisite and efficient alchemy table automation (the prison fire furnace is an exactly the same step, you can draw the gourd according to the same).

at last

Integrated motivation is a very powerful module. If you can complete AE2 with AE2, you can complete a lot of complex tasks, but how low well -known has few tutorials and high starting thresholds.The above steps seem to be tedious and complicated, but after understanding, it is actually a very smooth logic. In short, you hurry up with AE2.

1. Take out the list of items in the prison furnace in the item container reader and name it "items"

2. Write a integer constant with a value of 0 and an integer constant with a value of 4, named "0" and "4" respectively

3. Put "ITEMS", "0" and "4" in the SLICE (sliced) operator, remove the returned list and name it "Inputs"

4. Take out O (non -empty) operator and name it "not_empty"

5. Put "Items" and "Not_empty" in the count_p (condition count) computing symbols, remove the returned value and name it "NUM_OF_FULL_INPUTS" ",

6. Put the "NUM_OF_FULL_INPUTS" into the output item of the output port of the item to the specified location option, and click the additional number of this line to change the item transmission rate to 1 (do not forget to continuously export the bucket).