True · World Synthesis, Re -engraving tanks, homemade masters, keys display information ... Some interesting scripts on

Foreword

There are many magical scripts in the Discord channel of Kubejs, which is eye -opening, but it is difficult to visit Discord in China, and the 1.16.5 EXAMPLE Scripts sub -channel is a bit deep.Now I have the consent of the channel to carry some scripts to the encyclopedia and share it with you.

Authorize

text

Simple mineral uniform

Put in the server_scripts folder, the script is provided by Chefarug.

Only support the formula supported by "Kubejs", and all the metals under all Ingot (here are COPPER copper, Bronze bronze, TIN tin) in each formula(This is Mekanism).

Readers can modify the metal type in "Ingots" and the module ID of "MOD" to achieve the unity of simple mineral rhetoric they want.

Note: The naming rules of some mods are different.There are also ingot_tin, and some are tin_ingot. You need to modify the script slightly according to the actual situation.

Let Ingots = ['Copper', 'Bronze', 'Tin']

Let Mod = 'Mekanism'

for (let I of Ingots) {

Event.replaceoutput ({}, `#Forge: Ingots/$ {i}`, `Mod}: $ {i} _ingot`)

Event.replaceoutput ({}, `#Forge: Nuggets/$ {i}`, `$ {mod}: $ {i} _nugget`)

Event.replaceoutput ({}, `#Forge: Storage_blocks/$ {i}`, `$ {mod}: $ {i} _block`)

}

})

True World Synthetic

Put in the server_scripts folder, the script is provided by Chefarug.

 Let Removeblockproperties = (STR) => {

If (str.indexof ('[')! = -1) {

Output = str.substring (0, str.indexof ('['))

} Else {

Output = STR

}

Return output

}

let GetBlockfromkey = (Key, Object) => {Let Block = ''

if (key in object) {

block = Object [Key]

} Else {

block = 'mincrft: Air'

}

Return block

}

Let Blockfromindex = (Shape, Key, Index) => {

let output = ''

for (let I of shape) {

output = ''+output+i

}

Return getBlockfromkey (output [index], key)

}

let Getposfromindex = (Shape, CLICK_INDEX) => {

Let Total_length = 0

for (let I in shape) {

If (TOTAL_LENGTH+Shape [i] .Length> Click_index) {

Return {

X:+I, // This Kept Being a String. No Idea why, but+Forces it to int!

Z: CLICK_INDEX-TOTAL_LENGT

}

} Else {

Total_length = Total_length+Shape [i] .Length

}

}

// We will only get here IF it never reTurns anything. That Means Somethings Wrong!

Console.error (`recipe loading for a multiblock recipe failed! It appears that index of $ {click_index} is outSide the structure!

Return null

}

Global.debug = false // Change this to true to show some additive output useful for debugging recipes not working. Play Cauise Logspamglobal.multiblockCraft = (output, output_count, shape, key, click_item, click_index) => {{

Onevent ('Block.richt_click', event => {{

If (event.hand == 'main_hand' &&PEVENT.Player.GetheldiTem (event.hand) == click_item) {

event.entity.swingarm (event.hand) // this doesn'T work as of writing this, but should be fixed soon

let index_pos = getposfromindex (shape, click_index)

Let Corner = {

x: event.block.x-index_pos.x,

y: event.block.y,

Z: event.block.z-index_pos.z

}

let Current_index = -1

Let Current_check = {}

Let Current_rel_POS = {}

Let Validate_Struction = TRUE

let all_pos = []

// Let the value begin!

for (s of shape) {

for (I of s) {{

Current_index ++

Current_rel_pos = getposfromindex (shape, current_index)

current_check = {

X: 0+Corner.x+Current_rel_pos.x,

Y: Corner.y,

Z: CORNER.Z+Current_rel_pos.z

}

Let Expected = getBlockfromindex (Shape, Key, Current_index) .tring ()

Let block = Removeblockproperties (event.World.getBlock (Current_check.x, Current_check.y, Current_check.z) if (global.Debug) {

console.log (`$ {block}, $ {expected}, $ {value_Struction}`)

}

if (block == Expected && Validate_Struction) {

all_pos.push (current_check)

} Else {

if (global.debug && value_Struction) {{

console.log (`Incorrect Block Found Found at $ {Current_check.x}, $ {Current_check.y}, $ {Current_check.z} for output $ {output}. Expec TED: '$ {Expected}' But Found '$ {block} 'Instead`)

}

Validate_Struction = FALSE

}

}

}

if (value_Struction) {

for (I of all_pos) {

event.server.runcommandsilent (`setBlock $ {i.x} $ {i.y} $ {i.z} minecraft: Air`))

}

Event.server.runcommandsilent (`Summon Minecraft: Item $ {event.block.x} $ {event.block.y+0.7} $ {event.block.z} {PickupDelay: 10, Mot Ion: [0.0, 0.2,0.0], Item: {id: $ {output} ", count: $ {output_count} b}`)

if (! Event.player.iscreativeMode ()) {) {) {) {) {) {

Event.item.setcount (event.item.getCount ()-1)

}

event.server.runcommandsilent (`Particle Minecraft: SPIT $ {event.block.x} $ {event.block.y+0.2} $ {event.block.z} $ {shape.length *0.2} 0.4 0.4 $ {shape[0] .Length*0.2} $ {current_index*10} `)

}

}

})

}

