File size: 15,032 Bytes
91485a4 | 1 2 3 4 | {"task_id": "FORGE_API_EX", "module": "api", "target_loader": "forge", "target_version": "1.20.1", "task_scope": "single_file", "entry_path": "src/main/java/com/example/examplemod/StarCompassItem.java", "instruction": "You are writing code for a Forge 1.20.1 mod (mod id 'examplemod'). Native Forge 1.20.1 APIs ONLY. In ONE self-contained file, implement a StarCompassItem: register items through a Forge DeferredRegister bound to the mod event bus via a register(IEventBus) method; expose the item as a RegistryObject named STAR_COMPASS with max stack size 1 and Rarity.EPIC; override isFoil so the compass always glints; override appendHoverText (the Level argument may be null) to append the translatable line 'tooltip.examplemod.star_compass.hint'. Do NOT use any net.neoforged.* class - it does not exist on Forge 1.20.1.", "context": "", "golden_reference": "package com.example.examplemod;\n\nimport java.util.List;\n\nimport net.minecraft.network.chat.Component;\nimport net.minecraft.world.item.Item;\nimport net.minecraft.world.item.ItemStack;\nimport net.minecraft.world.item.Rarity;\nimport net.minecraft.world.item.TooltipFlag;\nimport net.minecraft.world.level.Level;\nimport net.minecraftforge.eventbus.api.IEventBus;\nimport net.minecraftforge.registries.DeferredRegister;\nimport net.minecraftforge.registries.ForgeRegistries;\nimport net.minecraftforge.registries.RegistryObject;\n\npublic class StarCompassItem extends Item {\n public static final DeferredRegister<Item> ITEMS =\n DeferredRegister.create(ForgeRegistries.ITEMS, ExampleModHolder.MODID);\n\n public static final RegistryObject<Item> STAR_COMPASS =\n ITEMS.register(\"star_compass\",\n () -> new StarCompassItem(new Item.Properties().stacksTo(1).rarity(Rarity.EPIC)));\n\n public StarCompassItem(Properties props) {\n super(props);\n }\n\n @Override\n public boolean isFoil(ItemStack stack) {\n return true;\n }\n\n @Override\n public void appendHoverText(ItemStack stack, Level level,\n List<Component> tooltip, TooltipFlag flag) {\n tooltip.add(Component.translatable(\"tooltip.examplemod.star_compass.hint\"));\n }\n\n public static void register(IEventBus modEventBus) {\n ITEMS.register(modEventBus);\n }\n}\n\nclass ExampleModHolder {\n public static final String MODID = \"examplemod\";\n}\n", "eval_criteria": {"must_compile": true, "required_annotations": [], "forbidden_apis": ["net.neoforged", "net.fabricmc", "DeferredHolder", "DataComponents"], "allowed_legacy_apis": ["net.minecraftforge.*", "MinecraftForge.EVENT_BUS", "RegistryObject", "ForgeRegistries.*"], "gametest_required": false}}
{"task_id": "PORT_EX", "module": "porting", "target_loader": "neoforge", "target_version": "1.21.1", "task_scope": "multi_file", "instruction": "Port the complete mini-mod 'exbench' from Forge 1.20.1 to NeoForge 1.21.1. The repository contains an entry class, a registration class, a BaseEntityBlock subclass, a BlockEntity and a lang file. Preserve the package layout, mod id 'exbench', registry names and lang keys. Requirements: every registry reference must resolve on NeoForge 1.21.1 (DeferredHolder + vanilla Registries keys, no ForgeRegistries/RegistryObject); the @Mod entry class must use the NeoForge constructor-injected IEventBus instead of FMLJavaModLoadingContext; the block must expose the 1.20.5+ MapCodec codec(); BlockEntity persistence must use the 1.20.5+ loadAdditional/saveAdditional(CompoundTag, HolderLookup.Provider) signatures. Output one file per input file, keyed by its original relative path.", "context": {"src/main/java/com/example/exbench/ExBenchMod.java": "package com.example.exbench;\n\nimport net.minecraftforge.eventbus.api.IEventBus;\nimport net.minecraftforge.fml.common.Mod;\nimport net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;\n\n@Mod(ExBenchMod.MODID)\npublic class ExBenchMod {\n public static final String MODID = \"exbench\";\n\n public ExBenchMod() {\n IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();\n Registration.register(modEventBus);\n }\n}\n", "src/main/java/com/example/exbench/Registration.java": "package com.example.exbench;\n\nimport net.minecraft.world.item.BlockItem;\nimport net.minecraft.world.item.Item;\nimport net.minecraft.world.level.block.Block;\nimport net.minecraft.world.level.block.entity.BlockEntityType;\nimport net.minecraft.world.level.block.state.BlockBehaviour;\nimport net.minecraftforge.eventbus.api.IEventBus;\nimport net.minecraftforge.registries.DeferredRegister;\nimport net.minecraftforge.registries.ForgeRegistries;\nimport net.minecraftforge.registries.RegistryObject;\n\npublic final class Registration {\n public static final String MODID = ExBenchMod.MODID;\n\n public static final DeferredRegister<Block> BLOCKS =\n DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);\n public static final DeferredRegister<Item> ITEMS =\n DeferredRegister.create(ForgeRegistries.ITEMS, MODID);\n public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES =\n DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MODID);\n\n public static final RegistryObject<MoodLampBlock> MOOD_LAMP = BLOCKS.register(\"mood_lamp\",\n () -> new MoodLampBlock(BlockBehaviour.Properties.of().strength(1.5F, 6.0F)));\n public static final RegistryObject<Item> MOOD_LAMP_ITEM = ITEMS.register(\"mood_lamp\",\n () -> new BlockItem(MOOD_LAMP.get(), new Item.Properties()));\n public static final RegistryObject<BlockEntityType<MoodLampBlockEntity>> MOOD_LAMP_BE =\n BLOCK_ENTITIES.register(\"mood_lamp\",\n () -> BlockEntityType.Builder.of(MoodLampBlockEntity::new, MOOD_LAMP.get()).build(null));\n\n private Registration() {}\n\n public static void register(IEventBus modEventBus) {\n BLOCKS.register(modEventBus);\n ITEMS.register(modEventBus);\n BLOCK_ENTITIES.register(modEventBus);\n }\n}\n", "src/main/java/com/example/exbench/block/MoodLampBlock.java": "package com.example.exbench.block;\n\nimport com.example.exbench.blockentity.MoodLampBlockEntity;\nimport net.minecraft.core.BlockPos;\nimport net.minecraft.world.level.block.BaseEntityBlock;\nimport net.minecraft.world.level.block.RenderShape;\nimport net.minecraft.world.level.block.entity.BlockEntity;\nimport net.minecraft.world.level.block.state.BlockState;\n\npublic class MoodLampBlock extends BaseEntityBlock {\n\n public MoodLampBlock(Properties props) {\n super(props);\n }\n\n @Override\n public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {\n return new MoodLampBlockEntity(pos, state);\n }\n\n @Override\n public RenderShape getRenderShape(BlockState state) {\n return RenderShape.MODEL;\n }\n}\n", "src/main/java/com/example/exbench/blockentity/MoodLampBlockEntity.java": "package com.example.exbench.blockentity;\n\nimport com.example.exbench.Registration;\nimport net.minecraft.core.BlockPos;\nimport net.minecraft.nbt.CompoundTag;\nimport net.minecraft.world.level.block.entity.BlockEntity;\nimport net.minecraft.world.level.block.state.BlockState;\n\npublic class MoodLampBlockEntity extends BlockEntity {\n private int hue;\n\n public MoodLampBlockEntity(BlockPos pos, BlockState state) {\n super(Registration.MOOD_LAMP_BE.get(), pos, state);\n }\n\n public int getHue() {\n return hue;\n }\n\n public void setHue(int value) {\n hue = ((value % 360) + 360) % 360;\n setChanged();\n }\n\n @Override\n public void load(CompoundTag tag) {\n super.load(tag);\n hue = tag.getInt(\"hue\");\n }\n\n @Override\n protected void saveAdditional(CompoundTag tag) {\n super.saveAdditional(tag);\n tag.putInt(\"hue\", hue);\n }\n}\n", "src/main/resources/assets/exbench/lang/en_us.json": "{\n \"block.exbench.mood_lamp\": \"Mood Lamp\"\n}\n"}, "golden_reference": {"src/main/java/com/example/exbench/ExBenchMod.java": "package com.example.exbench;\n\nimport net.neoforged.bus.api.IEventBus;\nimport net.neoforged.fml.common.Mod;\n\n@Mod(ExBenchMod.MODID)\npublic class ExBenchMod {\n public static final String MODID = \"exbench\";\n\n public ExBenchMod(IEventBus modEventBus) {\n Registration.register(modEventBus);\n }\n}\n", "src/main/java/com/example/exbench/Registration.java": "package com.example.exbench;\n\nimport net.minecraft.core.registries.Registries;\nimport net.minecraft.world.item.BlockItem;\nimport net.minecraft.world.item.Item;\nimport net.minecraft.world.level.block.Block;\nimport net.minecraft.world.level.block.entity.BlockEntityType;\nimport net.minecraft.world.level.block.state.BlockBehaviour;\nimport net.neoforged.bus.api.IEventBus;\nimport net.neoforged.neoforge.registries.DeferredHolder;\nimport net.neoforged.neoforge.registries.DeferredRegister;\n\npublic final class Registration {\n public static final String MODID = ExBenchMod.MODID;\n\n public static final DeferredRegister<Block> BLOCKS =\n DeferredRegister.create(Registries.BLOCK, MODID);\n public static final DeferredRegister<Item> ITEMS =\n DeferredRegister.create(Registries.ITEM, MODID);\n public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES =\n DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, MODID);\n\n public static final DeferredHolder<Block, MoodLampBlock> MOOD_LAMP = BLOCKS.register(\"mood_lamp\",\n () -> new MoodLampBlock(BlockBehaviour.Properties.of().strength(1.5F, 6.0F)));\n public static final DeferredHolder<Item, Item> MOOD_LAMP_ITEM = ITEMS.register(\"mood_lamp\",\n () -> new BlockItem(MOOD_LAMP.get(), new Item.Properties()));\n public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<MoodLampBlockEntity>> MOOD_LAMP_BE =\n BLOCK_ENTITIES.register(\"mood_lamp\",\n () -> BlockEntityType.Builder.of(MoodLampBlockEntity::new, MOOD_LAMP.get()).build(null));\n\n private Registration() {}\n\n public static void register(IEventBus modEventBus) {\n BLOCKS.register(modEventBus);\n ITEMS.register(modEventBus);\n BLOCK_ENTITIES.register(modEventBus);\n }\n}\n", "src/main/java/com/example/exbench/block/MoodLampBlock.java": "package com.example.exbench.block;\n\nimport com.example.exbench.blockentity.MoodLampBlockEntity;\nimport com.mojang.serialization.MapCodec;\nimport net.minecraft.core.BlockPos;\nimport net.minecraft.world.level.block.BaseEntityBlock;\nimport net.minecraft.world.level.block.RenderShape;\nimport net.minecraft.world.level.block.entity.BlockEntity;\nimport net.minecraft.world.level.block.state.BlockState;\n\npublic class MoodLampBlock extends BaseEntityBlock {\n public static final MapCodec<MoodLampBlock> CODEC = simpleCodec(MoodLampBlock::new);\n\n public MoodLampBlock(Properties props) {\n super(props);\n }\n\n @Override\n protected MapCodec<? extends BaseEntityBlock> codec() {\n return CODEC;\n }\n\n @Override\n public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {\n return new MoodLampBlockEntity(pos, state);\n }\n\n @Override\n public RenderShape getRenderShape(BlockState state) {\n return RenderShape.MODEL;\n }\n}\n", "src/main/java/com/example/exbench/blockentity/MoodLampBlockEntity.java": "package com.example.exbench.blockentity;\n\nimport com.example.exbench.Registration;\nimport net.minecraft.core.BlockPos;\nimport net.minecraft.core.HolderLookup;\nimport net.minecraft.nbt.CompoundTag;\nimport net.minecraft.world.level.block.entity.BlockEntity;\nimport net.minecraft.world.level.block.state.BlockState;\n\npublic class MoodLampBlockEntity extends BlockEntity {\n private int hue;\n\n public MoodLampBlockEntity(BlockPos pos, BlockState state) {\n super(Registration.MOOD_LAMP_BE.get(), pos, state);\n }\n\n public int getHue() {\n return hue;\n }\n\n public void setHue(int value) {\n hue = ((value % 360) + 360) % 360;\n setChanged();\n }\n\n @Override\n protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {\n super.loadAdditional(tag, registries);\n hue = tag.getInt(\"hue\");\n }\n\n @Override\n protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {\n super.saveAdditional(tag, registries);\n tag.putInt(\"hue\", hue);\n }\n}\n", "src/main/resources/assets/exbench/lang/en_us.json": "{\n \"block.exbench.mood_lamp\": \"Mood Lamp\"\n}\n"}, "eval_criteria": {"must_compile": true, "required_annotations": ["@Mod"], "forbidden_apis": ["net.minecraftforge", "MinecraftForge.EVENT_BUS", "RegistryObject", "ForgeRegistries", "FMLJavaModLoadingContext", "getOrCreateTag"], "allowed_legacy_apis": [], "gametest_required": false}}
{"task_id": "MIX_EX", "module": "mixin", "target_loader": "neoforge", "target_version": "1.21.1", "task_scope": "single_file", "entry_path": "src/main/java/com/example/examplemod/mixin/SheepEatMixin.java", "instruction": "Write a Mixin for NeoForge 1.21.1 (Mojang mappings) that runs AFTER the full vanilla body of Sheep#eat(Level) (target: net.minecraft.world.entity.animal.Sheep#eat(Lnet/minecraft/world/level/Level;)V) and, on the server only, spawns 4 heart particles at the sheep position using ServerLevel#sendParticles. Use an @At(\"TAIL\") injection with the correct CallbackInfo type; cast the mixin target via (Sheep)(Object)this.", "context": "", "golden_reference": "package com.example.examplemod.mixin;\n\nimport net.minecraft.core.particles.ParticleTypes;\nimport net.minecraft.server.level.ServerLevel;\nimport net.minecraft.world.entity.animal.Sheep;\nimport net.minecraft.world.level.Level;\nimport org.spongepowered.asm.mixin.Mixin;\nimport org.spongepowered.asm.mixin.injection.At;\nimport org.spongepowered.asm.mixin.injection.Inject;\nimport org.spongepowered.asm.mixin.injection.callback.CallbackInfo;\n\n@Mixin(Sheep.class)\npublic abstract class SheepEatMixin {\n\n // TAIL injection into Sheep#eat(Level): fires once the vanilla body has finished.\n @Inject(method = \"eat(Lnet/minecraft/world/level/Level;)V\",\n at = @At(\"TAIL\"))\n private void examplemod$afterEat(Level level, CallbackInfo ci) {\n if (!level.isClientSide && level instanceof ServerLevel) {\n ServerLevel server = (ServerLevel) level;\n Sheep self = (Sheep) (Object) this;\n server.sendParticles(ParticleTypes.HEART,\n self.getX(), self.getY() + 0.8, self.getZ(),\n 4, 0.2, 0.2, 0.2, 0.0);\n }\n }\n}\n", "eval_criteria": {"must_compile": true, "required_annotations": ["@Mixin", "@Inject"], "forbidden_apis": ["net.minecraftforge"], "allowed_legacy_apis": [], "gametest_required": false}}
|