TartaricAcid / TouhouLittleMaid

A minecraft forge mod about the maid
http://page.cfpa.team/TouhouLittleMaid/
MIT License
396 stars 67 forks source link

[Bug] Multi-Blocks Altar visualizer in Patchouli doesn't recognize modified structure nbt #423

Closed EverettSummer closed 8 months ago

EverettSummer commented 1 year ago

Minecraft Version

What happened?

I want to make a datapack that provides compatibility for Terrafirmacraft (aka TFC), since the oak log in TFC has a different block id, I updated four nbt files in data/touhou_little_maid/structures folder, I used the Minecraft Development plugin of IntelliJ IDEA to update these nbt files like this: image

I have tested the datapack and the Multi-Blocks Alter can be formed using the TFC oak log by right-clicking with Gohei,

But the issue is the visualizer of the Patchouli book still claim I'm using the wrong block for the Altar. image

After searching the code, I noticed that the visualizer may use a hardcode block ID to match the blocks, the code is here:

src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/patchouli/MultiblockRegistry.java

    public static void init() {
        PatchouliAPI.IPatchouliAPI api = PatchouliAPI.get();
        IStateMatcher oakLogMatcher = api.predicateMatcher(Blocks.OAK_LOG.defaultBlockState(), state -> state.is(Blocks.OAK_LOG) && state.getValue(RotatedPillarBlock.AXIS) == Direction.Axis.Y);
        IStateMatcher redWoolMatcher = api.predicateMatcher(Blocks.RED_WOOL.defaultBlockState(), state -> state.is(Blocks.RED_WOOL));
        api.registerMultiblock(ID, api.makeMultiblock(TEMPLATE, 'O', oakLogMatcher, 'R', redWoolMatcher, ' ', api.anyMatcher()));
    }

I hope I can help to draft a PR, but I am not familiar with MC development and don't know how to read block id from the nbt data.

Relevant log output

No response

Contact Details

No response

EverettSummer commented 1 year ago

There is another issue after modified the NBT data, the Alter cannot place items due to the hardcoded block id in this code src/main/java/com/github/tartaricacid/touhoulittlemaid/block/multiblock/MultiBlockAltar.java L:65

            if (te instanceof TileEntityAltar) {
                boolean isRender = currentPos.equals(currentCenterPos);
                boolean canPlaceItem = blockInfo.pos.getY() == 2 && blockInfo.state.is(Blocks.OAK_LOG);
                ((TileEntityAltar) te).setForgeData(blockInfo.state, isRender,
                        canPlaceItem, direction, posList, canPlaceItemPosList);
            }
TartaricAcid commented 1 year ago

I'll look back and see how to modify it

TartaricAcid commented 8 months ago

I have now changed it to block tag. In theory, all logs should be correctly identified.