use of net.silentchaos512.gems.api.lib.EnumPartPosition in project SilentGems by SilentChaos512.
the class ToolPartRodGems method getModel.
@Override
public ModelResourceLocation getModel(ItemStack tool, EnumPartPosition 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;
}
use of net.silentchaos512.gems.api.lib.EnumPartPosition in project SilentGems by SilentChaos512.
the class ToolPartTipGems method getModel.
@Override
public ModelResourceLocation getModel(ItemStack tool, EnumPartPosition 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;
}
use of net.silentchaos512.gems.api.lib.EnumPartPosition 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;
boolean isBroken = ToolHelper.isBroken(tool);
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 (EnumPartPosition partPos : EnumPartPosition.values()) {
if (isBroken) {
if ((partPos == EnumPartPosition.HEAD_LEFT && item != ModItems.sword && item != ModItems.bow) || (partPos == EnumPartPosition.HEAD_MIDDLE && item != ModItems.bow) || (partPos == EnumPartPosition.HEAD_RIGHT && item != ModItems.bow) || partPos == EnumPartPosition.TIP) {
continue;
}
}
// Scepter rods on top of head.
if (tool.getItem() instanceof ItemGemScepter) {
if (partPos == EnumPartPosition.ROD) {
location = ToolRenderHelper.getInstance().getModel(tool, partPos);
rodModel = modelManager.getModel(location);
continue;
} else if (partPos == EnumPartPosition.ROD_DECO) {
quads.addAll(rodModel.getQuads(state, side, rand));
}
}
// Normal logic.
location = ToolRenderHelper.getInstance().getModel(tool, partPos);
if (location != null) {
model = modelManager.getModel(location);
if (model != null) {
quads.addAll(model.getQuads(state, side, rand));
}
}
}
if (ModuleAprilTricks.instance.moduleEnabled && ModuleAprilTricks.instance.isRightDay()) {
model = modelManager.getModel(ToolRenderHelper.getInstance().modelGooglyEyes);
quads.addAll(model.getQuads(state, side, rand));
}
return quads;
}
use of net.silentchaos512.gems.api.lib.EnumPartPosition in project SilentGems by SilentChaos512.
the class ToolHelper method recalculateStats.
/**
* Recalculate all stats and properties, including the rendering cache for the given tool. In general, this should be
* called any time changes are made to a tool (aside from incrementing statistics, or something like that). For
* example, this is called during construction, decoration, and for all tools in the players inventory during login.
*
* @param tool
*/
public static void recalculateStats(ItemStack tool) {
ToolPart[] parts = getConstructionParts(tool);
EnumMaterialGrade[] grades = getConstructionGrades(tool);
if (parts.length == 0)
return;
ToolStats stats = new ToolStats(tool, parts, grades).calculate();
// Reset render cache
for (EnumPartPosition pos : EnumPartPosition.values()) {
NBTTagCompound compound = tool.getTagCompound().getCompoundTag(ToolRenderHelper.NBT_MODEL_INDEX);
String str = "Layer" + pos.ordinal();
for (int frame = 0; frame < (tool.getItem() instanceof ItemGemBow ? 4 : 1); ++frame) compound.removeTag(str + (frame > 0 ? "_" + frame : ""));
compound.removeTag(str + "Color");
}
// Set color for parts
ToolPart renderHeadM = getRenderPart(tool, EnumPartPosition.HEAD_MIDDLE);
ToolPart renderHeadL = getRenderPart(tool, EnumPartPosition.HEAD_LEFT);
ToolPart renderHeadR = getRenderPart(tool, EnumPartPosition.HEAD_RIGHT);
ToolPart renderRodDeco = getRenderPart(tool, EnumPartPosition.ROD_DECO);
ToolPart renderRod = getRenderPart(tool, EnumPartPosition.ROD);
if (renderHeadM != null)
setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_HEAD_M + "Color", renderHeadM.getColor(tool));
if (renderHeadL != null)
setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_HEAD_L + "Color", renderHeadL.getColor(tool));
if (renderHeadR != null)
setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_HEAD_R + "Color", renderHeadR.getColor(tool));
if (renderRodDeco != null)
setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_ROD_DECO + "Color", renderRodDeco.getColor(tool));
if (renderRod != null)
setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_ROD + "Color", renderRod.getColor(tool));
setTagInt(tool, NBT_ROOT_PROPERTIES, NBT_PROP_DURABILITY, (int) stats.durability);
setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_HARVEST_SPEED, stats.harvestSpeed);
setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_MELEE_DAMAGE, stats.meleeDamage);
setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_MAGIC_DAMAGE, stats.magicDamage);
setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_MELEE_SPEED, stats.meleeSpeed);
setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_CHARGE_SPEED, stats.chargeSpeed);
setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_BLOCKING_POWER, stats.blockingPower);
setTagInt(tool, NBT_ROOT_PROPERTIES, NBT_PROP_ENCHANTABILITY, (int) stats.enchantability);
setTagInt(tool, NBT_ROOT_PROPERTIES, NBT_PROP_HARVEST_LEVEL, stats.harvestLevel);
setTagInt(tool, NBT_ROOT_PROPERTIES, NBT_TOOL_TIER, parts[0].getTier().ordinal());
}
Aggregations