Files
src
build.gradle
gradle.properties
settings.gradle
Code
25 187
src/main/resources/java/com/fieldarms/FieldArms.java
package com.fieldarms;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem;
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 FieldArms implements ModInitializer {
public static final Block WORKBENCH = new WeaponWorkbenchBlock(AbstractBlock.Settings.copy(Blocks.CRAFTING_TABLE));
public static final Item AMMUNITION = new Item(new Item.Settings());
public static final Item PISTOL = new GunItem(new Item.Settings().maxDamage(192), 6.0f, 12, 32.0);
public static final Item RIFLE = new GunItem(new Item.Settings().maxDamage(320), 8.0f, 8, 48.0);
public static final Item SHOTGUN = new GunItem(new Item.Settings().maxDamage(256), 10.0f, 24, 16.0);
private static Identifier id(String path) { return new Identifier("fieldarms", path); }
@Override
public void onInitialize() {
Registry.register(Registries.BLOCK, id("weapon_workbench"), WORKBENCH);
Registry.register(Registries.ITEM, id("weapon_workbench"), new BlockItem(WORKBENCH, new Item.Settings()));
Registry.register(Registries.ITEM, id("ammunition"), AMMUNITION);
Registry.register(Registries.ITEM, id("pistol"), PISTOL);
Registry.register(Registries.ITEM, id("rifle"), RIFLE);
Registry.register(Registries.ITEM, id("shotgun"), SHOTGUN);
ItemGroupEvents.modifyEntriesEvent(RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier("minecraft", "combat")))
.register(entries -> entries.addAfter(Items.CROSSBOW, PISTOL, RIFLE, SHOTGUN, AMMUNITION));
ItemGroupEvents.modifyEntriesEvent(RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier("minecraft", "functional_blocks")))
.register(entries -> entries.addAfter(Items.CRAFTING_TABLE, WORKBENCH));
}
}