tinycodinglm / mc /mc-0037.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame Contribute Delete
2.81 kB
{"type": "session", "harness": "opencode", "id": "mc-0037", "name": "Custom Items"}
{"type": "message", "message": {"role": "system", "content": "You are an expert Fabric mod developer. You write idiomatic Minecraft Fabric mods using Java, Fabric API, and Yarn mappings."}}
{"type": "message", "message": {"role": "user", "content": "How do I register custom items with different item settings and create custom item classes?"}}
{"type": "message", "message": {"role": "assistant", "content": "```java\npackage com.example.mymod;\n\nimport net.minecraft.item.Item;\nimport net.minecraft.registry.Registries;\nimport net.minecraft.registry.Registry;\nimport net.minecraft.util.Rarity;\n\npublic class MyItems {\n // Basic item\n public static final Item SIMPLE_ITEM = new Item(new Item.Settings());\n\n // Item with settings\n public static final Item CUSTOM_ITEM = new Item(\n new Item.Settings().maxCount(16).maxDamage(100).rarity(Rarity.RARE)\n );\n\n // Food item\n public static final Item CUSTOM_FOOD = new Item(\n new Item.Settings().food(new FoodComponent.Builder()\n .nutrition(3).saturationModifier(0.6f).snack().alwaysEdible().build())\n );\n\n // Sword item\n public static final Item CUSTOM_SWORD = new SwordItem(\n ToolMaterials.NETHERITE,\n new Item.Settings().attributeModifiers(\n SwordItem.createAttributeModifiers(ToolMaterials.NETHERITE, 4, -2.0f))\n );\n\n // Axe item\n public static final Item CUSTOM_AXE = new AxeItem(\n ToolMaterials.DIAMOND,\n new Item.Settings().attributeModifiers(\n AxeItem.createAttributeModifiers(ToolMaterials.DIAMOND, 6.0f, -3.2f))\n );\n\n public static void registerItems() {\n Registry.register(Registries.ITEM, MyMod.id(\"simple_item\"), SIMPLE_ITEM);\n Registry.register(Registries.ITEM, MyMod.id(\"custom_item\"), CUSTOM_ITEM);\n Registry.register(Registries.ITEM, MyMod.id(\"custom_food\"), CUSTOM_FOOD);\n Registry.register(Registries.ITEM, MyMod.id(\"custom_sword\"), CUSTOM_SWORD);\n Registry.register(Registries.ITEM, MyMod.id(\"custom_axe\"), CUSTOM_AXE);\n }\n}\n```\n\nCustom item with use action:\n```java\npublic class TeleportItem extends Item {\n public TeleportItem(Settings settings) { super(settings); }\n\n @Override\n public UseAction getUseAction(ItemStack stack) { return UseAction.BOW; }\n\n @Override\n public int getMaxUseTime(ItemStack stack) { return 72000; }\n\n @Override\n public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {\n if (!world.isClient) {\n user.teleport(user.getX(), user.getY() + 10, user.getZ());\n stack.decrement(1);\n }\n return stack;\n }\n}\n```"}}