Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 565859e4a5 | |||
| d8721d51be | |||
| a65a3ed4f2 | |||
|
8a8a2724b1
|
|||
|
d70bacfb6a
|
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@@ -13,27 +13,18 @@ jobs:
|
||||
- name: checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: validate gradle wrapper
|
||||
uses: gradle/actions/wrapper-validation@v4
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- name: setup jdk
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'microsoft'
|
||||
- name: setup gradle cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
- name: make gradle wrapper executable
|
||||
run: chmod +x ./gradlew
|
||||
- name: build
|
||||
run: ./gradlew build
|
||||
- name: capture build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
@@ -1,4 +1,5 @@
|
||||
// 1.21.11 -999999999-01-01T00:00:00 More Spear Enchantments/ModEnchantmentGenerator
|
||||
f288993ccfd4a1a816cceedb4192d4250a1aee2e data/more_spear_enchants/enchantment/poisoning.json
|
||||
26301511d9703bb0aa4f568054802c48bd441405 data/more_spear_enchants/enchantment/thundering.json
|
||||
a05e3914c688a81cb95ed0afed46f7a5149bf228 data/more_spear_enchants/enchantment/withering.json
|
||||
9b422d06a47d72f3038701f2dee8ba2b69f0ae48 data/more_spear_enchants/enchantment/crippling.json
|
||||
5344ffb88ac84ee106698b33d2a371acb43e9e32 data/more_spear_enchants/enchantment/poisoning.json
|
||||
32bf712156f43dd8d319f624514d5a2988cd9ea9 data/more_spear_enchants/enchantment/thundering.json
|
||||
fae6996317beaa6871f6706360cd2f6b4e4d9ab7 data/more_spear_enchants/enchantment/withering.json
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"anvil_cost": 5,
|
||||
"description": {
|
||||
"translate": "enchantment.more_spear_enchants.crippling"
|
||||
},
|
||||
"effects": {
|
||||
"minecraft:post_attack": [
|
||||
{
|
||||
"affected": "victim",
|
||||
"effect": {
|
||||
"type": "more_spear_enchants:crippling",
|
||||
"duration": {
|
||||
"type": "minecraft:linear",
|
||||
"base": 2.0,
|
||||
"per_level_above_first": 1.0
|
||||
}
|
||||
},
|
||||
"enchanted": "attacker"
|
||||
}
|
||||
]
|
||||
},
|
||||
"max_cost": {
|
||||
"base": 1,
|
||||
"per_level_above_first": 15
|
||||
},
|
||||
"max_level": 3,
|
||||
"min_cost": {
|
||||
"base": 1,
|
||||
"per_level_above_first": 10
|
||||
},
|
||||
"slots": [
|
||||
"hand"
|
||||
],
|
||||
"supported_items": "#more_spear_enchants:spears",
|
||||
"weight": 10
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
{
|
||||
"affected": "victim",
|
||||
"effect": {
|
||||
"type": "more_spear_enchants:poisoning_effect",
|
||||
"type": "more_spear_enchants:poison",
|
||||
"duration": {
|
||||
"type": "minecraft:linear",
|
||||
"base": 3.0,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{
|
||||
"affected": "victim",
|
||||
"effect": {
|
||||
"type": "more_spear_enchants:lightning_effect",
|
||||
"type": "more_spear_enchants:lightning",
|
||||
"amount": {
|
||||
"type": "minecraft:linear",
|
||||
"base": 0.4,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{
|
||||
"affected": "victim",
|
||||
"effect": {
|
||||
"type": "more_spear_enchants:withering_effect",
|
||||
"type": "more_spear_enchants:withering",
|
||||
"duration": {
|
||||
"type": "minecraft:linear",
|
||||
"base": 2.0,
|
||||
|
||||
@@ -13,11 +13,9 @@ import net.minecraft.enchantment.effect.EnchantmentEntityEffect;
|
||||
|
||||
public class ModEnchantmentEffects {
|
||||
public static final RegistryKey<Enchantment> THUNDERING = of("thundering");
|
||||
public static MapCodec<LightningEnchantmentEffect> LIGHTNING_EFFECT = register("lightning_effect", LightningEnchantmentEffect.CODEC);
|
||||
public static final RegistryKey<Enchantment> WITHERING = of("withering");
|
||||
public static MapCodec<WitheringEnchantmentEffect> WITHERING_EFFECT = register("withering_effect", WitheringEnchantmentEffect.CODEC);
|
||||
public static final RegistryKey<Enchantment> POISONING = of("poisoning");
|
||||
public static MapCodec<PoisonEnchantmentEffect> POISONING_EFFECT = register("poisoning_effect", PoisonEnchantmentEffect.CODEC);
|
||||
public static final RegistryKey<Enchantment> CRIPPLING = of("crippling");
|
||||
|
||||
|
||||
private static RegistryKey<Enchantment> of(String path) {
|
||||
@@ -31,6 +29,11 @@ public class ModEnchantmentEffects {
|
||||
|
||||
public static void registerModEnchantmentEffects() {
|
||||
MoreSpearEnchantments.LOGGER.info("Registering EnchantmentEffects for " + MoreSpearEnchantments.MOD_ID);
|
||||
|
||||
register("lightning", LightningEnchantmentEffect.CODEC);
|
||||
register("poison", PoisonEnchantmentEffect.CODEC);
|
||||
register("withering", WitheringEnchantmentEffect.CODEC);
|
||||
register("crippling", CripplingEnchantmentEffect.CODEC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,25 @@ public class ModEnchantmentGenerator extends FabricDynamicRegistryProvider {
|
||||
new WitheringEnchantmentEffect(EnchantmentLevelBasedValue.linear(2.0f, 1.0f)) // 2s base, +1s per level
|
||||
)
|
||||
);
|
||||
// Our new enchantment, "Crippling."
|
||||
register(entries, ModEnchantmentEffects.CRIPPLING, Enchantment.builder(
|
||||
Enchantment.definition(
|
||||
registries.getOrThrow(RegistryKeys.ITEM).getOrThrow(ModTags.Items.SPEARS),
|
||||
10,
|
||||
3,
|
||||
Enchantment.leveledCost(1, 10),
|
||||
Enchantment.leveledCost(1, 15),
|
||||
5,
|
||||
AttributeModifierSlot.HAND
|
||||
)
|
||||
)
|
||||
.addEffect(
|
||||
EnchantmentEffectComponentTypes.POST_ATTACK,
|
||||
EnchantmentEffectTarget.ATTACKER,
|
||||
EnchantmentEffectTarget.VICTIM,
|
||||
new CripplingEnchantmentEffect(EnchantmentLevelBasedValue.linear(2.0f, 1.0f)) // 2s base, +1s per leve
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private void register(Entries entries, RegistryKey<Enchantment> key, Enchantment.Builder builder, ResourceCondition... resourceConditions) {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package dev.sillyangel.more_spear_enchantments.enchantment.effect;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.enchantment.EnchantmentEffectContext;
|
||||
import net.minecraft.enchantment.EnchantmentLevelBasedValue;
|
||||
import net.minecraft.enchantment.effect.EnchantmentEntityEffect;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public record CripplingEnchantmentEffect(EnchantmentLevelBasedValue duration) implements EnchantmentEntityEffect {
|
||||
public static final MapCodec<CripplingEnchantmentEffect> CODEC = RecordCodecBuilder.mapCodec(instance ->
|
||||
instance.group(
|
||||
EnchantmentLevelBasedValue.CODEC.fieldOf("duration").forGetter(CripplingEnchantmentEffect::duration)
|
||||
).apply(instance, CripplingEnchantmentEffect::new)
|
||||
);
|
||||
|
||||
@Override
|
||||
public void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity target, Vec3d pos) {
|
||||
if (target instanceof LivingEntity victim) {
|
||||
if (context.owner() != null && context.owner() instanceof PlayerEntity player) {
|
||||
int Duration = (int) (this.duration.getValue(level) * 50); // Convert to ticks
|
||||
int slownessAmplifier = level - 1; // Level 1 = Slowness 0, Level 2 = Slowness I, Level 3 = Slowness II
|
||||
int weaknessAmplifier = level - 1; // Level 1 = Weakness 0, Level 2 = Weakness I, Level 3 = Weakness II
|
||||
victim.addStatusEffect(new StatusEffectInstance(
|
||||
StatusEffects.SLOWNESS,
|
||||
Duration,
|
||||
slownessAmplifier,
|
||||
false,
|
||||
true
|
||||
));
|
||||
victim.addStatusEffect(new StatusEffectInstance(
|
||||
StatusEffects.WEAKNESS,
|
||||
Duration,
|
||||
weaknessAmplifier,
|
||||
false,
|
||||
true
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapCodec<? extends EnchantmentEntityEffect> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user