File size: 1,422 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
package net.minecraft.world.entity;

import net.minecraft.world.item.ItemStack;

public class Crackiness {
    public static final Crackiness GOLEM = new Crackiness(0.75F, 0.5F, 0.25F);
    public static final Crackiness WOLF_ARMOR = new Crackiness(0.95F, 0.69F, 0.32F);
    private final float fractionLow;
    private final float fractionMedium;
    private final float fractionHigh;

    private Crackiness(float p_332482_, float p_329781_, float p_335121_) {
        this.fractionLow = p_332482_;
        this.fractionMedium = p_329781_;
        this.fractionHigh = p_335121_;
    }

    public Crackiness.Level byFraction(float p_330247_) {
        if (p_330247_ < this.fractionHigh) {
            return Crackiness.Level.HIGH;
        } else if (p_330247_ < this.fractionMedium) {
            return Crackiness.Level.MEDIUM;
        } else {
            return p_330247_ < this.fractionLow ? Crackiness.Level.LOW : Crackiness.Level.NONE;
        }
    }

    public Crackiness.Level byDamage(ItemStack p_328846_) {
        return !p_328846_.isDamageableItem() ? Crackiness.Level.NONE : this.byDamage(p_328846_.getDamageValue(), p_328846_.getMaxDamage());
    }

    public Crackiness.Level byDamage(int p_329022_, int p_332255_) {
        return this.byFraction((float)(p_332255_ - p_329022_) / (float)p_332255_);
    }

    public static enum Level {
        NONE,
        LOW,
        MEDIUM,
        HIGH;
    }
}