use of net.silentchaos512.gear.item.RepairKitItem in project Silent-Gear by SilentChaos512.
the class SGearJeiPlugin method registerRecipes.
@Override
public void registerRecipes(IRecipeRegistration reg) {
assert Minecraft.getInstance().level != null;
RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
// Repair kit hints
for (RepairKitItem item : Registration.getItems(RepairKitItem.class)) {
String itemName = NameUtils.fromItem(item).getPath();
reg.addRecipes(Collections.singleton(new ShapelessRecipe(SilentGear.getId(itemName + "_fill_hint"), "", new ItemStack(item), NonNullList.of(Ingredient.EMPTY, Ingredient.of(item), PartMaterialIngredient.of(PartType.MAIN), PartMaterialIngredient.of(PartType.MAIN), PartMaterialIngredient.of(PartType.MAIN)))), VanillaRecipeCategoryUid.CRAFTING);
reg.addRecipes(Collections.singleton(new ShapelessRecipe(SilentGear.getId(itemName + "_fill_hint_frag"), "", new ItemStack(item), NonNullList.of(Ingredient.EMPTY, Ingredient.of(item), Ingredient.of(ModItems.FRAGMENT), Ingredient.of(ModItems.FRAGMENT), Ingredient.of(ModItems.FRAGMENT)))), VanillaRecipeCategoryUid.CRAFTING);
}
reg.addRecipes(recipeManager.getRecipes().stream().filter(SGearJeiPlugin::isGearCraftingRecipe).collect(Collectors.toList()), GEAR_CRAFTING);
// Compounders
reg.addRecipes(recipeManager.getRecipes().stream().filter(r -> r.getType() == CompoundingRecipe.COMPOUNDING_FABRIC_TYPE).collect(Collectors.toList()), Const.COMPOUNDING_FABRIC);
reg.addRecipes(recipeManager.getRecipes().stream().filter(r -> r.getType() == CompoundingRecipe.COMPOUNDING_GEM_TYPE).collect(Collectors.toList()), Const.COMPOUNDING_GEM);
reg.addRecipes(recipeManager.getRecipes().stream().filter(r -> r.getType() == CompoundingRecipe.COMPOUNDING_METAL_TYPE).collect(Collectors.toList()), Const.COMPOUNDING_METAL);
for (int i = 2; i <= 4; ++i) {
reg.addRecipes(Collections.singleton(CompoundingRecipe.makeExample(Const.FABRIC_COMPOUNDER_INFO, i, new FabricCompoundingRecipe(SilentGear.getId("fabric_example_" + i)))), Const.COMPOUNDING_FABRIC);
reg.addRecipes(Collections.singleton(CompoundingRecipe.makeExample(Const.GEM_COMPOUNDER_INFO, i, new GemCompoundingRecipe(SilentGear.getId("gem_example_" + i)))), Const.COMPOUNDING_GEM);
reg.addRecipes(Collections.singleton(CompoundingRecipe.makeExample(Const.METAL_COMPOUNDER_INFO, i, new MetalCompoundingRecipe(SilentGear.getId("metal_example_" + i)))), Const.COMPOUNDING_METAL);
}
// Grading
reg.addRecipes(Collections.singleton(new MaterialGraderRecipeCategory.GraderRecipe()), Const.GRADING);
// Salvaging
reg.addRecipes(recipeManager.getRecipes().stream().filter(r -> r.getType() == SalvagingRecipe.SALVAGING_TYPE).collect(Collectors.toList()), Const.SALVAGING);
addInfoPage(reg, CraftingItems.RED_CARD_UPGRADE);
addInfoPage(reg, CraftingItems.SPOON_UPGRADE);
for (Item item : Registration.getItems(item -> item instanceof ICoreTool)) {
addInfoPage(reg, item);
}
}
use of net.silentchaos512.gear.item.RepairKitItem in project Silent-Gear by SilentChaos512.
the class FillRepairKitRecipe method assemble.
@Override
public ItemStack assemble(CraftingContainer inv) {
StackList list = StackList.from(inv);
ItemStack repairKit = list.uniqueOfType(RepairKitItem.class).copy();
repairKit.setCount(1);
RepairKitItem repairKitItem = (RepairKitItem) repairKit.getItem();
for (ItemStack mat : list.allMatches(FillRepairKitRecipe::isRepairMaterial)) {
if (!repairKitItem.addMaterial(repairKit, mat)) {
// Repair kit is too full to accept more materials
return ItemStack.EMPTY;
}
}
return repairKit;
}
use of net.silentchaos512.gear.item.RepairKitItem in project Silent-Gear by SilentChaos512.
the class QuickRepairRecipe method matches.
@Override
public boolean matches(CraftingContainer inv, Level worldIn) {
// Need 1 gear, 1 repair kit, and optional materials
ItemStack gear = ItemStack.EMPTY;
boolean foundKit = false;
float repairKitEfficiency = Config.Common.missingRepairKitEfficiency.get().floatValue();
List<ItemStack> materials = new ArrayList<>();
for (int i = 0; i < inv.getContainerSize(); ++i) {
ItemStack stack = inv.getItem(i);
if (!stack.isEmpty()) {
// noinspection ChainOfInstanceofChecks
if (stack.getItem() instanceof ICoreItem) {
if (!gear.isEmpty()) {
return false;
}
gear = stack;
} else if (stack.getItem() instanceof RepairKitItem) {
if (foundKit) {
return false;
}
foundKit = true;
repairKitEfficiency = getKitEfficiency(stack);
} else if (MaterialManager.from(stack) != null) {
materials.add(stack);
} else {
return false;
}
}
}
if (gear.isEmpty() || repairKitEfficiency < 0.1E-9)
return false;
for (ItemStack stack : materials) {
if (!ModRecipes.isRepairMaterial(gear, stack)) {
return false;
}
}
return true;
}
use of net.silentchaos512.gear.item.RepairKitItem in project Silent-Gear by SilentChaos512.
the class QuickRepairRecipe method getRemainingItems.
@Override
public NonNullList<ItemStack> getRemainingItems(CraftingContainer inv) {
NonNullList<ItemStack> list = NonNullList.withSize(inv.getContainerSize(), ItemStack.EMPTY);
StackList stackList = StackList.from(inv);
ItemStack gear = stackList.uniqueMatch(s -> s.getItem() instanceof ICoreItem);
ItemStack repairKit = stackList.uniqueMatch(s -> s.getItem() instanceof RepairKitItem);
for (int i = 0; i < list.size(); ++i) {
ItemStack stack = inv.getItem(i);
if (stack.getItem() instanceof RepairKitItem) {
repairWithLooseMaterials(gear, repairKit, stackList.allMatches(mat -> ModRecipes.isRepairMaterial(gear, mat)));
RepairKitItem item = (RepairKitItem) stack.getItem();
ItemStack copy = stack.copy();
item.removeRepairMaterials(copy, item.getRepairMaterials(gear, copy, RepairContext.Type.QUICK));
list.set(i, copy);
} else if (stack.hasContainerItem()) {
list.set(i, stack.getContainerItem());
}
}
return list;
}
use of net.silentchaos512.gear.item.RepairKitItem in project Silent-Gear by SilentChaos512.
the class QuickRepairRecipe method assemble.
@Override
public ItemStack assemble(CraftingContainer inv) {
StackList list = StackList.from(inv);
ItemStack gear = list.uniqueOfType(ICoreItem.class).copy();
ItemStack repairKit = list.uniqueOfType(RepairKitItem.class);
Collection<ItemStack> mats = list.allMatches(mat -> ModRecipes.isRepairMaterial(gear, mat));
// Repair with materials first
repairWithLooseMaterials(gear, repairKit, mats);
// Then use repair kit, if necessary
if (gear.getDamageValue() > 0 && repairKit.getItem() instanceof RepairKitItem) {
RepairKitItem item = (RepairKitItem) repairKit.getItem();
int value = item.getDamageToRepair(gear, repairKit, RepairContext.Type.QUICK);
if (value > 0) {
gear.setDamageValue(gear.getDamageValue() - Math.round(value));
}
}
GearData.incrementRepairCount(gear, 1);
GearData.recalculateStats(gear, ForgeHooks.getCraftingPlayer());
return gear;
}
Aggregations