use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.
the class RecipeMixedMaterialItem method getMaterials.
protected ItemStackList getMaterials(InventoryCrafting inv) {
ItemStackList list = ItemStackList.create();
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i);
ToolPart part = ToolPartRegistry.fromStack(stack);
if (part != null && !part.isBlacklisted(stack) && part instanceof ToolPartMain) {
list.add(stack);
}
}
return list;
}
use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.
the class RecipeDecorateArmor 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;
// Find armor 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 IArmor) {
tool = stack;
toolRow = row;
toolCol = col;
}
}
}
// Found armor piece?
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);
int validPartCount = (StackHelper.isEmpty(west) ? 0 : 1) + (StackHelper.isEmpty(north) ? 0 : 1) + (StackHelper.isEmpty(east) ? 0 : 1) + (StackHelper.isEmpty(south) ? 0 : 1);
if (!checkIsDecorationMaterial(west) || !checkIsDecorationMaterial(north) || !checkIsDecorationMaterial(east) || !checkIsDecorationMaterial(south)) {
return StackHelper.empty();
}
// Check for other pieces (invalid for armor) and get all repair values.
EnumMaterialTier toolTier = ArmorHelper.getArmorTier(tool);
ToolPart part;
int partsFound = 0;
for (i = 0; i < inv.getSizeInventory(); ++i) {
stack = inv.getStackInSlot(i);
if (StackHelper.isValid(stack) && !(stack.getItem() instanceof IArmor)) {
part = ToolPartRegistry.fromStack(stack);
// Invalid part or not a part?
if (part == null || !(part instanceof ToolPartMain)) {
return StackHelper.empty();
}
// Found a part.
++partsFound;
// Add to total repair value.
repairValue += part.getRepairAmount(tool, stack);
}
}
// Make sure we got no other parts.
if (partsFound != validPartCount) {
return StackHelper.empty();
}
ItemStack result = ArmorHelper.decorateArmor(tool, west, north, east, south);
// Repair.
result.attemptDamageItem(-repairValue, SilentGems.random);
// Recalculate stats.
ArmorHelper.recalculateStats(result);
ArmorHelper.incrementStatRedecorated(result, 1);
return result;
}
use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.
the class RecipeMultiGemBow method getGems.
private ItemStack[] getGems(InventoryCrafting inv, boolean orientation) {
ItemStack gem1 = inv.getStackInRowAndColumn(1, 2);
ItemStack gem2 = inv.getStackInRowAndColumn(orientation ? 0 : 2, 1);
ItemStack gem3 = inv.getStackInRowAndColumn(1, 0);
gem1 = ToolPartRegistry.fromStack(gem1) instanceof ToolPartMain ? gem1 : StackHelper.empty();
gem2 = ToolPartRegistry.fromStack(gem2) instanceof ToolPartMain ? gem2 : StackHelper.empty();
gem3 = ToolPartRegistry.fromStack(gem3) instanceof ToolPartMain ? gem3 : StackHelper.empty();
return StackHelper.isEmpty(gem1) || StackHelper.isEmpty(gem2) || StackHelper.isEmpty(gem3) ? null : new ItemStack[] { gem1, gem2, gem3 };
}
use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.
the class RecipeMultiGemTool method getGems.
private ItemStack[] getGems(InventoryCrafting inv) {
List<ItemStack> list = Lists.newArrayList();
ItemStack stack;
for (int i = 0; i < inv.getSizeInventory(); ++i) {
stack = inv.getStackInSlot(i);
ToolPart part = ToolPartRegistry.fromStack(stack);
if (part != null && part instanceof ToolPartMain) {
list.add(stack);
}
}
return list.toArray(new ItemStack[list.size()]);
}
use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.
the class ArmorHelper method decorate.
private static ItemStack decorate(ItemStack armor, ItemStack material, ArmorPartPosition pos) {
if (StackHelper.isEmpty(armor))
return StackHelper.empty();
if (StackHelper.isEmpty(material))
return armor;
ToolPart part = ToolPartRegistry.fromDecoStack(material);
if (part == null)
return null;
// Only main parts (like gems) work
if (!(part instanceof ToolPartMain))
return armor;
ItemStack result = StackHelper.safeCopy(armor);
setTagPart(result, pos.getDecoKey(), part, EnumMaterialGrade.fromStack(material));
return result;
}
Aggregations