forked from xemnes/twilightforest
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3ca567
commit aa5191b
Showing
18 changed files
with
618 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/twilightforest/compat/jei/ScepterRepairingRecipeWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
244
src/main/java/twilightforest/item/ItemTFScepterLifeDrain.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.