Compare commits
3 Commits
67ea3b977b
...
df7465a59f
Author | SHA1 | Date | |
---|---|---|---|
df7465a59f | |||
6f2adfd6d3 | |||
e97967903b |
@ -34,7 +34,12 @@ fun addEquipmentTags(tagsProvider: TagsProvider) {
|
||||
.add(MItems.TRITANIUM_BOOTS)
|
||||
.add(MItems.SIMPLE_TRITANIUM_BOOTS)
|
||||
|
||||
tagsProvider.items.Appender(ItemTags.SWORDS).add(MItems.TRITANIUM_SWORD).add(MItems.ENERGY_SWORD)
|
||||
tagsProvider.items.Appender(ItemTags.SWORDS)
|
||||
.add(MItems.TRITANIUM_SWORD)
|
||||
.add(MItems.ENERGY_SWORD)
|
||||
.add(MItems.FALLING_SUN)
|
||||
.add(MItems.WITHERED_STEEL_SWORD)
|
||||
|
||||
tagsProvider.items.Appender(ItemTags.AXES).add(MItems.TRITANIUM_AXE)
|
||||
tagsProvider.items.Appender(ItemTags.PICKAXES).add(MItems.TRITANIUM_PICKAXE)
|
||||
tagsProvider.items.Appender(ItemTags.SHOVELS).add(MItems.TRITANIUM_SHOVEL)
|
||||
|
@ -76,4 +76,12 @@ object ServerConfig : AbstractConfig("misc") {
|
||||
builder.pop()
|
||||
}
|
||||
}
|
||||
|
||||
val WITHER_SKELETON_HELMET_CHANCE: Double by builder
|
||||
.comment("Chance of Wither Skeleton spawning with Netherite Helmet AND Withered Steel sword")
|
||||
.defineInRange("WITHER_SKELETON_HELMET_CHANCE", 0.1, 0.0, 1.0)
|
||||
|
||||
val WITHER_SKELETON_SWORD_CHANCE: Double by builder
|
||||
.comment("Chance of Wither Skeleton spawning with Withered Steel sword")
|
||||
.defineInRange("WITHER_SKELETON_HELMET_CHANCE", 0.24, 0.0, 1.0)
|
||||
}
|
||||
|
@ -6,24 +6,28 @@ import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.neoforged.bus.api.SubscribeEvent
|
||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent
|
||||
import ru.dbotthepony.mc.otm.config.ServerConfig
|
||||
import ru.dbotthepony.mc.otm.core.otmRandom
|
||||
import ru.dbotthepony.mc.otm.registry.game.MItems
|
||||
|
||||
|
||||
object WitheredSkeletonSpawnHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
fun onEntityJoin(event: EntityJoinLevelEvent) {
|
||||
val entity = event.entity
|
||||
if (entity is WitherSkeleton){
|
||||
|
||||
val giveHelmet = entity.random.nextFloat() < 0.1f
|
||||
val giveSword = entity.random.nextFloat() < 0.24f
|
||||
if (entity is WitherSkeleton) {
|
||||
val giveHelmet = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_HELMET_CHANCE
|
||||
val giveSword = event.level.otmRandom.nextFloat() < ServerConfig.WITHER_SKELETON_SWORD_CHANCE
|
||||
|
||||
if (giveHelmet) {
|
||||
entity.setItemSlot(EquipmentSlot.HEAD, ItemStack(Items.NETHERITE_HELMET))
|
||||
entity.setItemSlot(EquipmentSlot.MAINHAND, ItemStack(MItems.WITHERED_STEEL_SWORD))
|
||||
} else if (giveSword) {
|
||||
entity.setItemSlot(EquipmentSlot.MAINHAND, ItemStack(MItems.WITHERED_STEEL_SWORD))
|
||||
if (!entity.hasItemInSlot(EquipmentSlot.HEAD))
|
||||
entity.setItemSlot(EquipmentSlot.HEAD, ItemStack(Items.NETHERITE_HELMET))
|
||||
}
|
||||
|
||||
if (giveSword || giveHelmet) {
|
||||
if (!entity.hasItemInSlot(EquipmentSlot.MAINHAND) || entity.getItemBySlot(EquipmentSlot.MAINHAND).item == Items.STONE_SWORD)
|
||||
entity.setItemSlot(EquipmentSlot.MAINHAND, ItemStack(MItems.WITHERED_STEEL_SWORD))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,23 +13,19 @@ import net.minecraft.world.item.Tiers
|
||||
import net.minecraft.world.item.component.ItemAttributeModifiers
|
||||
import ru.dbotthepony.mc.otm.registry.game.MItems
|
||||
|
||||
class WitheredSteelSwordItem(properties: Item.Properties) : SwordItem(Tiers.IRON, properties){
|
||||
class WitheredSteelSwordItem(properties: Properties) : SwordItem(Tiers.IRON, properties) {
|
||||
private val attributes: ItemAttributeModifiers
|
||||
|
||||
init {
|
||||
var builder = ItemAttributeModifiers.builder()
|
||||
val builder = ItemAttributeModifiers.builder()
|
||||
builder.add(Attributes.ATTACK_DAMAGE, AttributeModifier(BASE_ATTACK_DAMAGE_ID, 4.5, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND)
|
||||
builder.add(Attributes.ATTACK_SPEED, AttributeModifier(BASE_ATTACK_SPEED_ID, -2.4, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND)
|
||||
|
||||
attributes = builder.build()
|
||||
}
|
||||
|
||||
override fun getMaxDamage(stack: ItemStack): Int {
|
||||
return 420
|
||||
}
|
||||
|
||||
override fun isEnchantable(p_41456_: ItemStack): Boolean {
|
||||
return p_41456_.count == 1
|
||||
override fun isEnchantable(stack: ItemStack): Boolean {
|
||||
return stack.count == 1
|
||||
}
|
||||
|
||||
override fun getEnchantmentValue(stack: ItemStack): Int {
|
||||
@ -41,13 +37,12 @@ class WitheredSteelSwordItem(properties: Item.Properties) : SwordItem(Tiers.IRON
|
||||
}
|
||||
|
||||
override fun hurtEnemy(stack: ItemStack, target: LivingEntity, attacker: LivingEntity): Boolean {
|
||||
target.addEffect(MobEffectInstance(MobEffects.WITHER, 100, 0))
|
||||
return super.hurtEnemy(stack, target, attacker)
|
||||
val status = super.hurtEnemy(stack, target, attacker)
|
||||
if (status) target.addEffect(MobEffectInstance(MobEffects.WITHER, 100, 0))
|
||||
return status
|
||||
}
|
||||
|
||||
override fun getDefaultAttributeModifiers(stack: ItemStack): ItemAttributeModifiers {
|
||||
return attributes
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user