com.yungnickyoung.minecraft.yungsapi.module.PotionModuleFabric Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of YungsApi-1.21-Fabric Show documentation
Show all versions of YungsApi-1.21-Fabric Show documentation
A common API for YUNG's Minecraft mods
The newest version!
package com.yungnickyoung.minecraft.yungsapi.module;
import com.yungnickyoung.minecraft.yungsapi.api.autoregister.AutoRegisterPotion;
import com.yungnickyoung.minecraft.yungsapi.autoregister.AutoRegisterField;
import com.yungnickyoung.minecraft.yungsapi.autoregister.AutoRegistrationManager;
import net.minecraft.class_1293;
import net.minecraft.class_1842;
import net.minecraft.class_2378;
import net.minecraft.class_7923;
/**
* Registration of Potions.
*/
public class PotionModuleFabric {
public static void processEntries() {
AutoRegistrationManager.POTIONS.stream()
.filter(data -> !data.processed())
.forEach(PotionModuleFabric::register);
}
private static void register(AutoRegisterField data) {
AutoRegisterPotion autoRegisterPotion = (AutoRegisterPotion) data.object();
class_1293 mobEffectInstance = autoRegisterPotion.getMobEffectInstance();
String name = data.name().method_12836() + "." + data.name().method_12832();
class_1842 potion = new class_1842(name, mobEffectInstance);
autoRegisterPotion.setSupplier(() -> potion);
// Register mob effect
class_2378.method_10230(class_7923.field_41179, data.name(), potion);
data.markProcessed();
}
}