This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
EnergonRelics/src/main/java/com/thebrokenrail/energonrelics/potion/CustomPotions.java

58 lines
2.8 KiB
Java

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 {
@SuppressWarnings("SameParameterValue")
private CustomStatusEffect(StatusEffectType type, int color) {
super(type, color);
}
}
public final StatusEffect statusEffect;
public final StatusEffectInstance statusEffectInstance;
private final Potion potion;
private final Potion longPotion;
private CustomPotion(StatusEffect statusEffect, StatusEffectInstance statusEffectInstance, Potion potion, Potion longPotion) {
this.statusEffect = statusEffect;
this.statusEffectInstance = statusEffectInstance;
this.potion = potion;
this.longPotion = longPotion;
}
}
public static CustomPotion VERIDIUM_POISON_EFFECT;
public static void register() {
VERIDIUM_POISON_EFFECT = registerEffect("veridium_poison", 16711909);
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));
StatusEffectInstance statusEffectInstance = new StatusEffectInstance(effect, 1800);
Potion potion = Registry.register(Registry.POTION, new Identifier(EnergonRelics.NAMESPACE, name), new Potion(EnergonRelics.NAMESPACE + '.' + name, statusEffectInstance));
Potion longPotion = Registry.register(Registry.POTION, new Identifier(EnergonRelics.NAMESPACE, "long_" + name), new Potion(EnergonRelics.NAMESPACE + '.' + name, new StatusEffectInstance(effect, 4800)));
return new CustomPotion(effect, statusEffectInstance, potion, longPotion);
}
private static void registerBrewingRecipes() {
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EnergonRelics.Items.VERIDIUM_POWDER, VERIDIUM_POISON_EFFECT.potion);
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(VERIDIUM_POISON_EFFECT.potion, Items.REDSTONE, VERIDIUM_POISON_EFFECT.longPotion);
}
}