Files
src
build.gradle
gradle.properties
settings.gradle
Code
10 178
src/main/java/com/example/zazaextract/ZazaExtract.java
package com.example.zazaextract;
import java.util.List;
import java.util.Optional;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.ConsumableComponents;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
public class ZazaExtract implements ModInitializer {
private static final RegistryKey<Item> KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of("zaza_extract", "zaza_extract"));
public static final Item EXTRACT = Registry.register(Registries.ITEM, KEY, new Item(new Item.Settings()
.registryKey(KEY)
.maxCount(1)
.component(DataComponentTypes.POTION_CONTENTS, new PotionContentsComponent(
Optional.empty(), Optional.of(5882118),
List.of(new StatusEffectInstance(StatusEffects.NAUSEA, 3600)), Optional.empty()))
.component(DataComponentTypes.CONSUMABLE, ConsumableComponents.DRINK)
.useRemainder(Items.GLASS_BOTTLE)));
private static final RegistryKey<Item> ULTIMATE_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of("zaza_extract", "zaza_extract_ultimate"));
public static final Item ULTIMATE_EXTRACT = Registry.register(Registries.ITEM, ULTIMATE_KEY, new Item(new Item.Settings()
.registryKey(ULTIMATE_KEY)
.maxCount(1)
.component(DataComponentTypes.POTION_CONTENTS, new PotionContentsComponent(
Optional.empty(), Optional.of(5882118),
List.of(new StatusEffectInstance(StatusEffects.NAUSEA, 4800),
new StatusEffectInstance(StatusEffects.STRENGTH, 3600, 1)), Optional.empty()))
.component(DataComponentTypes.CONSUMABLE, ConsumableComponents.DRINK)
.useRemainder(Items.GLASS_BOTTLE)));
@Override
public void onInitialize() {
ItemGroupEvents.modifyEntriesEvent(RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.of("minecraft", "food_and_drinks")))
.register(entries -> {
entries.add(EXTRACT);
entries.add(ULTIMATE_EXTRACT);
});
}
}