// Center Click_index cheat sheet: 1x1: 0, 3x3: 4, 5x5: 12, 7x7: 24. Formula: (Total Blocks -1)/2. Remember, The First Thing IS 0! Global.multibl OCKCRAFT ('Minecraft: Diamond', 2, [// Global is necessary to call it outside the script file.

// The top line is the western direction of the world.

'CCC',

'CCC',

'CCC'

], {{

C: Minecraft: Coal_block ',

},

'Minecraft: Diamond', 4

)

In the last paragraph, the first 'mincraft: diamond' represents the product diamond, "2" represents the number of products 2, "C" represents different blocks (like an orderly synthetic formula), and the second 'minecraft: diamond'It means to activate the items required by this formula, and "4" indicates the size of the structure (1x1: 0, 3x3: 4, 5x5: 12, 7x7: 24).

That is, use a coal block to put a 3*3 shape on the ground, and then use the diamond to click right in the middle of the coal block in the middle.

Two diamonds on the ground.

Homemade "Master Ball"

Put in the server_scripts folder, the script is provided by Chefarug.

Readers can change CaptureItem and CaptureDitem to any item, such as items added by COT or Kubejs.

 const captureItem = 'MINECRAFT: Diamond' // The diamonds are set as empty capture props

Const CaptureDitem = {name: 'Minecraft: EMERALD', DisplayName: 'Soul Emerald'} // Determine the emerald as the capture props that have been captured to the creature

// Because it is English, there are "A" and "AN".

