Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new data extracting solution #261

Open
smartcmd opened this issue Jun 16, 2024 · 0 comments
Open

feat: new data extracting solution #261

smartcmd opened this issue Jun 16, 2024 · 0 comments
Labels
Documentation Improvements or additions to documentation

Comments

@smartcmd
Copy link
Member

smartcmd commented Jun 16, 2024

Here we list the data which can only be generated from BDS:

Data for each block state

  • name: Block::getName()
  • blockAABB(the bounding box of a specific block state): Block::getCollisionShape()
  • burnOdds(also named burnAbility): Block::getBurnOdds()
  • flameOdds(also named burnChance): Block::getFlameOdds()
  • lightDampening: Block::getLight() -> Brightness::value
  • lightEmission: Block::getLightEmission() -> Brightness::value
  • explosionResistance: Block::getExplosionResistance()
  • friction: Block::getFriction()
  • hardness(also named destroySpeed): Block::getDestroySpeed()
  • thickness: Block::getThickness()
  • canContainLiquid: Block::getLegacyBlock() -> BlockLegacy::canContainLiquid()
  • canDropWithAnyTool(also named canHarvestWithHand): Block::canDropWithAnyTool()
  • mapColor: Block::getMapColor()

Block material data for each block tyoe

How to get a block's material:

auto & material = block.getMaterial()
  • canBeMovingBlock: Material::getBlocksMotion()
  • canHavePrecipitation: Material::getBlocksPrecipitation()
  • isAlwaysDestroyable: Material::isAlwaysDestroyable()
  • isLiquid: Material::isLiquid()
  • isSolid: Material::isSolid()
  • isSolidBlocking: Material::isSolidBlocking()
  • isSuperHot: Material::isSuperHot()
  • translucency: Material::getTranslucency()
  • materialType: ??? We get it using Material::isType() indirectly

The current method that we get a block's material type:

#include <mc/world/level/material/Material.h>
#include <mc/enums/MaterialType.h>

MaterialType findMaterialType(const Material & material) {
    for (MaterialType type : materialTypes) {
        if (material.isType(type)) {
            return type;
        }
    }
    return MaterialType::Any;
}

Data for each item type

  • armorValue: Item::getArmorValue()
  • toughnessValue: Item::getToughnessValue()
  • attackDamage: Item::getAttackDamage()
  • isDamageable: Item::isDamageable()
  • id: Item::getId()
  • name: Item::getFullItemName()
  • maxDamage: Item::getMaxDamage()
  • maxStackSize: Item::getMaxStackSize()
  • name: Item::getFullItemName()

Special correct tools for some blocks

The current code:

void dumpBlockCorrectToolSpecial() {
    CompoundTag global = CompoundTag();
    BlockTypeRegistry::forEachBlock([&global](const BlockLegacy& blockLegacy) {
        auto correctItemList = ListTag();
        auto & block = blockLegacy.getDefaultState();
        for (const auto &item: ItemRegistryManager::getItemRegistry().getNameToItemMap() | std::views::values) {
            auto itemStack = ItemStack(*item, 1, 0);
            if (itemStack.canDestroySpecial(block)) {
                correctItemList.add(StringTag(item->getFullItemName()));
            }
        }
        if (correctItemList.size() != 0) {
            global.put(blockLegacy.getTypeName(), correctItemList);
        }
        return true;
    });
    writeNBT("data/block_correct_tool_special.nbt", global);
}

Block tag map

Contains all block tags that each block type has. see the example file

The current code that we generate this file can be found here.
It is a little ugly, and we would like to find a better implementation

Item tag map

Contains all item tags that each item type has. see the example file
It is similar to the block tag map.

The current code that we generate this file can be found here.
We also would like to find a better implementation

@smartcmd smartcmd added the Documentation Improvements or additions to documentation label Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant