Skip to content

Commit

Permalink
Added ForestAura stuff to BalanceConfig and BrewRecipes, added the Ch…
Browse files Browse the repository at this point in the history
…eckUtils checkForestAura check (unused), started to work on the triggering (very WIP)
  • Loading branch information
Emafire003 committed Jul 30, 2024
1 parent 77b03d4 commit e6e9e3d
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/main/java/me/emafire003/dev/lightwithin/LightWithin.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class LightWithin implements ModInitializer, EntityComponentInitializer {
entry(InnerLightType.EARTHEN, Arrays.asList(TargetType.SELF, TargetType.ENEMIES, TargetType.ALLIES, TargetType.VARIANT)),
entry(InnerLightType.WIND, Arrays.asList(TargetType.SELF, TargetType.ALL, TargetType.ALLIES)),
entry(InnerLightType.AQUA, Arrays.asList(TargetType.SELF, TargetType.ENEMIES, TargetType.ALLIES, TargetType.ALL)),
entry(InnerLightType.FOREST_AURA, Arrays.asList(TargetType.ENEMIES, TargetType.ENEMIES, TargetType.SELF)),
entry(InnerLightType.FOREST_AURA, Arrays.asList(TargetType.ALL, TargetType.SELF)),
entry(InnerLightType.FROG, List.of(TargetType.ALL))
);

Expand Down Expand Up @@ -593,13 +593,13 @@ else if(component.getTargets().equals(TargetType.ENEMIES)){
component.getDuration(), player).execute();
}

