Данные могли устареть: источник временно недоступен, показан кэш.

DPlib
Datapack Library | Provides Maths, Threading, Real datetime ...
- Загрузки
- 273
- Подписчики
- 5
- Обновлён
- 19 мая 2023 г.
- Лицензия
- MIT
Опубликован 20 апреля 2023 г.

The complete documentation can be found here.
Datapack library
DPlib is a library for datapack developed in mcfunction. It is designed so that you can directly include the module you want in your datapack, without worrying about performance or compatibility and without creating dependencies. It is designed for performance and simplicity, it can be used in any datapack requiring simple or complex functions while being as fast as possible.
This library contains:
- dplib.math
- Number-theoretic and representation
- Power and logarithm
- Trigonometry
- RNG and LCG
- Other various functions
- dplib.datetime
- Real world date and time
- Local time
- Time and duration calculation
- Time conversion
- dplib.threading
- Code threading with contextual entities
- Hierarchical threading
- Scoreboard ID
- dplib.benchmark
- Benchmarking for development only
How it works
You just need to import the module(s) you need (they work independently) into the data folder of your datapack, you then need to load it by executing this command at the beginning of your datapack load file :
function dplib.<module>:load
You may also need to tick the module, if so add this to the beginning of your tick file :
function dplib.<module>:tick
To ensure proper de-installation, you must include this line in the uninstallation file :
function dplib.<module>:uninstall
In general, the input scoreboard for parameters is dplib.<module>.in and the output scoreboard is dplib.<module>.in. The automatically managed variables are in dplib.<module>.main
For example, you can calculate how far away the nearest cow is:
# Puts the player's coordinates in parameters of the function
execute as Someone store result score $x1 dplib.math.in run data get entity @s Pos[0]
execute as Someone store result score $y1 dplib.math.in run data get entity @s Pos[1]
execute as Someone store result score $z1 dplib.math.in run data get entity @s Pos[2]
# Puts the nearest cow coordinates in parameters of the function
execute at Someone as @e[sort=nearest,type=cow,limit=1] store result score $x2 dplib.math.in run data get entity @s Pos[0]
execute at Someone as @e[sort=nearest,type=cow,limit=1] store result score $y2 dplib.math.in run data get entity @s Pos[1]
execute at Someone as @e[sort=nearest,type=cow,limit=1] store result score $z2 dplib.math.in run data get entity @s Pos[2]
# Calculates the distance using a tool provided by this library
function dplib.math:tools/distance
# Displays the result above the player's hotbar
title Someone actionbar [{"text":"Nearest Cow : ","color":"red"},{"score":{"name":"$out","objective":"dplib.math.out"},"color":"yellow"},{"text":"m","color":"yellow"}]
Or you can simply get the real world timestamp live:
scoreboard players get unix_timestamp dplib.datetime.main
This library is made to be used with Data-pack Helper Plus extension, it is easier to find the functions thanks to the auto completion provided by the extension and a library of aliases.
The complete documentation can be found here.
It is advisable to credit the project :
This datapack uses DPlib
https://github.com/Z0rillac/DPlib
Ченджлог
v1.2.1Релиз1.19.4 · 19 мая 2023 г.
- Added an icon if DPlib is used as a dependency.
- Fix the dplib.threading documentation. Some terms were still in the old version.
- Fix of
dplib.threading:hierarchy/set_chilf_ofanddplib.threading:hierarchy/set_parent_of, the target was not setting up.
v1.2Релиз1.19.4 · 19 мая 2023 г.
New features!
This version brings new concepts and new features: the possibility to get the real date and time, the possibility to control exactly who runs which function, many optimizations and more.
Changelog
Global
subdomains divided into separate modules
core renamed to private
added a module manager
shared enum and const values are in the module manager
Separation and rewriting of the doc
addition of full IMP-doc
hidden private files with DHP
Updated credit request
Updated license
dplib.math
added functions with binary search algorithm, a bit slower but extremely accurate:
- sin_bsa
- cos_bsa
- tan_bsa
added lcg random generators:
- random_binary_lcg
- random_range_lcg
- random_lcg
added lcm
fsin, fcos, have been replaced by sin, cos
ftan, tan have been replaced by tan_bsa
sin, cos have been replaced by sin_bsa, cos_bsa
sin, cos anti overflow scaling
sqrt optimized, 1250 times faster
cbrt optimized, 19 times faster
gcd optimized, 0.3 times faster
clamp optimized
comb optimized
random fixed, it could not mathematically give -2147483648
some parameters have been unified:
- copysign:
$numberbecomes$in1,$sourcebecomes$in2 - pow:
$numberbecomes$in1,$exponentbecomes$in2
- copysign:
dplib.threading
added a threading module to control the execution of functions
- thread/new
- thread/kill
- hierarchy/set_child_of
- hierarchy/set_parent_of
- scheduler
- dplib.threading:child (predicate)
- dplib.threading:parent (predicate)
dplib.datetime
Added a module to get the real world date and time
- get unix timestamp
- get UTC datetime
- get local time
- conversion/timestamp_to_datetime
- uninstallation warn
dplib.benchmark
added a benchmark module for datapack development
- start
v1.1Релиз1.18, 1.18.1 · 20 апреля 2023 г.
Datapack library v1.1
- adds faster trigonometric function : fcos, fsin, ftan
- adds more useful constants
- updates docs
v1.0Релиз1.17, 1.17.1 · 20 апреля 2023 г.
Datapack library
v1.0.0
- Basic mathematical tools and functions.
- Full documentation
Комментарии
Загружаем…