Jump to content

[1.8] Item rendered with wrong transformation


cubex2

Recommended Posts

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?

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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