Skip to content

Commit

Permalink
swap config to QuiltConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Platymemo committed Jan 15, 2024
1 parent a7ea75e commit 2fd521d
Show file tree
Hide file tree
Showing 21 changed files with 118 additions and 184 deletions.
11 changes: 0 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@ dependencies {

// REI integration
modImplementation "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}"

// We have to manually override the version of Architectury used by REI to run on Quilt
// modLocalRuntime "dev.architectury:architectury-fabric:${project.architectury_override_version}"

// ClothConfig
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}") {
exclude(group: "net.fabricmc.fabric-api")
}

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}

loom {
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ org.gradle.parallel = true
archives_base_name=alaskanativecraft

# Dependencies
clothconfig_version=11.1.106
modmenu_version=7.2.1
rei_version=12.0.652
# architectury_override_version=6.2.46
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# The latest versions are available at https://lambdaurora.dev/tools/import_quilt.html
minecraft = "1.20.1"
quilt_mappings = "1.20.1+build.23"
quilt_loader = "0.19.4"
quilt_loader = "0.21.0"

quilted_fabric_api = "7.1.2+0.87.0-1.20.1"
quilted_fabric_api = "7.3.1+0.89.3-1.20.1"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.platymemo.alaskanativecraft;

import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks;
import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.entity.AlaskaEntities;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import com.github.platymemo.alaskanativecraft.loot.function.AlaskaLootFunctionTypes;
Expand All @@ -10,10 +11,12 @@
import com.github.platymemo.alaskanativecraft.worldgen.feature.AlaskaFeatures;

import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.loader.api.config.v2.QuiltConfig;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;

public class AlaskaNativeCraft implements ModInitializer {
public static final String MOD_ID = "alaskanativecraft";
public static final AlaskaConfig CONFIG = QuiltConfig.create(MOD_ID, "config", AlaskaConfig.class);

@Override
public void onInitialize(ModContainer container) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,85 +1,80 @@
package com.github.platymemo.alaskanativecraft.config;

import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
import me.shedaniel.autoconfig.annotation.ConfigEntry;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import org.quiltmc.config.api.ReflectiveConfig;
import org.quiltmc.config.api.annotations.Comment;
import org.quiltmc.config.api.annotations.FloatRange;
import org.quiltmc.config.api.values.TrackedValue;

@Config(name = AlaskaNativeCraft.MOD_ID)
public class AlaskaConfig implements ConfigData {
@ConfigEntry.Gui.Excluded
private static boolean registered = false;
@ConfigEntry.Gui.TransitiveObject
@ConfigEntry.Category("spawning")
public SpawnOptions spawning = new SpawnOptions();
@ConfigEntry.Gui.TransitiveObject
@ConfigEntry.Category("generation")
public GenerationOptions generation = new GenerationOptions();
public class AlaskaConfig extends ReflectiveConfig {
@Comment("Spawning Options")
public final SpawnOptions spawning = new SpawnOptions();
@Comment("Generation Options")
public final GenerationOptions generation = new GenerationOptions();

public boolean snowballConversion = false;
public boolean mooseEatBark = true;
@ConfigEntry.Gui.CollapsibleObject
public SealFishing sealFishing = new SealFishing();
@ConfigEntry.Gui.RequiresRestart
public boolean snowOverhaul = true;
@ConfigEntry.Gui.RequiresRestart
public float snowSlow = 0.1f;
@Comment("Do Snowballs Convert Birds")
public final TrackedValue<Boolean> snowballConversion = this.value(false);
@Comment("Do Moose Strip Logs")
public final TrackedValue<Boolean> mooseEatBark = this.value(true);
@Comment("Seal Fish Hunting Mechanics")
public final SealFishing sealFishing = new SealFishing();
@Comment("Enables Snow Overhaul")
public final TrackedValue<Boolean> snowOverhaul = this.value(true);
@Comment("How Much Snow Slows Entities")
@FloatRange(min = 0.0f, max = 1.0f)
public final TrackedValue<Float> snowSlow = this.value(0.1f);

public static synchronized AlaskaConfig getConfig() {
if (!registered) {
AutoConfig.register(AlaskaConfig.class, GsonConfigSerializer::new);
registered = true;
}

return AutoConfig.getConfigHolder(AlaskaConfig.class).getConfig();
}

public static class SealFishing {
public boolean sealsHuntFish = true;
@ConfigEntry.Gui.Tooltip(count = 2)
public boolean sealsEatHuntedFish = true;
@ConfigEntry.Gui.Tooltip(count = 2)
public boolean sealsBreedFromHuntedFish = false;
public static class SealFishing extends Section {
@Comment("Do Seals Hunt Fish")
public final TrackedValue<Boolean> sealsHuntFish = this.value(true);
@Comment("Do Seals Eat Hunted Fish")
@Comment("WARNING:")
@Comment("Disabling this may cause lag from fish drops.")
public final TrackedValue<Boolean> sealsEatHuntedFish = this.value(true);
@Comment("Do Seals Breed From Eating Hunted Fish")
@Comment("WARNING:")
@Comment("Enabling this may cause seal populations to drastically rise.")
public final TrackedValue<Boolean> sealsBreedFromHuntedFish = this.value(false);
@Comment("The chance a seal breeds whenever it hunts fish")
@FloatRange(min = 0.0f, max = 1.0f)
public final TrackedValue<Float> sealsBreedChance = this.value(0.1f);
}

public static class SpawnOptions {
@ConfigEntry.Gui.CollapsibleObject
public SpawnSettings sealOceanSettings = new SpawnSettings(5, 1, 4);
@ConfigEntry.Gui.CollapsibleObject
public SpawnSettings mooseSettings = new SpawnSettings(2, 1, 3);
@ConfigEntry.Gui.CollapsibleObject
public SpawnSettings ptarmiganSettings = new SpawnSettings(5, 2, 5);
public static class SpawnOptions extends Section {
@Comment("Seal Spawning Options")
public final SpawnSettings sealSettings = new SpawnSettings(5, 1, 4);
@Comment("Moose Spawning Options")
public final SpawnSettings mooseSettings = new SpawnSettings(2, 1, 3);
@Comment("Ptarmigan Spawning Options")
public final SpawnSettings ptarmiganSettings = new SpawnSettings(5, 2, 5);

public static class SpawnSettings {
@ConfigEntry.Gui.RequiresRestart
public int weight;
@ConfigEntry.Gui.RequiresRestart
public int minGroupSize;
@ConfigEntry.Gui.RequiresRestart
public int maxGroupSize;
public static class SpawnSettings extends Section {
@Comment("How Often the Spawned Mob will be This One")
public final TrackedValue<Integer> weight;
@Comment("The Minimum Number of This Mob to Spawn at Once")
public final TrackedValue<Integer> minGroupSize;
@Comment("The Maximum Number of This Mob to Spawn at Once")
public final TrackedValue<Integer> maxGroupSize;

public SpawnSettings(int weight, int minGroupSize, int maxGroupSize) {
this.weight = weight;
this.minGroupSize = minGroupSize;
this.maxGroupSize = maxGroupSize;
this.weight = this.value(weight);
this.minGroupSize = this.value(minGroupSize);
this.maxGroupSize = this.value(maxGroupSize);
}
}
}

public static class GenerationOptions {
@ConfigEntry.Gui.RequiresRestart
public boolean genDriftwood = true;
@ConfigEntry.Gui.RequiresRestart
public boolean genBlueberry = true;
@ConfigEntry.Gui.RequiresRestart
public boolean genCloudberry = true;
@ConfigEntry.Gui.RequiresRestart
public boolean genRaspberry = true;
@ConfigEntry.Gui.RequiresRestart
public boolean genSalmonberry = true;
@ConfigEntry.Gui.RequiresRestart
public boolean genLabradorTea = true;
public static class GenerationOptions extends Section {
@Comment("Generate Driftwood")
public final TrackedValue<Boolean> genDriftwood = this.value(true);
@Comment("Generate Blueberries")
public final TrackedValue<Boolean> genBlueberry = this.value(true);
@Comment("Generate Low-Bush Salmonberries")
public final TrackedValue<Boolean> genCloudberry = this.value(true);
@Comment("Generate Raspberries")
public final TrackedValue<Boolean> genRaspberry = this.value(true);
@Comment("Generate Salmonberries")
public final TrackedValue<Boolean> genSalmonberry = this.value(true);
@Comment("Generate Labrador Tea Flowers")
public final TrackedValue<Boolean> genLabradorTea = this.value(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Map;

import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.config.AlaskaConfig.SpawnOptions.SpawnSettings;
import com.github.platymemo.alaskanativecraft.entity.damage.AlaskaDamageTypes;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import com.github.platymemo.alaskanativecraft.item.HarpoonItem;
Expand Down Expand Up @@ -68,22 +68,29 @@ private static void initAttributes() {
}

private static void initSpawns() {
AlaskaConfig.SpawnOptions spawnOptions = AlaskaConfig.getConfig().spawning;
SpawnSettings sealSettings = AlaskaNativeCraft.CONFIG.spawning.sealSettings;
BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_SEAL),
SpawnGroup.WATER_CREATURE, SEAL,
spawnOptions.sealOceanSettings.weight,
spawnOptions.sealOceanSettings.minGroupSize,
spawnOptions.sealOceanSettings.maxGroupSize);
sealSettings.weight.value(),
sealSettings.minGroupSize.value(),
sealSettings.maxGroupSize.value()
);

SpawnSettings mooseSettings = AlaskaNativeCraft.CONFIG.spawning.mooseSettings;
BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_MOOSE),
SpawnGroup.CREATURE, MOOSE,
spawnOptions.mooseSettings.weight,
spawnOptions.mooseSettings.minGroupSize,
spawnOptions.mooseSettings.maxGroupSize);
mooseSettings.weight.value(),
mooseSettings.minGroupSize.value(),
mooseSettings.maxGroupSize.value()
);

SpawnSettings ptarmiganSettings = AlaskaNativeCraft.CONFIG.spawning.ptarmiganSettings;
BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_PTARMIGAN),
SpawnGroup.AMBIENT, PTARMIGAN,
spawnOptions.ptarmiganSettings.weight,
spawnOptions.ptarmiganSettings.minGroupSize,
spawnOptions.ptarmiganSettings.maxGroupSize);
ptarmiganSettings.weight.value(),
ptarmiganSettings.minGroupSize.value(),
ptarmiganSettings.maxGroupSize.value()
);
}

private static <E extends EntityType<?>> E add(String name, E type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.EnumSet;

import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.entity.ai.goal.AdultMeleeAttackGoal;
import com.github.platymemo.alaskanativecraft.entity.ai.goal.ChildEscapeDangerGoal;
import com.github.platymemo.alaskanativecraft.mixin.AxeItemAccessor;
Expand Down Expand Up @@ -181,7 +181,7 @@ protected Vec3d locateLogPos() {

@Override
public boolean canStart() {
if (!AlaskaConfig.getConfig().mooseEatBark) {
if (!AlaskaNativeCraft.CONFIG.mooseEatBark.value()) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.platymemo.alaskanativecraft.entity;

import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.entity.ai.goal.GroundFoodMateGoal;
import com.github.platymemo.alaskanativecraft.sound.AlaskaSoundEvents;
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
Expand Down Expand Up @@ -298,7 +298,7 @@ static class HuntFishGoal extends MeleeAttackGoal {

@Override
public boolean canStart() {
if (!AlaskaConfig.getConfig().sealFishing.sealsHuntFish) {
if (!AlaskaNativeCraft.CONFIG.sealFishing.sealsHuntFish.value()) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.EnumSet;
import java.util.List;

import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.entity.SealEntity;
import org.jetbrains.annotations.Nullable;

Expand All @@ -28,7 +28,7 @@ public GroundFoodMateGoal(AnimalEntity animal) {

@Override
public boolean canStart() {
if (this.animal instanceof SealEntity && !AlaskaConfig.getConfig().sealFishing.sealsEatHuntedFish) {
if (this.animal instanceof SealEntity && !AlaskaNativeCraft.CONFIG.sealFishing.sealsEatHuntedFish.value()) {
return false;
}

Expand Down Expand Up @@ -82,7 +82,7 @@ public void tick() {
private void feed() {
if (this.foodEntity.getStack().getCount() > 0) {
this.foodEntity.getStack().decrement(1);
if (!(this.animal instanceof SealEntity) || AlaskaConfig.getConfig().sealFishing.sealsBreedFromHuntedFish) {
if (AlaskaNativeCraft.CONFIG.sealFishing.sealsBreedFromHuntedFish.value() && this.animal.getRandom().nextFloat() < AlaskaNativeCraft.CONFIG.sealFishing.sealsBreedChance.value()) {
this.animal.lovePlayer(null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Map;
import java.util.UUID;

import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.entity.effect.AlaskaEffects;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import com.github.platymemo.alaskanativecraft.tags.AlaskaTags;
Expand Down Expand Up @@ -91,7 +91,7 @@ protected LivingEntityMixin(EntityType<?> type, World world) {
private void anc$getVelocityWithSnowBoost(CallbackInfoReturnable<Float> cir) {
if (this.anc$isOnSnowshoeSpeedBlock()
&& (this.getEquippedStack(EquipmentSlot.FEET).isOf(AlaskaItems.SNOWSHOES)
|| (AlaskaConfig.getConfig().snowOverhaul
|| (AlaskaNativeCraft.CONFIG.snowOverhaul.value()
&& this.getEquippedStack(EquipmentSlot.FEET).isOf(AlaskaItems.MUKLUKS)))) {
cir.setReturnValue(1.0f);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.platymemo.alaskanativecraft.mixin;

import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.item.AlaskaItems;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -25,7 +25,7 @@ public class PowderSnowBlockMixin {

@Redirect(method = "onEntityCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setMovementMultiplier(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/Vec3d;)V"))
private void anc$dontSlowWithMukluks(Entity entity, BlockState state, Vec3d vec3d) {
if (!(entity instanceof LivingEntity) || (AlaskaConfig.getConfig().snowOverhaul && ((LivingEntity) entity).getEquippedStack(EquipmentSlot.FEET).isOf(AlaskaItems.MUKLUKS))) {
if (!(entity instanceof LivingEntity) || (AlaskaNativeCraft.CONFIG.snowOverhaul.value() && ((LivingEntity) entity).getEquippedStack(EquipmentSlot.FEET).isOf(AlaskaItems.MUKLUKS))) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.platymemo.alaskanativecraft.mixin;

import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft;
import com.github.platymemo.alaskanativecraft.config.AlaskaConfig;
import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -23,7 +22,7 @@
public class SnowballEntityMixin {
@Inject(at = @At("TAIL"), method = "onEntityHit")
private void makeThatBirbAPtarmigan(EntityHitResult entityHitResult, CallbackInfo ci) {
if (AlaskaConfig.getConfig().snowballConversion) {
if (AlaskaNativeCraft.CONFIG.snowballConversion.value()) {
Entity entity = entityHitResult.getEntity();
if ((entity instanceof ParrotEntity && !(entity instanceof PtarmiganEntity)) || entity instanceof ChickenEntity) {
Identifier ptarmigan = new Identifier(AlaskaNativeCraft.MOD_ID, "ptarmigan");
Expand Down
Loading

0 comments on commit 2fd521d

Please sign in to comment.