use of net.silentchaos512.gems.api.lib.EnumMaterialTier in project SilentGems by SilentChaos512.
the class ToolRenderHelperBase method getRarity.
public EnumRarity getRarity(ItemStack tool) {
EnumMaterialTier tier = ToolHelper.getToolTier(tool);
boolean enchanted = tool.isItemEnchanted();
switch(tier) {
case SUPER:
return EnumRarity.EPIC;
case REGULAR:
return enchanted ? EnumRarity.RARE : EnumRarity.UNCOMMON;
case MUNDANE:
default:
return enchanted ? EnumRarity.RARE : EnumRarity.COMMON;
}
}
use of net.silentchaos512.gems.api.lib.EnumMaterialTier in project SilentGems by SilentChaos512.
the class ItemGemArmor method getMaxDamage.
@Override
public int getMaxDamage(ItemStack stack) {
EnumMaterialTier tier = ToolHelper.getToolTier(stack);
int x = ArmorHelper.getMaxDamage(stack);
float y = (1.8f * x + 1515) / 131;
float z = tier != null ? y * (tier.ordinal() + 1f) / 2f : y;
return (int) (MAX_DAMAGE_ARRAY[armorType.getIndex()] * z);
}
use of net.silentchaos512.gems.api.lib.EnumMaterialTier in project SilentGems by SilentChaos512.
the class ModParts method init.
public static void init() {
// Head and deco
ToolPartRegistry.putPart(new ToolPartFlint());
// ToolPartRegistry.putPart(new ToolPartGlass());
for (EnumGem gem : EnumGem.values()) ToolPartRegistry.putPart(new ToolPartGem(gem, false));
for (EnumGem gem : EnumGem.values()) ToolPartRegistry.putPart(new ToolPartGem(gem, true));
// Rods @formatter:off
ToolPartRegistry.putPart(new ToolPartRodGems("RodWood", EnumMaterialTier.MUNDANE, new ItemStack(Items.STICK), 0x896727, "stickWood", 1.0f, 1.0f, 1.0f, 1.0f, 0.8f));
ToolPartRegistry.putPart(new ToolPartRodGems("RodBone", EnumMaterialTier.MUNDANE, new ItemStack(Items.BONE), 0xFFFDE9, 1.1f, 0.9f, 1.1f, 0.9f, 1.0f));
ToolPartRegistry.putPart(new ToolPartRodGems("RodStone", EnumMaterialTier.MUNDANE, ModItems.craftingMaterial.toolRodStone, 0x777777, "stickStone", 0.9f, 1.1f, 1.0f, 1.0f, 0.7f));
ToolPartRegistry.putPart(new ToolPartRodGems("RodIron", EnumMaterialTier.REGULAR, ModItems.craftingMaterial.toolRodIron, 0xA2A2A2, "stickIron", 1.25f, 1.0f, 1.0f, 1.0f, 0.9f));
ToolPartRegistry.putPart(new ToolPartRodGems("RodGold", EnumMaterialTier.SUPER, ModItems.craftingMaterial.toolRodGold, 0xC8AE09, "stickGold", 1.15f, 1.0f, 1.15f, 1.0f, 1.0f));
ToolPartRegistry.putPart(new ToolPartRodGems("RodSilver", EnumMaterialTier.SUPER, ModItems.craftingMaterial.toolRodSilver, 0xF2F2F2, "stickSilver", 1.0f, 1.15f, 1.0f, 1.15f, // @formatter:on
1.0f));
// Tips
ToolPartRegistry.putPart(new ToolPartTipGems("TipIron", EnumTipUpgrade.IRON));
ToolPartRegistry.putPart(new ToolPartTipGems("TipGold", EnumTipUpgrade.GOLD));
ToolPartRegistry.putPart(new ToolPartTipGems("TipDiamond", EnumTipUpgrade.DIAMOND));
ToolPartRegistry.putPart(new ToolPartTipGems("TipEmerald", EnumTipUpgrade.EMERALD));
// Armor Frames
for (EnumMaterialTier tier : EnumMaterialTier.values()) {
for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
if (slot.getSlotType() == EntityEquipmentSlot.Type.ARMOR) {
String key = "frame_" + slot.name().toLowerCase() + "_" + tier.name().toLowerCase();
ToolPartRegistry.putPart(new ArmorPartFrameGems(key, slot, tier));
}
}
}
}
use of net.silentchaos512.gems.api.lib.EnumMaterialTier in project SilentGems by SilentChaos512.
the class RecipeDecorateTool method getCraftingResult.
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
int i;
int toolRow = 0;
int toolCol = 0;
ItemStack stack;
ItemStack tool = StackHelper.empty();
int repairValue = 0;
int ammoValue = 0;
// Find tool position
for (int row = 0; row < inv.getWidth(); ++row) {
for (int col = 0; col < inv.getHeight(); ++col) {
stack = inv.getStackInRowAndColumn(row, col);
if (StackHelper.isValid(stack) && stack.getItem() instanceof ITool) {
tool = stack;
toolRow = row;
toolCol = col;
}
}
}
// Found a tool?
if (StackHelper.isEmpty(tool)) {
return StackHelper.empty();
}
// Check adjacent materials
ItemStack west = inv.getStackInRowAndColumn(toolRow - 1, toolCol);
ItemStack north = inv.getStackInRowAndColumn(toolRow, toolCol - 1);
ItemStack east = inv.getStackInRowAndColumn(toolRow + 1, toolCol);
ItemStack south = inv.getStackInRowAndColumn(toolRow, toolCol + 1);
if (!checkIsDecorationMaterial(west) || !checkIsDecorationMaterial(north) || !checkIsDecorationMaterial(east) || !checkIsDecorationMaterial(south)) {
return StackHelper.empty();
}
// Check other materials and get all repair values.
List<ItemStack> otherMats = Lists.newArrayList();
EnumMaterialTier toolTier = ToolHelper.getToolTier(tool);
for (i = 0; i < inv.getSizeInventory(); ++i) {
stack = inv.getStackInSlot(i);
if (StackHelper.isValid(stack) && !(stack.getItem() instanceof ITool)) {
ToolPart part = ToolPartRegistry.fromDecoStack(stack);
// Invalid part or not a part?
if (part == null) {
return StackHelper.empty();
}
// Valid for tool tier?
if (!part.validForToolOfTier(toolTier) && !(part instanceof ToolPartMain)) {
return StackHelper.empty();
}
int repairAmount = part.getRepairAmount(tool, stack);
if (repairAmount > 0) {
repairValue += repairAmount;
++ammoValue;
}
otherMats.add(stack);
}
}
if (otherMats.isEmpty()) {
return StackHelper.empty();
}
ItemStack result = StackHelper.safeCopy(tool);
result = ToolHelper.decorateTool(tool, west, north, east, south);
boolean lockedStats = result.getTagCompound().getBoolean(ToolHelper.NBT_LOCK_STATS);
// Other materials
for (ItemStack other : otherMats) {
ToolPart part = ToolPartRegistry.fromDecoStack(other);
EnumMaterialGrade grade = EnumMaterialGrade.fromStack(other);
if (StackHelper.isValid(result) && part instanceof ToolPartRod) {
ToolHelper.setRenderPart(result, part, grade, ToolPartPosition.ROD);
} else if (part instanceof ToolPartTip) {
if (lockedStats) {
// Tips change stats, so using them with locked tools is not allowed.
return StackHelper.empty();
}
ToolHelper.setConstructionTip(result, part);
}
}
if (repairValue > 0) {
// Makes odd repair values line up better (2 polished stone on pickaxe makes a full repair, etc.)
repairValue += 1;
}
// Tool repair multiplier
repairValue *= ((ITool) tool.getItem()).getRepairMultiplier();
// Repair.
ItemHelper.attemptDamageItem(result, -repairValue, SilentGems.instance.random);
// Restore ammo.
if (result.getItem() instanceof IAmmoTool && ammoValue > 0) {
IAmmoTool ammoTool = (IAmmoTool) result.getItem();
ammoTool.addAmmo(result, ammoValue * GemsConfig.TOMAHAWK_AMMO_PER_MAT);
}
// Recalculate stats.
ToolHelper.recalculateStats(result);
ToolHelper.incrementStatRedecorated(result, 1);
// Change the UUID so that rendering cache updates immediately for recipe output.
result.getTagCompound().removeTag(ToolHelper.NBT_UUID + "Most");
result.getTagCompound().removeTag(ToolHelper.NBT_UUID + "Least");
ToolHelper.getUUID(result);
return result;
}
use of net.silentchaos512.gems.api.lib.EnumMaterialTier in project SilentGems by SilentChaos512.
the class RecipeMixedMaterialItem method partTiersMatch.
protected boolean partTiersMatch(InventoryCrafting inv) {
EnumMaterialTier tier = null;
// Check mains
for (ItemStack stack : getMaterials(inv)) {
ToolPart part = ToolPartRegistry.fromStack(stack);
if (tier == null) {
tier = part.getTier();
} else if (tier != part.getTier()) {
return false;
}
}
// No mains found?
if (tier == null) {
return false;
}
// Tier restrictions?
if (tierRestriction != null && tier != tierRestriction) {
return false;
}
// Check rod
ItemStack rod = getRod(inv);
if (StackHelper.isValid(rod))
return ToolPartRegistry.fromStack(rod).validForToolOfTier(tier);
// Check frame
ItemStack frame = getFrame(inv);
if (StackHelper.isValid(frame)) {
ToolPart partFrame = ToolPartRegistry.fromStack(frame);
if (partFrame instanceof ArmorPartFrame) {
return partFrame.validForToolOfTier(tier) && doesFrameMatchItem((ArmorPartFrame) partFrame);
}
}
return true;
}
Aggregations