custom items now use new builder DSL syntax, implementing first new set begins tmr
build / build (push) Failing after 3m16s

This commit is contained in:
2026-07-08 00:58:10 +01:00
parent 5f6350943e
commit 5b57baafb1
6 changed files with 192 additions and 361 deletions
@@ -0,0 +1,133 @@
package dev.zxq5.items.sets
import dev.zxq5.items.core.ArmorSet
import dev.zxq5.items.core.GenericGearSet
import dev.zxq5.items.core.gearItem
import net.minecraft.core.component.DataComponents
import net.minecraft.sounds.SoundEvents
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.effect.MobEffectInstance
import net.minecraft.world.effect.MobEffects
import net.minecraft.world.entity.EntityType
import net.minecraft.world.entity.LivingEntity
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
import net.minecraft.world.item.equipment.ArmorType
import net.minecraft.world.level.Level
import java.util.*
object Witherite: GenericGearSet() {
override val materialName = "witherite"
override val materialDefinition
get() = super.materialDefinition.copy(assetId = materialKey)
val SHIELD by gearItem("witherite_shield", ::Item) {
properties {
component(DataComponents.BLOCKS_ATTACKS, BlocksAttacks(
0.25f, // 5 tick warmup
1.0f, // standard disable cooldown
listOf(
BlocksAttacks.DamageReduction(
90.0f, // horizontalBlockingAngle — 90° arc each side (180° total, same as vanilla)
Optional.empty(), // type — empty = blocks all damage types
0.0f, // base — flat damage reduction
1.0f // factor — multiplier (1.0 = block 100% of damage)
)
), // full block — check if this constant exists, else build the list manually
BlocksAttacks.ItemDamageFunction.DEFAULT, // check for this constant too
Optional.empty(), // no bypass
Optional.empty(), // default block sound
Optional.empty() // default disable sound
))
}
}
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)
}
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 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 by gearItem("witherite_boots", ::Item) {
properties {
humanoidArmor(armorMaterial, ArmorType.BOOTS)
}
smithingUpgrade(Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE, Items.NETHERITE_BOOTS, Items.WITHER_SKELETON_SKULL)
}
override val armorSet: ArmorSet = ArmorSet(HELMET, CHESTPLATE, LEGGINGS, BOOTS)
override val items = listOf(SWORD, AXE, SHIELD, HELMET, CHESTPLATE, LEGGINGS, BOOTS)
override fun onLoad() {
// empty function - this must be called to initialise the above properties ^
}
}
open class WitheriteWeapon(properties: Properties): Item(properties) {
override fun hurtEnemy(itemStack: ItemStack, mob: LivingEntity, attacker: LivingEntity) {
super.hurtEnemy(itemStack, mob, attacker)
if (attacker.level().isClientSide) return
val amplifier = if (attacker is Player) { 0 } else { 2 }
mob.addEffect(MobEffectInstance(MobEffects.WITHER, 60, amplifier), attacker)
}
}
class WitheriteSword(properties: Properties) : WitheriteWeapon(properties) {
override fun use(level: Level, user: Player, hand: InteractionHand): InteractionResult {
if (level.isClientSide
|| !user.isCrouching
|| !Witherite.fullSetEquippedBy(user)
) return InteractionResult.PASS;
val skull = WitherSkull(EntityType.WITHER_SKULL, level)
skull.setPos(user.eyePosition)
skull.deltaMovement = user.lookAngle
level.addFreshEntity(skull)
skull.playSound(SoundEvents.WITHER_SHOOT)
return InteractionResult.SUCCESS;
}
}