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;
}
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;
}
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()]);
}
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;
}
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);
}
Aggregations