ExplosiveAPI

API for count gunpowder power in items
g1_en.png

g1_en.png

g64_en.png

g64_en.png

Description

English

The phrase G power here stands for gunpowder power.

About the mod

The mod is a counter of explosive substances. Take vanilla gunpowder, for example.
By default, its explosiveness is measured in 1 G power:
image
If you have a stack of gunpowder in your hand, inventory, or chest, the slot will have a total of 64 G of power:
image

How the counter works

First, during the server-side launch, a graph is built from all the recipes. The explosion hazard starts being calculated from bottom to top. Items that are not in the configs and do not have a recipe receive 0G; then items with a recipe are considered: the mod calculates the amount of G power, adds it up, and divides it by the output quantity and the number of recipes. For example, dynamite. It is crafted from 5 sand and 5 gunpowder -> sand = 0G -> gunpowder = 1G -> dynamite = 5G.

What functions can be used for your add-on

You will only need the GunpowderCounter class.
Checking for the completion of recipe analysis: GunpowderCounter.isCacheLoaded();
Obtaining G power from an item: GunpowderCounter.getExplosivePowerFromItem(ItemStack stack);
Obtaining a copy of the entire map of explosive items (ResourceLocation, Integer): GunpowderCounter.getPowerCache();
Recalculating G power: GunpowderCounter.recomputeCache(Level level);

Русский

Словосочетание G сила здесь расшифровывается, как gunpowder сила (ну типа пороховая сила).

О моде

Мод из себя представляет счетчик взрывоопасных веществ. Возьмем, например, ванильный порох.
По умолчанию его взрывоопасность измеряется в 1 G силу:
image
Если у вас в руке, инвентаре или сундуке будет стак пороха, то суммарно у слота будет 64 G силы:
image

Как работает счетчик

Сначала во время запуска серверной части строится граф из всех рецептов. Взрывоопасность начинает считаться снизу вверх. Предметы, которых нет в конфигах, и у которых нет рецепта, получают 0G, потом рассматриваются предметы с рецептом: мод считает количество G силы, складывает ее и делит на количество на выходе и количество рецептов. Например, динамит. Он крафтится из 5 песка и 5 пороха -> песок = 0G -> порох = 1G -> динамит = 5G.

Какие функции могут использоваться для вашего аддона

Вам понадобится только класс GunpowderCounter.
Проверка на завершения анализа рецептов: GunpowderCounter.isCacheLoaded();
Получение G силы из предмета: GunpowderCounter.getExplosivePowerFromItem(ItemStack stack);
Получение копии вообще всей карты взрывоопасных вещей(ResourceLocation, Integer): GunpowderCounter.getPowerCache();
Пересчит G силы: GunpowderCounter.recomputeCache(Level level);

ExplosiveAPI Team

profile avatar
Owner
  • 2
    Projects
  • 20
    Downloads

More from bmd070