#How best to display an item on the lid of a shulker box

21 messages · Page 1 of 1 (latest)

queen skiff
#

I'm attempting to reproduce some of the functionality of the ShulkerPlus mod which, I assume, is effectively abandoned by the creator.
I've figured the data part of setting which item to display, and I've worked out displaying the lid item on placed shulker boxes.
I'm a bit lost on displaying the lid item when the shulker is in inventory, held in hand, or is a loose item.

I have some thoughts, but I'm trying to avoid an X Y problem.

Where should I be looking to hook into the rendering pipeline to show that item on the lid?

queen skiff
royal breach
#

fun

royal breach
#

right now my intuition says you should compose the unbaked calls with your own

queen skiff
#

Any item can be attached to the shulker. (well any item that can be placed in the second slot on an anvil)

royal breach
#
public class ReleaseTester1215 implements ModInitializer {
    public static final String MOD_ID = "releasetester1215";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    @Override
    public void onInitialize() {
        MixinEnvironment.getCurrentEnvironment().audit();
        SpecialBlockRendererRegistry.register(
                Blocks.SHULKER_BOX,
                SpecialModelTypesAccessor.me$getBlockToModelType().get(
                        Blocks.BLACK_SHULKER_BOX
                )
        );
    }
}
#
private record CustomSpecialModel<T>(SpecialModelRenderer<T> composed) implements SpecialModelRenderer<Pair<T, ItemStack>> {

        @Override
        public void render(@Nullable Pair<T, ItemStack> data, ItemDisplayContext displayContext, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, boolean glint) {
            var originalData = Nullables.map(
                    data,
                    Pair::getLeft
            );
            composed.render(originalData, displayContext, matrices, vertexConsumers, light, overlay, glint);
        }

        @Override
        public @NotNull Pair<T, ItemStack> getData(ItemStack stack) {
            return new Pair<>(composed.getData(stack), Nullables.map(
                    stack.get(DataComponentTypes.CONTAINER),
                    ContainerComponent::copyFirstStack
            ));
        }
    }

    private record CustomUnbakedShulkerSpecialModel(SpecialModelRenderer.Unbaked unbaked, MapCodec<CustomUnbakedShulkerSpecialModel> codec) implements SpecialModelRenderer.Unbaked {
        CustomUnbakedShulkerSpecialModel(SpecialModelRenderer.Unbaked unbaked) {
            this(unbaked, asSuper(unbaked.getCodec()).xmap(
                    CustomUnbakedShulkerSpecialModel::new,
                    CustomUnbakedShulkerSpecialModel::unbaked
            ));
        }

        @Override
        public SpecialModelRenderer<?> bake(LoadedEntityModels entityModels) {
            return new CustomSpecialModel<>(unbaked.bake(entityModels));`
        }

        @Override
        public MapCodec<? extends SpecialModelRenderer.Unbaked> getCodec() {
            return codec;
        }

        @SuppressWarnings("unchecked")
        private static MapCodec<SpecialModelRenderer.Unbaked> asSuper(MapCodec<? extends SpecialModelRenderer.Unbaked> codec) {
            return (MapCodec<SpecialModelRenderer.Unbaked>) codec;
        }
    }
#

something like that, although that's entirely untested

#

probably missing a few steps also

#

or completely wrong? 🤔

#

you could also potentially use the model loading api?

#

idk

#

model loading api seems better. probably go that route instead of the above

queen skiff
#

Thank you for this I'll give it a closer look tomorrow when I'm fresh.
Can you point me to a reference on the model loading api?

royal breach
#

There is a really outdated tutorial on the wiki

#

Other than that

#

I just tried and couldn't figure it out

royal breach
#

It's only at datagen