Create icon indicating copy to clipboard operation
Create copied to clipboard

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

Open RosaryMala opened this issue 1 year ago • 1 comments

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;
            }
        }

RosaryMala avatar Sep 09 '25 11:09 RosaryMala

Figured I'd add that the incompatibility between custom entity models and resource packs (Namely Fresh Animations) also exists, so ideally any solution can be compatible with both mods and resource packs.

SolidStateDj avatar Mar 10 '26 18:03 SolidStateDj