// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java
// @Mod(DarkUtils.MOD_ID)
// public class DarkUtils {
//     
//     public static final String MOD_ID = "darkutils";
//     
//     public static final String MOD_NAME = "Dark Utilities";
//     
//     public static final Logger LOG = LogManager.getLogger(MOD_NAME);
//     
//     public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate));
//     
//     public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X");
//     
//     public static RegistryHelper registry;
//     
//     public static Content content;
//     
//     public static AddonManager addons;
//     
//     public DarkUtils() {
//         
//         registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP));
//         content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry));
//         NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u));
//         registry.initialize(FMLJavaModLoadingContext.get().getModEventBus());
//         
//         // Addons
//         addons = new AddonManager();
//     }
// }


import net.darkhax.bookshelf.util.PlayerUtils;
import net.darkhax.darkutils.DarkUtils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.ServerStatisticsManager;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
import net.minecraftforge.event.entity.living.LivingExperienceDropEvent;
import net.minecraftforge.event.world.BlockEvent;
package net.darkhax.darkutils.features.charms;


public class CharmEffects {
    
    public static void applySleepCharmEffect (Entity user, ItemStack item) {
        
        if (user instanceof PlayerEntity) {
            
            // Set sleep timer above threshold for instant sleeping.
            if (((PlayerEntity) user).isSleeping()) {
                
                ((PlayerEntity) user).sleepTimer = 100;
            }
            
            // Passively decrease the time since last rest stat. This is what phantom spawning
            // looks at.
            if (user instanceof ServerPlayerEntity) {
                
                final Stat<?> sleepStat = Stats.CUSTOM.get(Stats.TIME_SINCE_REST);
                final ServerStatisticsManager statsManager = ((ServerPlayerEntity) user).getStats();
                final int timeSinceLastSlept = statsManager.getValue(sleepStat);
                statsManager.setValue((PlayerEntity) user, sleepStat, Math.max(timeSinceLastSlept - 100, 0));
            }
        }
    }
    
    public static void applyPortalCharmEffect (Entity user, ItemStack item) {
        
        if (user instanceof PlayerEntity) {
            
            // Set portal counter above the threshold for instant entry.
            ((PlayerEntity) user).portalCounter = 100;
        }
    }
    
    public static void applyExperienceCharmTickEffect (Entity user, ItemStack item) {
        
        if (user instanceof PlayerEntity) {
            
            // Completely disable the xp cooldown counter.
            ((PlayerEntity) user).xpCooldown = 0;
        }
    }
    
    public static void handleExpCharmEntity (LivingExperienceDropEvent event) {
        
        if (event.getAttackingPlayer() != null) {
            
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java
// @Mod(DarkUtils.MOD_ID)
// public class DarkUtils {
//     
//     public static final String MOD_ID = "darkutils";
//     
//     public static final String MOD_NAME = "Dark Utilities";
//     
//     public static final Logger LOG = LogManager.getLogger(MOD_NAME);
//     
//     public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate));
//     
//     public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X");
//     
//     public static RegistryHelper registry;
//     
//     public static Content content;
//     
//     public static AddonManager addons;
//     
//     public DarkUtils() {
//         
//         registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP));
//         content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry));
//         NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u));
//         registry.initialize(FMLJavaModLoadingContext.get().getModEventBus());
//         
//         // Addons
//         addons = new AddonManager();
//     }
// }


// Path: src/main/java/net/darkhax/darkutils/features/charms/CharmEffects.java
import net.darkhax.bookshelf.util.PlayerUtils;
import net.darkhax.darkutils.DarkUtils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.ServerStatisticsManager;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
import net.minecraftforge.event.entity.living.LivingExperienceDropEvent;
import net.minecraftforge.event.world.BlockEvent;

package net.darkhax.darkutils.features.charms;


public class CharmEffects {
    
    public static void applySleepCharmEffect (Entity user, ItemStack item) {
        
        if (user instanceof PlayerEntity) {
            
            // Set sleep timer above threshold for instant sleeping.
            if (((PlayerEntity) user).isSleeping()) {
                
                ((PlayerEntity) user).sleepTimer = 100;
            }
            
            // Passively decrease the time since last rest stat. This is what phantom spawning
            // looks at.
            if (user instanceof ServerPlayerEntity) {
                
                final Stat<?> sleepStat = Stats.CUSTOM.get(Stats.TIME_SINCE_REST);
                final ServerStatisticsManager statsManager = ((ServerPlayerEntity) user).getStats();
                final int timeSinceLastSlept = statsManager.getValue(sleepStat);
                statsManager.setValue((PlayerEntity) user, sleepStat, Math.max(timeSinceLastSlept - 100, 0));
            }
        }
    }
    
    public static void applyPortalCharmEffect (Entity user, ItemStack item) {
        
        if (user instanceof PlayerEntity) {
            
            // Set portal counter above the threshold for instant entry.
            ((PlayerEntity) user).portalCounter = 100;
        }
    }
    
    public static void applyExperienceCharmTickEffect (Entity user, ItemStack item) {
        
        if (user instanceof PlayerEntity) {
            
            // Completely disable the xp cooldown counter.
            ((PlayerEntity) user).xpCooldown = 0;
        }
    }
    
    public static void handleExpCharmEntity (LivingExperienceDropEvent event) {
        
        if (event.getAttackingPlayer() != null) {
            
            final Item charm = DarkUtils.content.experienceCharm;