//=======================Aura Light=======================
//=======================Forest Aura Light=======================
public static void activateForestAura(LightComponent component, PlayerEntity player){
List<LivingEntity> targets = new ArrayList<>();

if(component.getTargets().equals(TargetType.ENEMIES)){
if(component.getTargets().equals(TargetType.ALL)){
targets.addAll(getEnemies(player));
player.sendMessage(Text.translatable("light.description.activation.forest_aura.enemies"), true);
player.sendMessage(Text.translatable("light.description.activation.forest_aura.all"), true);
}else if(component.getTargets().equals(TargetType.SELF)){
targets.add(player);
player.sendMessage(Text.translatable("light.description.activation.forest_aura.self"), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class BalanceConfig {
public static SimpleConfig CONFIG;
private static ConfigProvider configs;

private static final int ver = 1;
private static final int ver = 2;
public static int VERSION;

public static int HEAL_MAX_POWER;
Expand Down Expand Up @@ -61,6 +61,11 @@ public class BalanceConfig {
public static int AQUA_MIN_POWER;
public static int AQUA_MIN_DURATION;

public static int FOREST_AURA_MAX_POWER;
public static int FOREST_AURA_MAX_DURATION;
public static int FOREST_AURA_MIN_POWER;
public static int FOREST_AURA_MIN_DURATION;

private static final String config_name = "_balancing";

public static void handleVersionChange(){
Expand Down Expand Up @@ -180,6 +185,13 @@ private static void createConfigs() {
configs.addKeyValuePair(new Pair<>("aqua_max_duration", 18), "The maximum duration of some effects that can be applied (like water slide, conduit, etc.)");
configs.addKeyValuePair(new Pair<>("aqua_min_duration", 1), "The minimum duration (see above)");

configs.addKeyValuePair(new Pair<>("spacer", "spacer"), "");

configs.addKeyValuePair(new Pair<>("forest_aura_max_power", 10), "The maximum power multiplier (Determines power of status effects, number of drowned spawned, if the cage will spawn a trident and lightning )");
configs.addKeyValuePair(new Pair<>("forest_aura_min_power", 1), "The minimum power multiplier (see above)");
configs.addKeyValuePair(new Pair<>("forest_aura_max_duration", 18), "The maximum duration of some effects that can be applied (like water slide, conduit, etc.)");
configs.addKeyValuePair(new Pair<>("forest_aura_min_duration", 1), "The minimum duration (see above)");

}

public static void reloadConfig(){
Expand Down Expand Up @@ -233,6 +245,11 @@ private static void assignConfigs() {
AQUA_MAX_DURATION = CONFIG.getOrDefault("aqua_max_duration", 18);
AQUA_MIN_POWER = CONFIG.getOrDefault("aqua_min_power", 1);
AQUA_MIN_DURATION = CONFIG.getOrDefault("aqua_min_duration", 1);

FOREST_AURA_MAX_POWER = CONFIG.getOrDefault("forest_aura_max_power", 10);
FOREST_AURA_MAX_DURATION = CONFIG.getOrDefault("forest_aura_max_duration", 18);
FOREST_AURA_MIN_POWER = CONFIG.getOrDefault("forest_aura_min_power", 1);
FOREST_AURA_MIN_DURATION = CONFIG.getOrDefault("forest_aura_min_duration", 1);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public static void registerRecipes(){

registerTargetsForType(InnerLightType.EARTHEN, light_nbt);

light_nbt = nbt.copy();
light_nbt.putString(TYPE_INGREDIENT_KEY, InnerLightType.FOREST_AURA.name());
CustomBrewRecipeRegister.registerCustomRecipeNbt(LightItems.BOTTLED_LIGHT, ForestAuraLight.INGREDIENT, LightItems.BOTTLED_LIGHT, nbt, null, light_nbt);

registerTargetsForType(InnerLightType.EARTHEN, light_nbt);

for(Item frog_item : FrogLight.INGREDIENTS){
light_nbt = nbt.copy();
light_nbt.putString(TYPE_INGREDIENT_KEY, InnerLightType.FROG.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import me.emafire003.dev.lightwithin.config.Config;
import me.emafire003.dev.lightwithin.lights.forestaura_puffs.ForestPuffColor;
import me.emafire003.dev.lightwithin.particles.LightParticlesUtil;
import me.emafire003.dev.lightwithin.sounds.LightSounds;
import me.emafire003.dev.lightwithin.status_effects.LightEffects;
import me.emafire003.dev.lightwithin.util.TargetType;
import net.fabricmc.loader.api.FabricLoader;
Expand All @@ -20,7 +19,6 @@
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Box;
Expand Down Expand Up @@ -71,23 +69,22 @@ public ForestAuraLight(List<LivingEntity> targets, double cooldown_time, double
color = "forest_aura";
}

//TODO make new stuff for the forest light
private void checkSafety(){
if(this.power_multiplier > BalanceConfig.AQUA_MAX_POWER){
power_multiplier = BalanceConfig.AQUA_MAX_POWER;
if(this.power_multiplier > BalanceConfig.FOREST_AURA_MAX_POWER){
power_multiplier = BalanceConfig.FOREST_AURA_MAX_POWER;
}
if(this.power_multiplier < BalanceConfig.AQUA_MIN_POWER){
power_multiplier = BalanceConfig.AQUA_MIN_POWER;
if(this.power_multiplier < BalanceConfig.FOREST_AURA_MIN_POWER){
power_multiplier = BalanceConfig.FOREST_AURA_MIN_POWER;
}
int max_duration = BalanceConfig.AQUA_MAX_DURATION;
int max_duration = BalanceConfig.FOREST_AURA_MAX_DURATION;
if(Config.MULTIPLY_DURATION_LIMIT){
max_duration = (int) (BalanceConfig.AQUA_MAX_DURATION * Config.DURATION_MULTIPLIER);
max_duration = (int) (BalanceConfig.FOREST_AURA_MAX_DURATION * Config.DURATION_MULTIPLIER);
}
if(this.duration > max_duration){
this.duration = max_duration;
}
if(this.duration < BalanceConfig.AQUA_MIN_DURATION){
this.duration = BalanceConfig.AQUA_MIN_DURATION;
if(this.duration < BalanceConfig.FOREST_AURA_MIN_DURATION){
this.duration = BalanceConfig.FOREST_AURA_MIN_DURATION;
}
}

Expand All @@ -103,17 +100,18 @@ public void execute(){
}


//TODO sounds
caster.getWorld().playSound(caster, caster.getBlockPos(), LightSounds.AQUA_LIGHT, SoundCategory.PLAYERS, 1, 1);
//caster.getWorld().playSound(caster, caster.getBlockPos(), LightSounds.AQUA_LIGHT, SoundCategory.PLAYERS, 1, 1);
LightComponent component = LIGHT_COMPONENT.get(caster);

//TODO playsound spawn particles and such

//ALL section (drowneds)
if(component.getTargets().equals(TargetType.SELF)){
//The -1 is because status effect levels start from 0
caster.addStatusEffect(new StatusEffectInstance(LightEffects.FOREST_AURA, this.duration, (int) this.power_multiplier-1));

}
//TODO this should probably be instead ALL except the other forest aura wielders
else if(component.getTargets().equals(TargetType.ENEMIES)){
else if(component.getTargets().equals(TargetType.ALL)){
//I think it should be 1-(2 +1 per level) puffs

if(caster.getWorld().isClient()){
Expand Down Expand Up @@ -161,6 +159,7 @@ else if(component.getTargets().equals(TargetType.ENEMIES)){

}


/*First chunck of Puffs:
* Level 0-5:
* - GREEN
Expand All @@ -184,7 +183,7 @@ else if(component.getTargets().equals(TargetType.ENEMIES)){


//TODO either change this or the other one
public static double PUFF_BLOCK_RANGE = 2;
public static double PUFF_BLOCK_RANGE = 1.5;

private static final int max_tries = 10000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public abstract class LivingEntityDamageTriggersMixin {
)
private void damageTriggers(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
LivingEntity entity = (LivingEntity) (Object) this;
//TODO add suffocation damage (aka in_wall)
if (source.getName().equalsIgnoreCase("freeze") && !entity.hasStatusEffect(LightEffects.FREEZE_RESISTANCE)) {
EntityFreezingEvent.EVENT.invoker().freezing(entity);
}else if(source.isOf(DamageTypes.ON_FIRE)){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package me.emafire003.dev.lightwithin.particles;

import com.mojang.serialization.Codec;
import me.emafire003.dev.lightwithin.LightWithin;
import me.emafire003.dev.lightwithin.particles.coloredpuff.ColoredPuffParticleEffect;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

import java.util.function.Function;

public class LightParticles {
public static final DefaultParticleType HEALLIGHT_PARTICLE = FabricParticleTypes.simple();
public static final DefaultParticleType DEFENSELIGHT_PARTICLE = FabricParticleTypes.simple();
Expand Down
26 changes: 23 additions & 3 deletions src/main/java/me/emafire003/dev/lightwithin/util/CheckUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.DamageTypeTags;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.tag.*;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.state.property.Properties;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.world.biome.Biome;
import org.jetbrains.annotations.NotNull;

import java.util.*;
Expand Down Expand Up @@ -666,11 +666,13 @@ public static boolean checkFrost(PlayerEntity player){
return true;
}

//TODO move to tags
Item main = player.getMainHandStack().getItem();
Item off = player.getOffHandStack().getItem();
if(items.contains(main) || items.contains(off)){
return true;
}
//TODO move to tags
return checkBlocks(player, toBlockList(TriggerConfig.FROST_TRIGGER_BLOCKS), Config.TRIGGER_BLOCK_RADIUS);
}

Expand Down Expand Up @@ -705,6 +707,7 @@ public static boolean checkWind(PlayerEntity player){
return true;
}

//TODO move to tags
return checkMultipleBlocks(player, toBlockList(TriggerConfig.WIND_TRIGGER_BLOCKS), Config.TRIGGER_BLOCK_RADIUS, 7);
}

Expand All @@ -726,6 +729,23 @@ public static boolean checkAqua(PlayerEntity player){
return checkWaterLogggedOrListBlocks(player, toBlockList(TriggerConfig.AQUA_TRIGGER_BLOCKS), Config.TRIGGER_BLOCK_RADIUS);
}

/**Used to check if the player has something that can be considered a ForestAura source
*
* @param player The player to perform checks on*/
public static boolean checkForestAura(PlayerEntity player){
RegistryEntry<Biome> biome = player.getWorld().getBiome(player.getBlockPos());
if(biome.isIn(BiomeTags.IS_FOREST) || biome.isIn(BiomeTags.IS_JUNGLE) || biome.isIn(BiomeTags.IS_TAIGA)){
return true;
}

//Maybe if they are standing on a tree? Or maybe if they have a lot of trees around?
//Maybe even the saplings in the hand

ItemStack main = player.getMainHandStack();
ItemStack off = player.getOffHandStack();
return main.isIn(ItemTags.SAPLINGS) || off.isIn(ItemTags.SAPLINGS);
}

public static boolean checkFalling(LivingEntity entity) {
if(entity instanceof PlayerEntity){
return entity.fallDistance > 5 && !entity.isFallFlying() && !entity.isOnGround() && !entity.isClimbing() && !((PlayerEntity) entity).getAbilities().flying && !entity.isSwimming();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,73 @@ else if(component.getTargets().equals(TargetType.ENEMIES)){
}
}


//TODO actually implement
public static void checkForestAura(PlayerEntity player, LightComponent component, Entity attacker, Entity target){
double trigger_sum = 0;
/**If the player has ALL as target, he needs to be hurt (or an ally has to die, but that depends on the trigger event)*/
if(component.getTargets().equals(TargetType.ALL)){

//Triggers with: Low health, Very low health, Surrounded, forest

//Checks if the player is very low health
if(CheckUtils.checkSelfDanger(player, Config.HP_PERCENTAGE_SELF)){
trigger_sum = trigger_sum+TriggerConfig.BLAZING_ALL_VERY_LOW_HEALTH;
//Checks if the player has low health
}else if(CheckUtils.checkSelfDanger(player, Config.HP_PERCENTAGE_SELF+Config.HP_PERCENTAGE_INCREMENT)){
trigger_sum=trigger_sum+TriggerConfig.BLAZING_ALL_LOW_HEALTH;
}
//Checks if the player is surrounded
if(Config.CHECK_SURROUNDED && CheckUtils.checkSurrounded(player)){
trigger_sum=trigger_sum+TriggerConfig.BLAZING_ALL_SURROUNDED;
}
if(player.isOnFire()){
trigger_sum = trigger_sum+TriggerConfig.BLAZING_ALL_ONFIRE;
}
//Checks if the player has low armor durability
if(Config.CHECK_ARMOR_DURABILITY && CheckUtils.checkArmorDurability(player, Config.DUR_PERCENTAGE_SELF)){
trigger_sum=trigger_sum+TriggerConfig.BLAZING_ALL_ARMOR_DURABILITY;
}
//Checks if the player has the optimal criteria for activation
if(CheckUtils.checkBlazing(player)){
trigger_sum=trigger_sum+TriggerConfig.BLAZING_ALL_CONDITIONS;
}
if(trigger_sum >= MIN_TRIGGER){
sendLightTriggered((ServerPlayerEntity) player);
}
}
/**CHECKS if the player has ENEMIES as target, either his or his allies health needs to be low*/
else if(component.getTargets().equals(TargetType.ENEMIES) || component.getTargets().equals(TargetType.VARIANT)){

if(CheckUtils.checkSelfDanger(player, Config.HP_PERCENTAGE_SELF+Config.HP_PERCENTAGE_INCREMENT/2)){
trigger_sum = trigger_sum+TriggerConfig.BLAZING_ENEMIES_VERY_LOW_HEALTH;
}
//Checks if the player is surrounded
if(Config.CHECK_SURROUNDED && CheckUtils.checkSurrounded(player)){
trigger_sum=trigger_sum+TriggerConfig.BLAZING_ENEMIES_SURROUNDED;
}
if(player.isOnFire()){
trigger_sum = trigger_sum+TriggerConfig.BLAZING_ENEMIES_ONFIRE;
}
//Checks if the player'sallies have low armor durability
if(!player.equals(target) && Config.CHECK_ARMOR_DURABILITY && CheckUtils.checkAllyArmor(player, target, Config.DUR_PERCENTAGE_ALLIES)){
trigger_sum=trigger_sum+TriggerConfig.BLAZING_ENEMIES_ALLY_ARMOR_DURABILITY;
}
//Checks if the player has low armor durability
if(Config.CHECK_ARMOR_DURABILITY && CheckUtils.checkArmorDurability(player, Config.DUR_PERCENTAGE_SELF)){
trigger_sum=trigger_sum+TriggerConfig.BLAZING_ENEMIES_ARMOR_DURABILITY;
}
//Checks if the player has the optimal criteria for activation
if(CheckUtils.checkBlazing(player)){
trigger_sum=trigger_sum+TriggerConfig.BLAZING_ENEMIES_CONDITIONS;
}
if(trigger_sum >= MIN_TRIGGER){
sendLightTriggered((ServerPlayerEntity) player);
}
}

}

public static void checkFrog(PlayerEntity player, LightComponent component, LivingEntity attacker, Entity target){
if(CheckUtils.checkSelfDanger(player, Config.HP_PERCENTAGE_SELF+25)
|| CheckUtils.checkSurrounded(player)
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/lightwithin/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"light.description.earthen": "Your light draws its power from the earth around you",
"light.description.wind": "Your light shines in the wind",
"light.description.aqua": "Your light best reflects upon watery surfaces",
"light.description.forest_aura": "You are one with the forest",
"light.description.frog": "*croak* Wait what?! Frogs?!",

"light.description.target.self": "Your light shall guide you and you alone!",
Expand Down

0 comments on commit e6e9e3d

Please sign in to comment.