your current location:首页 > news>Use CRT to add a simple little prompt to the drawer [CRT] CRAFTTWEAKER MINECRAFT Game

Use CRT to add a simple little prompt to the drawer [CRT] CRAFTTWEAKER MINECRAFT Game

2024-12-10 17:58:37|Myriagame |source:minecraft skins

This tutorial is set by the author to use the CC by-NC protocol.

The drawer is a very useful storage container. When the drawer is placed in the world, you can see what he stored in him, but as long as you dig it down?IntersectionIntersectionEssenceWhen digging the drawer, you accidentally pressed the chain and dug a large number of drawers. I do n’t know what to install in each drawer. I want to put it back to the original one.This is really disgusting, so this tutorial was born.

In the case of not making a module, the easiest way to know what is installed in each drawer is to add a Tooltip with CRT.The needs of the need to extract the required elements through the NBT of the drawer.

Let's place the general cables with four different levels of 63 in the four -grid drawer, and then dig him down with an ax. At this time, using/CT Hand to get his tag is the following string.

. Withtag ({material: "birch", tile: {mat: "birch", upgrades: [], cap: 8, x: 1691, y: 4, forgecaps: {}, z: z:-85, ID: "StorageDrawers: Basicdrawers.4", DIR: 2 as byte, DRAWERS: [{Item: {ID: "Mekanism: Transmitter", count: 1, tag: {tier: 0}, damage: 0 asshnt}, count: 63}, {item: {id: "mekanism: trans mitter", count: 1, tag: {tier: 2}, damage: 0 as short}, count: 63}, {item: {id: ID: {id:"Mekanism: Transmitter", Count: 1, Tag: {Tier: 3}, DAMAGE: 0 as Short}, Count: 63}, {item: "mekanism: transmitter", count: 1, tag: {tier: 1}, damage: 0 as short}, count: 63}]}})

This string is very big, but it doesn't matter, just need to remove us that we can't use it.

. Withtag ({{

Tile: {

Drawers: [[

{Item: {id: "mekanism: transmitter", count: 1, tag: {tier: 0}, damage: 0 as short}, count: 63},,, 63},

{Item: {id: "mekanism: transmitter", count: 1, tag: {tier: 2}, damage: 0 as short}, count: 63},,, 63},

{Item: {id: "mekanism: transmitter", count: 1, tag: {tier: 3}, damage: 0 as short}, count: 63},,, 63},,, 63},,, 63},

{Item: {id: "mekanism: transmitter", count: 1, tag: {tier: 1}, damage: 0 as short}, count: 63}

]}

})

It is clear now, items are stored in the list of Drawers.First look at the first element, the ID of items, Tag and Meta are stored in Item, and the number of items is stored alone.

The need for the elements is known, and it is OK just to extract them.

 Import Crafttweaker.data.idata; // guide package, nothing to say

import crafttweaker.item.iitemstack;

Val Basicdrawers4 as Iitemstack [] = [, ]; // Four slot drawers.

Val Basicdrawers2 as IItemstack [] = Basicdrawers4++;

Val Basicdrawers1 as IItemstack [] = Basicdrawers2+; // Four slot drawers+two -slot drawer+one slot drawer.

For I in Basicdrawers1 {// traversed a drawer with at least one slot.

I.addadAdVANCEDTOOLTIP (function (item) {// Add an AdvancedTooltip to each drawer. You need to return a string as Tooltip.

VAR II0 = "§B empty"; // First give II0 a value as "empty".

Item.hastag &&! ISNULL (item.tag.tile) &&! Isnull (item.tag.tile.drawers)) {// If the drawer has tag and tile and drawers are not null.

Val d = item.tag.tile.drawers as idata; // assign d value to item.tag.tile.drawers, which is convenient to write the following.

if (! isnull (d [0]) &&! isnull (d [0] .Item)) {// d is a list, then d [0] is the first element of D, that is, the {in the above example aboveItem: {id: "mekanism: trans mitter", count: 1, tag: {tier: 0}, damage: 0 as shop}, count: 63}.

// Want to add a Tooltip that is easy to understand to the drawer, then we need to get the name and quantity of this item.Val I = itemutils.getItem (// itemutils can obtain IITEMSTACK. IitemStack. Iitemutils.getITEM (LOCATION As String, Meta as int = 0).

D [0] .item.id.asstring (), // string.Location that needs to be obtained, that is, the ID: "Mekanism: Transmitter" in the example above.

D [0] .item.damage.asshort () // int.Meta that needs to be obtained, that is, the damage: 0 as short in the example above.

); // At this point we have already got this item. The name of this item is very simple. Iitemstack.displayName is the name of the item, but we also need to obtain the TAG and quantity of this item.Because some items are distinguished according to tags, it will be chaotic without the name of TAG.

Val T =! Isnull (d [0] .Item.tag)? D [0] .Item.tag as idata: {}; // This is a ternary operation.If this element contains tag, then assign t assignment to {tier: 0} in the example above, otherwise the empty IDATA.

Val c = d [0] .count.asint () as int; // This gets the number of items in the element.The names and quantities needed at this time have been obtained, and it is OK to be repaid for II0.

II0 = I.Withtag (T) .displayName ~ "§R*§B" ~ C; // Cake each component together to get this string of String: "Basic Universal Cable*63".

}} // If the IF function above goes normally, then the value of II0 at this time is "Basic General Cable*63", otherwise "empty".Just return to II0 and prefix.

Return "§A The first slot item is: §B" ~ II0;

});

}

for I in Basicdrawers2 {// Basically the same as above

I.addadAdVANCDTOOLTIP (function (item) {

Var II1 = "§B empty";

Item.hastag &&! ISNULL (item.tag.tile) &&! Isnull (item.tag.tile.drawers)) {

Value d = item.tag.tile.drawers as idata;

if (! Isnull (d [1]) &&! Isnull (d [1] .Item)) i1 = itemutils.getITEM (d [1] .Item.id.asstring (), d [1] .Item.damage.asshort ()). Withthtag (! isnull (d [1] .Item.tag)? d [1] .Item.tag as idata: {}).Count.asint ();

}

Return "§A The second slot item is: §B" ~ II1;

});

}

for I in Basicdrawers4 {

I.addadAdVANCDTOOLTIP (function (item) {

Var II2 = "§B empty";

Item.hastag &&! ISNULL (item.tag.tile) &&! Isnull (item.tag.tile.drawers)) {

Value d = item.tag.tile.drawers as idata;

if (! Isnull (d [2]) &&! Isnull (d [2] .Item)) II2 = itemutils.getITEM (d [2] .Item.id.asstring (), d [2] .Item.damage.asshort ()). Withthtag (! isnull (d [2] .Item.tag)? d [2] .Item.tag as idata: {}). DisplayName ~ "§R*§B" ~ d [2]...Count.asint ();}

Return "§A third slot item is: §B" ~ II2;

});

}

for I in Basicdrawers4 {

I.addadAdVANCDTOOLTIP (function (item) {

Var II3 = "§B empty";

Item.hastag &&! ISNULL (item.tag.tile) &&! Isnull (item.tag.tile.drawers)) {

Value d = item.tag.tile.drawers as idata;

if (! isnull (d [3]) &&! Isnull (d [3] .Item)) II3 = itemutils.getITEM (d [3] .Item.id.asstring (), d [3] .Item.damage.asshort ()). Withthtag (! isnull (d [3] .Item.tag)? d [3] .Item.tag as idata: {}). DisplayName ~ "§R*§B" ~ d [3]..Count.asint ();

}

Return "§A fourth slot item is: §B" ~ II3;

});

}

The final effect is as shown in the figure below