Skip to content

Add API so mods that don't use vanilla minecraft model types internally can specify locations for conductor hats. #9218

@RosaryMala

Description

@RosaryMala

Currently CreateHatArmorLayer.java can only handle entity models that extend HierarchicalModel or AgeableListModel. Some mods, such as Alex's Mobs, use their own format, and would need some sort of API in order to work.

Below is an example that gets Alex's Mobs and other mods using Citatel to work.

        } else if (entityModel instanceof AdvancedEntityModel<?> model) {
            String partName = "head";
            if (!info.part().isEmpty()) {
                partName = info.part();
            }
            List<AdvancedModelBox> boxesToHead = new ArrayList<>();

            AdvancedModelBox headBox = null;
            for (AdvancedModelBox modelBox : model.getAllParts()) {
                if (modelBox.boxName!= null && modelBox.boxName.equals(partName)) {
                    headBox = modelBox;
                    break;
                }
            }
            while(headBox != null){
                boxesToHead.add(0, headBox);
                headBox = headBox.getParent();
            }

            if (!boxesToHead.isEmpty()) {
                boxesToHead.forEach(part -> part.translateAndRotate(ms));

                AdvancedModelBox lastChild = boxesToHead.get(boxesToHead.size() - 1);
                if (lastChild!= null) {
                    ModelBox cube = lastChild.cubeList.get(Mth.clamp(info.cubeIndex(), 0, lastChild.cubeList.size() - 1));
                    ms.translate(info.offset().x() / 16.0F, (cube.posY1 - cube.posY2 + info.offset().y()) / 16.0F, info.offset().z() / 16.0F);
                    float max = Math.max(cube.posX2 - cube.posX1, cube.posZ2 - cube.posZ1) / 8.0F * info.scale();
                    ms.scale(max, max, max);
                }

                ms.scale(1, -1, -1);
                ms.translate(0, -2.25F / 16.0F, 0);
                msr.rotateXDegrees(-8.5F);
                BlockState air = Blocks.AIR.defaultBlockState();
                CachedBuffers.partial(hat, air)
                        .disableDiffuse()
                        .light(light)
                        .renderInto(ms, buffer.getBuffer(Sheets.cutoutBlockSheet()));
                ms.popPose();
                return;
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: apiIssue or PR is related to APIstatus: confirmedIssue's details are known, it is consistently reproducible, and it needs a fixtype: bugIssue where something isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions