Added Collapse effect and enchantment

This commit is contained in:
patience 2026-03-10 01:09:25 +00:00
parent ed1aaddcf5
commit c2460cf91e
No known key found for this signature in database
5 changed files with 115 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect;
import xyz.nearmisses.patience.mc_rebalance.enchant_effects.CollapseEffect;
import xyz.nearmisses.patience.mc_rebalance.enchant_effects.CrumbleEffect;
import xyz.nearmisses.patience.mc_rebalance.enchant_effects.SmackEffect;
import xyz.nearmisses.patience.mc_rebalance.enchant_effects.WindupEffect;
@ -24,4 +25,5 @@ public class ModEnchantments {
public static MapCodec<WindupEffect> Effect_Windup = register("windup", WindupEffect.CODEC);
public static MapCodec<SmackEffect> Effect_Smack = register("smack", SmackEffect.CODEC);
public static MapCodec<CrumbleEffect> Effect_Crumble = register("crumble",CrumbleEffect.CODEC);
public static MapCodec<CollapseEffect> Effect_Collapse = register("collapse", CollapseEffect.CODEC);
}

View file

@ -0,0 +1,60 @@
package xyz.nearmisses.patience.mc_rebalance.enchant_effects;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.Holder;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.enchantment.EnchantedItemInUse;
import net.minecraft.world.item.enchantment.LevelBasedValue;
import net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
public record CollapseEffect(LevelBasedValue amount) implements EnchantmentEntityEffect {
public static final MapCodec<CollapseEffect> CODEC = RecordCodecBuilder.mapCodec(instance ->
instance.group(
LevelBasedValue.CODEC.fieldOf("amount").forGetter(CollapseEffect::amount)
).apply(instance, CollapseEffect::new)
);
// Remind me to come back to this when I can be bothered to figure out tags.
private static ArrayList<Holder<MobEffect>> defaultViableEffects() {
ArrayList<Holder<MobEffect>> defaults = new ArrayList<>();
defaults.add(MobEffects.POISON);
defaults.add(MobEffects.WITHER);
return defaults;
}
@Override
public void apply(ServerLevel world, int level, EnchantedItemInUse context, Entity target, Vec3 pos) {
if(target instanceof LivingEntity enemy){
ArrayList<Holder<MobEffect>> viableEffects = defaultViableEffects();
for (Holder<MobEffect> viableEffect : viableEffects) {
if (enemy.hasEffect(viableEffect)) {
MobEffectInstance effect = enemy.getEffect(viableEffect);
// This is not the same way it's calculated in the Wither Skeleton file. This is because the Wither Skeleton version is wither-specific.
// Until we figure out the appropriate balance for these effects in a zero-immunity context (and I figure out a better way to simplify the maths), this should be easier to account for.
// It's also still reasonably interesting because it creates a choice between Crumble for Wither effect and poison splash potions,
// as well as punishing loading too many effects at once due to their local iframes.
// AKA: this minimises the odds that players start 1-tapping each other.
enemy.hurt(enemy.damageSources().magic(), (effect.getAmplifier() + 1) * effect.getDuration() * this.amount.calculate(level) * 0.05f);
enemy.invulnerableTime = 0;
}
}
}
}
@Override
public @NotNull MapCodec<? extends EnchantmentEntityEffect> codec() {
return CODEC;
}
}

View file

@ -4,7 +4,8 @@
"enchantment.mc_rebalance.clutch.desc": "Reduces fall damage and ender pearl teleportation damage.",
"enchantment.mc_rebalance.whallop.desc": "Massively increases knockback on shovels",
"enchantment.mc_rebalance.trowel.desc": "Makes shovels instamine valid blocks",
"enchantment.mc_rebalance.exploit.desc": "Has the effect of windup and massively reduces attack damage.\nAttacks do more damage against enemies holding a shield or totem.",
"enchantment.mc_rebalance.exploit.desc": "Winds up, massively reduces attack damage.\nAttacks do much more damage against enemies holding a shield or totem.",
"enchantment.mc_rebalance.windup.desc": "Replaces attack cooldown with item cooldown",
"enchantment.mc_rebalance.smack.desc": "Disables elytra on hit. Reduced windup."
"enchantment.mc_rebalance.smack.desc": "Disables elytra on hit. Reduced windup.",
"enchantment.mc_rebalance.collapse.desc": "Winds up slowly. Hits remove Poison and Wither effects, dealing their damage all at once."
}

View file

@ -28,6 +28,7 @@
"enchantment.mc_rebalance.whallop": "Whallop",
"enchantment.mc_rebalance.trowel": "Trowel",
"enchantment.mc_rebalance.exploit": "Exploit",
"enchantment.mc_rebalance.collapse": "Collapse",
"block.mc_rebalance.parched_ghast": "Parched Ghast",
"item.mc_rebalance.parched_ghast": "Parched Ghast"
}

View file

@ -0,0 +1,49 @@
{
"anvil_cost": 5,
"description": {
"translate": "enchantment.mc_rebalance.collapse"
},
"effects": {
"minecraft:attributes": [
{
"amount": 1024,
"attribute": "generic.attack_speed",
"id": "mc_rebalance:enchantment.windup",
"operation": "add_value"
}
],
"minecraft:post_attack": [
{
"affected": "victim",
"enchanted": "attacker",
"effect": {
"type": "mc_rebalance:windup",
"amount": 0.2
}
},
{
"affected": "victim",
"enchanted": "attacker",
"effect": {
"type": "mc_rebalance:collapse",
"amount": 1.0
}
}
]
},
"exclusive_set": "#mc_rebalance:exclusive_set/capability",
"max_cost": {
"base": 51,
"per_level_above_first": 10
},
"max_level": 1,
"min_cost": {
"base": 1,
"per_level_above_first": 10
},
"slots": [
"mainhand"
],
"supported_items": "#mc_rebalance:enchantable/hoe",
"weight": 10
}