Skip to content

Translation notice

This page was translated with machine translation and may contain inaccuracies. If you can help improve it, please open an issue or submit a pull request.

Appendix 4: Miscellaneous

Some scattered information is placed here, and some are quoted in the text.

Rotation format conversion

by ethan

How to convert entity rotation to a rotation transformation.

This function will convert the Rotationof a display entity into a rotation transformation usingleft_rotationandright_rotation and reset the entity's yaw and pitch to 0. This can be used to get around the issue of display entities rotations visually snapping to integer degrees.

How to convert entity rotation data into display entity rotation transformation

Use the following function to display the entityRotationNBTtag data is converted totransformationunder tagleft_rotationandright_rotationTransform and reset itsRotation tag。 This can be used to display entities visually rotated an integer degree, but not logically rotated.

mcfunction
## initialises transformation NBT in storage
data modify storage ns:temp transformation set value {left_rotation:{axis:[0f,1f,0f],angle:0f},right_rotation:{axis:[1f,0f,0f],angle:0f}}
## calculates rotation transformation angles using yaw and pitch respectively.
execute store result storage ns:temp transformation.left_rotation.angle float -0.00001745329251 run data get entity @s Rotation[0] 1000
execute store result storage ns:temp transformation.right_rotation.angle float 0.00001745329251 run data get entity @s Rotation[1] 1000
## applies rotation transformations.
data modify entity @s transformation merge from storage ns:temp transformation
## resets entity rotation.
execute at @s run tp @s ~ ~ ~ 0 0

Note: It overwrites both left and right rotations, and will create a shear if the scale transformation is non-uniform.

Note: This function also overrides the initial rotation and re-rotation transformation of the display entity, and if the zoom ratio of the display entity is inconsistent, clipping will occur.

Blocks that do not block the entity

by ethan

The following are blocktags that do not block entity blocks. Those who need them can get them themselves.

json
{
            "values": [
                "#minecraft:banners",
                "#minecraft:bee_growables",
                "#minecraft:buttons",
                "#minecraft:corals",
                "#minecraft:doors",
                "#minecraft:fence_gates",
                "#minecraft:fire",
                "#minecraft:flowers",
                "#minecraft:pressure_plates",
                "#minecraft:rails",
                "#minecraft:saplings",
                "#minecraft:signs",
                "#minecraft:wall_corals",
                "#minecraft:wool_carpets",
                "minecraft:air",
                "minecraft:attached_melon_stem",
                "minecraft:attached_pumpkin_stem",
                "minecraft:bamboo_sapling",
                "minecraft:brown_mushroom",
                "minecraft:cave_air",
                "minecraft:cobweb",
                "minecraft:comparator",
                "minecraft:crimson_fungus",
                "minecraft:crimson_roots",
                "minecraft:dead_brain_coral",
                "minecraft:dead_brain_coral_fan",
                "minecraft:dead_brain_coral_wall_fan",
                "minecraft:dead_bubble_coral",
                "minecraft:dead_bubble_coral_fan",
                "minecraft:dead_bubble_coral_wall_fan",
                "minecraft:dead_bush",
                "minecraft:dead_fire_coral",
                "minecraft:dead_fire_coral_fan",
                "minecraft:dead_fire_coral_wall_fan",
                "minecraft:dead_horn_coral",
                "minecraft:dead_horn_coral_fan",
                "minecraft:dead_horn_coral_wall_fan",
                "minecraft:dead_tube_coral",
                "minecraft:dead_tube_coral_fan",
                "minecraft:dead_tube_coral_wall_fan",
                "minecraft:fern",
                "minecraft:grass",
                "minecraft:kelp",
                "minecraft:kelp_plant",
                "minecraft:ladder",
                "minecraft:large_fern",
                "minecraft:lever",
                "minecraft:lily_pad",
                "minecraft:nether_portal",
                "minecraft:nether_sprouts",
                "minecraft:nether_wart",
                "minecraft:red_mushroom",
                "minecraft:redstone_torch",
                "minecraft:redstone_wall_torch",
                "minecraft:redstone_wire",
                "minecraft:repeater",
                "minecraft:scaffolding",
                "minecraft:seagrass",
                "minecraft:soul_torch",
                "minecraft:soul_wall_torch",
                "minecraft:structure_void",
                "minecraft:sugar_cane",
                "minecraft:tall_grass",
                "minecraft:tall_seagrass",
                "minecraft:torch",
                "minecraft:tripwire",
                "minecraft:tripwire_hook",
                "minecraft:twisting_vines",
                "minecraft:twisting_vines_plant",
                "minecraft:vine",
                "minecraft:void_air",
                "minecraft:wall_torch",
                "minecraft:warped_fungus",
                "minecraft:warped_roots",
                "minecraft:water",
                "minecraft:weeping_vines",
                "minecraft:weeping_vines_plant",
                "minecraft:small_dripleaf",
                "minecraft:glow_lichen",
                "minecraft:moss_carpet",
                "minecraft:spore_blossom",
                "minecraft:hanging_roots",
                "minecraft:light",
                "minecraft:sculk_vein",
                "minecraft:frogspawn"
            ]
        }

Explosion intensity

by ethan

I just read mj's defense source code and got an important conclusion. It may be useful. Explosion intensity = 1-distance from explosion center to entity/explosion diameter Explosion momentum = unit vector from explosion center to entity eye * explosion intensity

Item tooltip vertex id applicable from 1.17 to 1.21

by Xuanyu1725 item tooltip vertex id

How to display a uniform sphere

alt text

A non-recursive ray tracing simulation

alt text

Optimize Thirteen Articles

by Jiuqiu

  1. Do not add entity if not necessary
  2. It is best to use scoreboard when calculations are involved
  3. store result is best used only when converting data types
  4. When judging numerical values, try to only use scoreboard
  5. In judgments that do not involve nbt, try to use predicate (there are no complete test results for this one)
  6. Use selector. Try to use execute to change the executor, and then use @s in the function instead of calling the selector multiple times.
  7. You may need to consider the performance penalty of function calls
  8. Keep the fewest statements in the tick and use if unless to split execution as much as possible
  9. The first reaction should not be to think of nbt operations, but to refine the command and other parts of the data pack, such as item achievement
  10. For index type designs, consider the scoreboard tree
  11. Unnecessary high frequency can be changed to low frequency that is executed only when the score count reaches a certain value.
  12. Don't try to complete operations with actual calculation volume greater than 1gt in 1gt
  13. If it involves some operations with a large amount of calculation, it can be completed by occupying the player's tick that does not affect the experience, such as init, before switching dimensions, etc.

Powered by VitePress and GitHub Pages