const pronountest = (s, c) => {{

If (c) {{

Return ''

} Else if (/#eiou ].*/.test (S)) {

Return 'An'

} Else {

Return 'a'

}

}

Onevent ('item.richt_click', event => {{

if (event.Item.id === CaptureDitem.name) {event.server.runcommandsilent (`Summon $ {event.item.nbt.captureness} $ {event.player.x} $ {event.player.y+0.7} $ {Event.player.z} $ {event.item.nbt.captureddata} `)

Event.item.count--

}

})

Onevent ('item.entity_interact', event => {{

If (event.Item.id === Captureitem &&! Event.target.player &&TARGET.TYPE! = 'Minecraft: Ender_dragon') {// Except for the last shadow dragon, you can add other prohibited entities

Let nbt = event.target.fullnbt

Delete nbt.uuid

Event.server.runcommandsilent (`Summon Minecraft: Item $ {event.target.x} $ {event.target.y} $ {event.target.z} {Pickupdelay: 10, motion: [0. [0. 0,0.2,0.0],Item: {id: $ {captureDitem.name} ", count: 1b, tag: {display: {na me: '{" text ":" $ {capturedITEM.displayName} "," italic ": false} ', Lore: ['{"text": "Contains the sound of $ {pronounTest (event.target.name, nbt.customName)} $ {event.target.name}"}, "$ {e {e {e {e vent.target.Type} ", CaptudeDATA: $ {nbt}}}`)

Event.target.y = -400

Event.target.health = 1 // does not kill immediately, so as not to occur.

}})

In essence, throwing the original creatures into the void, recorded all the NBTs, and summoned one of the same, it was no longer the same.

However, this script has a defect: the domesticated creatures will have the information of death.

So my personal method is: temporarily close the death information.Hill a stolen bell

 Event.server.runcommandsilent (`Gamerule ShowdeathMesges False`)

Event.target.y = -400

event.target.kill ()

event.server.runcommandsilent (`GameRule ShowdeathMesges True`)

Shock display information

Put in the client_scripts folder and are provided by Lady Lexxie.

Press Shift to display Tooltip and set the color of each line.

 Onevent ('item.tooltip', e => {

E.addadVANCED ('Kubejs: Test_item', (Item, Advanced, Text) => {

If (! E.isshift ()) {{

Text.add (1, [text.of ('hold') .gold (), text.of ('shift') .yllow (), text.of ('to see more info.'). GOLD ()]Cure

}

If (e.isshift ()) {{

Text.add (1, [text.of ('default:'), text.of ('50 '), text.of (' mb/t ')]

Text.add (2, [text.of ('basic:'), text.of ('100'), text.of ('mb/t')]

Text.add (3, [text.of ('Improved:') .gold (), text.of ('500') .yllow (), text.of ('mb/t'). Gold ()])

Text.add (4, [text.of ('advanced:') .darkaqua (), text.of ('2,000') .aqua (), text.of ('mb/t'). Darkaqua ()])

Text.add (5, [text.of ('ultimate:') .Darkgray (), text.of ('10, 000 ') .gray (), text.of (' mb/t '). darkgray ()])Text.add (6, [text.of ('infinity:') .Darkpurple (), text.of ('2,147,483,647'). Lightpurple (), text.of ('mb/t').

}

})

})

The effect is shown in the figure:

Cow in the re -engraved tank

Put in the server_scripts folder, the script is provided by Chefarug.

 let anvilsquashingRecipes = {}; Let Squashed = []

const addsquash = (o, e, i) => {

If (! AnvilsquashingRecipes [E]) ANVILSQUASHINGRECIPES [E] = {}

AnvilsquashingRcipes [e] [i] = o

}

const addsquashingRecipe = (output, entity, input) => {

// Typeof an array is object, not array

If (Typeof Entity == 'Object') {{

Ifof input == 'Object') {// Both Plural

For (E of Entity) {

For (I of Input) {

Addsquash (outPut, e, i)

}

}} Else {// Entity plural, input singular

For (E of Entity) {

Addsquash (output, e, input)

}

}

} Else {

Ifof input == 'Object') {// Entity Singular, input Plural

For (I of Input) {

Addsquash (outPut, Entity, I)

}

} Else {// both singular

Addsquash (output, entity, input)

}

}

}

Onevent ('Entity.attack', E => {{

Let block = e.entity.block.down; let type = e.entity.type

If (e.Source.type === 'Anvil'

&& anvilsquashingRecipes [type]

"

Block.set (anvilsquashingRecipes [type] [block.id]) Squashed.push (e.entity.id)

E.entity.kill ()

}

})

Onevent ('Entity.drops', E => {

Let index = squashed.indexof (e.entity.id)

If (INDEX> -1) {

Squashed.splic (index, 1)

E.cancel

}

})

// Example: Use an anvil to press the cow into the ice into snow

addsquashings ('Minecraft: Snow_block', 'Minecraft: Cow', 'Minecraft: Ice')

It is worth mentioning that this script can make some more interesting changes, such as anvil (iron anvil) in e.Source.type === 'Anvil'.Mechanical_saw.And let block = e.entity.block.down; this sentence can remove the .down and became the block where the target entity was located instead of the box under its feet.

So there can be: addsquashingRecipe ('Minecraft: Skeleton_skull', 'Minecraft: Skeleton', 'Minecraft: Air')

When the skeleton is damaged by the dynamic saw, a skull is generated at its location (after generating the skull of the skull, the skeleton is transferred to the void kill, so as not to turn around repeatedly).

Please look forward to more content, and welcome the community to replenish.