Skip to content

Commit

Permalink
Use explosion without particle to push away entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glyceryl6 committed Aug 17, 2024
1 parent ee9b457 commit c5b6a70
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@

import cn.teampancake.theaurorian.common.entities.boss.MoonQueen;
import cn.teampancake.theaurorian.common.entities.phase.AttackPhase;
import cn.teampancake.theaurorian.common.registry.TASoundEvents;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.SimpleExplosionDamageCalculator;
import net.minecraft.world.phys.Vec3;

import java.util.Optional;

public class MoonQueenMoonBefallPhase extends AttackPhase<MoonQueen> {

private static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR =
new SimpleExplosionDamageCalculator(Boolean.FALSE, Boolean.FALSE, (Optional.of(3.0F)), (Optional.empty()));

public MoonQueenMoonBefallPhase() {
super(3, 1, 26, 0);
}
Expand All @@ -20,10 +31,14 @@ public void onStart(MoonQueen entity) {}

@Override
public void tick(MoonQueen entity) {
Level level = entity.level();
entity.setDeltaMovement(Vec3.ZERO);
if (entity.getAttackTicks() == 14) {
entity.pushAwaySurroundingEntities(5.0D, 2.0D);
entity.level().broadcastEntityEvent(entity, (byte)77);
if (!level.isClientSide && entity.getAttackTicks() == 14) {
level.explode(entity, Explosion.getDefaultDamageSource(level, entity),
EXPLOSION_DAMAGE_CALCULATOR, entity.getX(), entity.getY(), entity.getZ(), (3.0F),
Boolean.FALSE, Level.ExplosionInteraction.NONE, ParticleTypes.EXPLOSION,
ParticleTypes.EXPLOSION_EMITTER, TASoundEvents.EMPTY);
level.broadcastEntityEvent(entity, (byte) 77);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class TASoundEvents {
public static final DeferredHolder<SoundEvent, SoundEvent> CRYSTALLINE_SWORD_SHOOT = register("crystalline_sword_shoot");
public static final DeferredHolder<SoundEvent, SoundEvent> WEEPING_WILLOW_BELL = register("weeping_willow_bell");
public static final DeferredHolder<SoundEvent, SoundEvent> BACKGROUND_MUSIC = register("music");
public static final DeferredHolder<SoundEvent, SoundEvent> EMPTY = register("empty");

private static DeferredHolder<SoundEvent, SoundEvent> register(String sound) {
return SOUND_EVENTS.register(sound, () -> SoundEvent.createVariableRangeEvent(TheAurorian.prefix(sound)));
Expand Down

0 comments on commit c5b6a70

Please sign in to comment.