Search in sources :

Example 1 with ItemGemBow

use of net.silentchaos512.gems.item.tool.ItemGemBow in project SilentGems by SilentChaos512.

the class ToolPartFlint method getColor.

@Override
public int getColor(ItemStack toolOrArmor, IPartPosition position, int animationFrame) {
    Item item = toolOrArmor.getItem();
    boolean isTextureUncolored = position == ToolPartPosition.ROD_DECO || item instanceof IArmor || item instanceof ItemGemBow || item instanceof ItemGemShield;
    return isTextureUncolored || ToolHelper.isBroken(toolOrArmor) ? COLOR : 0xFFFFFF;
}
Also used : Item(net.minecraft.item.Item) ItemGemShield(net.silentchaos512.gems.item.tool.ItemGemShield) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) IArmor(net.silentchaos512.gems.api.IArmor)

Example 2 with ItemGemBow

use of net.silentchaos512.gems.item.tool.ItemGemBow 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 ItemGemBow

use of net.silentchaos512.gems.item.tool.ItemGemBow in project SilentGems by SilentChaos512.

the class ToolRenderHelper method buildModelSet.

/**
 * Creates the list of all possible models.
 */
protected void buildModelSet() {
    if (modelSet != null) {
        return;
    }
    Set<ModelResourceLocation> set = Sets.newConcurrentHashSet();
    for (ToolPart part : ToolPartRegistry.getValues()) {
        for (ToolPartPosition pos : ToolPartPosition.values()) {
            for (Item itemTool : ModItems.tools) {
                for (int frame = 0; frame < (itemTool instanceof ItemGemBow ? 4 : 1); ++frame) {
                    ModelResourceLocation model = part.getModel(new ItemStack(itemTool), pos, frame);
                    if (model != null) {
                        set.add(model);
                    }
                }
            }
        }
    }
    // Bow "arrow" models
    arrowModels = new ModelResourceLocation[8];
    for (int i = 0; i < 8; ++i) {
        String tier = i < 4 ? "regular" : "super";
        ModelResourceLocation model = new ModelResourceLocation(SilentGems.RESOURCE_PREFIX + "bow/bow_arrow_" + tier + (i & 3));
        if (model != null)
            set.add(model);
        arrowModels[i] = model;
    }
    modelSet = set;
    models = set.toArray(new ModelResourceLocation[set.size()]);
}
Also used : Item(net.minecraft.item.Item) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ToolPartPosition(net.silentchaos512.gems.api.lib.ToolPartPosition) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ItemGemBow

use of net.silentchaos512.gems.item.tool.ItemGemBow in project SilentGems by SilentChaos512.

the class ToolRenderHelper method getAnimationFrame.

/**
 * Gets the animation frame for bows. Returns 0 for everything else.
 */
public int getAnimationFrame(ItemStack tool) {
    if (tool != null && tool.getItem() instanceof ItemGemBow) {
        EntityPlayer player = Minecraft.getMinecraft().player;
        float pull = tool.getItem().getPropertyGetter(ItemGemBow.RESOURCE_PULL).apply(tool, player.world, player);
        float pulling = tool.getItem().getPropertyGetter(ItemGemBow.RESOURCE_PULLING).apply(tool, player.world, player);
        if (pull > 0.9f)
            return 3;
        if (pull > 0.65f)
            return 2;
        if (pulling > 0f)
            return 1;
    }
    return 0;
}
Also used : ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 5 with ItemGemBow

use of net.silentchaos512.gems.item.tool.ItemGemBow in project SilentGems by SilentChaos512.

the class ToolRenderHelper method getModel.

/**
 * Gets the model for the specified tool and position. Gets the animation frame on its own. Models are cached for
 * performance.
 */
@Nullable
public ModelResourceLocation getModel(ItemStack tool, ToolPartPosition pos) {
    if (StackHelper.isEmpty(tool)) {
        return modelError;
    }
    IModelData modelData = getModelCache(tool);
    int frame = getAnimationFrame(tool);
    boolean isBow = tool.getItem() instanceof ItemGemBow;
    if (modelData == null) {
        updateModelCache(tool);
        modelData = getModelCache(tool);
    }
    if (ToolHelper.isBroken(tool) || modelData == null || modelData.getModel(pos, frame) == null) {
        // Bow "arrow" models
        if (pos == ToolPartPosition.ROD_GRIP && isBow) {
            return getArrowModel(tool, frame);
        }
        // Get the render part for this position.
        ToolPart part = ToolHelper.getRenderPart(tool, pos);
        if (part == null) {
            return null;
        }
        // Get the desired model for the current position and animation frame.
        return !ToolHelper.isBroken(tool) ? part.getModel(tool, pos, frame) : part.getBrokenModel(tool, pos, frame);
    }
    // Grab the cached model.
    return modelData.getModel(pos, frame);
}
Also used : ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) IModelData(net.silentchaos512.gems.lib.client.IModelData) Nullable(javax.annotation.Nullable)

Aggregations

ItemGemBow (net.silentchaos512.gems.item.tool.ItemGemBow)9 Item (net.minecraft.item.Item)4 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)3 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)3 ItemGemShield (net.silentchaos512.gems.item.tool.ItemGemShield)3 ItemStack (net.minecraft.item.ItemStack)2 IArmor (net.silentchaos512.gems.api.IArmor)2 ToolPartPosition (net.silentchaos512.gems.api.lib.ToolPartPosition)2 IModelData (net.silentchaos512.gems.lib.client.IModelData)2 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 Matrix4f (javax.vecmath.Matrix4f)1 Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemBow (net.minecraft.item.ItemBow)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