From e7963901a8c64642d3e91096ba1df70df86f218a Mon Sep 17 00:00:00 2001 From: Badtz Date: Tue, 5 Mar 2024 09:43:05 -0800 Subject: [PATCH] implement poison and wither effects --- .../bone/effects/BoneEffectRegistry.java | 4 +++- .../me/woach/bone/effects/PoisonEffect.java | 24 +++++++++++++++++++ .../me/woach/bone/effects/WitherEffect.java | 24 +++++++++++++++++++ .../resources/assets/bone/lang/en_us.json | 4 +++- .../data/bone/bones/wither_skeleton.json | 9 +++++++ .../data/bone/bones/zombie_villager.json | 9 +++++++ 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/woach/bone/effects/PoisonEffect.java create mode 100644 src/main/java/me/woach/bone/effects/WitherEffect.java create mode 100644 src/main/resources/data/bone/bones/wither_skeleton.json create mode 100644 src/main/resources/data/bone/bones/zombie_villager.json diff --git a/src/main/java/me/woach/bone/effects/BoneEffectRegistry.java b/src/main/java/me/woach/bone/effects/BoneEffectRegistry.java index 411b750..a304a84 100644 --- a/src/main/java/me/woach/bone/effects/BoneEffectRegistry.java +++ b/src/main/java/me/woach/bone/effects/BoneEffectRegistry.java @@ -13,7 +13,9 @@ public enum BoneEffectRegistry { SPIKE("spike", () -> new SpikeEffect()), HIGH_JUMP("high_jump", () -> new HighJumpEffect()), SLOW_FALL("slow_fall", () -> new SlowFallEffect()), - DOLPHIN_KICK("dolphin_kick", () -> new DolphinKickEffect()); + DOLPHIN_KICK("dolphin_kick", () -> new DolphinKickEffect()), + POISON("poison", () -> new PoisonEffect()), + WITHER("wither", () -> new WitherEffect()); private final String path; private final Supplier effectSupplier; diff --git a/src/main/java/me/woach/bone/effects/PoisonEffect.java b/src/main/java/me/woach/bone/effects/PoisonEffect.java new file mode 100644 index 0000000..a2622f1 --- /dev/null +++ b/src/main/java/me/woach/bone/effects/PoisonEffect.java @@ -0,0 +1,24 @@ +package me.woach.bone.effects; + +import me.woach.bone.effects.bonetype.GenericBoneType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.entity.effect.StatusEffects; + +public class PoisonEffect extends BoneEffect { + public PoisonEffect() { + super(Rarity.RARE, new GenericBoneType(), EquipmentSlot.MAINHAND); + } + + @Override + public void onTargetDamaged(LivingEntity user, Entity target, int level) { + if (target instanceof LivingEntity) { + ((LivingEntity) target) + .addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, (level + 1) * 20, level, + false, true, false)); + } + super.onTargetDamaged(user, target, level); + } +} diff --git a/src/main/java/me/woach/bone/effects/WitherEffect.java b/src/main/java/me/woach/bone/effects/WitherEffect.java new file mode 100644 index 0000000..1382047 --- /dev/null +++ b/src/main/java/me/woach/bone/effects/WitherEffect.java @@ -0,0 +1,24 @@ +package me.woach.bone.effects; + +import me.woach.bone.effects.bonetype.GenericBoneType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.entity.effect.StatusEffects; + +public class WitherEffect extends BoneEffect { + public WitherEffect() { + super(Rarity.RARE, new GenericBoneType(), EquipmentSlot.MAINHAND); + } + + @Override + public void onTargetDamaged(LivingEntity user, Entity target, int level) { + if (target instanceof LivingEntity) { + ((LivingEntity) target) + .addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, (level + 1) * 20, level, + false, true, false)); + } + super.onTargetDamaged(user, target, level); + } +} diff --git a/src/main/resources/assets/bone/lang/en_us.json b/src/main/resources/assets/bone/lang/en_us.json index 7fd6fed..a51439b 100644 --- a/src/main/resources/assets/bone/lang/en_us.json +++ b/src/main/resources/assets/bone/lang/en_us.json @@ -30,5 +30,7 @@ "enchantment.bone.spike": "Spike", "enchantment.bone.high_jump": "High Jump", "enchantment.bone.slow_fall": "Slow Fall", - "enchantment.bone.dolphin_kick": "Dolphin Kick" + "enchantment.bone.dolphin_kick": "Dolphin Kick", + "enchantment.bone.poison": "Poison", + "enchantment.bone.wither": "Wither" } \ No newline at end of file diff --git a/src/main/resources/data/bone/bones/wither_skeleton.json b/src/main/resources/data/bone/bones/wither_skeleton.json new file mode 100644 index 0000000..53cda5f --- /dev/null +++ b/src/main/resources/data/bone/bones/wither_skeleton.json @@ -0,0 +1,9 @@ +{ + "enabled": true, + "chance": 125, + "effects": { + "WEAPON": "bone:wither", + "DIGGER": "bone:wither" + }, + "entity": "minecraft:wither_skeleton" +} \ No newline at end of file diff --git a/src/main/resources/data/bone/bones/zombie_villager.json b/src/main/resources/data/bone/bones/zombie_villager.json new file mode 100644 index 0000000..223bbe7 --- /dev/null +++ b/src/main/resources/data/bone/bones/zombie_villager.json @@ -0,0 +1,9 @@ +{ + "enabled": true, + "chance": 125, + "effects": { + "WEAPON": "bone:poison", + "DIGGER": "bone:poison" + }, + "entity": "minecraft:zombie_villager" +} \ No newline at end of file