Skip to content

Commit

Permalink
too lazy to finish, but started redoing burst
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Jan 24, 2025
1 parent 008a069 commit 92e8933
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,8 @@ public static final class BurstShapeProperties {
@ConfigEntry(id = "potencyModifier", type = EntryType.DOUBLE, translation = "config.arcanuscontinuum.potencyModifier")
public static double potencyModifier = 0;

@ConfigEntry(id = "strength", type = EntryType.FLOAT, translation = "config.arcanuscontinuum.strength")
@FloatRange(min = 0, max = 10)
public static float strength = 3.5f;
@ConfigEntry(id = "radius", type = EntryType.FLOAT, translation = "config.arcanuscontinuum.burstShape.radius")
public static float radius = 4f;
}

// TODO uncomment this when we have guided shot done & set enabled to true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
package dev.cammiescorner.arcanuscontinuum.common.spell_components.shapes;

import com.google.common.collect.Sets;
import dev.cammiescorner.arcanuscontinuum.ArcanusConfig;
import dev.cammiescorner.arcanuscontinuum.api.spells.SpellEffect;
import dev.cammiescorner.arcanuscontinuum.api.spells.SpellGroup;
import dev.cammiescorner.arcanuscontinuum.api.spells.SpellShape;
import dev.cammiescorner.arcanuscontinuum.common.packets.s2c.SyncExplosionParticlesPacket;
import dev.cammiescorner.arcanuscontinuum.common.registry.ArcanusSpellComponents;
import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
Expand All @@ -28,7 +18,6 @@

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class BurstSpellShape extends SpellShape {
public BurstSpellShape() {
Expand All @@ -44,80 +33,33 @@ public BurstSpellShape() {
}

@Override
public void cast(@Nullable LivingEntity caster, Vec3 castFrom, @Nullable Entity castSource, ServerLevel world, ItemStack stack, List<SpellEffect> effects, List<SpellGroup> spellGroups, int groupIndex, double potency) {
public void cast(@Nullable LivingEntity caster, Vec3 castFrom, @Nullable Entity castSource, ServerLevel level, ItemStack stack, List<SpellEffect> effects, List<SpellGroup> spellGroups, int groupIndex, double potency) {
Entity sourceEntity = castSource != null ? castSource : caster;
float radius = ArcanusConfig.SpellShapes.BurstShapeProperties.radius;
AABB boundingBox = new AABB(castFrom.add(-radius, -radius, -radius), castFrom.add(radius, radius, radius));
potency += getPotencyModifier();
float strength = ArcanusConfig.SpellShapes.BurstShapeProperties.strength;

world.gameEvent(caster, GameEvent.EXPLODE, new Vec3(castFrom.x(), castFrom.y(), castFrom.z()));
Set<BlockPos> affectedBlocks = Sets.newHashSet();
for(BlockPos blockPos : BlockPos.betweenClosedStream(boundingBox).toList()) {
Vec3 pos = Vec3.atCenterOf(blockPos);

for(int j = 0; j < 16; ++j) {
for(int k = 0; k < 16; ++k) {
for(int l = 0; l < 16; ++l) {
if(j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15) {
double d = j / 15F * 2F - 1F;
double e = k / 15F * 2F - 1F;
double f = l / 15F * 2F - 1F;
double g = Math.sqrt(d * d + e * e + f * f);
d /= g;
e /= g;
f /= g;
float h = strength * (0.7F + world.random.nextFloat() * 0.6F);
double m = castFrom.x();
double n = castFrom.y();
double o = castFrom.z();

for(; h > 0F; h -= 0.225F) {
BlockPos blockPos = new BlockPos((int) m, (int) n, (int) o);
BlockState blockState = world.getBlockState(blockPos);

if(!world.isInWorldBounds(blockPos))
break;

if(!blockState.isAir() && blockState.getFluidState().isEmpty())
h -= (blockState.getBlock().getExplosionResistance() + 0.3F) * 0.3F;

if(!world.isEmptyBlock(blockPos))
affectedBlocks.add(blockPos);
if(pos.distanceTo(castFrom) <= radius)
continue;

m += d * 0.3F;
n += e * 0.3F;
o += f * 0.3F;
}
}
}
}
for(SpellEffect effect : new HashSet<>(effects))
effect.effect(caster, sourceEntity, level, new BlockHitResult(pos, Direction.UP, blockPos, true), effects, stack, potency);
}

float f = strength * 2;
int k = Mth.floor(castFrom.x() - f - 1);
int l = Mth.floor(castFrom.x() + f + 1);
int r = Mth.floor(castFrom.y() - f - 1);
int s = Mth.floor(castFrom.y() + f + 1);
int t = Mth.floor(castFrom.z() - f - 1);
int u = Mth.floor(castFrom.z() + f + 1);
List<Entity> affectedEntities = world.getEntities(sourceEntity == caster ? caster : null, new AABB(k, r, t, l, s, u), entity -> entity.isAlive() && !entity.isSpectator()).stream().toList();

for(SpellEffect effect : new HashSet<>(effects)) {
if(effect.shouldTriggerOnceOnExplosion()) {
effect.effect(caster, sourceEntity, world, new EntityHitResult(sourceEntity), effects, stack, potency);
effect.effect(caster, sourceEntity, level, new EntityHitResult(sourceEntity), effects, stack, potency);
continue;
}

for(Entity entity : affectedEntities) {
effect.effect(caster, sourceEntity, world, new EntityHitResult(entity), effects, stack, potency);
}
for(BlockPos blockPos : affectedBlocks) {
effect.effect(caster, sourceEntity, world, new BlockHitResult(Vec3.atCenterOf(blockPos), Direction.UP, blockPos, true), effects, stack, potency);
}
for(Entity entity : level.getEntities(sourceEntity == caster ? caster : null, boundingBox, entity -> entity.isAlive() && !entity.isSpectator() && castFrom.distanceTo(entity.position()) <= radius))
effect.effect(caster, sourceEntity, level, new EntityHitResult(entity), effects, stack, potency);
}

world.playSeededSound(null, castFrom.x(), castFrom.y(), castFrom.z(), SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 4F, (1F + (world.random.nextFloat() - world.random.nextFloat()) * 0.2F) * 0.7F, 1L);

for(ServerPlayer player : PlayerLookup.tracking(world, BlockPos.containing(castFrom.x(), castFrom.y(), castFrom.z()))) {
SyncExplosionParticlesPacket.send(player, castFrom.x(), castFrom.y(), castFrom.z(), strength, effects.contains(ArcanusSpellComponents.MINE.get()));
}
castNext(caster, castFrom, castSource, world, stack, spellGroups, groupIndex, potency);
// TODO add vfx & sfx for burst
castNext(caster, castFrom, castSource, level, stack, spellGroups, groupIndex, potency);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void generateTranslations(TranslationBuilder builder) {
builder.add("config.arcanuscontinuum.lifeSpanModifier", "Life Span Modifier");
builder.add("config.arcanuscontinuum.range", "Range");
builder.add("config.arcanuscontinuum.delay", "Delay");
builder.add("config.arcanuscontinuum.strength", "Strength");
builder.add("config.arcanuscontinuum.burstShape.radius", "Burst Radius");
builder.add("config.arcanuscontinuum.maximumManaLock", "Maximum Mana Lock");
builder.add("config.arcanuscontinuum.maximumAggressorbs", "Maximum Aggressorbs");
builder.add("config.arcanuscontinuum.baseDamage", "Base Damage");
Expand Down

0 comments on commit 92e8933

Please sign in to comment.