@@ -0,0 +1,96 @@
|
||||
package dev.zxq5.items
|
||||
|
||||
import dev.zxq5.Fantasysmp
|
||||
import dev.zxq5.items.ModItems.register
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.Identifier
|
||||
import net.minecraft.resources.ResourceKey
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
import net.minecraft.sounds.SoundSource
|
||||
import net.minecraft.tags.ItemTags
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.InteractionResult
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.EntityType
|
||||
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.ToolMaterial
|
||||
import net.minecraft.world.item.equipment.*
|
||||
import net.minecraft.world.level.Level
|
||||
|
||||
|
||||
object Witherite {
|
||||
val base_durability = 40;
|
||||
val witherite_material_key: ResourceKey<EquipmentAsset> = ResourceKey.create<EquipmentAsset>(
|
||||
EquipmentAssets.ROOT_ID,
|
||||
Identifier.fromNamespaceAndPath(Fantasysmp.MOD_ID, "witherite")
|
||||
)
|
||||
|
||||
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,
|
||||
witherite_material_key,
|
||||
)
|
||||
|
||||
val WITHERITE_SWORD = register("witherite_sword", ::WitheriteSword,
|
||||
Item.Properties().sword(ToolMaterial.NETHERITE, 3.0F, -2.4F)
|
||||
)
|
||||
val WITHERITE_HELMET = register(
|
||||
"witherite_helmet",
|
||||
::Item,
|
||||
Item.Properties().humanoidArmor(armorMaterial , ArmorType.HELMET)
|
||||
.durability(ArmorType.HELMET.getDurability(armorMaterial.durability))
|
||||
)
|
||||
|
||||
val WITHERITE_CHESTPLATE = register(
|
||||
"witherite_chestplate",
|
||||
::Item,
|
||||
Item.Properties().humanoidArmor(armorMaterial , ArmorType.CHESTPLATE)
|
||||
.durability(ArmorType.CHESTPLATE.getDurability(armorMaterial.durability))
|
||||
)
|
||||
|
||||
val WITHERITE_LEGGINGS = register(
|
||||
"witherite_leggings",
|
||||
::Item,
|
||||
Item.Properties().humanoidArmor(armorMaterial , ArmorType.LEGGINGS)
|
||||
.durability(ArmorType.LEGGINGS.getDurability(armorMaterial.durability))
|
||||
)
|
||||
|
||||
val WITHERITE_BOOTS = register(
|
||||
"witherite_boots",
|
||||
::Item,
|
||||
Item.Properties().humanoidArmor(armorMaterial , ArmorType.BOOTS)
|
||||
.durability(ArmorType.BOOTS.getDurability(armorMaterial.durability))
|
||||
)
|
||||
|
||||
val ITEMS = listOf(WITHERITE_SWORD, WITHERITE_HELMET, WITHERITE_CHESTPLATE, WITHERITE_LEGGINGS, WITHERITE_BOOTS)
|
||||
|
||||
fun init() {}
|
||||
}
|
||||
|
||||
class WitheriteSword(properties: Properties) : Item(properties) {
|
||||
override fun use(level: Level, user: Player, hand: InteractionHand): InteractionResult {
|
||||
if (level.isClientSide) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user