Files
src
build.gradle
gradle.properties
settings.gradle
Code
29 316
src/main/java/com/kodari/shurikens/Shurikens.java
package com.kodari.shurikens;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
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 Shurikens implements ModInitializer {
public static final String ID = "shurikens";
private static final RegistryKey<EntityType<?>> PROJECTILE_KEY = RegistryKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of(ID, "shuriken"));
public static final EntityType<ShurikenEntity> PROJECTILE = Registry.register(Registries.ENTITY_TYPE, PROJECTILE_KEY,
EntityType.Builder.<ShurikenEntity>create((type, world) -> new ShurikenEntity(type, world), SpawnGroup.MISC)
.dimensions(0.35F, 0.35F).build(PROJECTILE_KEY));
public static final Item WOODEN = register("wooden_shuriken", 2F, 2);
public static final Item STONE = register("stone_shuriken", 3.5F, 3);
public static final Item IRON = register("iron_shuriken", 5F, 5);
public static final Item DIAMOND = register("diamond_shuriken", 7F, 7);
public static final Item NETHERITE = register("netherite_shuriken", 9.5F, 10);
private static Item register(String name, float damage, int targets) {
RegistryKey<Item> key = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(ID, name));
return Registry.register(Registries.ITEM, key, new ShurikenItem(new Item.Settings().registryKey(key), damage, targets));
}
@Override
public void onInitialize() {
ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(entries -> {
entries.add(WOODEN); entries.add(STONE); entries.add(IRON); entries.add(DIAMOND); entries.add(NETHERITE);
});
}
}