new item builder kinda works. making sure everything is moved across, then i gotta start on the new set
build / build (push) Failing after 3m33s
build / build (push) Failing after 3m33s
This commit is contained in:
+2
-1
@@ -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" }
|
||||
}
|
||||
|
||||
@@ -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) }
|
||||
}
|
||||
}
|
||||
// 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
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
+32
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<EquipmentAsset> = ResourceKey.create<EquipmentAsset>(
|
||||
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,
|
||||
|
||||
@@ -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<ItemImplementation>()
|
||||
|
||||
val all: List<ItemImplementation> 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<EquipmentAsset> = materialName.resourceKey()
|
||||
open val materialKey: ResourceKey<EquipmentAsset>
|
||||
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<Item, List<RecipeSpec>>()
|
||||
|
||||
private val itemTags = mutableMapOf<Item, List<TagKey<Item>>>()
|
||||
|
||||
internal fun registerDatagen(item: Item, recipes: List<RecipeSpec>, tags: List<TagKey<Item>>) {
|
||||
private val itemModels = mutableMapOf<Item, ModelSpec>()
|
||||
|
||||
internal fun registerDatagen(item: Item, recipes: List<RecipeSpec>, tags: List<TagKey<Item>>, model: ModelSpec) {
|
||||
itemRecipes[item] = recipes
|
||||
itemTags[item] = tags
|
||||
itemModels[item] = model
|
||||
}
|
||||
|
||||
|
||||
val modelSpecs: Map<Item, ModelSpec> get() = itemModels
|
||||
|
||||
override fun generateRecipes(registries: HolderLookup.Provider, exporter: RecipeOutput) {
|
||||
val itemLookup: HolderGetter<Item> = registries.lookupOrThrow(Registries.ITEM)
|
||||
|
||||
@@ -148,13 +162,15 @@ object ModItems {
|
||||
}
|
||||
.build()
|
||||
|
||||
private val eagerLoad = listOf(Witherite, Dragonite)
|
||||
private val eagerLoad = listOf<GenericGearSet>(
|
||||
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<Item> = ArmorMaterials.NETHERITE.repairIngredient,
|
||||
val assetId: ResourceKey<EquipmentAsset> = 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<String>, val key: Map<Char, Item>) : 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<T : Item>(
|
||||
private val owner: GenericGearSet,
|
||||
val name: String,
|
||||
@@ -202,6 +248,11 @@ class GearItemBuilder<T : Item>(
|
||||
private var properties = Item.Properties()
|
||||
private val recipes = mutableListOf<RecipeSpec>()
|
||||
private val tags = mutableListOf<TagKey<Item>>()
|
||||
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<T : Item>(
|
||||
|
||||
internal fun build(): T {
|
||||
val item = ModItems.register(name, itemFactory, properties)
|
||||
owner.registerDatagen(item, recipes, tags)
|
||||
owner.registerDatagen(item, recipes, tags, modelSpec)
|
||||
return item
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
// 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 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 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 AXE = register("witherite_axe", ::WitheriteWeapon,
|
||||
Item.Properties()
|
||||
.enchantable(armorMaterial.enchantmentValue)
|
||||
.axe(ToolMaterial.NETHERITE, 5F, -3F))
|
||||
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)
|
||||
}
|
||||
|
||||
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 HELMET = register(
|
||||
"witherite_helmet",
|
||||
::Item,
|
||||
Item.Properties().humanoidArmor(armorMaterial , ArmorType.HELMET)
|
||||
.enchantable(armorMaterial.enchantmentValue)
|
||||
.durability(ArmorType.HELMET.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 CHESTPLATE = register(
|
||||
"witherite_chestplate",
|
||||
::Item,
|
||||
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)
|
||||
}
|
||||
|
||||
Item.Properties()
|
||||
.enchantable(armorMaterial.enchantmentValue)
|
||||
.humanoidArmor(armorMaterial , ArmorType.CHESTPLATE)
|
||||
.durability(ArmorType.CHESTPLATE.getDurability(armorMaterial.durability))
|
||||
)
|
||||
//
|
||||
// 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))
|
||||
// )
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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<EquipmentAsset> = ResourceKey.create(
|
||||
EquipmentAssets.ROOT_ID,
|
||||
Identifier.fromNamespaceAndPath(Fantasysmp.MOD_ID, this),
|
||||
)
|
||||
|
||||
fun mcItemTag(path: String): TagKey<Item> = TagKey.create(
|
||||
Registries.ITEM,
|
||||
Identifier.withDefaultNamespace(path)
|
||||
)
|
||||
Reference in New Issue
Block a user