Created
April 23, 2025 00:46
-
-
Save jprugel/51f5c487a9fa64d5bb2b458fa5aab694 to your computer and use it in GitHub Desktop.
Mod Items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jprugel.sera.item; | |
import jprugel.sera.Sera; | |
import net.minecraft.item.Item; | |
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; | |
import java.util.function.Function; | |
public class ModItems { | |
public static final Item VAULT_LOCK = register("vault_lock", VaultLockItem::new, new Item.Settings()); | |
public static void initialize() { | |
} | |
public static Item register(String name, Function<Item.Settings, Item> itemFactory, Item.Settings settings) { | |
// Create the item key. | |
RegistryKey<Item> itemKey = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(Sera.MOD_ID, name)); | |
// Create the item instance. | |
Item item = itemFactory.apply(settings.registryKey(itemKey)); | |
// Register the item. | |
Registry.register(Registries.ITEM, itemKey, item); | |
return item; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jprugel.sera.item; | |
import eu.pb4.polymer.core.api.item.PolymerItem; | |
import net.minecraft.item.Item; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.item.Items; | |
import xyz.nucleoid.packettweaker.PacketContext; | |
public class VaultLockItem extends Item implements PolymerItem { | |
public VaultLockItem(Settings settings) { | |
super(settings); | |
} | |
@Override | |
public Item getPolymerItem(ItemStack itemStack, PacketContext packetContext) { | |
return Items.BOOK; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment