Advertisement
Guest User

PotionList

a guest
Aug 1st, 2020
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. package com.author.example.lists;
  2.  
  3. import com.author.example.Main;
  4. import net.minecraft.item.Item;
  5. import net.minecraft.potion.*;
  6. import net.minecraftforge.fml.RegistryObject;
  7. import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
  8. import net.minecraftforge.registries.DeferredRegister;
  9. import net.minecraftforge.registries.ForgeRegistries;
  10. import java.lang.reflect.InvocationTargetException;
  11. import java.lang.reflect.Method;
  12.  
  13. public class PotionList {
  14.  
  15. public static final DeferredRegister<Effect> EFFECTS = DeferredRegister.create(ForgeRegistries.POTIONS, Main.MOD_ID);
  16.  
  17. public static final RegistryObject<Effect> MOD_POTION_EFFECT = EFFECTS.register("mod_potion", () -> new ModPotionEffect(EffectType.BENEFICIAL, 0xabd84e));
  18.  
  19.  
  20. public static final DeferredRegister<Potion> POTIONS = DeferredRegister.create(ForgeRegistries.POTION_TYPES, Main.MOD_ID);
  21.  
  22. public static final RegistryObject<Potion> MOD_POTION = POTIONS.register("mod_potion", () -> new Potion(new EffectInstance(MOD_POTION_EFFECT.get(), 600)));
  23.  
  24. //.addAttributesModifier(SharedMonsterAttributes.MAX_HEALTH,
  25. //"", (double)0.5f, AttributeModifier.Operation.MULTIPLY_TOTAL)
  26.  
  27. private static Method brewing_mixes;
  28.  
  29. private static void addMix(Potion start, Item ingredient, Potion result) {
  30. if (brewing_mixes == null) {
  31. brewing_mixes = ObfuscationReflectionHelper.findMethod(PotionBrewing.class, "addMix", Potion.class, Item.class, Potion.class);
  32. brewing_mixes.setAccessible(true);
  33. }
  34.  
  35. try {
  36. brewing_mixes.invoke(null, start, ingredient, result);
  37. } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e){
  38. e.printStackTrace();
  39. }
  40. }
  41.  
  42. public static void addBrewingRecipes() {
  43. addMix(Potions.AWKWARD, ItemList.MOD_BERRIES.get(), MOD_POTION.get());
  44. }
  45.  
  46. public static class ModPotionEffect extends Effect {
  47.  
  48. public ModPotionEffect(EffectType typeIn, int liquidColorIn) {
  49. super(typeIn, liquidColorIn);
  50. }
  51. }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement