aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/util/CheatHelper.java
blob: e54684bb7da86a794d68ed1d1a368424bcc0b463 (plain)
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
package makamys.neodymium.util;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.world.World;

public class CheatHelper {
    
    private static final boolean IS_DEV_ENVIRONMENT = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
    
    public static boolean canCheat() {
        if(IS_DEV_ENVIRONMENT) {
            return true;
        } else {
            return isCreative(Minecraft.getMinecraft().thePlayer);
        }
    }

    public static boolean isCreative(EntityPlayer player) {
        return player != null && player.capabilities.isCreativeMode;
    }

    public static boolean isCreativeByName(String player) {
        World world = Minecraft.getMinecraft().theWorld;
        if(world != null) {
            return isCreative(world.getPlayerEntityByName(player));
        }
        return false;
    }
    
}