your current location:首页 > news>[CRT] CRAFTTWEAKER MINECRAFT Game

[CRT] CRAFTTWEAKER MINECRAFT Game

2024-12-09 18:29:45|Myriagame |source:minecraft skins

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

This tutorial is suitable for Crafttweaker, whether the API is compatible with it

Here I recommend a tool NotePad ++’s Zenscript statement highlight


When you are familiar with the basic magic reform, with the goal of doing things, you have prepared to implement a large -scale magic reform, but there are many mechanized steps for large -scale magic reforms. Use simple cycles to solve some problems, but this will satisfy this satisfaction.Is it?

Calculate

Whether you are playing red stone or programming, you have a certain understanding of the basic logical operations.

operation Represents Assignment = non -(not)

! Not equal! = Equal to

== greater than

> Greater than equal to> = less than <= and (and) & or (or) | different or (xor)

^

if

The basic format of if statement is as follows:

if (condition) {{

Statement 1 // When the condition is true, execute statement 1

} Else {

Statement 2 // Converse execution of statement 2

}

The orange part can be omitted, naturally you can also use else if

In addition to the basic logic operations above, the conditional part can also use the IN/HAS table condition

Such as: LoadedMods in "thermalexPansion" has been loaded with the MOD and installed with thermal expansion.

IveRedient

In the cycle, you need to set an array variable.for example:

varm mclogs = [, , , , , ] as IITEMSTACKK[];

The latter AS IITEMSTAC

However, IITEMSTACK has a lot of restrictions. He cannot use ore and cannot use NBT items. At this time, you can use a smaller Iingredient.

The flexible use of the meta value

There are 16 types of wool, and each color wool is divided into different meta values.Suppose you need to delete the synthesis of the Meta value of 3 to 12, what will you do?

recipes.remove (); //?

This will delete the synthesis of all wool, but we only need 3 to 12, obviously not.

recipes.remove ();

recipes.remove ();

Elastic

So until 12?

This is OK, but this is very tired.

As well

var banWools = [, , ...] as IItemstack [];;

Delete it with another cycle, but this is still not simple enough.

Since the ID is the same, it is only different from the META value. It is obviously a bit redundant to copy n the same items. So what should I do?

valry wool = .definition; // Use IITEMDEFINITIONS to define all the IDs of the ID

Val Meta = [3,4,5,6,7,8,9,10,11,12] as int [] // Define all the meta values ​​you need

for I in Meta {

Recipes.remove (wool.makestack (i)); // Use makestack to call items with specific meta values}

Special, the META value required for this chestnut is continuous, and you can do it like this

For I in 3 to 13 {// The interval is [3,13). This right limit is not included. You need to use 3 to 12. What you have to write is 3 to 13. Pay attention to

Recipes.remove (wool.makestack (i));

}

There are a few empty

// 3 to 12, but we plan 5 and 9

for I in 3 to 13 {{

If (i! = 5 & i! = 9) {

Itemdef.makestack (i) .addshifttooltip ("Help Me!");

}

}

Using these you can write a witty saplings conversion script, as follows

Val Sapling = .definition;

for I in 0 to 6 {{

If (i! = 5) {{

Recipes.addshapeless (Sapling.makestack (i+1), [Sapling.makeStack (i), Sapling.makestack (i), Sapling.makestack (i)];

} Else {

Recipes.addshapeless (Sapling.makestack (0), [Sapling.makestack (i), Sapling.makestack (i), Sapling.makestack (i)];

}

}

Custom function

Zenscript is actually similar to JavaScript

Basic format function name (input variable) output variable type {

Sentence

Return function return value;

}

The orange part can omit

In ZS, it is mainly modified and synthesized. Generally, the function that does not return the value is Void Function. This function does not require Return

chestnut

Construct a function, print the positive number of less than the n in the log in the log

function real (n as int) {

For I in 1 to (n+1) {{

Print (i);

}

}

A function with a return value requires Return, but not necessarily required.

For example, construct a function, return two outputs to add

Function ADD (A AS Int, B AS int) as int {

Return a+b;

}

Below is the main data type of Zenscript

Name action int integer (range is -2147483648 to 2147483647)Float single precision floating point number (allowed decimal) double

Double-precision floating point number (allowable decimal) byte byte integer (range is -128 to 127) SHORT short integer (range is -32768 to 32767) BOOL

True/False String string (things in the double quotes) VOID

Air IITEMSTACK

MC items (may need Import Crafttweaker.Item.iiteMStack;) IliquidStackmc fluid (may need Import Crafttweaker.liquid.iliquestack;)

IORDICENTRY

MC mineral dictionary (may need Import Crafttweaker.oredict.ioreDictical;) IINGREDIENT material, see the introduction of the ingredient above (may require Import Crafttweaker.ITEM.INGREDIENT;)