package dev.zxq5.items import dev.zxq5.items.ModItems.register 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.ToolMaterial import net.minecraft.world.item.component.BlocksAttacks import net.minecraft.world.item.component.UseCooldown import net.minecraft.world.item.equipment.ArmorMaterial import net.minecraft.world.item.equipment.ArmorType import net.minecraft.world.level.Level import java.util.* object Witherite: GenericGearSet() { val SHIELD = register("witherite_shield", ::Item, 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 = 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 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") } } 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; } }