this might actually work
build / build (push) Has been cancelled

This commit is contained in:
2026-06-30 22:26:46 +01:00
parent dd42e078ac
commit 1c1362d6ea
30 changed files with 526 additions and 26 deletions
+42 -5
View File
@@ -1,12 +1,16 @@
package dev.zxq5
import dev.zxq5.items.ModItems
import dev.zxq5.items.ModItems.CUSTOM_CREATIVE_TAB
import dev.zxq5.items.ModItems.CUSTOM_CREATIVE_TAB_KEY
import dev.zxq5.items.Witherite
import dev.zxq5.items.isWearingFullSet
import net.fabricmc.api.ModInitializer
import net.minecraft.core.Registry
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.world.item.Item
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents
import net.fabricmc.fabric.api.event.player.AttackEntityCallback
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.LivingEntity
import org.slf4j.LoggerFactory
object Fantasysmp : ModInitializer {
@@ -22,5 +26,38 @@ object Fantasysmp : ModInitializer {
logger.info("Hello Fabric world!")
ModItems.init();
// Register the group.
registerItemEffects()
}
private fun registerItemEffects() {
ServerTickEvents.END_SERVER_TICK.register { server ->
for (player in server.playerList.players) {
if (player.isWearingFullSet(Witherite.ARMOUR_SET)) {
player.removeEffect(MobEffects.WITHER)
}
}
}
AttackEntityCallback.EVENT.register { player, world, hand, entity, _ ->
if (world.isClientSide) return@register InteractionResult.PASS
if (hand != InteractionHand.MAIN_HAND) return@register InteractionResult.PASS
if (player.getItemInHand(hand).item != Witherite.SWORD) return@register InteractionResult.PASS
if (entity is LivingEntity) {
entity.addEffect(MobEffectInstance(MobEffects.WITHER, 60, 1), player)
}
InteractionResult.PASS
}
AttackEntityCallback.EVENT.register { player, world, hand, entity, _ ->
if (world.isClientSide) return@register InteractionResult.PASS
if (hand != InteractionHand.MAIN_HAND) return@register InteractionResult.PASS
if (player.getItemInHand(hand).item != Witherite.AXE) return@register InteractionResult.PASS
if (entity is LivingEntity) {
entity.addEffect(MobEffectInstance(MobEffects.WITHER, 60, 1), player)
}
InteractionResult.PASS
}
}
}