2020-07-22 22:31:22 +00:00
|
|
|
package com.thebrokenrail.energonrelics.potion;
|
|
|
|
|
|
|
|
import com.thebrokenrail.energonrelics.EnergonRelics;
|
|
|
|
import com.thebrokenrail.energonrelics.mixin.BrewingRecipeRegistryAccessor;
|
|
|
|
import net.minecraft.entity.effect.StatusEffect;
|
|
|
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
|
|
|
import net.minecraft.entity.effect.StatusEffectType;
|
|
|
|
import net.minecraft.item.Items;
|
|
|
|
import net.minecraft.potion.Potion;
|
|
|
|
import net.minecraft.potion.Potions;
|
|
|
|
import net.minecraft.util.Identifier;
|
|
|
|
import net.minecraft.util.registry.Registry;
|
|
|
|
|
|
|
|
public class CustomPotions {
|
|
|
|
public static class CustomPotion {
|
|
|
|
private static class CustomStatusEffect extends StatusEffect {
|
2020-07-25 22:22:59 +00:00
|
|
|
@SuppressWarnings("SameParameterValue")
|
2020-07-22 22:31:22 +00:00
|
|
|
private CustomStatusEffect(StatusEffectType type, int color) {
|
|
|
|
super(type, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final StatusEffect statusEffect;
|
2020-07-28 22:18:54 +00:00
|
|
|
public final StatusEffectInstance statusEffectInstance;
|
2020-07-22 22:31:22 +00:00
|
|
|
private final Potion potion;
|
|
|
|
private final Potion longPotion;
|
|
|
|
|
2020-07-28 22:18:54 +00:00
|
|
|
private CustomPotion(StatusEffect statusEffect, StatusEffectInstance statusEffectInstance, Potion potion, Potion longPotion) {
|
2020-07-22 22:31:22 +00:00
|
|
|
this.statusEffect = statusEffect;
|
2020-07-28 22:18:54 +00:00
|
|
|
this.statusEffectInstance = statusEffectInstance;
|
2020-07-22 22:31:22 +00:00
|
|
|
this.potion = potion;
|
|
|
|
this.longPotion = longPotion;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 23:26:04 +00:00
|
|
|
public static CustomPotion VERIDIUM_POISON_EFFECT;
|
2020-07-22 22:31:22 +00:00
|
|
|
|
|
|
|
public static void register() {
|
2020-07-22 23:26:04 +00:00
|
|
|
VERIDIUM_POISON_EFFECT = registerEffect("veridium_poison", 16711909);
|
2020-07-22 22:31:22 +00:00
|
|
|
registerBrewingRecipes();
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("SameParameterValue")
|
|
|
|
private static CustomPotion registerEffect(String name, int color) {
|
|
|
|
StatusEffect effect = Registry.register(Registry.STATUS_EFFECT, new Identifier(EnergonRelics.NAMESPACE, name), new CustomPotion.CustomStatusEffect(StatusEffectType.HARMFUL, color));
|
2020-07-28 22:18:54 +00:00
|
|
|
StatusEffectInstance statusEffectInstance = new StatusEffectInstance(effect, 1800);
|
|
|
|
Potion potion = Registry.register(Registry.POTION, new Identifier(EnergonRelics.NAMESPACE, name), new Potion(EnergonRelics.NAMESPACE + '.' + name, statusEffectInstance));
|
2020-07-22 22:31:22 +00:00
|
|
|
Potion longPotion = Registry.register(Registry.POTION, new Identifier(EnergonRelics.NAMESPACE, "long_" + name), new Potion(EnergonRelics.NAMESPACE + '.' + name, new StatusEffectInstance(effect, 4800)));
|
2020-07-28 22:18:54 +00:00
|
|
|
return new CustomPotion(effect, statusEffectInstance, potion, longPotion);
|
2020-07-22 22:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void registerBrewingRecipes() {
|
2020-08-20 23:03:47 +00:00
|
|
|
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EnergonRelics.Items.VERIDIUM_POWDER, VERIDIUM_POISON_EFFECT.potion);
|
2020-07-22 23:26:04 +00:00
|
|
|
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(VERIDIUM_POISON_EFFECT.potion, Items.REDSTONE, VERIDIUM_POISON_EFFECT.longPotion);
|
2020-07-22 22:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|