Skip to content

Commit

Permalink
Some minor fixes (#446)
Browse files Browse the repository at this point in the history
* update neogradleto the new jarjar handling

* update codecs
  • Loading branch information
Minecraftschurli authored Apr 22, 2024
1 parent 92e6403 commit 82fc20a
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 45 deletions.
47 changes: 23 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import com.github.minecraftschurlimods.helperplugin.api
import com.github.minecraftschurlimods.helperplugin.localGradleProperty
import com.github.minecraftschurlimods.helperplugin.version
import com.github.minecraftschurlimods.helperplugin.moddependencies.ModDependency
import com.github.minecraftschurlimods.helperplugin.sourceSets

plugins {
idea
Expand All @@ -16,12 +17,6 @@ helper.withTestSourceSet()

val include: Configuration by configurations.creating {
isTransitive = false
dependencies.configureEach {
if (this is ExternalDependency) {
val strictVersion = this.versionConstraint.strictVersion
project.jarJar.ranged(this, strictVersion)
}
}
}
sourceSets.configureEach {
configurations.getByName(implementationConfigurationName).extendsFrom(include)
Expand Down Expand Up @@ -104,6 +99,7 @@ val embeddium = helper.dependencies.optional("embeddium")

dependencies {
implementation(helper.neoforge())
testImplementation(helper.testframework())

// jei for integration
val jeiApiDep = helper.minecraftVersion.zip(jei.version) { mc, version -> "mezz.jei:jei-${mc}-common-api:${version}" }
Expand All @@ -127,8 +123,7 @@ dependencies {

// geckolib for animations
val geckolibDep = helper.minecraftVersion.zip(geckolib.version) { mc, version -> "software.bernie.geckolib:geckolib-neoforge-${mc}:${version}" }
compileOnly(geckolibDep)
runtimeOnly(geckolibDep)
implementation(geckolibDep)
testRuntimeOnly(geckolibDep)
"dataRuntimeOnly"(geckolibDep)

Expand All @@ -151,29 +146,29 @@ dependencies {
}

// add internal libraries
val codecLibVersion = project.localGradleProperty("dependency.codeclib.version")
val codecLibDep = codecLibVersion.map { "com.github.minecraftschurlimods:codeclib:$it" }
include(codecLibDep)
val betterKeybindLibVersion = project.localGradleProperty("dependency.betterkeybindlib.version")
val betterKeybindLibDep = betterKeybindLibVersion.map { "com.github.minecraftschurlimods:betterkeybindlib:$it" }
include(betterKeybindLibDep)
val betterHudLibVersion = project.localGradleProperty("dependency.betterhudlib.version")
val betterHudLibDep = betterHudLibVersion.map { "com.github.minecraftschurlimods:betterhudlib:$it" }
include(betterHudLibDep)
val codeclib = project.localGradleProperty("dependency.codeclib.version").map { "com.github.minecraftschurlimods:codeclib:$it" }
jarJar(codeclib)
"apiCompileOnly"(codeclib)
implementation(codeclib)
testImplementation(codeclib)

val betterkeybindlib = project.localGradleProperty("dependency.betterkeybindlib.version").map { "com.github.minecraftschurlimods:betterkeybindlib:$it" }
jarJar(betterkeybindlib)
implementation(betterkeybindlib)

val betterhudlib = project.localGradleProperty("dependency.betterhudlib.version").map { "com.github.minecraftschurlimods:betterhudlib:$it" }
jarJar(betterhudlib)
implementation(betterhudlib)

val easyDatagenLibVersion = project.localGradleProperty("dependency.easydatagenlib.version")
val easyDatagenLibApiDep = easyDatagenLibVersion.map { "com.github.minecraftschurlimods:easydatagenlib:${it}:api" }
val easyDatagenLibDep = easyDatagenLibVersion.map { "com.github.minecraftschurlimods:easydatagenlib:${it}" }
"apiCompileOnly"(easyDatagenLibApiDep)
"dataImplementation"(easyDatagenLibDep)

testImplementation("net.neoforged:testframework:${helper.neoVersion.get()}")

val jetbrainsAnnotations = "org.jetbrains:annotations:23.0.0"
compileOnly(jetbrainsAnnotations)
"apiCompileOnly"(jetbrainsAnnotations)
testCompileOnly(jetbrainsAnnotations)
"dataCompileOnly"(jetbrainsAnnotations)
sourceSets.forEach {
it.compileOnlyConfigurationName("org.jetbrains:annotations:23.0.0")
}
}

helper.withCommonRuns()
Expand All @@ -196,6 +191,10 @@ tasks.javadoc {
source = sourceSets.api.get().allJava
}

tasks.jar {
exclude("com/github/minecraftschurlimods/arsmagicalegacy/api/data")
}

helper.publication.pom {
organization {
name = "Minecraftschurli Mods"
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pluginManagement {
plugins {
id("net.neoforged.gradle.userdev") version "7.0.80"
id("com.github.minecraftschurlimods.helperplugin") version "1.9"
id("net.neoforged.gradle.userdev") version "7.0.106"
id("com.github.minecraftschurlimods.helperplugin") version "1.11"
}
repositories {
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI;
import com.github.minecraftschurlimods.arsmagicalegacy.api.util.ITranslatable;
import com.github.minecraftschurlimods.codeclib.CodecHelper;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.advancements.critereon.MinMaxBounds;
Expand All @@ -14,6 +13,7 @@
import net.minecraft.resources.RegistryFileCodec;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ExtraCodecs;
import net.minecraft.world.entity.player.Player;

import java.util.Objects;
Expand All @@ -28,8 +28,8 @@ public record Ability(Affinity affinity, MinMaxBounds.Doubles bounds) implements
public static final ResourceKey<Registry<Ability>> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(ArsMagicaAPI.MOD_ID, ABILITY));

public static final Codec<Ability> DIRECT_CODEC = RecordCodecBuilder.create(inst -> inst.group(
CodecHelper.forRegistry(ArsMagicaAPI.get()::getAffinityRegistry).fieldOf("affinity").forGetter(Ability::affinity),
CodecHelper.DOUBLE_MIN_MAX_BOUNDS.fieldOf("bounds").forGetter(Ability::bounds)
ExtraCodecs.lazyInitializedCodec(() -> ArsMagicaAPI.get().getAffinityRegistry().byNameCodec()).fieldOf("affinity").forGetter(Ability::affinity),
MinMaxBounds.Doubles.CODEC.fieldOf("bounds").forGetter(Ability::bounds)
).apply(inst, Ability::new));

public static final Codec<Holder<Ability>> REFERENCE_CODEC = RegistryFileCodec.create(REGISTRY_KEY, DIRECT_CODEC);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.minecraftschurlimods.arsmagicalegacy.api.spell;

import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI;
import com.github.minecraftschurlimods.codeclib.CodecHelper;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.Codec;
import net.minecraft.util.ExtraCodecs;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.UnmodifiableView;

Expand All @@ -15,7 +15,7 @@
* A shape group is a part of a spell, which can be exchanged to change the casting, but not the effect of a spell.
*/
public record ShapeGroup(List<ISpellPart> parts, List<Pair<ISpellShape, List<ISpellModifier>>> shapesWithModifiers) {
public static final Codec<ShapeGroup> CODEC = CodecHelper.forRegistry(ArsMagicaAPI.get()::getSpellPartRegistry).listOf().xmap(ShapeGroup::of, ShapeGroup::parts);
public static final Codec<ShapeGroup> CODEC = ExtraCodecs.lazyInitializedCodec(() -> ArsMagicaAPI.get().getSpellPartRegistry().byNameCodec()).listOf().xmap(ShapeGroup::of, ShapeGroup::parts);
public static final ShapeGroup EMPTY = of(List.of());

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.minecraftschurlimods.arsmagicalegacy.api.spell;

import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI;
import com.github.minecraftschurlimods.codeclib.CodecHelper;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.Codec;
import net.minecraft.util.ExtraCodecs;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.UnmodifiableView;

Expand All @@ -13,7 +13,7 @@
import java.util.Objects;

public record SpellStack(List<ISpellPart> parts, List<Pair<ISpellPart, List<ISpellModifier>>> partsWithModifiers) {
public static final Codec<SpellStack> CODEC = CodecHelper.forRegistry(ArsMagicaAPI.get()::getSpellPartRegistry).listOf().xmap(SpellStack::of, SpellStack::parts);
public static final Codec<SpellStack> CODEC = ExtraCodecs.lazyInitializedCodec(() -> ArsMagicaAPI.get().getSpellPartRegistry().byNameCodec()).listOf().xmap(SpellStack::of, SpellStack::parts);
public static final SpellStack EMPTY = of(List.of());

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.minecraftschurlimods.arsmagicalegacy.common.ritual.requirement;

import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.RitualRequirement;
import com.github.minecraftschurlimods.codeclib.CodecHelper;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.advancements.critereon.MinMaxBounds;
Expand All @@ -10,7 +9,7 @@
import net.minecraft.world.entity.player.Player;

public record HeightRequirement(MinMaxBounds.Ints range) implements RitualRequirement {
public static final Codec<HeightRequirement> CODEC = RecordCodecBuilder.create(inst -> inst.group(CodecHelper.INT_MIN_MAX_BOUNDS.fieldOf("height").forGetter(HeightRequirement::range)).apply(inst, HeightRequirement::new));
public static final Codec<HeightRequirement> CODEC = RecordCodecBuilder.create(inst -> inst.group(MinMaxBounds.Ints.CODEC.fieldOf("height").forGetter(HeightRequirement::range)).apply(inst, HeightRequirement::new));

public static HeightRequirement any() {
return new HeightRequirement(MinMaxBounds.Ints.ANY);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.minecraftschurlimods.arsmagicalegacy.common.ritual.requirement;

import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.RitualRequirement;
import com.github.minecraftschurlimods.codeclib.CodecHelper;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.BlockPos;
Expand All @@ -19,7 +18,7 @@

public record ItemRequirement(List<Ingredient> ingredients, int radius) implements RitualRequirement {
public static final Codec<ItemRequirement> CODEC = RecordCodecBuilder.create(inst -> inst.group(
CodecHelper.INGREDIENT.listOf().fieldOf("ingredients").forGetter(ItemRequirement::ingredients),
Ingredient.CODEC_NONEMPTY.listOf().fieldOf("ingredients").forGetter(ItemRequirement::ingredients),
ExtraCodecs.NON_NEGATIVE_INT.fieldOf("radius").forGetter(ItemRequirement::radius)
).apply(inst, ItemRequirement::new));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI;
import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.RitualRequirement;
import com.github.minecraftschurlimods.codeclib.CodecHelper;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.advancements.critereon.MinMaxBounds;
Expand All @@ -11,7 +10,7 @@
import net.minecraft.world.entity.player.Player;

public record MagicLevelRequirement(MinMaxBounds.Ints bounds) implements RitualRequirement {
public static final Codec<MagicLevelRequirement> CODEC = RecordCodecBuilder.create(inst -> inst.group(CodecHelper.INT_MIN_MAX_BOUNDS.fieldOf("level").forGetter(MagicLevelRequirement::bounds)).apply(inst, MagicLevelRequirement::new));
public static final Codec<MagicLevelRequirement> CODEC = RecordCodecBuilder.create(inst -> inst.group(MinMaxBounds.Ints.CODEC.fieldOf("level").forGetter(MagicLevelRequirement::bounds)).apply(inst, MagicLevelRequirement::new));

@Override
public Codec<? extends RitualRequirement> codec() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.minecraftschurlimods.arsmagicalegacy.common.ritual.requirement;

import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.RitualRequirement;
import com.github.minecraftschurlimods.codeclib.CodecHelper;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.advancements.critereon.MinMaxBounds;
Expand All @@ -10,7 +9,7 @@
import net.minecraft.world.entity.player.Player;

public record MoonPhaseRequirement(MinMaxBounds.Ints phase) implements RitualRequirement {
public static final Codec<MoonPhaseRequirement> CODEC = RecordCodecBuilder.create(inst -> inst.group(CodecHelper.INT_MIN_MAX_BOUNDS.fieldOf("phase").forGetter(MoonPhaseRequirement::phase)).apply(inst, MoonPhaseRequirement::new));
public static final Codec<MoonPhaseRequirement> CODEC = RecordCodecBuilder.create(inst -> inst.group(MinMaxBounds.Ints.CODEC.fieldOf("phase").forGetter(MoonPhaseRequirement::phase)).apply(inst, MoonPhaseRequirement::new));

public static MoonPhaseRequirement any() {
return new MoonPhaseRequirement(MinMaxBounds.Ints.ANY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.Context;
import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.Ritual;
import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.RitualTrigger;
import com.github.minecraftschurlimods.codeclib.CodecHelper;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.advancements.critereon.EntityPredicate;
Expand All @@ -19,7 +18,7 @@
import java.util.Map;

public record EntityDeathTrigger(EntityPredicate predicate) implements RitualTrigger {
public static final Codec<EntityDeathTrigger> CODEC = RecordCodecBuilder.create(inst -> inst.group(CodecHelper.ENTITY_PREDICATE.fieldOf("entity").forGetter(EntityDeathTrigger::predicate)).apply(inst, EntityDeathTrigger::new));
public static final Codec<EntityDeathTrigger> CODEC = RecordCodecBuilder.create(inst -> inst.group(EntityPredicate.CODEC.fieldOf("entity").forGetter(EntityDeathTrigger::predicate)).apply(inst, EntityDeathTrigger::new));

@Override
public void register(Ritual ritual) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.Context;
import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.Ritual;
import com.github.minecraftschurlimods.arsmagicalegacy.api.ritual.RitualTrigger;
import com.github.minecraftschurlimods.codeclib.CodecHelper;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.advancements.critereon.EntityPredicate;
Expand All @@ -22,7 +21,7 @@
import java.util.Map;

public record EntitySummonTrigger(EntityPredicate predicate) implements RitualTrigger {
public static final Codec<EntitySummonTrigger> CODEC = RecordCodecBuilder.create(inst -> inst.group(CodecHelper.ENTITY_PREDICATE.fieldOf("entity").forGetter(EntitySummonTrigger::predicate)).apply(inst, EntitySummonTrigger::new));
public static final Codec<EntitySummonTrigger> CODEC = RecordCodecBuilder.create(inst -> inst.group(EntityPredicate.CODEC.fieldOf("entity").forGetter(EntitySummonTrigger::predicate)).apply(inst, EntitySummonTrigger::new));

public static EntitySummonTrigger simple(EntityType<?> entityType) {
return new EntitySummonTrigger(EntityPredicate.Builder.entity().of(entityType).build());
Expand Down

0 comments on commit 82fc20a

Please sign in to comment.