Search in sources :

Example 1 with IRegistryObject

use of net.silentchaos512.lib.registry.IRegistryObject in project SilentGems by SilentChaos512.

the class ToolHelper method createToolName.

public static String createToolName(Item item, List<ItemStack> materials) {
    ToolPart part;
    LocalizationHelper loc = SilentGems.localizationHelper;
    Set<String> prefixSet = Sets.newLinkedHashSet();
    Set<String> materialSet = Sets.newLinkedHashSet();
    for (ItemStack stack : materials) {
        part = ToolPartRegistry.fromStack(stack);
        if (part != null) {
            String prefix = part.getDisplayNamePrefix(stack);
            if (prefix != null && !prefix.isEmpty())
                prefixSet.add(prefix);
            materialSet.add(part.getDisplayName(stack));
        }
    }
    String prefix = String.join(" ", prefixSet);
    if (!prefix.isEmpty())
        prefix += " ";
    String delimiter = loc.getLocalizedString("tool.silentgems:delimiter");
    String materialName = String.join(delimiter, materialSet);
    String toolName = ((IRegistryObject) item).getName();
    String name = loc.getLocalizedString("tool", toolName, materialName);
    return prefix + name;
}
Also used : ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) IRegistryObject(net.silentchaos512.lib.registry.IRegistryObject) ItemStack(net.minecraft.item.ItemStack) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 2 with IRegistryObject

use of net.silentchaos512.lib.registry.IRegistryObject in project SilentGems by SilentChaos512.

the class ToolPartGem method getModel.

@Override
public ModelResourceLocation getModel(ItemStack tool, ToolPartPosition pos, int frame) {
    String name = ((IRegistryObject) tool.getItem()).getName();
    name = SilentGems.RESOURCE_PREFIX + name + "/" + name;
    String gemNum = tool.getItem() instanceof ItemGemBow ? "" : "" + gem.ordinal();
    String frameNum = frame == 3 ? "_3" : "";
    switch(pos) {
        case HEAD:
            name += gemNum + frameNum;
            break;
        case ROD_DECO:
            name += "_deco";
            break;
        default:
            return null;
    }
    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) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 3 with IRegistryObject

use of net.silentchaos512.lib.registry.IRegistryObject in project SilentGems by SilentChaos512.

the class ToolPartRodGems method getModel.

@Override
public ModelResourceLocation getModel(ItemStack tool, ToolPartPosition pos, int frame) {
    String name = ((IRegistryObject) tool.getItem()).getName();
    name = SilentGems.RESOURCE_PREFIX + name.toLowerCase() + "/" + name + "_" + rodName;
    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 4 with IRegistryObject

use of net.silentchaos512.lib.registry.IRegistryObject 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 5 with IRegistryObject

use of net.silentchaos512.lib.registry.IRegistryObject 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

IRegistryObject (net.silentchaos512.lib.registry.IRegistryObject)5 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)4 ArrayList (java.util.ArrayList)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ToolPartPosition (net.silentchaos512.gems.api.lib.ToolPartPosition)1 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)1 ItemGemBow (net.silentchaos512.gems.item.tool.ItemGemBow)1 ItemGemScepter (net.silentchaos512.gems.item.tool.ItemGemScepter)1 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)1 LogHelper (net.silentchaos512.lib.util.LogHelper)1