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

54 lines
2.5 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 {
private CustomStatusEffect(StatusEffectType type, int color) {
super(type, color);
}
}
public final StatusEffect statusEffect;
private final Potion potion;
private final Potion longPotion;
private CustomPotion(StatusEffect statusEffect, Potion potion, Potion longPotion) {
this.statusEffect = statusEffect;
this.potion = potion;
this.longPotion = longPotion;
}
}
public static CustomPotion VERIDIUM_POISONING_EFFECT;
public static void register() {
VERIDIUM_POISONING_EFFECT = registerEffect("veridium_poisoning", 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));
Potion potion = Registry.register(Registry.POTION, new Identifier(EnergonRelics.NAMESPACE, name), new Potion(EnergonRelics.NAMESPACE + '.' + name, new StatusEffectInstance(effect, 1800)));
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, potion, longPotion);
}
private static void registerBrewingRecipes() {
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EnergonRelics.VERIDIUM_POWDER_ITEM, VERIDIUM_POISONING_EFFECT.potion);
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(VERIDIUM_POISONING_EFFECT.potion, Items.REDSTONE, VERIDIUM_POISONING_EFFECT.longPotion);
}
}