Skip to content

Commit

Permalink
Scepter repair improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
IcarussOne committed Sep 28, 2024
1 parent b3ca567 commit aa5191b
Show file tree
Hide file tree
Showing 18 changed files with 618 additions and 552 deletions.
44 changes: 43 additions & 1 deletion src/main/java/twilightforest/compat/JEI.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,63 @@
package twilightforest.compat;

import com.google.common.collect.Lists;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.NonNullList;
import twilightforest.block.TFBlocks;
import twilightforest.compat.jei.ScepterRepairingRecipeWrapper;
import twilightforest.item.TFItems;

import java.util.List;

@JEIPlugin
public class JEI implements IModPlugin {

@Override
public void register(IModRegistry registry) {
registry.addRecipeCatalyst(new ItemStack(TFBlocks.uncrafting_table), VanillaRecipeCategoryUid.CRAFTING);

IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();

recipeTransferRegistry.addRecipeTransferHandler(new UncraftingRecipeTransferHandler());

// ----- CRAFTING RECIPES ----- //
registry.addRecipes(Lists.newArrayList(
// Scepters
new ScepterRepairingRecipeWrapper(TFItems.twilight_scepter, Items.ENDER_PEARL),
new ScepterRepairingRecipeWrapper(TFItems.lifedrain_scepter, Items.FERMENTED_SPIDER_EYE),
new ScepterRepairingRecipeWrapper(TFItems.zombie_scepter, Items.ROTTEN_FLESH, getStrengthPotions()),
new ScepterRepairingRecipeWrapper(TFItems.shield_scepter, Items.GOLDEN_APPLE)
), VanillaRecipeCategoryUid.CRAFTING);
}

@SuppressWarnings("unused")
private List<ItemStack> getScepters(Item scepter) {
ItemStack stack = new ItemStack(scepter);
ItemStack stackHalf = stack.copy();
ItemStack stackFull = stack.copy();

stackHalf.setItemDamage(stack.getItemDamage() / 2);
stackFull.setItemDamage(stack.getItemDamage());

return NonNullList.from(stack, stackHalf, stackFull);
}

private List<ItemStack> getStrengthPotions() {
ItemStack potion = new ItemStack(Items.POTIONITEM);
ItemStack splash = new ItemStack(Items.SPLASH_POTION);
ItemStack lingering = new ItemStack(Items.LINGERING_POTION);
return NonNullList.from(
PotionUtils.addPotionToItemStack(potion.copy(), PotionTypes.STRENGTH), PotionUtils.addPotionToItemStack(potion.copy(), PotionTypes.LONG_STRENGTH), PotionUtils.addPotionToItemStack(potion, PotionTypes.STRONG_STRENGTH),
PotionUtils.addPotionToItemStack(splash.copy(), PotionTypes.STRENGTH), PotionUtils.addPotionToItemStack(splash.copy(), PotionTypes.LONG_STRENGTH), PotionUtils.addPotionToItemStack(splash, PotionTypes.STRONG_STRENGTH),
PotionUtils.addPotionToItemStack(lingering.copy(), PotionTypes.STRENGTH), PotionUtils.addPotionToItemStack(lingering.copy(), PotionTypes.LONG_STRENGTH), PotionUtils.addPotionToItemStack(lingering, PotionTypes.STRONG_STRENGTH)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package twilightforest.compat.jei;

import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ScepterRepairingRecipeWrapper implements ICraftingRecipeWrapper {

private final List<List<ItemStack>> inputs;
private final ItemStack output;

public ScepterRepairingRecipeWrapper(Item scepter, Item repairItem, List<ItemStack> extra) {
List<ItemStack> scepterList, repairItemList, extraList;

{
ItemStack stack = new ItemStack(scepter);
ItemStack stackHalf = stack.copy();
ItemStack stackFull = stack.copy();

stackHalf.setItemDamage(stack.getItemDamage() / 2);
stackFull.setItemDamage(stack.getItemDamage());

scepterList = NonNullList.from(stack, stackHalf, stackFull);
this.output = stack;
}

{
repairItemList = Collections.singletonList(new ItemStack(repairItem));
extraList = extra;
}

this.inputs = new ArrayList<>();
this.inputs.add(scepterList);
this.inputs.add(repairItemList);
if (extraList != null) this.inputs.add(extraList);
}

public ScepterRepairingRecipeWrapper(Item scepter, Item repairItem) {
this(scepter, repairItem, null);
}

@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
ingredients.setInputLists(VanillaTypes.ITEM, this.inputs);
ingredients.setOutput(VanillaTypes.ITEM, this.output);
}
}
244 changes: 0 additions & 244 deletions src/main/java/twilightforest/item/ItemTFScepterLifeDrain.java

This file was deleted.

Loading

0 comments on commit aa5191b

Please sign in to comment.