Added Crumble (/marking)
This commit is contained in:
parent
a6e7f81322
commit
6b3f2f845e
|
|
@ -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.CrumbleEffect;
|
||||
import xyz.nearmisses.patience.mc_rebalance.enchant_effects.SmackEffect;
|
||||
import xyz.nearmisses.patience.mc_rebalance.enchant_effects.WindupEffect;
|
||||
|
||||
|
|
@ -22,4 +23,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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
package xyz.nearmisses.patience.mc_rebalance.enchant_effects;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
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.Objects;
|
||||
|
||||
public record CrumbleEffect(LevelBasedValue amount) implements EnchantmentEntityEffect {
|
||||
public static final MapCodec<CrumbleEffect> CODEC = RecordCodecBuilder.mapCodec(instance ->
|
||||
instance.group(
|
||||
LevelBasedValue.CODEC.fieldOf("amount").forGetter(CrumbleEffect::amount)
|
||||
).apply(instance, CrumbleEffect::new)
|
||||
);
|
||||
|
||||
@Override
|
||||
public void apply(ServerLevel world, int level, EnchantedItemInUse context, Entity target, Vec3 pos) {
|
||||
if (target instanceof Player player && player.getActiveEffects().iterator().hasNext()) {
|
||||
MobEffectInstance effect = player.getActiveEffects().iterator().next();
|
||||
player.getActiveEffects().remove(effect);
|
||||
player.getActiveEffects().add(new MobEffectInstance(MobEffects.WITHER,
|
||||
(int)(effect.getDuration() * this.amount.calculate(level)),
|
||||
(effect.getAmplifier() > 0 ? effect.getAmplifier() - 1 : 0) + (player.hasEffect(MobEffects.WITHER) ? Objects.requireNonNull(player.getEffect(MobEffects.WITHER)).getAmplifier() : 0)
|
||||
));
|
||||
//Optional<MobEffectInstance> effect = player.getActiveEffects().stream()
|
||||
// .skip((int) (player.getActiveEffects().size() * Math.random())).findFirst();
|
||||
//if(effect.isPresent() && effect.get().getEffect().value().getCategory().equals(MobEffectCategory.HARMFUL)) {
|
||||
//Object[] effects = player.getActiveEffects().toArray();
|
||||
//Object effect = effects[(int) (effects.length * Math.random())];
|
||||
//if(effect instanceof MobEffectInstance)
|
||||
//MCRebalance.LOGGER.info(effect.toString());
|
||||
|
||||
// player.addEffect(new MobEffectInstance(effect.get().getEffect(), (int)(effect.get().getDuration() * this.amount.calculate(level)), effect.get().getAmplifier()));
|
||||
|
||||
//(int)(20 * this.amount.calculate(level))
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull MapCodec<? extends EnchantmentEntityEffect> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
"effect.mc_rebalance.shattered": "Shattered",
|
||||
"enchantment.mc_rebalance.windup": "Windup",
|
||||
"enchantment.mc_rebalance.smack": "Smack",
|
||||
"enchantment.mc_rebalance.crumble": "Crumble",
|
||||
"block.mc_rebalance.parched_ghast": "Parched Ghast",
|
||||
"item.mc_rebalance.parched_ghast": "Parched Ghast"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"anvil_cost": 5,
|
||||
"description": {
|
||||
"translate": "enchantment.mc_rebalance.crumble"
|
||||
},
|
||||
"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:crumble",
|
||||
"amount": 1.2
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"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": "#minecraft:shovels",
|
||||
"weight": 10
|
||||
}
|
||||
Loading…
Reference in a new issue