diff --git a/build.gradle.kts b/build.gradle.kts index b52c012..25926b5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -49,6 +49,7 @@ tasks.processResources { val version = version inputs.property("version", version) + duplicatesStrategy = DuplicatesStrategy.INCLUDE filesMatching("fabric.mod.json") { expand("version" to version) } @@ -78,7 +79,7 @@ tasks.jar { val projectName = project.name inputs.property("projectName", projectName) - duplicatesStrategy = DuplicatesStrategy.EXCLUDE + duplicatesStrategy = DuplicatesStrategy.INCLUDE from("LICENSE") { rename { "${it}_$projectName" } } diff --git a/src/client/kotlin/dev/zxq5/client/FantasysmpDataGenerator.kt b/src/client/kotlin/dev/zxq5/client/FantasysmpDataGenerator.kt index 27427b7..50a124c 100644 --- a/src/client/kotlin/dev/zxq5/client/FantasysmpDataGenerator.kt +++ b/src/client/kotlin/dev/zxq5/client/FantasysmpDataGenerator.kt @@ -2,6 +2,7 @@ package dev.zxq5.client import dev.zxq5.ModItemTagProvider import dev.zxq5.ModRecipeProvider +import dev.zxq5.items.GenericGearSet import dev.zxq5.items.ItemImplementation import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint @@ -9,21 +10,34 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput import net.minecraft.client.data.models.BlockModelGenerators import net.minecraft.client.data.models.ItemModelGenerators +import net.minecraft.client.data.models.model.ModelTemplates object FantasysmpDataGenerator : DataGeneratorEntrypoint { override fun onInitializeDataGenerator(fabricDataGenerator: FabricDataGenerator) { val pack = fabricDataGenerator.createPack() pack.addProvider(::ModRecipeProvider) // main-safe, can live in either sourceSet - pack.addProvider(::ModItemTagProvider) // main-safe - pack.addProvider(::ModModelProvider) // needs client, since ItemModelGenerators is client-only +// pack.addProvider(::ModItemTagProvider) // main-safe +// pack.addProvider(::ModModelProvider) // needs client, since ItemModelGenerators is client-only } } // client sourceSet -class ModModelProvider(output: FabricPackOutput) : FabricModelProvider(output) { - override fun generateBlockStateModels(blockModels: BlockModelGenerators) {} +//class ModModelProvider(output: FabricPackOutput) : FabricModelProvider(output) { +// override fun generateBlockStateModels(blockModels: BlockModelGenerators) {} +// +// override fun generateItemModels(itemModels: ItemModelGenerators) { +// ItemImplementation.all.forEach { it.generateModels(itemModels) } +// } +//} - override fun generateItemModels(itemModels: ItemModelGenerators) { - ItemImplementation.all.forEach { it.generateItemModels(itemModels) } - } -} \ No newline at end of file +// client sourceSet +//fun ItemImplementation.generateModels(itemModels: ItemModelGenerators) { +// if (this !is GenericGearSet) return +// modelSpecs.forEach { (item, spec) -> +// when (spec) { +// ModelSpec.Generated -> itemModels.generateFlatItem(item, ModelTemplates.FLAT_ITEM) +// ModelSpec.Handheld -> itemModels.generateFlatItem(item, ModelTemplates.FLAT_HANDHELD_ITEM) +// ModelSpec.None -> {} // nothing to do — hand-authored JSON covers it +// } +// } +//} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_axe.json b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_axe.json new file mode 100644 index 0000000..30a9a2c --- /dev/null +++ b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_axe.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_addition": { + "conditions": { + "items": [ + { + "items": "minecraft:wither_skeleton_skull" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "fantasysmp:witherite_axe" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_addition" + ] + ], + "rewards": { + "recipes": [ + "fantasysmp:witherite_axe" + ] + } +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_boots.json b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_boots.json new file mode 100644 index 0000000..4ef36f8 --- /dev/null +++ b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_boots.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_addition": { + "conditions": { + "items": [ + { + "items": "minecraft:wither_skeleton_skull" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "fantasysmp:witherite_boots" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_addition" + ] + ], + "rewards": { + "recipes": [ + "fantasysmp:witherite_boots" + ] + } +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_chestplate.json b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_chestplate.json new file mode 100644 index 0000000..65c6187 --- /dev/null +++ b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_chestplate.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_addition": { + "conditions": { + "items": [ + { + "items": "minecraft:wither_skeleton_skull" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "fantasysmp:witherite_chestplate" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_addition" + ] + ], + "rewards": { + "recipes": [ + "fantasysmp:witherite_chestplate" + ] + } +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_helmet.json b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_helmet.json new file mode 100644 index 0000000..81ef2c1 --- /dev/null +++ b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_helmet.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_addition": { + "conditions": { + "items": [ + { + "items": "minecraft:wither_skeleton_skull" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "fantasysmp:witherite_helmet" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_addition" + ] + ], + "rewards": { + "recipes": [ + "fantasysmp:witherite_helmet" + ] + } +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_leggings.json b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_leggings.json new file mode 100644 index 0000000..ec35362 --- /dev/null +++ b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_leggings.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_addition": { + "conditions": { + "items": [ + { + "items": "minecraft:wither_skeleton_skull" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "fantasysmp:witherite_leggings" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_addition" + ] + ], + "rewards": { + "recipes": [ + "fantasysmp:witherite_leggings" + ] + } +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_sword.json b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_sword.json new file mode 100644 index 0000000..76fd0ad --- /dev/null +++ b/src/main/generated/data/fantasysmp/advancement/recipes/combat/witherite_sword.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_addition": { + "conditions": { + "items": [ + { + "items": "minecraft:wither_skeleton_skull" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "fantasysmp:witherite_sword" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_addition" + ] + ], + "rewards": { + "recipes": [ + "fantasysmp:witherite_sword" + ] + } +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/recipe/witherite_axe.json b/src/main/generated/data/fantasysmp/recipe/witherite_axe.json new file mode 100644 index 0000000..df4003a --- /dev/null +++ b/src/main/generated/data/fantasysmp/recipe/witherite_axe.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smithing_transform", + "addition": "minecraft:wither_skeleton_skull", + "base": "minecraft:netherite_axe", + "result": { + "id": "fantasysmp:witherite_axe" + }, + "template": "minecraft:netherite_upgrade_smithing_template" +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/recipe/witherite_boots.json b/src/main/generated/data/fantasysmp/recipe/witherite_boots.json new file mode 100644 index 0000000..d221852 --- /dev/null +++ b/src/main/generated/data/fantasysmp/recipe/witherite_boots.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smithing_transform", + "addition": "minecraft:wither_skeleton_skull", + "base": "minecraft:netherite_boots", + "result": { + "id": "fantasysmp:witherite_boots" + }, + "template": "minecraft:netherite_upgrade_smithing_template" +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/recipe/witherite_chestplate.json b/src/main/generated/data/fantasysmp/recipe/witherite_chestplate.json new file mode 100644 index 0000000..a054143 --- /dev/null +++ b/src/main/generated/data/fantasysmp/recipe/witherite_chestplate.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smithing_transform", + "addition": "minecraft:wither_skeleton_skull", + "base": "minecraft:netherite_chestplate", + "result": { + "id": "fantasysmp:witherite_chestplate" + }, + "template": "minecraft:netherite_upgrade_smithing_template" +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/recipe/witherite_helmet.json b/src/main/generated/data/fantasysmp/recipe/witherite_helmet.json new file mode 100644 index 0000000..0c7ac6c --- /dev/null +++ b/src/main/generated/data/fantasysmp/recipe/witherite_helmet.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smithing_transform", + "addition": "minecraft:wither_skeleton_skull", + "base": "minecraft:netherite_helmet", + "result": { + "id": "fantasysmp:witherite_helmet" + }, + "template": "minecraft:netherite_upgrade_smithing_template" +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/recipe/witherite_leggings.json b/src/main/generated/data/fantasysmp/recipe/witherite_leggings.json new file mode 100644 index 0000000..141ca97 --- /dev/null +++ b/src/main/generated/data/fantasysmp/recipe/witherite_leggings.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smithing_transform", + "addition": "minecraft:wither_skeleton_skull", + "base": "minecraft:netherite_leggings", + "result": { + "id": "fantasysmp:witherite_leggings" + }, + "template": "minecraft:netherite_upgrade_smithing_template" +} \ No newline at end of file diff --git a/src/main/generated/data/fantasysmp/recipe/witherite_sword.json b/src/main/generated/data/fantasysmp/recipe/witherite_sword.json new file mode 100644 index 0000000..f6e8bb3 --- /dev/null +++ b/src/main/generated/data/fantasysmp/recipe/witherite_sword.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smithing_transform", + "addition": "minecraft:wither_skeleton_skull", + "base": "minecraft:netherite_sword", + "result": { + "id": "fantasysmp:witherite_sword" + }, + "template": "minecraft:netherite_upgrade_smithing_template" +} \ No newline at end of file diff --git a/src/main/kotlin/dev/zxq5/Fantasysmp.kt b/src/main/kotlin/dev/zxq5/Fantasysmp.kt index 07f43d0..dd6093e 100644 --- a/src/main/kotlin/dev/zxq5/Fantasysmp.kt +++ b/src/main/kotlin/dev/zxq5/Fantasysmp.kt @@ -4,6 +4,7 @@ import dev.zxq5.items.ItemImplementation import dev.zxq5.items.ItemTagAdder import dev.zxq5.items.ModItems import dev.zxq5.items.Witherite +//import dev.zxq5.items.Witherite import net.fabricmc.api.ModInitializer import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider @@ -49,7 +50,11 @@ class ModRecipeProvider( ): RecipeProvider { return object : RecipeProvider(registries, exporter) { override fun buildRecipes() { - ItemImplementation.all.forEach { it.generateRecipes(registries, exporter) } + print("GENERATING ALL RECIPES") + ItemImplementation.all.forEach { + print("GENERATING RECIPES FOR" + it.items.toString()) + it.generateRecipes(registries, exporter) + } } } } diff --git a/src/main/kotlin/dev/zxq5/items/Dragonite.kt b/src/main/kotlin/dev/zxq5/items/Dragonite.kt index e6f82b1..f06491e 100644 --- a/src/main/kotlin/dev/zxq5/items/Dragonite.kt +++ b/src/main/kotlin/dev/zxq5/items/Dragonite.kt @@ -22,29 +22,10 @@ import net.minecraft.world.item.equipment.* import net.minecraft.world.level.Level -object Dragonite { - const val BASE_DURABILITY = 40; - val MATERIAL: ResourceKey = ResourceKey.create( - EquipmentAssets.ROOT_ID, - Identifier.fromNamespaceAndPath(Fantasysmp.MOD_ID, "dragonite") - ) - - val armorMaterial = ArmorMaterial( - BASE_DURABILITY, - mapOf( - ArmorType.HELMET to 3, - ArmorType.CHESTPLATE to 8, - ArmorType.LEGGINGS to 6, - ArmorType.BOOTS to 3, - ArmorType.BODY to 19, - ), - 5, - SoundEvents.ARMOR_EQUIP_NETHERITE, - 3.0f, - 0.1f, - ItemTags.REPAIRS_NETHERITE_ARMOR, - MATERIAL, - ) +object Dragonite: GenericGearSet() { + override val materialName = "dragonite" + override val materialDefinition + get() = super.materialDefinition.copy(assetId = materialKey) val SWORD = register("dragonite_sword", ::DragoniteSword, Item.Properties() @@ -56,7 +37,7 @@ object Dragonite { "dragonite_helmet", ::Item, Item.Properties() - .enchantable(Witherite.armorMaterial.enchantmentValue) + .enchantable(armorMaterial.enchantmentValue) .humanoidArmor(armorMaterial , ArmorType.HELMET) .durability(ArmorType.HELMET.getDurability(armorMaterial.durability)) ) @@ -65,7 +46,7 @@ object Dragonite { "dragonite_chestplate", ::Item, Item.Properties() - .enchantable(Witherite.armorMaterial.enchantmentValue) + .enchantable(armorMaterial.enchantmentValue) .humanoidArmor(armorMaterial , ArmorType.CHESTPLATE) .component(DataComponents.GLIDER, Unit.INSTANCE) .durability(ArmorType.CHESTPLATE.getDurability(armorMaterial.durability)) @@ -75,7 +56,7 @@ object Dragonite { "dragonite_leggings", ::Item, Item.Properties() - .enchantable(Witherite.armorMaterial.enchantmentValue) + .enchantable(armorMaterial.enchantmentValue) .humanoidArmor(armorMaterial , ArmorType.LEGGINGS) .durability(ArmorType.LEGGINGS.getDurability(armorMaterial.durability)) ) @@ -84,7 +65,7 @@ object Dragonite { "dragonite_boots", ::Item, Item.Properties() - .enchantable(Witherite.armorMaterial.enchantmentValue) + .enchantable(armorMaterial.enchantmentValue) .humanoidArmor(armorMaterial , ArmorType.BOOTS) .durability(ArmorType.BOOTS.getDurability(armorMaterial.durability)) ) @@ -101,18 +82,19 @@ object Dragonite { Item.Properties() ) - val ITEMS = listOf(SWORD, HELMET, CHESTPLATE, LEGGINGS, BOOTS, INGOT, SCALE) - val ARMOUR_SET = ArmorSet(HELMET, CHESTPLATE, LEGGINGS, BOOTS) - - fun init() {} + override val armorSet: ArmorSet = ArmorSet(HELMET, CHESTPLATE, LEGGINGS, BOOTS) + override val items = listOf(SWORD, HELMET, CHESTPLATE, LEGGINGS, BOOTS, SCALE, INGOT) + override fun onLoad() {} } class DragoniteSword(properties: Properties) : Item(properties) { override fun use(level: Level, user: Player, hand: InteractionHand): InteractionResult { -// if (level.isClientSide || !user.isWearingFullSet(Dragonite.ARMOUR_SET)) return InteractionResult.PASS + if (level.isClientSide || !Dragonite.fullSetEquippedBy(user)) return InteractionResult.PASS val direction = user.lookAngle - user.deltaMovement = direction.scale(2.0) + + val scale = if (user.isFallFlying) { 4.0 } else { 1.5 } + user.deltaMovement = direction.scale(scale) user.hurtMarked = true level.playSound(null, user.x, user.y, user.z, diff --git a/src/main/kotlin/dev/zxq5/items/Items.kt b/src/main/kotlin/dev/zxq5/items/Items.kt index fc4c1d9..e91d935 100644 --- a/src/main/kotlin/dev/zxq5/items/Items.kt +++ b/src/main/kotlin/dev/zxq5/items/Items.kt @@ -3,11 +3,11 @@ package dev.zxq5.items import dev.zxq5.Fantasysmp import dev.zxq5.util.id import dev.zxq5.util.resourceKey +import kotlinx.serialization.descriptors.StructureKind import net.fabricmc.fabric.api.creativetab.v1.FabricCreativeModeTab import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagsProvider import net.minecraft.advancements.criterion.InventoryChangeTrigger import net.minecraft.advancements.criterion.ItemPredicate -import net.minecraft.client.data.models.ItemModelGenerators import net.minecraft.core.Holder import net.minecraft.core.HolderGetter import net.minecraft.core.HolderLookup @@ -41,8 +41,9 @@ abstract class ItemImplementation { abstract fun onLoad() open fun generateRecipes(registries: HolderLookup.Provider, exporter: RecipeOutput) {} + open fun generateItemTags(tags: ItemTagAdder) {} - open fun generateItemModels(models: ItemModelGenerators) {} +// open fun generateItemModels(models: ItemModelGenerators) {} init { register(this) @@ -50,30 +51,43 @@ abstract class ItemImplementation { companion object { private val _all = mutableListOf() + val all: List get() = _all + fun register(impl: ItemImplementation) = _all.add(impl) } } abstract class GenericGearSet: ItemImplementation() { abstract val materialName: String + abstract val armorSet: ArmorSet - open val materialKey: ResourceKey = materialName.resourceKey() + open val materialKey: ResourceKey + get() = materialName.resourceKey() + + open val materialDefinition: GearMaterialDef + get() = GearMaterialDef.NETHERITE - open val materialDefinition: GearMaterialDef = GearMaterialDef() val armorMaterial: ArmorMaterial by lazy { materialDefinition.toArmorMaterial() } private val itemRecipes = mutableMapOf>() + private val itemTags = mutableMapOf>>() - internal fun registerDatagen(item: Item, recipes: List, tags: List>) { + private val itemModels = mutableMapOf() + + internal fun registerDatagen(item: Item, recipes: List, tags: List>, model: ModelSpec) { itemRecipes[item] = recipes itemTags[item] = tags + itemModels[item] = model } + + val modelSpecs: Map get() = itemModels + override fun generateRecipes(registries: HolderLookup.Provider, exporter: RecipeOutput) { val itemLookup: HolderGetter = registries.lookupOrThrow(Registries.ITEM) @@ -148,13 +162,15 @@ object ModItems { } .build() - private val eagerLoad = listOf(Witherite, Dragonite) + private val eagerLoad = listOf( + Witherite, + Dragonite, + ) fun onLoad() { // ensure that implementations such as creative tab are loaded and initialised eagerLoad ItemImplementation.all.forEach { it.onLoad() } - Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, CUSTOM_CREATIVE_TAB_KEY, CUSTOM_CREATIVE_TAB); } } @@ -168,7 +184,31 @@ data class GearMaterialDef( val knockbackResistance: Float = ArmorMaterials.NETHERITE.knockbackResistance, val repairIngredient: TagKey = ArmorMaterials.NETHERITE.repairIngredient, val assetId: ResourceKey = ArmorMaterials.NETHERITE.assetId, -) +) { + companion object { + val NETHERITE = GearMaterialDef( + durability = ArmorMaterials.NETHERITE.durability, + defence = ArmorMaterials.NETHERITE.defense, + enchantability = ArmorMaterials.NETHERITE.enchantmentValue, + equipSound = ArmorMaterials.NETHERITE.equipSound, + toughness = ArmorMaterials.NETHERITE.toughness, + knockbackResistance = ArmorMaterials.NETHERITE.knockbackResistance, + repairIngredient = ArmorMaterials.NETHERITE.repairIngredient, + assetId = ArmorMaterials.NETHERITE.assetId, + ) + val DIAMOND = GearMaterialDef( + durability = ArmorMaterials.DIAMOND.durability, + defence = ArmorMaterials.DIAMOND.defense, + enchantability = ArmorMaterials.DIAMOND.enchantmentValue, + equipSound = ArmorMaterials.DIAMOND.equipSound, + toughness = ArmorMaterials.DIAMOND.toughness, + knockbackResistance = ArmorMaterials.DIAMOND.knockbackResistance, + repairIngredient = ArmorMaterials.DIAMOND.repairIngredient, + assetId = ArmorMaterials.DIAMOND.assetId, + ) + } +} + fun GearMaterialDef.toArmorMaterial(): ArmorMaterial { return ArmorMaterial( @@ -194,6 +234,12 @@ sealed interface RecipeSpec { data class Shaped(val pattern: List, val key: Map) : RecipeSpec } +sealed interface ModelSpec { + data object Generated : ModelSpec // plain flat 2D item icon + data object Handheld : ModelSpec // flat icon, held like a tool + data object None : ModelSpec // hand-written JSON already exists, skip auto-gen +} + class GearItemBuilder( private val owner: GenericGearSet, val name: String, @@ -202,6 +248,11 @@ class GearItemBuilder( private var properties = Item.Properties() private val recipes = mutableListOf() private val tags = mutableListOf>() + private var modelSpec: ModelSpec = ModelSpec.None + + fun model(spec: ModelSpec) { + modelSpec = spec + } fun properties(block: Item.Properties.() -> Item.Properties) { properties = properties.block() @@ -221,7 +272,7 @@ class GearItemBuilder( internal fun build(): T { val item = ModItems.register(name, itemFactory, properties) - owner.registerDatagen(item, recipes, tags) + owner.registerDatagen(item, recipes, tags, modelSpec) return item } } diff --git a/src/main/kotlin/dev/zxq5/items/Witherite.kt b/src/main/kotlin/dev/zxq5/items/Witherite.kt index 50ddd6a..d34fe4f 100644 --- a/src/main/kotlin/dev/zxq5/items/Witherite.kt +++ b/src/main/kotlin/dev/zxq5/items/Witherite.kt @@ -1,8 +1,11 @@ package dev.zxq5.items import dev.zxq5.items.ModItems.register +import dev.zxq5.util.mcItemTag import net.minecraft.core.component.DataComponents import net.minecraft.sounds.SoundEvents +import net.minecraft.tags.ItemTags +import net.minecraft.tags.TagKey import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult import net.minecraft.world.effect.MobEffectInstance @@ -13,6 +16,7 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items import net.minecraft.world.item.ToolMaterial import net.minecraft.world.item.component.BlocksAttacks import net.minecraft.world.item.component.UseCooldown @@ -23,6 +27,10 @@ import java.util.* object Witherite: GenericGearSet() { + override val materialName = "witherite" + override val materialDefinition + get() = super.materialDefinition.copy(assetId = materialKey) + val SHIELD = register("witherite_shield", ::Item, Item.Properties() .component(DataComponents.BLOCKS_ATTACKS, BlocksAttacks( @@ -43,63 +51,107 @@ object Witherite: GenericGearSet() { )) ) - val SWORD = register("witherite_sword", ::WitheriteSword, - Item.Properties() - .enchantable(armorMaterial.enchantmentValue) - .component(DataComponents.USE_COOLDOWN, UseCooldown(2f)) - .sword(ToolMaterial.NETHERITE, 3F, -2.4F) - ) +// val SWORD = register("witherite_sword", ::WitheriteSword, +// Item.Properties() +// .enchantable(armorMaterial.enchantmentValue) +// .component(DataComponents.USE_COOLDOWN, UseCooldown(2f)) +// .sword(ToolMaterial.NETHERITE, 3F, -2.4F) +// ) - val AXE = register("witherite_axe", ::WitheriteWeapon, - Item.Properties() - .enchantable(armorMaterial.enchantmentValue) - .axe(ToolMaterial.NETHERITE, 5F, -3F)) +// val AXE = register("witherite_axe", ::WitheriteWeapon, +// Item.Properties() +// .enchantable(armorMaterial.enchantmentValue) +// .axe(ToolMaterial.NETHERITE, 5F, -3F)) + val SWORD by gearItem("witherite_sword", ::WitheriteSword) { + properties { + enchantable(armorMaterial.enchantmentValue) + .component(DataComponents.USE_COOLDOWN, UseCooldown(2f)) + .sword(ToolMaterial.NETHERITE, 3F, -2.4F) + } + smithingUpgrade(Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE, Items.NETHERITE_SWORD, Items.WITHER_SKELETON_SKULL) + } - val HELMET = register( - "witherite_helmet", - ::Item, - Item.Properties().humanoidArmor(armorMaterial , ArmorType.HELMET) - .enchantable(armorMaterial.enchantmentValue) - .durability(ArmorType.HELMET.getDurability(armorMaterial.durability)) - ) + val AXE by gearItem("witherite_axe", ::WitheriteWeapon) { + properties { + enchantable(armorMaterial.enchantmentValue) + .component(DataComponents.USE_COOLDOWN, UseCooldown(2f)) + .axe(ToolMaterial.NETHERITE, 3F, -3F) + } + smithingUpgrade(Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE, Items.NETHERITE_AXE, Items.WITHER_SKELETON_SKULL) + tags( + mcItemTag("axes") + ) + } - val CHESTPLATE = register( - "witherite_chestplate", - ::Item, + val HELMET by gearItem("witherite_helmet", ::Item) { + properties { + humanoidArmor(armorMaterial, ArmorType.HELMET) + } + smithingUpgrade(Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE, Items.NETHERITE_HELMET, Items.WITHER_SKELETON_SKULL) + } - Item.Properties() - .enchantable(armorMaterial.enchantmentValue) - .humanoidArmor(armorMaterial , ArmorType.CHESTPLATE) - .durability(ArmorType.CHESTPLATE.getDurability(armorMaterial.durability)) - ) + val CHESTPLATE by gearItem("witherite_chestplate", ::Item) { + properties { + humanoidArmor(armorMaterial, ArmorType.CHESTPLATE) + } + smithingUpgrade(Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE, Items.NETHERITE_CHESTPLATE, Items.WITHER_SKELETON_SKULL) + } - val LEGGINGS = register( - "witherite_leggings", - ::Item, - Item.Properties() - .enchantable(armorMaterial.enchantmentValue) - .humanoidArmor(armorMaterial , ArmorType.LEGGINGS) - .durability(ArmorType.LEGGINGS.getDurability(armorMaterial.durability)) - ) + val LEGGINGS by gearItem("witherite_leggings", ::Item) { + properties { + humanoidArmor(armorMaterial, ArmorType.LEGGINGS) + } + smithingUpgrade(Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE, Items.NETHERITE_LEGGINGS, Items.WITHER_SKELETON_SKULL) + } - val BOOTS = register( - "witherite_boots", - ::Item, - Item.Properties() - .enchantable(armorMaterial.enchantmentValue) - .humanoidArmor(armorMaterial , ArmorType.BOOTS) - .durability(ArmorType.BOOTS.getDurability(armorMaterial.durability)) - ) + val BOOTS by gearItem("witherite_boots", ::Item) { + properties { + humanoidArmor(armorMaterial, ArmorType.BOOTS) + } + smithingUpgrade(Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE, Items.NETHERITE_BOOTS, Items.WITHER_SKELETON_SKULL) + } + +// +// val HELMET = register( +// "witherite_helmet", +// ::Item, +// Item.Properties().humanoidArmor(armorMaterial , ArmorType.HELMET) +// .enchantable(armorMaterial.enchantmentValue) +// .durability(ArmorType.HELMET.getDurability(armorMaterial.durability)) +// ) +// +// val CHESTPLATE = register( +// "witherite_chestplate", +// ::Item, +// +// Item.Properties() +// .enchantable(armorMaterial.enchantmentValue) +// .humanoidArmor(armorMaterial , ArmorType.CHESTPLATE) +// .durability(ArmorType.CHESTPLATE.getDurability(armorMaterial.durability)) +// ) +// +// val LEGGINGS = register( +// "witherite_leggings", +// ::Item, +// Item.Properties() +// .enchantable(armorMaterial.enchantmentValue) +// .humanoidArmor(armorMaterial , ArmorType.LEGGINGS) +// .durability(ArmorType.LEGGINGS.getDurability(armorMaterial.durability)) +// ) +// +// val BOOTS = register( +// "witherite_boots", +// ::Item, +// Item.Properties() +// .enchantable(armorMaterial.enchantmentValue) +// .humanoidArmor(armorMaterial , ArmorType.BOOTS) +// .durability(ArmorType.BOOTS.getDurability(armorMaterial.durability)) +// ) - override val materialName = "witherite" - override val materialDefinition = super.materialDefinition.copy(assetId = materialKey) override val armorSet: ArmorSet = ArmorSet(HELMET, CHESTPLATE, LEGGINGS, BOOTS) override val items = listOf(SWORD, AXE, SHIELD, HELMET, CHESTPLATE, LEGGINGS, BOOTS) - - override fun onLoad() { - TODO("Not yet implemented") - } + override fun onLoad() {} } open class WitheriteWeapon(properties: Properties): Item(properties) { diff --git a/src/main/kotlin/dev/zxq5/util/util.kt b/src/main/kotlin/dev/zxq5/util/util.kt index 243e674..b306b9e 100644 --- a/src/main/kotlin/dev/zxq5/util/util.kt +++ b/src/main/kotlin/dev/zxq5/util/util.kt @@ -1,7 +1,10 @@ package dev.zxq5.util import dev.zxq5.Fantasysmp +import net.minecraft.core.registries.Registries import net.minecraft.resources.Identifier import net.minecraft.resources.ResourceKey +import net.minecraft.tags.TagKey +import net.minecraft.world.item.Item import net.minecraft.world.item.equipment.EquipmentAsset import net.minecraft.world.item.equipment.EquipmentAssets @@ -10,3 +13,8 @@ fun String.resourceKey(): ResourceKey = ResourceKey.create( EquipmentAssets.ROOT_ID, Identifier.fromNamespaceAndPath(Fantasysmp.MOD_ID, this), ) + +fun mcItemTag(path: String): TagKey = TagKey.create( + Registries.ITEM, + Identifier.withDefaultNamespace(path) +) \ No newline at end of file diff --git a/src/main/resources/data/fantasysmp/recipe/witherite_axe.json b/src/main/resources/witherite_axe.json similarity index 100% rename from src/main/resources/data/fantasysmp/recipe/witherite_axe.json rename to src/main/resources/witherite_axe.json diff --git a/src/main/resources/data/fantasysmp/recipe/witherite_boots.json b/src/main/resources/witherite_boots.json similarity index 100% rename from src/main/resources/data/fantasysmp/recipe/witherite_boots.json rename to src/main/resources/witherite_boots.json diff --git a/src/main/resources/data/fantasysmp/recipe/witherite_chestplate.json b/src/main/resources/witherite_chestplate.json similarity index 100% rename from src/main/resources/data/fantasysmp/recipe/witherite_chestplate.json rename to src/main/resources/witherite_chestplate.json diff --git a/src/main/resources/data/fantasysmp/recipe/witherite_helmet.json b/src/main/resources/witherite_helmet.json similarity index 100% rename from src/main/resources/data/fantasysmp/recipe/witherite_helmet.json rename to src/main/resources/witherite_helmet.json diff --git a/src/main/resources/data/fantasysmp/recipe/witherite_leggings.json b/src/main/resources/witherite_leggings.json similarity index 100% rename from src/main/resources/data/fantasysmp/recipe/witherite_leggings.json rename to src/main/resources/witherite_leggings.json diff --git a/src/main/resources/data/fantasysmp/recipe/witherite_shield.json b/src/main/resources/witherite_shield.json similarity index 100% rename from src/main/resources/data/fantasysmp/recipe/witherite_shield.json rename to src/main/resources/witherite_shield.json diff --git a/src/main/resources/data/fantasysmp/recipe/witherite_sword.json b/src/main/resources/witherite_sword.json similarity index 100% rename from src/main/resources/data/fantasysmp/recipe/witherite_sword.json rename to src/main/resources/witherite_sword.json