Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey, I'm trying to have an item rendered as a combination of two models. Everything works so far but the item is scaled and rotated wrong:

 

Part of the ClientProxy:

 

 

ModelResourceLocation l;

 

Item item = ChestTransporter.chestTransporter;

l = new ModelResourceLocation("chesttransporter:vanilla", "inventory");

ModelBakery.addVariantName(item, "chesttransporter:vanilla");

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, l);

 

 

IModel:

 

 

public class MyModel implements IModel

{

    public static final ModelResourceLocation CORE = new ModelResourceLocation("chesttransporter:item/handle_wood", "inventory");

    public static final ModelResourceLocation WOOD = new ModelResourceLocation("chesttransporter:item/vanilla1", "inventory");

 

    @Override

    public Collection<ResourceLocation> getDependencies()

    {

        return ImmutableList.copyOf(new ResourceLocation[]{CORE, WOOD});

    }

 

    @Override

    public Collection<ResourceLocation> getTextures()

    {

        return Collections.EMPTY_LIST;

    }

 

    @Override

    public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)

    {

        try

        {

            IModel model = ModelLoaderRegistry.getModel(CORE);

            IBakedModel baked1 = model.bake(state, format, bakedTextureGetter);

 

            model = ModelLoaderRegistry.getModel(WOOD);

            IBakedModel baked2 = model.bake(state, format, bakedTextureGetter);

 

            return new BakedModelTwoParts(baked1, baked2);

        } catch (Exception e)

        {

            e.printStackTrace();

        }

        return null;

    }

 

    @Override

    public IModelState getDefaultState()

    {

        return ModelRotation.X0_Y0;

    }

}

 

 

 

SmartItemModel:

 

 

public class BakedModelTwoParts implements IFlexibleBakedModel, ISmartItemModel

{

    private final IBakedModel core2;

    private IBakedModel core;

 

    public BakedModelTwoParts(IBakedModel core, IBakedModel core2)

    {

        this.core = core;

        this.core2 = core2;

    }

 

    @Override

    public List<BakedQuad> getFaceQuads(EnumFacing side)

    {

        return core.getFaceQuads(side);

    }

 

    @Override

    public List<BakedQuad> getGeneralQuads()

    {

        List<BakedQuad> quads = new ArrayList<BakedQuad>();

        quads.addAll(core.getGeneralQuads());

        quads.addAll(core2.getGeneralQuads());

        return quads;

    }

 

    @Override

    public VertexFormat getFormat()

    {

        return Attributes.DEFAULT_BAKED_FORMAT;

    }

 

    @Override

    public boolean isAmbientOcclusion()

    {

        return core.isAmbientOcclusion();

    }

 

    @Override

    public boolean isGui3d()

    {

        return core.isGui3d();

    }

 

    @Override

    public boolean isBuiltInRenderer()

    {

        return false;

    }

 

    @Override

    public TextureAtlasSprite getTexture()

    {

        return core.getTexture();

    }

 

    @Override

    public ItemCameraTransforms getItemCameraTransforms()

    {

        return core2.getItemCameraTransforms();

    }

 

    @Override

    public IBakedModel handleItemState(ItemStack stack)

    {

        return this;

    }

}

 

 

 

ModelLoader

 

 

public class CustomModelLoader implements ICustomModelLoader

{

    @Override

    public boolean accepts(ResourceLocation modelLocation)

    {

        return modelLocation.getResourceDomain().equals("chesttransporter") && modelLocation.getResourcePath().endsWith("vanilla");

    }

 

    @Override

    public IModel loadModel(ResourceLocation modelLocation) throws IOException

    {

        return new MyModel();

    }

 

    @Override

    public void onResourceManagerReload(IResourceManager resourceManager)

    {

 

    }

}

 

 

 

Is there anything I'm missing or did wrong?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.