[KJS TRICKS] View the specific value of Magic Pond Magic [KJS] Kubejs Minecraft Game

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

A long time ago, I was playing with 1.12 plant magic.At that time, there was a purpose in the plant magic dictionary of the plant magic dictionary called "magic quantitative statistics". There was only one sentence to click in: "There is no kind of thing."Until now, I want to know how much magic power in a magic pond can only use the forest staff to see it. Although I know this is the design concept of plant magic, and that everyone's usual magic is excessively produced, butAs a magic -changing author, it is necessary to know how much magic it is needed for a formula. This is based on how much magic can a magic pond be installed, so the following code is written.

Pure Kubejs

 Onevent ('block.richt_click', e => {{

Let ManaPools = ['Botania: Mana_pool', 'Botania: Diluted_pool', 'Botania: Fabulous_pool', 'Botania: Creative_pool'

If (ManaPools.Cludes (e.block.id)) && e.player.mainhanditem == 'Minecraft: Air') {

Let mana = e.block.entitydata.mana;

Let cap = e.block.entitydata.manacap;

If (e.block.id! = 'Botania: Creative_pool') {

E.server.runcommandsilent (`title $ {e.player.name.getstring ()} actionbar {" text ":" mana: $ {mana}/$ {cap} "}`);

}

Else {

E.Server.Runcommandsilent (`title $ {e.player.name.getstring ()} actionbar {" text ":" mana: ∞ "});

}

E.player.swingarm (main_hand);

}

})

First of all, this code monitor the block.richt_click incident, so obviously this is a server script that should be placed in the server_scripts folder.

Then we know that the plant magic has four magic ponds, where their block IDs are placed in a array.

When the player right -click a block, this code will detect whether the box ID you clicks by the player belongs to the array mentioned above (which is more than writing four or judgment) and whether the player’s master is empty (you also you alsoIt can be changed to items other than air, such as forest staff).

Then get the magic data of the magic pond. These data are stored in the block physical data of the magic pond in the form of NBT, and you can access it with EntityData.Mana is the current magic power, and Manacap is the upper limit of the magic pond.

For the creation of magic ponds, special offices are specially displayed, and the unlimited display is directly displayed. For other magic pools, the magic value and capacity is displayed normally. This is achieved by silently running.Of course, you can also use Paintapi, but that's much trouble.

Finally, in order to give players a feeling of really being operating, let the player's hand wave, main_hand is a global variable that comes with Kubejs, and you don't need to declare pre -declaration.

The last effect is:

If you install jade

Obviously, right -click and check that it is convenient to display the module with block information such as JADE directly, so if you have installed jade, try the following code:

 Let $ WailaclientRegistration;

let $ waitckaccessor;

if (Platform.isClientenvalonment ()) {{) {

$ WailaClientRegistration = Java.loadClass ('Snownee.jade.impl.WailaLientregification');

$ Waitckaccessor = java.loadClass ('Snownee.jade.api.blockAccessor');

}

Startupevents.postinit (Event => {

If (! Platform.isClientenvalonment ()) Return;

$ WailaClientRegistration.Instance.addtooltipCollectCallback (0, accessor) => {{{{{{

If (! (Accessor Instanceof $ WailaBlockAccessor)) Return;

Ifssor.getBlockness () == NULL) Return;

If (accessor.getBlockntity (). GetcurrentMana == NULL || Accessor.getBlockIntity (). Getmaxmana == null) Return;

Let addtotooltip = Comp => Tooltip ['add (net.minecraft.network.chatwork.chat.com)'] (Comp); Let mana = accessor.getBlockity (). Getcu rrentmana ();

Let cap = accessor.getBlockIntity (). GetMaxmana ();

Addtotooltip (text.aqua (`$ {text.translate ('jade.tooltip.mana'). GetString ()}: $ {mana}/$ {cap}`));

});

$ WailaClientRegistration.Instance.addtooltipCollectCallback (0, accessor) => {{{{{{

If (! (Accessor Instanceof $ WailaBlockAccessor)) Return;

Ifssor.getBlockness () == NULL) Return;

Let blockity = accessor.getBlockentity ();

If (blockity.getmana == null || blocktmaxmana == null || blockbindingpos == null) Return;

Let addtotooltip = Comp => Tooltip ['add (net.minecraft.network.chatwork.chat.com)'] (comp);

Let pos = blockentity.getbindingpos ();

Let mana = blockentity.getmana ();

Let cap = blockentity.getmaxmana (); addtotooltip (addtotooltip (

Text.aqua (

`$ {

POS == NULL

? Text.translate ('jade.tooltip.notbound'). GetString ()

: `$ {Text.translate ('jade.tooltip.boundto'). GetString ()} $ {pos.x} $ {pos.y} $ {pos.z}` ``

} `

Cure

);

Addtotooltip (text.aqua (`$ {text.translate ('jade.tooltip.mana'). GetString ()}: $ {mana}/$ {cap}`));

});

$ WailaClientRegistration.Instance.addtooltipCollectCallback (0, accessor) => {{{{{{

If (! (Accessor Instanceof $ WailaBlockAccessor)) Return;

If (accessor.block.id! = 'Botania: runic_altar') Return; let addtotooltip = comp => Tooltip ) '] (comp);

Let mana = accessor.getBlocktity (). GetcurrenTmana ();

Let cap = accessor.getBlocktity (). Manatoget;

Addtotooltip (text.aqua (`$ {text.translate ('jade.tooltip.mana'). GetString ()}: $ {mana}/$ {cap}`));

});

});

Note 1: The translation keys in Text.translate () need to write a language file by yourself, or change it directly to hard codes.

Note 2: This code needs to be placed in the startup_scripts folder.

I first saw a post made by @Dragonmaster's Discord in Kubejs in Kubejs.Check the method of magic -related block entity, and then change the code of DragonMaster. The effect is:

Obviously, the effect of this code is much stronger than the above (although the repeated code is a bit), not only can you view the magic value of any block with magic capacity, but also the position of the production energy flower binding.