Skip to content

Commit

Permalink
More scaling damage options
Browse files Browse the repository at this point in the history
  • Loading branch information
jss2a98aj committed Feb 23, 2023
1 parent 358ff2b commit 261fe06
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 9 deletions.
14 changes: 14 additions & 0 deletions src/main/java/jss/bugtorch/config/BugTorchConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,16 @@ public class BugTorchConfig {
public static boolean potionParticlesAreClearForClientPlayer;
public static float reduceLightningVolume;
public static boolean removeEntityDuplicateExtendedPropertiesIdentifierSpam;
public static float scaledDrowningDamageMaxHealthFlat;
public static float scaledDrowningDamageMaxHealthMult;
public static float scaledPoisonDamageMaxHealthFlat;
public static float scaledPoisonDamageMaxHealthMult;
public static float scaledStarvationDamageMaxHealthFlat;
public static float scaledStarvationDamageMaxHealthMult;
public static float scaledSuffocationDamageMaxHealthFlat;
public static float scaledSuffocationDamageMaxHealthMult;
public static float scaledWitherDamageMaxHealthFlat;
public static float scaledWitherDamageMaxHealthMult;

//Mixin mod bugfixes
public static boolean fixGanysSurfaceOpenTrapdoorBackTexture;
Expand Down Expand Up @@ -216,9 +223,16 @@ public static void loadBaseMixinConfig(File configFile) {
potionParticlesAreClearForClientPlayer = config.getBoolean("potionParticlesAreClearForClientPlayer", categoryTweaks, false, "Potion particles coming off of the player entity you control are always clear.");
reduceLightningVolume = config.getFloat("reduceLightningVolume", categoryTweaks, 10000f, 2f, 10000f, "Reduces lightning volume and effective range.\nSet to 10,000 to disable.");
removeEntityDuplicateExtendedPropertiesIdentifierSpam = config.getBoolean("removeEntityDuplicateExtendedPropertiesIdentifierSpam", categoryTweaks, true, "Removes \"An attempt was made to register extended properties using an existing key\" log spam caused by some mods.");
scaledDrowningDamageMaxHealthFlat = config.getFloat("scaledDrowningDamageMaxHealthFlat", categoryTweaks, 0f, 0f, 20000f, "Amount of flat player health to remove each drowning tick.\nSet to 0 to disable.");
scaledDrowningDamageMaxHealthMult = config.getFloat("scaledDrowningDamageMaxHealthMult", categoryTweaks, 0f, 0f, 1f, "Portion of max player health to remove each drowning tick.\nSet to 0 to disable.");
scaledPoisonDamageMaxHealthFlat = config.getFloat("scaledPoisonDamageMaxHealthFlat", categoryTweaks, 0f, 0f, 20000f, "Portion of max player health to remove each poison effect tick.\nSet to 0 to disable.");
scaledPoisonDamageMaxHealthMult = config.getFloat("scaledPoisonDamageMaxHealthMult", categoryTweaks, 0f, 0f, 1f, "Portion of max player health to remove each poison effect tick.\nSet to 0 to disable.");
scaledStarvationDamageMaxHealthFlat = config.getFloat("scaledStarvationDamageMaxHealthFlat", categoryTweaks, 0f, 0f, 20000f, "Amount of flat player health to remove each starvation tick.\nSet to 0 to disable.");
scaledStarvationDamageMaxHealthMult = config.getFloat("scaledStarvationDamageMaxHealthMult", categoryTweaks, 0f, 0f, 1f, "Portion of max player health to remove each starvation tick.\nSet to 0 to disable.");
scaledSuffocationDamageMaxHealthFlat = config.getFloat("scaledSuffocationDamageMaxHealthFlat", categoryTweaks, 0f, 0f, 20000f, "Portion of max player health to remove each suffocation tick.\nSet to 0 to disable.");
scaledSuffocationDamageMaxHealthMult = config.getFloat("scaledSuffocationDamageMaxHealthMult", categoryTweaks, 0f, 0f, 1f, "Portion of max player health to remove each suffocation tick.\nSet to 0 to disable.");
scaledWitherDamageMaxHealthFlat = config.getFloat("scaledWitherDamageMaxHealthFlat", categoryTweaks, 0f, 0f, 20000f, "Portion of max player health to remove each wither effect tick.\nSet to 0 to disable.");
scaledWitherDamageMaxHealthMult = config.getFloat("scaledWitherDamageMaxHealthMult", categoryTweaks, 0f, 0f, 1f, "Portion of max player health to remove each wither effect tick.\nSet to 0 to disable.");

lanPortToUseForOverride = config.getInt("lanPortToUseForOverride", categoryTweaks, 25565, 1024 , 49151, "Port to use for lanPortOverride.");

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/jss/bugtorch/mixinplugin/BugTorchEarlyMixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,21 @@ public List<String> getMixins(Set<String> loadedCoreMods) {
if(BugTorchConfig.removeEntityDuplicateExtendedPropertiesIdentifierSpam) {
mixins.add("minecraft.logcleanup.MixinEntity");
}
if(BugTorchConfig.scaledDrowningDamageMaxHealthMult > 0f) {
if(BugTorchConfig.scaledDrowningDamageMaxHealthFlat > 0f || BugTorchConfig.scaledDrowningDamageMaxHealthMult > 0f) {
mixins.add("minecraft.tweaks.entitylivingbase.MixinScalingDrowningDamage");
}
if(BugTorchConfig.scaledStarvationDamageMaxHealthMult > 0f) {
if(BugTorchConfig.scaledStarvationDamageMaxHealthFlat > 0f || BugTorchConfig.scaledStarvationDamageMaxHealthMult > 0f) {
mixins.add("minecraft.tweaks.MixinFoodStats");
}
if(BugTorchConfig.scaledDrowningDamageMaxHealthMult > 0f) {
if(BugTorchConfig.scaledDrowningDamageMaxHealthFlat > 0f || BugTorchConfig.scaledDrowningDamageMaxHealthMult > 0f) {
mixins.add("minecraft.tweaks.entitylivingbase.MixinScalingSuffocationDamage");
}
if(BugTorchConfig.scaledPoisonDamageMaxHealthFlat > 0f || BugTorchConfig.scaledPoisonDamageMaxHealthMult > 0f) {
mixins.add("minecraft.tweaks.potion.MixinsPotionPoison");
}
if(BugTorchConfig.scaledWitherDamageMaxHealthFlat > 0f || BugTorchConfig.scaledWitherDamageMaxHealthMult > 0f) {
mixins.add("minecraft.tweaks.potion.MixinsPotionWither");
}

return mixins;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ public abstract class MixinFoodStats {
target = "Lnet/minecraft/entity/player/EntityPlayer;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z"
)
)
private boolean starvationDamage(EntityPlayer player, DamageSource source, float damage) {
private boolean bugTorch$scalingStarvationDamage(EntityPlayer player, DamageSource source, float damage) {
float survivalThreshold = player.worldObj.difficultySetting == EnumDifficulty.HARD ? 0f : 1f;
return player.attackEntityFrom(source, Math.min(player.getHealth() - survivalThreshold, BugTorchConfig.scaledStarvationDamageMaxHealthMult * player.getMaxHealth()));
return player.attackEntityFrom(source, Math.min(
BugTorchConfig.scaledStarvationDamageMaxHealthMult * player.getMaxHealth() + BugTorchConfig.scaledStarvationDamageMaxHealthFlat,
player.getHealth() - survivalThreshold
));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ public abstract class MixinScalingDrowningDamage {
ordinal = 1
)
)
private boolean scalingDrowningDamage(EntityLivingBase entity, DamageSource source, float damage) {
return entity.attackEntityFrom(source, (entity instanceof EntityPlayer) ? BugTorchConfig.scaledDrowningDamageMaxHealthMult * entity.getMaxHealth() : damage);
private boolean bugTorch$scalingDrowningDamage(EntityLivingBase entity, DamageSource source, float damage) {
return entity.attackEntityFrom(source,
(entity instanceof EntityPlayer)
? BugTorchConfig.scaledDrowningDamageMaxHealthMult * entity.getMaxHealth() + BugTorchConfig.scaledDrowningDamageMaxHealthFlat
: damage
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ public abstract class MixinScalingSuffocationDamage {
ordinal = 0
)
)
private boolean scalingSuffocationDamage(EntityLivingBase entity, DamageSource source, float damage) {
return entity.attackEntityFrom(source, (entity instanceof EntityPlayer) ? BugTorchConfig.scaledSuffocationDamageMaxHealthMult * entity.getMaxHealth() : damage);
private boolean bugTorch$scalingSuffocationDamage(EntityLivingBase entity, DamageSource source, float damage) {
return entity.attackEntityFrom(source,
(entity instanceof EntityPlayer)
? BugTorchConfig.scaledSuffocationDamageMaxHealthMult * entity.getMaxHealth() + BugTorchConfig.scaledSuffocationDamageMaxHealthFlat
: damage);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package jss.bugtorch.mixins.early.minecraft.tweaks.potion;

import jss.bugtorch.config.BugTorchConfig;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = Potion.class)
public class MixinsPotionPoison {

/**
* @author jss2a98aj
* @reason Makes poison effect damage scale with max health.
*/
@Redirect(
method = "performEffect",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/EntityLivingBase;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z",
ordinal = 0
)
)
private boolean bugTorch$scalingWitherEffectDamage(EntityLivingBase entity, DamageSource source, float damage) {
return entity.attackEntityFrom(source,
(entity instanceof EntityPlayer)
? Math.min(
BugTorchConfig.scaledPoisonDamageMaxHealthMult * entity.getMaxHealth() + BugTorchConfig.scaledPoisonDamageMaxHealthFlat,
entity.getHealth() - 1f
)
: damage);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package jss.bugtorch.mixins.early.minecraft.tweaks.potion;

import jss.bugtorch.config.BugTorchConfig;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = Potion.class)
public class MixinsPotionWither {

/**
* @author jss2a98aj
* @reason Makes wither effect damage scale with max health.
*/
@Redirect(
method = "performEffect",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/EntityLivingBase;attackEntityFrom(Lnet/minecraft/util/DamageSource;F)Z",
ordinal = 1
)
)
private boolean bugTorch$scalingWitherEffectDamage(EntityLivingBase entity, DamageSource source, float damage) {
return entity.attackEntityFrom(source,
(entity instanceof EntityPlayer)
? BugTorchConfig.scaledWitherDamageMaxHealthMult * entity.getMaxHealth() + BugTorchConfig.scaledWitherDamageMaxHealthFlat
: damage);
}

}

0 comments on commit 261fe06

Please sign in to comment.