Skip to content

PalaceoftheRepublic/AiMath

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AiMath

Mathematics Functions Library Datapack
数学関数ライブラリデータパック

動作確認済みバージョン / Verified minecraft versions

  • 1.17.1
  • 1.18.x

使い方 / How To Use

基本 / Basics

  1. math: in に入力を設定します。
    data modify storage math: in set value (INPUT/入力)
  2. 関数を呼びます。
    function #math:xxx
  3. 結果が取得できます。
    data get storage math: out

関数の上書き / Override functions

関数は全て#math:xxxの形式でfunctionタグになっています。
そのためこのデータパックのファイルを直接書き換えなくても、他のデータパックから挙動を上書きすることができます。
All functions are defined as function tags in the form of #math:xxx.
Therefore, you can overwrite the behavior from other datapacks without directly rewriting the files in this datapack.

#math:sinの挙動を変えたい場合  
When you want to override the behavior of #math:sin.  
  
math/tags/functions/sin.json  
{  
    "replace": true,  
    "values": [  
        "your_datapack:sin"  
    ]  
}

関数の追加 / Add functions

好きな関数をヘルプ(#math:help)に追加表示できます。
You can add a new line of any function you like to the help(#math:help).

#math:your_functionのヘルプを追加したい場合  
If you want to add help for #math:your_function  

math/tags/functions/help/functions.json  
{  
    "replace": false,  
    "values": [  
        "your_datapack:help/your_function"  
    ]  
}
your_datapack/functions/help/your_function.mcfunction  
tellraw @s {"text":"function #math:your_function","underlined": true,"clickEvent": {"action": "run_command","value": "/function your_datapack:your_function/help"}}

現在標準で対応している関数一覧 / Default Supported Functions

  1. sin
  2. cos
  3. tan
  4. sqrt
  5. random
  6. dice
  7. maze

sin/cos/tan

sin/cos/tanを取得します。角度は度数法で指定します。
入力(math: in) : 角度(int)
出力(math: out): sin(double)

data modify storage math: in set value 30
function #math:sin
data get storage math: out
-> 0.5d

sqrt

平方根を取得します。 入力は0.00000001(一億分の一)から100000000(一億)まで。結果は有効数字4桁です。
入力(math: in) : 実数(double)
出力(math: out): 平方根(double)

data modify storage math: in set value 0.05
function #math:sqrt
data get storage math: out
-> 0.22360000000000002d

random

0 から 2147483647 までの乱数を生成します。
入力(math: in) : なし(-)
出力(math: out): 乱数(int)

function #math:random
data get storage math: out
-> 1195316795

dice

サイコロを振った結果を返します。ダイスは1024面くらいまで推奨です。
入力(math: in) : N個のX面ダイス[N, X] / NdX ([int, int])
出力(math: out.dice): それぞれの出目[出目1, 出目2, ...] / Numbers of dice rolls ([int, int, ...])
出力(math: out.sum) : 合計値 / SUM (int)

data modify storage math: in set value [10,6]
function #math:dice
data get storage math: out
-> {dice: [4, 5, 1, 3, 5, 4, 3, 3, 1, 4], sum: 33}

maze

32x32部屋までのクラスタリング迷路を生成します。
一時的にエンティティを使用しているので、プレイヤーのいる場所からなど
確実に読み込まれているチャンクから呼び出してください。
入力(math: in) : N部屋xM部屋の迷路[N, M] / NxM-room maze ([int, int])
出力(math: out): 迷路 / Maze ([[■/□,...],...])
(おまけ)math:maze/dump テスト用。変更可能性あり。迷路生成結果math:outをログに表示するだけです。

data modify storage math: in set value [4,3]
function #math:maze
data get storage math: out
-> [
["", "", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", "", ""],
["", "", "", "", "", "", "", "", ""]
]

連絡はこちら / Contact

https://twitter.com/AiAkaishi

ライセンス / LICENSE

These codes are released under the MIT License, see LICENSE.

About

Mathematics Functions Library Datapack

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • mcfunction 97.0%
  • Python 3.0%