Skip to content

Commit

Permalink
cursed energy amount
Browse files Browse the repository at this point in the history
  • Loading branch information
RadonCoding committed Nov 5, 2023
1 parent 184a072 commit b55a9d8
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 26 deletions.
35 changes: 18 additions & 17 deletions src/main/java/radon/jujutsu_kaisen/ExplosionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.LogicalSide;
Expand Down Expand Up @@ -45,20 +46,20 @@ public static void onLevelTick(TickEvent.LevelTickEvent event) {
if (event.level.dimension() != explosion.dimension) return;

float radius = Math.min(explosion.radius, explosion.radius * (0.5F + ((float) explosion.age / explosion.duration)));
int minX = Mth.floor(explosion.position.getX() - radius - 1.0F);
int maxX = Mth.floor(explosion.position.getX() + radius + 1.0F);
int minY = Mth.floor(explosion.position.getY() - radius - 1.0F);
int maxY = Mth.floor(explosion.position.getY() + radius + 1.0F);
int minZ = Mth.floor(explosion.position.getZ() - radius - 1.0F);
int maxZ = Mth.floor(explosion.position.getZ() + radius + 1.0F);
int minX = Mth.floor(explosion.position.y() - radius - 1.0F);
int maxX = Mth.floor(explosion.position.x() + radius + 1.0F);
int minY = Mth.floor(explosion.position.y() - radius - 1.0F);
int maxY = Mth.floor(explosion.position.y() + radius + 1.0F);
int minZ = Mth.floor(explosion.position.z() - radius - 1.0F);
int maxZ = Mth.floor(explosion.position.z() + radius + 1.0F);

if (explosion.age == 0) {
event.level.playSound(null, explosion.position.getX(), explosion.position.getY(), explosion.position.getZ(),
event.level.playSound(null, explosion.position.x(), explosion.position.y(), explosion.position.z(),
SoundEvents.GENERIC_EXPLODE, SoundSource.MASTER, 10.0F, 1.0F);
AABB bounds = new AABB(explosion.position.getX() - (explosion.radius * 2.0F), explosion.position.getY() - (explosion.radius * 2.0F),
explosion.position.getZ() - (explosion.radius * 2.0F),
explosion.position.getX() + (explosion.radius * 2.0F), explosion.position.getY() + (explosion.radius * 2.0F),
explosion.position.getZ() + (explosion.radius * 2.0F));
AABB bounds = new AABB(explosion.position.x() - (explosion.radius * 2.0F), explosion.position.y() - (explosion.radius * 2.0F),
explosion.position.z() - (explosion.radius * 2.0F),
explosion.position.x() + (explosion.radius * 2.0F), explosion.position.y() + (explosion.radius * 2.0F),
explosion.position.z() + (explosion.radius * 2.0F));

for (ServerPlayer player : event.level.getEntitiesOfClass(ServerPlayer.class, bounds)) {
PacketHandler.sendToClient(new CameraShakeS2CPacket(1.0F, 5.0F, explosion.duration), player);
Expand All @@ -68,9 +69,9 @@ public static void onLevelTick(TickEvent.LevelTickEvent event) {
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
double distance = (x - explosion.position.getX()) * (x - explosion.position.getX()) +
(y - explosion.position.getY()) * (y - explosion.position.getY()) +
(z - explosion.position.getZ()) * (z - explosion.position.getZ());
double distance = (x - explosion.position.x()) * (x - explosion.position.x()) +
(y - explosion.position.y()) * (y - explosion.position.y()) +
(z - explosion.position.z()) * (z - explosion.position.z());

double adjusted = radius * ((double) explosion.age / explosion.duration);

Expand Down Expand Up @@ -112,21 +113,21 @@ public static void onLevelTick(TickEvent.LevelTickEvent event) {
explosions.removeAll(remove);
}

public static void spawn(ResourceKey<Level> dimension, BlockPos position, float radius, int duration, @Nullable LivingEntity instigator, DamageSource source, boolean fire) {
public static void spawn(ResourceKey<Level> dimension, Vec3 position, float radius, int duration, @Nullable LivingEntity instigator, DamageSource source, boolean fire) {
explosions.add(new ExplosionData(dimension, position, radius, duration, instigator, source, fire));
}

private static class ExplosionData {
private final ResourceKey<Level> dimension;
private final BlockPos position;
private final Vec3 position;
private final float radius;
private final int duration;
private int age;
private final @Nullable LivingEntity instigator;
private final DamageSource source;
private boolean fire;

public ExplosionData(ResourceKey<Level> dimension, BlockPos position, float radius, int duration, @Nullable LivingEntity instigator, DamageSource source, boolean fire) {
public ExplosionData(ResourceKey<Level> dimension, Vec3 position, float radius, int duration, @Nullable LivingEntity instigator, DamageSource source, boolean fire) {
this.dimension = dimension;
this.position = position;
this.radius = radius;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/radon/jujutsu_kaisen/ability/misc/Smash.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void run(LivingEntity owner) {

@Override
public float getCost(LivingEntity owner) {
return JJKAbilities.isChanneling(owner, this) && this.getCharge(owner) >= 20 ? 0.0F : 1.0F;
return JJKAbilities.isChanneling(owner, this) && this.getCharge(owner) >= 20 ? 0.0F : 0.5F;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void tick() {

float radius = Math.min(MAX_EXPLOSION, RADIUS * this.getPower());
int duration = (int) (radius / 5.0F * 20);
ExplosionHandler.spawn(this.level().dimension(), BlockPos.containing(this.position().add(0.0D, this.getBbHeight() / 2.0F, 0.0D)),
ExplosionHandler.spawn(this.level().dimension(), this.position().add(0.0D, this.getBbHeight() / 2.0F, 0.0D),
radius, duration, owner, JJKDamageSources.indirectJujutsuAttack(this, owner, JJKAbilities.HOLLOW_PURPLE.get()), false);
} else {
this.hurtEntities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void tick() {

if (this.onGround()) {
if (this.explosionTime == 0) {
ExplosionHandler.spawn(this.level().dimension(), this.blockPosition(), this.getSize() * 1.5F,
ExplosionHandler.spawn(this.level().dimension(), this.position(), this.getSize() * 1.5F,
EXPLOSION_DURATION, owner, JJKDamageSources.indirectJujutsuAttack(this, owner, JJKAbilities.MAXIMUM_METEOR.get()), true);
this.explosionTime++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected void onHit(@NotNull HitResult result) {

if (this.getOwner() instanceof LivingEntity owner) {
Vec3 location = result.getLocation();
ExplosionHandler.spawn(this.level().dimension(), BlockPos.containing(location.x(), location.y(), location.z()), Math.min(MAX_EXPLOSION, EXPLOSIVE_POWER * this.getPower()),
ExplosionHandler.spawn(this.level().dimension(), location, Math.min(MAX_EXPLOSION, EXPLOSIVE_POWER * this.getPower()),
20, owner, JJKDamageSources.indirectJujutsuAttack(this, owner, JJKAbilities.EMBER_INSECTS.get()), true);
}
this.discard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected void onHit(@NotNull HitResult result) {

if (this.getOwner() instanceof LivingEntity owner) {
Vec3 location = result.getLocation();
ExplosionHandler.spawn(this.level().dimension(), BlockPos.containing(location.x(), location.y(), location.z()), Math.min(MAX_EXPLOSION, EXPLOSIVE_POWER * this.getPower()),
ExplosionHandler.spawn(this.level().dimension(), location, Math.min(MAX_EXPLOSION, EXPLOSIVE_POWER * this.getPower()),
20, owner, JJKDamageSources.indirectJujutsuAttack(this, owner, JJKAbilities.FIRE_ARROW.get()), true);
}
this.discard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected void onHit(@NotNull HitResult result) {

if (this.getOwner() instanceof LivingEntity owner) {
Vec3 location = result.getLocation();
ExplosionHandler.spawn(this.level().dimension(), BlockPos.containing(location.x(), location.y(), location.z()), Math.min(MAX_EXPLOSION, EXPLOSIVE_POWER * this.getPower()),
ExplosionHandler.spawn(this.level().dimension(), location, Math.min(MAX_EXPLOSION, EXPLOSIVE_POWER * this.getPower()),
20, owner, JJKDamageSources.indirectJujutsuAttack(this, owner, JJKAbilities.FIREBALL.get()), true);
}
this.discard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void tick() {
this.setPos(pos);

Vec3 offset = new Vec3(this.getX(), this.getY() + (this.getBbHeight() / 2.0F), this.getZ());
ExplosionHandler.spawn(this.level().dimension(), BlockPos.containing(offset), this.power * 2.0F, 3 * 20, owner,
ExplosionHandler.spawn(this.level().dimension(), offset, this.power * 2.0F, 3 * 20, owner,
JJKDamageSources.indirectJujutsuAttack(this, owner, JJKAbilities.MAXIMUM_UZUMAKI.get()), false);

this.hurtEntities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected void onHit(@NotNull HitResult pResult) {

if (this.getOwner() instanceof LivingEntity owner) {
Vec3 offset = new Vec3(this.getX(), this.getY() + (this.getBbHeight() / 2.0F), this.getZ());
ExplosionHandler.spawn(this.level().dimension(), BlockPos.containing(offset), Math.min(MAX_EXPLOSION, EXPLOSIVE_POWER * this.getPower()), 20, owner,
ExplosionHandler.spawn(this.level().dimension(), offset, Math.min(MAX_EXPLOSION, EXPLOSIVE_POWER * this.getPower()), 20, owner,
JJKDamageSources.indirectJujutsuAttack(this, owner, JJKAbilities.RED.get()), false);
}
this.discard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public boolean causeFallDamage(float pFallDistance, float pMultiplier, @NotNull
boolean result = super.causeFallDamage(pFallDistance, pMultiplier, pSource);

if (result && pFallDistance >= EXPLOSION_FALL_DISTANCE) {
ExplosionHandler.spawn(this.level().dimension(), this.blockPosition(), EXPLOSION_POWER, EXPLOSION_DURATION, this, null, false);
ExplosionHandler.spawn(this.level().dimension(), this.position(), EXPLOSION_POWER, EXPLOSION_DURATION, this, null, false);
}
return result;
}
Expand Down

0 comments on commit b55a9d8

Please sign in to comment.