File size: 1,851 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package net.minecraft.world.level;

import javax.annotation.Nullable;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.phys.Vec3;

public interface Explosion {
    static DamageSource getDefaultDamageSource(Level p_309890_, @Nullable Entity p_311046_) {
        return p_309890_.damageSources().explosion(p_311046_, getIndirectSourceEntity(p_311046_));
    }

    @Nullable
    static LivingEntity getIndirectSourceEntity(@Nullable Entity p_362403_) {
        return switch (p_362403_) {
            case PrimedTnt primedtnt -> primedtnt.getOwner();
            case LivingEntity livingentity -> livingentity;
            case Projectile projectile when projectile.getOwner() instanceof LivingEntity livingentity1 -> livingentity1;
            case null, default -> null;
        };
    }

    ServerLevel level();

    Explosion.BlockInteraction getBlockInteraction();

    @Nullable
    LivingEntity getIndirectSourceEntity();

    @Nullable
    Entity getDirectSourceEntity();

    float radius();

    Vec3 center();

    boolean canTriggerBlocks();

    boolean shouldAffectBlocklikeEntities();

    public static enum BlockInteraction {
        KEEP(false),
        DESTROY(true),
        DESTROY_WITH_DECAY(true),
        TRIGGER_BLOCK(false);

        private final boolean shouldAffectBlocklikeEntities;

        private BlockInteraction(final boolean p_367015_) {
            this.shouldAffectBlocklikeEntities = p_367015_;
        }

        public boolean shouldAffectBlocklikeEntities() {
            return this.shouldAffectBlocklikeEntities;
        }
    }
}