Search in sources :

Example 6 with ToolPartPosition

use of net.silentchaos512.gems.api.lib.ToolPartPosition in project SilentGems by SilentChaos512.

the class ToolPartTipGems method getModel.

@Override
public ModelResourceLocation getModel(ItemStack tool, ToolPartPosition pos, int frame) {
    String name = ((IRegistryObject) tool.getItem()).getName();
    name = SilentGems.MODID + ":" + name.toLowerCase() + "/" + name + "_" + tipName + (frame == 3 ? "_3" : "");
    if (modelMap.containsKey(name)) {
        return modelMap.get(name);
    }
    name = name.toLowerCase();
    ModelResourceLocation model = new ModelResourceLocation(name, "inventory");
    modelMap.put(name, model);
    return model;
}
Also used : IRegistryObject(net.silentchaos512.lib.registry.IRegistryObject) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 7 with ToolPartPosition

use of net.silentchaos512.gems.api.lib.ToolPartPosition in project SilentGems by SilentChaos512.

the class ToolModel method getQuads.

@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    LogHelper log = SilentGems.logHelper;
    if (tool == null) {
        return new ArrayList<BakedQuad>();
    }
    if (modelManager == null) {
        modelManager = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager();
    }
    List<BakedQuad> quads = Lists.newArrayList();
    ModelResourceLocation location;
    IBakedModel model;
    IBakedModel rodModel = null;
    Item item = tool.getItem();
    // Invalid tools models.
    if (ToolHelper.getMaxDamage(tool) <= 0 && tool.getItem() instanceof IRegistryObject) {
        String name = ((IRegistryObject) tool.getItem()).getName();
        location = new ModelResourceLocation(SilentGems.MODID + ":" + name.toLowerCase() + "/_error", "inventory");
        model = modelManager.getModel(location);
        if (model != null) {
            quads.addAll(model.getQuads(state, side, rand));
        }
        return quads;
    }
    for (ToolPartPosition partPos : ToolPartPosition.values()) {
        // Scepter rods on top of head.
        if (tool.getItem() instanceof ItemGemScepter) {
            if (partPos == ToolPartPosition.ROD) {
                location = ToolRenderHelper.getInstance().getModel(tool, partPos);
                rodModel = modelManager.getModel(location);
                continue;
            } else if (partPos == ToolPartPosition.ROD_DECO) {
                quads.addAll(rodModel.getQuads(state, side, rand));
            }
        }
        // Normal logic.
        location = ToolRenderHelper.getInstance().getModel(tool, partPos);
        // debug += partPos + ": " + (location == null ? "null" : location.toString()) + "\n";
        if (location != null) {
            model = modelManager.getModel(location);
            if (model != null) {
                quads.addAll(model.getQuads(state, side, rand));
            }
        }
    }
    if (ModuleAprilTricks.instance.isEnabled() && ModuleAprilTricks.instance.isRightDay()) {
        model = modelManager.getModel(ToolRenderHelper.getInstance().modelGooglyEyes);
        quads.addAll(model.getQuads(state, side, rand));
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ItemGemScepter(net.silentchaos512.gems.item.tool.ItemGemScepter) Item(net.minecraft.item.Item) IRegistryObject(net.silentchaos512.lib.registry.IRegistryObject) ToolPartPosition(net.silentchaos512.gems.api.lib.ToolPartPosition) LogHelper(net.silentchaos512.lib.util.LogHelper) ArrayList(java.util.ArrayList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Aggregations

ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)6 ItemGemBow (net.silentchaos512.gems.item.tool.ItemGemBow)4 IRegistryObject (net.silentchaos512.lib.registry.IRegistryObject)4 Item (net.minecraft.item.Item)3 ToolPartPosition (net.silentchaos512.gems.api.lib.ToolPartPosition)3 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)3 IModelData (net.silentchaos512.gems.lib.client.IModelData)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 ItemStack (net.minecraft.item.ItemStack)1 ItemTool (net.minecraft.item.ItemTool)1 TextFormatting (net.minecraft.util.text.TextFormatting)1 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)1 EnumMaterialTier (net.silentchaos512.gems.api.lib.EnumMaterialTier)1 ToolStats (net.silentchaos512.gems.api.tool.ToolStats)1 ToolPartTip (net.silentchaos512.gems.api.tool.part.ToolPartTip)1 ItemGemAxe (net.silentchaos512.gems.item.tool.ItemGemAxe)1