Skip to content

Commit

Permalink
Added dropdown subcategories to configscreen and reorganized en_us la…
Browse files Browse the repository at this point in the history
…ngfile
  • Loading branch information
Flatkat committed Jan 26, 2025
1 parent b913623 commit 7739a81
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 87 deletions.
87 changes: 61 additions & 26 deletions src/main/java/dev/symphony/harmony/config/HarmonyConfigModel.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package dev.symphony.harmony.config;

import dev.symphony.harmony.Harmony;
import io.wispforest.owo.config.annotation.Config;
import io.wispforest.owo.config.annotation.Modmenu;
import io.wispforest.owo.config.annotation.RangeConstraint;
import io.wispforest.owo.config.annotation.SectionHeader;
import io.wispforest.owo.config.annotation.*;


import java.util.concurrent.TimeUnit;
Expand All @@ -15,58 +12,96 @@
public class HarmonyConfigModel {

// Transportation 🏳️‍⚧️
@SectionHeader("Transportation")
public boolean liquidsDeactivateElytra = true;
@SectionHeader("Trans")
public boolean exitVehicleOnDamage = true;
@HarmonyConfigCondition.ResourceConfigName(config_name = "recipe/saddle") public boolean saddleRecipe = true;
public boolean horseArmorPreventsBucking = true;
public boolean enderPearlsTeleportVehicles = true;
public boolean enderPearlsDamageVehicles = true;
public float furnaceMinecartSpeed = 1f;
public float furnaceMinecartSpeedInWater = 1f;
@RangeConstraint(min = 0f, max = 1f)
public float riptideAccelerationOnWater = 0.1f;
public boolean riptideCooldown = true;
public int riptideTimeMultiplier = 5;
public boolean reduceRiptideWaterDrag = true;

@Nest @Expanded public TransElytraCat transElytraCat = new TransElytraCat();
public static class TransElytraCat {
public boolean liquidsDeactivateElytra = true;
}

@Nest @Expanded public TransMinecartCat transMinecartCat = new TransMinecartCat();
public static class TransMinecartCat {
public float furnaceMinecartSpeed = 1f;
public float furnaceMinecartSpeedInWater = 1f;
}

@Nest @Expanded public TransSaddledCat transSaddledCat = new TransSaddledCat();
public static class TransSaddledCat {
@HarmonyConfigCondition.ResourceConfigName(config_name = "recipe/saddle") public boolean saddleRecipe = true;
public boolean horseArmorPreventsBucking = true;
public boolean enderPearlsTeleportVehicles = true;
public boolean enderPearlsDamageVehicles = true;
}

@Nest @Expanded public TransRiptideCat transRiptideCat = new TransRiptideCat();
public static class TransRiptideCat {
@RangeConstraint(min = 0f, max = 1f) public float riptideAccelerationOnWater = 0.1f;
public boolean riptideCooldown = true;
public int riptideTimeMultiplier = 5;
public boolean reduceRiptideWaterDrag = true;
}




// Food
@SectionHeader("Food")
public int stewStackSize = 16;
public int glowBerryEffect = 10;



// Building
@SectionHeader("Building")
public boolean armorStandStickArms = true;
public int armorStandSticks = 1;



// Redstone
@SectionHeader("Redstone")
public boolean oneTickCopperBulbDelay = true;
public boolean removeRedstoneLampDelay = true;



// Potions
@SectionHeader("Potions")
public boolean beaconsAffectTamedMobs = true;



// Combat
@SectionHeader("Combat")
public boolean tridentsReturnFromVoid = true;
public boolean changeItemDespawnTime = true;
private static final int ONE_HOUR = 60 * 60;

@RangeConstraint(min = 0, max = ONE_HOUR)
public int
itemDespawnTimeEasy = (int) TimeUnit.MINUTES.toSeconds(20),
itemDespawnTimeNormal = (int) TimeUnit.MINUTES.toSeconds(10),
itemDespawnTimeHard = (int) TimeUnit.MINUTES.toSeconds(5);
@Nest public ItemDespawnTimeCat itemDespawnTimeCat = new ItemDespawnTimeCat();
public static class ItemDespawnTimeCat {
private static final int ONE_HOUR = 60 * 60;
@RangeConstraint(min = 0, max = ONE_HOUR) public int
itemDespawnTimeEasy = (int) TimeUnit.MINUTES.toSeconds(20),
itemDespawnTimeNormal = (int) TimeUnit.MINUTES.toSeconds(10),
itemDespawnTimeHard = (int) TimeUnit.MINUTES.toSeconds(5);
}




// Mobs
@SectionHeader("Mobs")
public boolean wolvesGrowlAtMonsters = true;
public boolean mismatchedMobArmor = true;
public boolean permissiveParrotPerching = true;
public boolean husksDropSandOnConvert = true;

@Nest @Expanded public MobsHostileCat mobsHostileCat = new MobsHostileCat();
public static class MobsHostileCat {
public boolean mismatchedMobArmor = true;
}

@Nest @Expanded public MobsPetsCat mobsPetsCat = new MobsPetsCat();
public static class MobsPetsCat {
public boolean permissiveParrotPerching = true;
public boolean wolvesGrowlAtMonsters = true;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ private int modifyDespawnTime(int constant) {


int time = 20 * switch (this.getWorld().getDifficulty()) {
case PEACEFUL, EASY -> Harmony.CONFIG.itemDespawnTimeEasy();
case NORMAL -> Harmony.CONFIG.itemDespawnTimeNormal();
case HARD -> Harmony.CONFIG.itemDespawnTimeHard();
case PEACEFUL, EASY -> Harmony.CONFIG.itemDespawnTimeCat.itemDespawnTimeEasy();
case NORMAL -> Harmony.CONFIG.itemDespawnTimeCat.itemDespawnTimeNormal();
case HARD -> Harmony.CONFIG.itemDespawnTimeCat.itemDespawnTimeHard();
};

return time == 0 ? NEVER_DESPAWN_AGE : time;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public MobEntityMixin(EntityType<?> type, World world) {

@WrapOperation(method = "initEquipment", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/MobEntity;getEquipmentForSlot(Lnet/minecraft/entity/EquipmentSlot;I)Lnet/minecraft/item/Item;"))
private Item repeatRandomForEachSlot(EquipmentSlot equipmentSlot, int equipmentLevel, Operation<Item> original, @Local(argsOnly = true) Random random) {
if (!Harmony.CONFIG.mismatchedMobArmor())
if (!Harmony.CONFIG.mobsHostileCat.mismatchedMobArmor())
return original.call(equipmentSlot, equipmentLevel);

int level = random.nextInt(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class PlayerEntityMixin extends EntityImplMixin {

@ModifyExpressionValue(method = "tickMovement", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;updateShoulderEntity(Lnet/minecraft/nbt/NbtCompound;)V", ordinal = 0)), at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;fallDistance:F"))
private float removeFallCheck(float original) {
if (!Harmony.CONFIG.permissiveParrotPerching())
if (!Harmony.CONFIG.mobsPetsCat.permissiveParrotPerching())
return original;

return Integer.MIN_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SitOnOwnerShoulderGoalMixin {

@ModifyExpressionValue(method = "canStart", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerAbilities;flying:Z"))
private boolean modifyIsFlying(boolean original, @Local ServerPlayerEntity serverPlayerEntity) {
if (!Harmony.CONFIG.permissiveParrotPerching())
if (!Harmony.CONFIG.mobsPetsCat.permissiveParrotPerching())
return original;

return serverPlayerEntity.isGliding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected WolfEntityMixin(EntityType<? extends TameableEntity> entityType, World

@ModifyExpressionValue(method = "getAmbientSound", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;hasAngerTime()Z"))
private boolean shouldGrowl(boolean original) {
return original || (Harmony.CONFIG.wolvesGrowlAtMonsters() && this.isTamed() && !this.getNearbyMonsters().isEmpty());
return original || (Harmony.CONFIG.mobsPetsCat.wolvesGrowlAtMonsters() && this.isTamed() && !this.getNearbyMonsters().isEmpty());
}

@Unique
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public LiquidsDeactivateElytra(EntityType<?> type, World world) {

@ModifyExpressionValue(method = "canGlide", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;hasStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Z"))
private boolean cancelElytraInLiquid(boolean original) {
if(Harmony.CONFIG.liquidsDeactivateElytra()){
if(Harmony.CONFIG.transElytraCat.liquidsDeactivateElytra()){
if (original || this.isSubmergedInWater() || this.isInLava()) {
setSprinting(true);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public HorseArmorPreventsBucking(Inventory armorinventory) {

@ModifyExpressionValue(method = "updateAnger", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/AbstractHorseEntity;shouldAmbientStand()Z"))
private boolean rejectAngryWhenDrip(boolean original) {
if(Harmony.CONFIG.horseArmorPreventsBucking()){
if(Harmony.CONFIG.transSaddledCat.horseArmorPreventsBucking()){
if(FabricLoader.getInstance().isModLoaded("melody") && preventBuckingChance.get(Registries.ITEM.get(Identifier.of("melody:netherite_horse_armor"))) == null) {
// Temporary solution until we move this to a better, configurable system
// This is inside rejectAngryWhenDrip because if not it gets called too early, so it cant detect Melody nor is the armor item registered yet, so it doesnt work.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class FurnaceMinecartEntityMixin extends AbstractMinecartEntity {
@Inject(method = "getMaxSpeed",at= @At("RETURN"), cancellable = true)
void ChangeFurnaceMinecartSpeed(ServerWorld world, CallbackInfoReturnable<Double> cir){
if(super.isTouchingWater())
cir.setReturnValue(super.getMaxSpeed(world) * Harmony.CONFIG.furnaceMinecartSpeedInWater());
cir.setReturnValue(super.getMaxSpeed(world) * Harmony.CONFIG.transMinecartCat.furnaceMinecartSpeedInWater());
else
cir.setReturnValue(super.getMaxSpeed(world) * Harmony.CONFIG.furnaceMinecartSpeed());
cir.setReturnValue(super.getMaxSpeed(world) * Harmony.CONFIG.transMinecartCat.furnaceMinecartSpeed());
}

@Inject(method = "interact",at= @At(value = "HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EnderPearlsDontDismount {

@WrapOperation(method = "onCollision",at= @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;teleportTo(Lnet/minecraft/world/TeleportTarget;)Lnet/minecraft/server/network/ServerPlayerEntity;"))
ServerPlayerEntity TeleportMount(ServerPlayerEntity instance, TeleportTarget teleportTarget, Operation<ServerPlayerEntity> original){
if(instance.hasVehicle() && Harmony.CONFIG.enderPearlsTeleportVehicles()){
if(instance.hasVehicle() && Harmony.CONFIG.transSaddledCat.enderPearlsTeleportVehicles()){
// Find the mount that isn't riding any other mount and teleport it instead of the player
Entity vehicle = instance.getVehicle();
while(vehicle.hasVehicle()) {
Expand All @@ -31,7 +31,7 @@ ServerPlayerEntity TeleportMount(ServerPlayerEntity instance, TeleportTarget tel

@WrapOperation(method = "onCollision",at= @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;damage(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/damage/DamageSource;F)Z"))
boolean DamageAfterTeleportation(ServerPlayerEntity instance, ServerWorld world, DamageSource source, float amount, Operation<Boolean> original){
if(instance.hasVehicle() && Harmony.CONFIG.enderPearlsDamageVehicles() && Harmony.CONFIG.enderPearlsTeleportVehicles()) {
if(instance.hasVehicle() && Harmony.CONFIG.transSaddledCat.enderPearlsDamageVehicles() && Harmony.CONFIG.transSaddledCat.enderPearlsTeleportVehicles()) {
//The damage each entity takes from teleporting is halved to be consistent with horses taking fall damage
amount /= 2;
//Find the mount that isn't riding any other mount
Expand All @@ -52,6 +52,6 @@ boolean DamageAfterTeleportation(ServerPlayerEntity instance, ServerWorld world,

//Stop the player from leaving their vehicle when using an Ender Pearl
@WrapOperation(method = "onCollision",at= @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;detach()V"))
void StopDetaching(Entity instance, Operation<Void> original){if(!Harmony.CONFIG.enderPearlsTeleportVehicles()) {original.call(instance);}}
void StopDetaching(Entity instance, Operation<Void> original){if(!Harmony.CONFIG.transSaddledCat.enderPearlsTeleportVehicles()) {original.call(instance);}}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Mixin(LivingEntity.class)
public abstract class RiptideAcceleration extends Entity {

@Unique private static final float MODIFIER = Harmony.CONFIG.riptideAccelerationOnWater();
@Unique private static final float MODIFIER = Harmony.CONFIG.transRiptideCat.riptideAccelerationOnWater();
@Unique private static final float DEG = (float) (Math.PI / 180F);

@Shadow public abstract void setSprinting(boolean sprinting);
Expand All @@ -34,7 +34,7 @@ public RiptideAcceleration(EntityType<?> type, World world) {
)
)
private void accelerateWhenRiptide(CallbackInfo ci) {
if (Harmony.CONFIG.riptideAccelerationOnWater() != 0) {
if (Harmony.CONFIG.transRiptideCat.riptideAccelerationOnWater() != 0) {
if (!this.isTouchingWater()) return;
float f = getYaw();
float g = getPitch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public RiptideCooldown(Settings settings) {

@Inject(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;useRiptide(IFLnet/minecraft/item/ItemStack;)V"))
public void addCooldown(ItemStack stack, World world, LivingEntity user, int remainingUseTicks, CallbackInfoReturnable<Boolean> cir) {
if(Harmony.CONFIG.riptideCooldown()){
if(Harmony.CONFIG.transRiptideCat.riptideCooldown()){
RegistryEntry<Enchantment> entry = stack.getEnchantments().getEnchantments().stream()
.filter(act -> act.matchesId(Identifier.ofVanilla("riptide")))
.findFirst()
.orElse(null);
int level = EnchantmentHelper.getLevel(entry, stack);

if(user instanceof PlayerEntity && level > 0){
((PlayerEntity) user).getItemCooldownManager().set(this.getDefaultStack(), 15+level*Harmony.CONFIG.riptideTimeMultiplier());
((PlayerEntity) user).getItemCooldownManager().set(this.getDefaultStack(), 15+level*Harmony.CONFIG.transRiptideCat.riptideTimeMultiplier());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public RiptideReducedDrag(EntityType<?> type, World world) {
)
)
private boolean boostWhenRiptide(boolean original) {
if (Harmony.CONFIG.reduceRiptideWaterDrag()) {
if (Harmony.CONFIG.transRiptideCat.reduceRiptideWaterDrag()) {
return original || this.riptideTicks > 0;
}
return original;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public VariableRiptideDuration(net.minecraft.item.Item.Settings settings) {
@ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;useRiptide(IFLnet/minecraft/item/ItemStack;)V"), index = 0)
private int modifyRiptideTicks(int riptideTicks, @Local(argsOnly = true) ItemStack stack) {

if(Harmony.CONFIG.riptideTimeMultiplier()!=0){
if(Harmony.CONFIG.transRiptideCat.riptideTimeMultiplier()!=0){
RegistryEntry<Enchantment> entry = stack.getEnchantments().getEnchantments().stream()
.filter(act -> act.matchesId(Identifier.ofVanilla("riptide")))
.findFirst()
.orElse(null);
int level = EnchantmentHelper.getLevel(entry, stack);
return 15 + level*Harmony.CONFIG.riptideTimeMultiplier();
return 15 + level*Harmony.CONFIG.transRiptideCat.riptideTimeMultiplier();
}
return riptideTicks;
}
Expand Down
Loading

0 comments on commit 7739a81

Please sign in to comment.