Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public interface CommonConfigAccess {

int artifactCooldown();

int entityExplosionResistance();

long DEFAULT_DUST_MEDIA_AMOUNT = MediaConstants.DUST_UNIT;
long DEFAULT_SHARD_MEDIA_AMOUNT = MediaConstants.SHARD_UNIT;
long DEFAULT_CHARGED_MEDIA_AMOUNT = MediaConstants.CRYSTAL_UNIT;
Expand All @@ -36,6 +38,7 @@ public interface CommonConfigAccess {
int DEFAULT_TRINKET_COOLDOWN = 5;
int DEFAULT_ARTIFACT_COOLDOWN = 3;

int DEFAULT_ENTITY_EXPLOSION_RESISTANCE = 0;
}

public interface ClientConfigAccess {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import at.petrak.hexcasting.api.casting.getPositiveDoubleUnderInclusive
import at.petrak.hexcasting.api.casting.getVec3
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.common.casting.actions.selectors.OpGetEntitiesBy
import net.minecraft.core.BlockPos
import net.minecraft.util.Mth
import net.minecraft.world.effect.MobEffectInstance
import net.minecraft.world.effect.MobEffects
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.level.Level
import net.minecraft.world.phys.AABB
import net.minecraft.world.phys.Vec3
Expand Down Expand Up @@ -53,6 +57,25 @@ class OpExplode(val fire: Boolean) : SpellAction {
if (!env.canEditBlockAt(BlockPos.containing(pos)))
return

val resistanceLevel = HexConfig.common().entityExplosionResistance()

if (resistanceLevel > 0) {
val radius = strength * 4 / 3; // approximation
val aabb = AABB(pos.add(Vec3(-radius, -radius, -radius)), pos.add(Vec3(radius, radius, radius)))
val entitiesGot = env.world.getEntities(null, aabb)
.filter { entity -> entity is LivingEntity && entity != env.castingEntity }
.map { entity -> entity as LivingEntity }
entitiesGot.forEach { entity ->
entity.addEffect(
MobEffectInstance(
MobEffects.DAMAGE_RESISTANCE,
1, // 1 tick only, we want this to exclusively block the explosion
resistanceLevel - 1
)
)
}
}

env.world.explode(
env.castingEntity,
pos.x,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public static final class Common implements HexConfig.CommonConfigAccess, Config
@ConfigEntry.Gui.Tooltip
private int artifactCooldown = DEFAULT_ARTIFACT_COOLDOWN;

@ConfigEntry.Gui.Tooltip
private int entityExplosionResistance = DEFAULT_ENTITY_EXPLOSION_RESISTANCE;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing lang file entries for config options on fabric


@Override
public void validatePostLoad() throws ValidationException {
Expand Down Expand Up @@ -123,6 +125,11 @@ public int trinketCooldown() {
public int artifactCooldown() {
return artifactCooldown;
}

@Override
public int entityExplosionResistance() {
return entityExplosionResistance;
}
}

@Config(name = "client")
Expand Down
12 changes: 12 additions & 0 deletions Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class ForgeHexConfig implements HexConfig.CommonConfigAccess {
private static ForgeConfigSpec.IntValue trinketCooldown;
private static ForgeConfigSpec.IntValue artifactCooldown;

private static ForgeConfigSpec.IntValue entityExplosionResistance;

public ForgeHexConfig(ForgeConfigSpec.Builder builder) {
builder.push("Media Amounts");
dustMediaAmount = builder.comment("How much media a single Amethyst Dust item is worth")
Expand All @@ -43,6 +45,11 @@ public ForgeHexConfig(ForgeConfigSpec.Builder builder) {
artifactCooldown = builder.comment("Cooldown in ticks of a artifact")
.defineInRange("artifactCooldown", DEFAULT_ARTIFACT_COOLDOWN, 0, Integer.MAX_VALUE);
builder.pop();

builder.push("Misc");
entityExplosionResistance = builder.comment("How much entities should resist explosion damage, where the reduction is Value times 20%")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: grammar. also see main comment

Suggested change
entityExplosionResistance = builder.comment("How much entities should resist explosion damage, where the reduction is Value times 20%")
entityExplosionResistance = builder.comment("How much explosion resistance entities should have in 20% increments")

.defineInRange("entityExplosionResistance", DEFAULT_ENTITY_EXPLOSION_RESISTANCE, 0, 5);
builder.pop();
}

@Override
Expand Down Expand Up @@ -80,6 +87,11 @@ public int artifactCooldown() {
return artifactCooldown.get();
}

@Override
public int entityExplosionResistance() {
return entityExplosionResistance.get();
}

public static class Client implements HexConfig.ClientConfigAccess {
private static ForgeConfigSpec.BooleanValue ctrlTogglesOffStrokeOrder;
private static ForgeConfigSpec.BooleanValue disableInworldScrolling;
Expand Down