public class ClientProxy extends CommonProxy {
    Minecraft mc;
    public static ConcurrentHashMap<Integer, ChallengerMobType> challengerMobs = new ConcurrentHashMap<>();

    @Override
    public void init() {
        mc = Minecraft.getInstance();
        CommonProxy.networkManager.networkWrapper.registerMessage(0, ArmorBreakPacket.class, ArmorBreakPacket::encode,
                ArmorBreakPacket::decode, ArmorBreakPacket::handleClient);
        networkManager.networkWrapper.registerMessage(1, ChallengerMobPacket.class, ChallengerMobPacket::encode,
                ChallengerMobPacket::decode, ChallengerMobPacket::handleClient);
        MinecraftForge.EVENT_BUS.register(new ChallengerParticles());
    }

    @Override
    public void hurt(Player player, float newHealth) {
        player.setHealth(newHealth);
        player.animateHurt();
    }

    @Override
    public void playSound(Player player) {
        if (mc.player != null) {
            mc.player.playSound(SoundEvents.SHIELD_BREAK, 1F, 1F);
        }
    }

    @Override
    public void addChallengerMob(Monster entity, ChallengerMobType type) {
        challengerMobs.put(entity.getId(), type);
    }
} public class LowHealthSound {
    private static final String SOUND_KEY = "vtweaks:lowHealthSound";

    @SubscribeEvent
    public void registerEvent(PlayerEvent evt) {
        if (!ClientConfig.ENABLE_LOW_HEALTH_SOUND.get()) {
            return;
        }

        if (evt.getPlayer() == null || !evt.getPlayer().isAlive()) {
            return;
        }

        float vol = ClientConfig.LOW_HEALTH_VOLUME.get().floatValue();
        long now = System.currentTimeMillis();

        if (evt.getPlayer().getHealth() / evt.getPlayer().getMaxHealth() < ClientConfig.LOW_HEALTH_THRESHOLD.get()) {
            if (now >= getNextPlayTime(evt.getPlayer())) {
                BEATS type = getNextPlayType(evt.getPlayer());
                float pitch = type == BEATS.first ? 1F : .5F;
                long nextDelay = type == BEATS.first ? 200L : ClientConfig.LOW_HEALTH_FREQ.get();


                evt.getPlayer().playSound(SoundEvents.NOTE_BLOCK_BASEDRUM, vol, pitch);
                setNext(evt.getPlayer(), type == BEATS.first ? BEATS.second : BEATS.first, now + nextDelay);
            }
        }
    }

    private long getNextPlayTime(Player ent) {
        CompoundTag comp = ent.getPersistentData();
        if (comp.contains(SOUND_KEY)) {
            CompoundTag obj = comp.getCompound(SOUND_KEY);
            return obj.getLong("time");
        }
        return 0L;
    }

    private BEATS getNextPlayType(Player ent) {
        CompoundTag comp = ent.getPersistentData();
        if (comp.contains(SOUND_KEY)) {
            CompoundTag obj = comp.getCompound(SOUND_KEY);
            return BEATS.valueOf(obj.getString("type"));
        }
        return BEATS.first;
    }

    private void setNext(Player ent, BEATS b, long nextTime) {
        CompoundTag comp = ent.getPersistentData();
        CompoundTag obj = new CompoundTag();

        obj.putString("type", b.name());
        obj.putLong("time", nextTime);
        comp.put(SOUND_KEY, obj);
    }

    enum BEATS {
        first, second
    }
} public class SmallBees {
    @SubscribeEvent
    @OnlyIn(Dist.CLIENT)
    public void registerEvent(RenderLivingEvent.Pre<Bee, BeeModel<Bee>> evt) {
        if (ClientConfig.ENABLE_SMALL_BEES.get() && evt.getEntity() instanceof Bee) {
            evt.getMatrixStack().scale(.5F, .5F, .5F);
        }
    }
} public class CommonProxy {
    public static NetworkManager networkManager = new NetworkManager();

    public void init() {
        networkManager.networkWrapper.registerMessage(0, ArmorBreakPacket.class, ArmorBreakPacket::encode,
                ArmorBreakPacket::decode, ArmorBreakPacket::handleServer);
        networkManager.networkWrapper.registerMessage(1, ChallengerMobPacket.class, ChallengerMobPacket::encode,
                ChallengerMobPacket::decode, ChallengerMobPacket::handleServer);
    }

    public void playSound(Player player) {
        ArmorBreakPacket msg = new ArmorBreakPacket();
        networkManager.networkWrapper.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), msg);
    }

    public void hurt(Player player, float newHealth) {
        player.setHealth(newHealth);
    }

    public void addChallengerMob(Monster entity, ChallengerMobType type) {
        ChallengerMobPacket msg = new ChallengerMobPacket(entity.getId(), type);
        networkManager.networkWrapper.send(PacketDistributor.ALL.noArg(), msg);
    }
} @Mod.EventBusSubscriber
public class ClientConfig {
    public static final ForgeConfigSpec CLIENT_CONFIG;
    private static final Builder CLIENT_BUILDER = new Builder();

    public static ForgeConfigSpec.BooleanValue ENABLE_LOW_HEALTH_SOUND;
    public static ForgeConfigSpec.DoubleValue LOW_HEALTH_VOLUME;
    public static ForgeConfigSpec.DoubleValue LOW_HEALTH_THRESHOLD;
    public static ForgeConfigSpec.LongValue LOW_HEALTH_FREQ;

    public static ForgeConfigSpec.BooleanValue ENABLE_SMALL_BEES;

    public static ForgeConfigSpec.BooleanValue ENABLE_CHALLENGER_PARTICLES;

    private static final String CATEGORY_CLIENT = "client_configs";

    static {
        init();
        CLIENT_CONFIG = CLIENT_BUILDER.build();
    }

    public static void loadConfig(ForgeConfigSpec spec, Path path) {
        final CommentedFileConfig configData = CommentedFileConfig.builder(path).sync().autosave()
                .writingMode(WritingMode.REPLACE).build();
        configData.load();
        spec.setConfig(configData);
    }

    private static void init() {
        CLIENT_BUILDER.comment("Client Configuration Settings").push(CATEGORY_CLIENT);

        ENABLE_LOW_HEALTH_SOUND = CLIENT_BUILDER
                .comment("Enable a recurring heartbeat sound when health drops below a threshold")
                .define("enableLowHealthSound", true);
        LOW_HEALTH_VOLUME = CLIENT_BUILDER.comment("The volume at which to play the low health sound (if enabled)")
                .defineInRange("lowHealthSoundVolume", .5D, 0D, 1D);
        LOW_HEALTH_THRESHOLD = CLIENT_BUILDER
                .comment("The highest health percentage the player must have to trigger the low health sound")
                .defineInRange("lowHealthSoundThreshold", .25D, 0D, 1D);
        LOW_HEALTH_FREQ = CLIENT_BUILDER
                .comment("The frequency with which the low health sound will play (in milliseconds)")
                .defineInRange("lowHealthSoundFrequency", 2000, 0, Long.MAX_VALUE);

        ENABLE_SMALL_BEES = CLIENT_BUILDER
                .comment("If enabled, all bees will always be half-sized. Does not affect breeding or hitboxes")
                .define("enableSmallBees", true);

        ENABLE_CHALLENGER_PARTICLES = CLIENT_BUILDER
                .comment("Enable colored particles for challenger mobs (dependent on particle setting as well)")
                .define("enableChallengerMobParticles", true);

        CLIENT_BUILDER.pop();
    }
} @Mod.EventBusSubscriber
public class CommonConfig {
    public static final ForgeConfigSpec COMMON_CONFIG;
    private static final Builder COMMON_BUILDER = new Builder();

    public static ForgeConfigSpec.BooleanValue DISABLE_THUNDER_STORMS;
    public static ForgeConfigSpec.BooleanValue ENABLE_DEATH_MESSAGE;
    public static ForgeConfigSpec.BooleanValue ENABLE_CHEAP_ANVIL_REPAIR;

    public static ForgeConfigSpec.EnumValue<FoodTooltips> FOOD_TOOLTIP;
    public static ForgeConfigSpec.EnumValue<DurabilityTooltips> DURABILITY_TOOLTIP;

    private static final String CATEGORY_MISC = "miscellaneous";

    static {
        EnchantmentConfig.init(COMMON_BUILDER);
        MobTweakConfig.init(COMMON_BUILDER);
        BlockTweakConfig.init(COMMON_BUILDER);
        ItemTweakConfig.init(COMMON_BUILDER);
        init();
        COMMON_CONFIG = COMMON_BUILDER.build();
    }

    public static void loadConfig(ForgeConfigSpec spec, Path path) {
        final CommentedFileConfig configData = CommentedFileConfig.builder(path).sync().autosave()
                .writingMode(WritingMode.REPLACE).build();
        configData.load();
        spec.setConfig(configData);
    }

    private static void init() {
        COMMON_BUILDER.comment("Miscellaneous").push(CATEGORY_MISC);

        DISABLE_THUNDER_STORMS = COMMON_BUILDER
                .comment("Disables thunder storms, fixing glitched lighting from thunder and other side-effects")
                .define("enableStormTweak", true);
        ENABLE_DEATH_MESSAGE = COMMON_BUILDER.comment("Prints your death point in chat").define("enableDeathPoint",
                true);
        FOOD_TOOLTIP = COMMON_BUILDER.comment("Show food hunger & saturation on item hover")
                .defineEnum("foodTooltipSetting", FoodTooltips.WITH_SHIFT);
        DURABILITY_TOOLTIP = COMMON_BUILDER.comment("Show tool durability on item hover")
                .defineEnum("durabilityTooltipSetting", DurabilityTooltips.WITH_SHIFT);
        ENABLE_CHEAP_ANVIL_REPAIR = COMMON_BUILDER.comment("Makes all anvil tool repairs always cost 1 level of XP")
                .define("enableCheapAnvilRepair", true);

        COMMON_BUILDER.pop();
    }

    public enum FoodTooltips {
        NEVER, WITH_SHIFT, ALWAYS
    }

    public enum DurabilityTooltips {
        NEVER, WITH_SHIFT, ALWAYS
    }
} public class EnchantmentConfig {

    private static final String CATEGORY_ENCHANTMENTS = "enchantments";

    public static ForgeConfigSpec.BooleanValue ENABLE_LUMBERING;
    public static ForgeConfigSpec.IntValue LUMBERING_MAX_INT;
    public static ForgeConfigSpec.BooleanValue ENABLE_IMPERISHABLE;
    public static ForgeConfigSpec.BooleanValue ENABLE_FF_TWEAK;
    public static ForgeConfigSpec.IntValue IMPERISHABLE_RECIPE_COST;
    public static ForgeConfigSpec.IntValue LUMBERING_RECIPE_COST;
    public static ForgeConfigSpec.BooleanValue LUMBERING_CUTS_LEAVES;
    public static ForgeConfigSpec.BooleanValue LUMBERING_WOOD_STRICT;

    public static void init(ForgeConfigSpec.Builder COMMON_BUILDER) {
        COMMON_BUILDER.comment("Enchantments").push(CATEGORY_ENCHANTMENTS);

        ENABLE_LUMBERING = COMMON_BUILDER.comment("Enable the Lumbering enchantment for Axes").define("enableLumbering",
                true);
        LUMBERING_MAX_INT = COMMON_BUILDER.comment("The maximum amount of logs lumbering can destroy")
                .defineInRange("maxLumberCount", 1024, 1, Integer.MAX_VALUE);
        ENABLE_IMPERISHABLE = COMMON_BUILDER.comment("Enable the Imperishable enchantment for any breakable item")
                .define("enableImperishable", true);
        ENABLE_FF_TWEAK = COMMON_BUILDER.comment("Feather Falling IV or above directs 100% of fall damage to boots")
                .define("enableFeatherFallTweak", true);
        IMPERISHABLE_RECIPE_COST = COMMON_BUILDER.comment("Number of levels Imperishable costs to create in an anvil")
                .defineInRange("imperishableCost", 30, 1, 40);
        LUMBERING_RECIPE_COST = COMMON_BUILDER.comment("Number of levels Lumbering costs to create in an anvil")
                .defineInRange("lumberingCost", 16, 1, 40);
        LUMBERING_CUTS_LEAVES = COMMON_BUILDER
                .comment("Should the lumbering enchantment also prune the leaves of a tree?")
                .define("lumberingCutsLeaves", true);
        LUMBERING_WOOD_STRICT = COMMON_BUILDER.comment(
                "Should the lumbering enchantment be strict about wood types?\ne.g. if you're in a forest with mixed woods touching, should lumbering only break the same type of wood that was initially broken?")
                .define("lumberingIsStrictAboutWood", true);

        COMMON_BUILDER.pop();
    }
} public class EnchantmentImperishable extends Enchantment {
    public EnchantmentImperishable() {
        super(Rarity.UNCOMMON, EnchantmentCategory.BREAKABLE, EquipmentSlot.values());
        this.setRegistryName(new ResourceLocation(Constants.MODID, "imperishable"));
    }

    @Override
    public boolean checkCompatibility(Enchantment enchantment) {
        return this != enchantment;
    }

    @Override
    public int getMinCost(int par1) {
        return 0;
    }

    @Override
    public int getMaxCost(int par1) {
        return 0;
    }
} public class EnchantmentLumbering extends Enchantment {
    public EnchantmentLumbering() {
        super(Enchantment.Rarity.VERY_RARE, EnchantmentCategory.DIGGER, new EquipmentSlot[]{EquipmentSlot.MAINHAND});
        this.setRegistryName(new ResourceLocation(Constants.MODID, "lumbering"));
    }

    @Override
    public boolean checkCompatibility(Enchantment enchantment) {
        return this != enchantment;
    }

    @Override
    public boolean canEnchant(ItemStack stack) {
        return stack.canPerformAction(ToolActions.AXE_DIG);
    }

    @Override
    public int getMinCost(int par1) {
        return 0;
    }

    @Override
    public int getMaxCost(int par1) {
        return 0;
    }
} public class FeatherFallingTweak {
    @SubscribeEvent
    public void registerTweak(LivingHurtEvent event) {
        // Check if enchantment is disabled
        if (!EnchantmentConfig.ENABLE_FF_TWEAK.get()) {
            return;
        }
        // Ensures we're working on a player entity AND we're working with fall damage
        if (!(event.getEntity() instanceof ServerPlayer) || event.getSource() != DamageSource.FALL) {
            return;
        }

        ServerPlayer player = (ServerPlayer) event.getEntity();
        ItemStack boots = player.getInventory().getArmor(0);
        // Checks if boots are worn
        if (boots.isEmpty()) {
            return;
        }

        // Checks if FeatherFalling IV or higher is on the boots
        if (EnchantmentHelper.getItemEnchantmentLevel(Utils.getEnchantment("minecraft", "feather_falling"), boots) >= 4) {
            boots.hurt((int) event.getAmount(), player.getRandom(), player);
            event.setAmount(0.0F);
        }
    }
} public class EnchantmentImperishableHandler {
    // Breaking a block with any tool
    @SubscribeEvent
    public void register(BreakSpeed event) {
        if (!EnchantmentConfig.ENABLE_IMPERISHABLE.get()) {
            return;
        }

        if (event.getEntity() == null || !(event.getEntity() instanceof ServerPlayer)) {
            return;
        }

        ServerPlayer player = (ServerPlayer) event.getEntity();
        ItemStack stack = player.getItemInHand(InteractionHand.MAIN_HAND);
        if (stack.isEmpty()) {
            return;
        }

        if (EnchantmentHelper.getItemEnchantmentLevel(VTweaks.imperishable, stack) > 0) {
            if (stack.getDamageValue() >= (stack.getMaxDamage() - 1)) {
                event.getPlayer().playSound(SoundEvents.SHIELD_BREAK, 0.25F,
                        (float) Math.min(1.0F, 0.5F + event.getPlayer().getRandom().nextDouble()));
                event.setNewSpeed(0F);
            }
        }
    }

    // Attacking an entity with any tool
    @SubscribeEvent
    public void register(AttackEntityEvent event) {
        if (!EnchantmentConfig.ENABLE_IMPERISHABLE.get()) {
            return;
        }
        if (event.getPlayer() == null || event.getPlayer().isCreative()) {
            return;
        }

        ItemStack stack = event.getPlayer().getMainHandItem();
        if (EnchantmentHelper.getItemEnchantmentLevel(VTweaks.imperishable, stack) > 0) {
            if (stack.getDamageValue() >= (stack.getMaxDamage() - 1)) {
                if (event.isCancelable()) {
                    event.getPlayer().playSound(SoundEvents.SHIELD_BREAK, 1.0F,
                            (float) Math.min(1.0F, 0.5F + event.getPlayer().getRandom().nextDouble()));
                    event.getPlayer().displayClientMessage(new TranslatableComponent("vtweaks.tool.damaged"), true);
                    event.setCanceled(true);
                }
            }
        }
    }

    // Item use checks (e.g. shearing a sheep, tilling grass, etc.)
    @SubscribeEvent
    public void register(PlayerInteractEvent event) {
        if (!EnchantmentConfig.ENABLE_IMPERISHABLE.get()) {
            return;
        }
        if (event.getPlayer() == null || event.getPlayer().isCreative()) {
            return;
        }

        ItemStack stack = event.getPlayer().getMainHandItem();
        if (EnchantmentHelper.getItemEnchantmentLevel(VTweaks.imperishable, stack) > 0) {
            if (stack.getDamageValue() >= (stack.getMaxDamage() - 1)) {
                if (event.isCancelable()) {
                    event.getPlayer().playSound(SoundEvents.SHIELD_BREAK, 1.0F,
                            (float) Math.min(1.0F, 0.5F + event.getPlayer().getRandom().nextDouble()));
                    event.getPlayer().displayClientMessage(new TranslatableComponent("vtweaks.tool.damaged"), true);
                    event.setCanceled(true);
                }
            }
        }
    }

    // Armor damage checks
    @SubscribeEvent
    public void register(PlayerEvent event) {
        if (!EnchantmentConfig.ENABLE_IMPERISHABLE.get()) {
            return;
        }

        try {
            ArrayList<ItemStack> salvaged = Lists.newArrayList();
            for (ItemStack stack : event.getPlayer().getArmorSlots()) {
                if (stack.getItem() instanceof ArmorItem) {
                    ArmorItem armor = (ArmorItem) stack.getItem();
                    if (EnchantmentHelper.getItemEnchantmentLevel(VTweaks.imperishable, stack) > 0) {
                        if (armor.getDamage(stack) >= (armor.getMaxDamage(stack) - 1)) {
                            salvaged.add(stack);
                        }
                    }
                }
            }

            salvaged.forEach((stack) -> {
                ItemHandlerHelper.giveItemToPlayer(event.getPlayer(), stack.copy());
                event.getPlayer().setItemSlot(LivingEntity.getEquipmentSlotForItem(stack), ItemStack.EMPTY);
                event.getPlayer().getInventory().setChanged();
                VTweaks.proxy.playSound(event.getPlayer());
            });
        } catch (NullPointerException ignored) {
            return;
        }
    }
} public class EnchantmentLumberingHandler {
    @SubscribeEvent(priority = EventPriority.HIGHEST)
    public void register(BreakEvent event) {
        // Check if enchantment is disabled
        if (!EnchantmentConfig.ENABLE_LUMBERING.get()) {
            return;
        }
        // Check that state, world, player or player's held item all exist
        if (event.getState() == null || event.getWorld() == null || event.getPlayer() == null
                || event.getPlayer().getMainHandItem().isEmpty() || event.getPlayer().isCreative()
                || !(event.getWorld() instanceof ServerLevel)) {
            return;
        }
        ServerLevel world = (ServerLevel) event.getWorld();
        Player player = event.getPlayer();
        // Checks if the axe has lumbering
        if (EnchantmentHelper.getEnchantmentLevel(VTweaks.lumbering, player) > 0) {
            if (player.isCrouching()) {
                if (BlockTags.LOGS.contains(event.getState().getBlock())) {
                    chopTree(world, player, event.getPos(), event.getState(), 0);
                }
            }
        }
    }

    private boolean chopTree(ServerLevel world, Player player, BlockPos pos, BlockState original, int curr) {
        if (curr >= EnchantmentConfig.LUMBERING_MAX_INT.get()) {
            if (curr > EnchantmentConfig.LUMBERING_MAX_INT.get()) {
                VTweaks.getInstance().LOGGER.info("Somehow exceeded max lumbering count with value {} (max is {})",
                        curr, EnchantmentConfig.LUMBERING_MAX_INT.get());
            }
            return false;
        }
        for (int mod_x = -1; mod_x <= 1; mod_x++) {
            for (int mod_y = -1; mod_y <= 1; mod_y++) {
                for (int mod_z = -1; mod_z <= 1; mod_z++) {
                    BlockPos iterPos = pos.offset(mod_x, mod_y, mod_z);
                    if (iterPos != pos) {
                        if (!canStillChop(player)) {
                            return false;
                        }
                        if (woodMatchFilter(original, world.getBlockState(iterPos))) {
                            emulateBreak(world, iterPos, player, true);
                            if (!chopTree(world, player, iterPos, original, curr + 1)) {
                                return false;
                            }
                        } else if (EnchantmentConfig.LUMBERING_CUTS_LEAVES.get()) {
                            if (BlockTags.LEAVES.contains(world.getBlockState(iterPos).getBlock())) {
                                emulateBreak(world, iterPos, player, false);
                                if (!chopTree(world, player, iterPos, original, curr + 1)) {
                                    return false;
                                }
                            }
                        }

                    }
                }
            }
        }

        return true;
    }

    /**
     * Determines if the player can continue to chop down the tree
     *
     * @param player the player to check
     * @return
     */
    private boolean canStillChop(Player player) {
        if (!player.getMainHandItem().canPerformAction(ToolActions.AXE_DIG)) {
            return false;
        }
//        if (!player.getMainHandItem().getToolTypes().contains(ToolType.AXE)) {
//            return false;
//        }

        ItemStack axe = player.getMainHandItem().copy();
        IEnergyStorage cap = axe.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);

        // Energy Handling
        if (axe.hasTag()) {
            CompoundTag comp = axe.getTag();
            if (comp.contains("Energy")) {
                return comp.getInt("Energy") > 0;
            }
        }

        if (cap != null) {
            return cap.getEnergyStored() > 0;
        }

        // This will both save the tool, and save it for Imperishing
        return (axe.getMaxDamage() - axe.getDamageValue()) > 2;
    }

    private boolean woodMatchFilter(BlockState original, BlockState current) {
        if (EnchantmentConfig.LUMBERING_WOOD_STRICT.get()) {
            return original.getBlock().getRegistryName().equals(current.getBlock().getRegistryName());
        }
        return BlockTags.LOGS.contains(current.getBlock());
    }

    private void emulateBreak(ServerLevel world, BlockPos pos, Player player, boolean damageTool) {
        BlockState state = world.getBlockState(pos);

        state.onRemove(world, pos, state, false);
        Block.dropResources(state, world, pos, world.getBlockEntity(pos));
        world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
        if (damageTool) {
            player.getMainHandItem().hurt(1, player.getRandom(), null);
        }
    }
} public class DeathPoint {
    @SubscribeEvent
    public void registerTweak(LivingDeathEvent event) {
        // Check if feature is enabled
        if (!CommonConfig.ENABLE_DEATH_MESSAGE.get()) {
            return;
        }
        // Are you human?
        if (!(event.getEntity() instanceof Player)) {
            return;
        }

        Player player = (Player) event.getEntity();
        player.sendMessage(getCoordMessage(player.getOnPos()), UUID.randomUUID());
    }

    // Coincidentally compatible with Journeymap :D
    private TranslatableComponent getCoordMessage(BlockPos pos) {
        return new TranslatableComponent("vtweaks.death.message", pos.getX(), pos.getY(), pos.getZ());
    }
} public class StormTweak {
    @SubscribeEvent
    public void registerTweak(WorldEvent event) {
        // Check if feature is enabled
        if (!CommonConfig.DISABLE_THUNDER_STORMS.get() || event.getWorld() == null) {
            return;
        }
        // Converts storms to regular rain
        if (event.getWorld() != null) {
            if (event.getWorld().getLevelData().isRaining()) {
                if (event.getWorld().getLevelData().isThundering()) {
                    if (event.getWorld().getLevelData() instanceof ServerLevelData) {
                        ((ServerLevelData) event.getWorld().getLevelData()).setThundering(false);
                    }
                }
            }
        }
    }
} public class ToolTips {
    @SubscribeEvent
    @OnlyIn(Dist.CLIENT)
    public void registerTweak(ItemTooltipEvent event) {
        if (event.getItemStack().isEmpty()) {
            return;
        }

        ItemStack stack = event.getItemStack();
        boolean shift = Screen.hasShiftDown();

        // Food tooltip
        if (stack.getItem().getFoodProperties() != null) {
            // Checks to see if feature is enabled
            if (CommonConfig.FOOD_TOOLTIP.get() == CommonConfig.FoodTooltips.NEVER) {
                return;
            }

            FoodProperties food = stack.getItem().getFoodProperties();
            int hunger = food.getNutrition();
            float saturation = food.getSaturationModifier() * 10;

            if (CommonConfig.FOOD_TOOLTIP.get() == CommonConfig.FoodTooltips.ALWAYS) {
                event.getToolTip().add(getHungerString(hunger));
                event.getToolTip().add(getSaturationString((int) saturation));
            } else if (CommonConfig.FOOD_TOOLTIP.get() == CommonConfig.FoodTooltips.WITH_SHIFT && shift) {
                event.getToolTip().add(getHungerString(hunger));
                event.getToolTip().add(getSaturationString((int) saturation));
            }
        }

        if (stack.getItem().isDamageable(stack)) {
            // Checks to see if feature is enabled
            if (CommonConfig.DURABILITY_TOOLTIP.get() == CommonConfig.DurabilityTooltips.NEVER) {
                return;
            }

            if (CommonConfig.DURABILITY_TOOLTIP.get() == CommonConfig.DurabilityTooltips.ALWAYS) {
                event.getToolTip().add(getDurabilityString(stack));
            } else if (CommonConfig.DURABILITY_TOOLTIP.get() == CommonConfig.DurabilityTooltips.WITH_SHIFT && shift) {
                event.getToolTip().add(getDurabilityString(stack));
            }
        }
    }

    private TextComponent getHungerString(int hunger) {
        StringBuilder ret = new StringBuilder(ChatFormatting.GRAY + "Hunger:");

        for (int i = 0; i < (hunger / 2); i++) {
            ret.append(ChatFormatting.RED).append("\u2588");
        }
        if (hunger % 2 != 0) {
            ret.append(ChatFormatting.DARK_RED).append("\u258C");
        }
        return new TextComponent(ret.toString());
    }

    private TextComponent getSaturationString(int saturation) {
        StringBuilder ret = new StringBuilder(ChatFormatting.GRAY + "Sat:");
        for (int i = 0; i < saturation / 2; i++) {
            ret.append(ChatFormatting.RED).append("\u2588");
        }
        if (saturation % 2 != 0) {
            ret.append(ChatFormatting.RED).append("\u258C");
        }
        return new TextComponent(ret.toString());
    }

    private TextComponent getDurabilityString(ItemStack itemstack) {
        String ret = "Durability: ";
        int max = itemstack.getMaxDamage();
        int damage = itemstack.getDamageValue();
        float percentage = 1 - ((float) damage / (float) max);
        if (percentage >= .9) {
            return new TextComponent(
                    ret + ChatFormatting.LIGHT_PURPLE + (max - damage) + " / " + max + ChatFormatting.RESET);
        }
        if (percentage >= .8) {
            return new TextComponent(
                    ret + ChatFormatting.DARK_PURPLE + (max - damage) + " / " + max + ChatFormatting.RESET);
        }
        if (percentage >= .7) {
            return new TextComponent(
                    ret + ChatFormatting.BLUE + (max - damage) + " / " + max + ChatFormatting.RESET);
        }
        if (percentage >= .6) {
            return new TextComponent(
                    ret + ChatFormatting.DARK_AQUA + (max - damage) + " / " + max + ChatFormatting.RESET);
        }
        if (percentage >= .5) {
            return new TextComponent(
                    ret + ChatFormatting.DARK_GREEN + (max - damage) + " / " + max + ChatFormatting.RESET);
        }
        if (percentage >= .4) {
            return new TextComponent(
                    ret + ChatFormatting.GREEN + (max - damage) + " / " + max + ChatFormatting.RESET);
        }
        if (percentage >= .3) {
            return new TextComponent(
                    ret + ChatFormatting.YELLOW + (max - damage) + " / " + max + ChatFormatting.RESET);
        }
        if (percentage >= .2) {
            return new TextComponent(
                    ret + ChatFormatting.GOLD + (max - damage) + " / " + max + ChatFormatting.RESET);
        }
        if (percentage >= .1) {
            return new TextComponent(
                    ret + ChatFormatting.RED + (max - damage) + " / " + max + ChatFormatting.RESET);
        }
        return new TextComponent(
                ret + ChatFormatting.DARK_RED + (max - damage) + " / " + max + ChatFormatting.RESET);
    }
} public class BonemealTweaks {
    @SubscribeEvent
    public void registerTweak(RightClickBlock event) {
        // Checks if feature is enabled
        if (!BlockTweakConfig.ENABLE_BONEMEAL_TWEAK.get() || !(event.getEntity() instanceof Player)) {
            return;
        }

        Player player = (Player) event.getEntity();
        Level world = event.getWorld();
        Block testFor = world.getBlockState(event.getPos()).getBlock();
        Random rand = world.random;

        if (!player.getMainHandItem().isEmpty()) {
            ItemStack heldItem = player.getMainHandItem();
            if (heldItem.getItem() == Items.BONE_MEAL) {
                if (testFor == Blocks.CACTUS || testFor == Blocks.SUGAR_CANE) {
                    if (world.getBlockState(event.getPos().below(2)).getBlock() != testFor
                            && world.getBlockState(event.getPos().above()).isAir()) {
                        player.swing(InteractionHand.MAIN_HAND);
                        for (int i = 0; i < 8; i++) {
                            spawnParticles(world, rand, event.getPos());
                        }
                        if (!world.isClientSide()) {
                            if (!player.isCreative()) {
                                heldItem.setCount(heldItem.getCount() - 1);
                            }
                            world.setBlock(event.getPos().above(), world.getBlockState(event.getPos()), 2);
                        }
                    }
                }
            }
        }
    }

    private void spawnParticles(Level world, Random rand, BlockPos pos) {
        BlockState state = world.getBlockState(pos);
        double d0 = rand.nextGaussian() * 0.02D;
        double d1 = rand.nextGaussian() * 0.02D;
        double d2 = rand.nextGaussian() * 0.02D;
        world.addParticle(ParticleTypes.HAPPY_VILLAGER, (float) pos.getX() + rand.nextFloat(),
                (double) pos.getY() + (double) rand.nextFloat() * state.getShape(world, pos).max(Direction.Axis.Y),
                (float) pos.getZ() + rand.nextFloat(), d0, d1, d2);
    }
} public class CakeTweak {
    @SubscribeEvent
    public void registerTweak(BlockEvent.BreakEvent event) {
        // Checks if feature is enabled
        if (!BlockTweakConfig.ENABLE_CAKE_DROP.get()) {
            return;
        }

        Block block = event.getState().getBlock();
        if (event.getPlayer() != null && block instanceof CakeBlock) {
            if (event.getState().hasProperty(CakeBlock.BITES)) {
                int bites = event.getState().getValue(CakeBlock.BITES);
                if (bites == 0) {
                    ItemEntity cakeItem = new ItemEntity((Level) event.getWorld(),
                            (double) event.getPos().getX() + 0.5D, event.getPos().getY(),
                            (double) event.getPos().getZ() + 0.5D, new ItemStack(Items.CAKE));
                    cakeItem.setPickUpDelay(10);
                    event.getWorld().addFreshEntity(cakeItem);
                }
            }
        }
    }
} public class ChopDown {
    @SubscribeEvent
    public void registerEvent(BlockEvent.BreakEvent evt) {
        if (!BlockTweakConfig.ENABLE_TREE_CHOP_DOWN.get()) {
            return;
        }

        int lumberLvl = EnchantmentHelper.getItemEnchantmentLevel(VTweaks.lumbering, evt.getPlayer().getMainHandItem());

        // Drop early if lumbering..
        if (evt.getPlayer().isCrouching() && lumberLvl > 0) {
            return;
        }

        if (!(evt.getWorld() instanceof Level)) {
            return;
        }

        BlockPos initialPos = evt.getPos();
        Level level = (Level) evt.getWorld();
        Player player = evt.getPlayer();

        for (int dy = 0; dy < BlockTweakConfig.TREE_CHOP_DOWN_LOG_COUNT.get(); dy++) {
            if (!BlockTags.LOGS.contains(level.getBlockState(initialPos.offset(0, dy, 0)).getBlock())) {
                return;
            }
        }

        int rad = 32;
        int leaf = 5;
        Direction dir = getDirection(player.blockPosition(), initialPos);

        // Let's not chop down everything if it's basically not a tree
        boolean leavesFound = false;

        LinkedList<BlockPos> queue = new LinkedList<BlockPos>();
        HashMap<BlockPos, Integer> used = new HashMap<BlockPos, Integer>();

        queue.add(initialPos);
        used.put(initialPos, leaf);

        while (!queue.isEmpty()) {
            BlockPos top = queue.pollFirst();

            for (int dx = -1; dx <= 1; ++dx) {
                for (int dy = -1; dy <= 1; ++dy) {
                    for (int dz = -1; dz <= 1; ++dz) {
                        BlockPos tmpPos = top.offset(dx, dy, dz);
                        int step = used.get(top);
                        if (step <= 0 || tmpPos.distSqr(initialPos) > (rad * rad)) {
                            continue;
                        }

                        BlockState bs = level.getBlockState(tmpPos);
                        boolean isLog = BlockTags.LOGS.contains(bs.getBlock());
                        boolean isLeaf = BlockTags.LEAVES.contains(bs.getBlock());

                        if (isLeaf && !leavesFound) {
                            leavesFound = true;
                        }
                        // Check if there's a log directly above
                        if ((dy >= 0 && step == leaf && isLog) || isLeaf) {
                            step -= (isLeaf ? 1 : 0);
                            if (!used.containsKey(tmpPos) || used.get(tmpPos) < step) {
                                used.put(tmpPos, step);
                                queue.push(tmpPos);
                            }
                        }
                    }
                }
            }
        }

        if (leavesFound) {
            // Start moving things now that we've calculated it all
            for (Entry<BlockPos, Integer> entry : used.entrySet()) {
                BlockPos blockPos = entry.getKey();
                if (!initialPos.equals(blockPos) && canBeMoved(level, blockPos.offset(0, -1, 0))) {
                    BlockPos newPos = getNewPosition(initialPos, blockPos, dir);
                    moveAsBlockEntity(level, blockPos, newPos);
                }
            }
        }
    }

    private Direction getDirection(BlockPos playerPos, BlockPos brokenPos) {
        double x = (brokenPos.getX() + 0.5) - playerPos.getX();
        double z = (brokenPos.getZ() + 0.5) - playerPos.getZ();
        double abX = Math.abs(x);
        double abZ = Math.abs(z);
        int dirX = abX > abZ ? (int) Math.floor(abX / x) : 0;
        int dirZ = abX > abZ ? 0 : (int) Math.floor(abZ / z);
        if (dirX != 0) {
            return dirX == 1 ? Direction.EAST : Direction.WEST;
        }
        return dirZ == 1 ? Direction.SOUTH : Direction.NORTH;
    }

    private BlockPos getNewPosition(BlockPos initialBreakPos, BlockPos pos, Direction facing) {
        // Transforms height of tree into length of throw
        int transformedY = pos.getY() - initialBreakPos.getY();
        switch (facing) {
            case SOUTH:
                return pos.offset(0, 0, 1 + transformedY);
            case NORTH:
                return pos.offset(0, 0, 1 - transformedY);
            case EAST:
                return pos.offset(transformedY, 0, 1);
            case WEST:
                return pos.offset(-transformedY, 0, 1);
            default: // Up and Down won't be involved.
                return pos;
        }
    }

    private boolean canBeMoved(Level level, BlockPos pos) {
        BlockState bs = level.getBlockState(pos);
        Block b = bs.getBlock();

        return !bs.hasBlockEntity() && (BlockTags.LOGS.contains(b) || BlockTags.LEAVES.contains(b)
                || BlockTags.BEEHIVES.contains(b) || bs.isAir());
    }

    private void moveAsBlockEntity(Level level, BlockPos pos, BlockPos newPos) {
        BlockState bs = level.getBlockState(pos);
        // destroy some leaves
        if (BlockTags.LEAVES.contains(bs.getBlock()) && level.getRandom().nextBoolean()) {
            Block.dropResources(bs, level, newPos, null);
        } else {
            CustomFallingBlockEntity e = new CustomFallingBlockEntity(level, newPos, bs);
            level.addFreshEntity(e);
        }
        level.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
    }

    class CustomFallingBlockEntity extends FallingBlockEntity {
        public CustomFallingBlockEntity(Level level, BlockPos pos, BlockState s) {
            // Adjust by 0.5 to snap to block axis
            super(level, pos.getX() + (pos.getX() < 0 ? 0.5 : -0.5), pos.getY(),
                    pos.getZ() + (pos.getZ() < 0 ? 0.5 : -0.5), s);
            this.setBoundingBox(new AABB(pos.offset(0, 0, 0), pos.offset(1, 1, 1)));
            this.time = 1;
        }

        @Nullable
        @Override
        public ItemEntity spawnAtLocation(ItemStack stack, float offsetY) {
            BlockState state = this.getBlockState();

            if (state != null && state.getBlock() instanceof LeavesBlock) {
                Block.dropResources(state, this.level, this.getOnPos(), null);
                return null;
            }

            return super.spawnAtLocation(stack, offsetY);
        }
    }
} public class CropHelper {
    @SubscribeEvent(priority = EventPriority.LOWEST)
    public void registerVanilla(RightClickBlock event) {
        // Checks if feature is enabled
        if (!BlockTweakConfig.ENABLE_CROP_TWEAK.get()) {
            return;
        }

        if (event.getHand() != InteractionHand.MAIN_HAND) {
            return;
        }

        Level world = event.getWorld();
        BlockPos pos = event.getPos();
        BlockState state = world.getBlockState(pos);
        Player player = event.getPlayer();
        ResourceLocation name = state.getBlock().getRegistryName();

        for (String blackList : BlockTweakConfig.CROP_TWEAK_BLACKLIST.get()) {
            if (new ResourceLocation(blackList).equals(name)) {
                return;
            }
        }

        if (canHarvest(state)) {
            if (world instanceof ServerLevel) {
                harvest((ServerLevel) world, pos, state, player);
            }
            player.swing(InteractionHand.MAIN_HAND);
            event.setCanceled(true);
        }
    }

    private boolean canHarvest(BlockState state) {
        Block block = state.getBlock();
        if (block instanceof CropBlock) {
            return ((CropBlock) block).isMaxAge(state);
        } else if (block instanceof NetherWartBlock) {
            return state.getValue(NetherWartBlock.AGE) >= 3;
        } else if (block instanceof CocoaBlock) {
            return state.getValue(CocoaBlock.AGE) >= 2;
        }
        return false;
    }

    private void harvest(ServerLevel world, BlockPos pos, BlockState state, Player player) {
        List<ItemStack> drops = Block.getDrops(state, world, pos, null);
        world.destroyBlock(pos, false);
        boolean needPlant = true;
        for (ItemStack stack : drops) {
            if (needPlant && plant(world, pos, stack)) {
                needPlant = false;
            }
            ItemHandlerHelper.giveItemToPlayer(player, stack);
        }
    }

    private boolean plant(ServerLevel world, BlockPos pos, ItemStack stack) {
        Item item = stack.getItem();
        if (item instanceof BlockItem) {
            BlockPlaceContext  context = new DirectionalPlaceContext(world, pos, Direction.DOWN, stack, Direction.UP);
            return ((BlockItem) item).place(context) == InteractionResult.SUCCESS;
        }
        return false;
    }
} public class AnvilRepairTweaks {
    @SubscribeEvent
    public void registerEvent(AnvilUpdateEvent evt) {
        if (!CommonConfig.ENABLE_CHEAP_ANVIL_REPAIR.get()) {
            return;
        }
        if (evt.getLeft().isEmpty() || evt.getRight().isEmpty()) {
            VTweaks.getInstance().LOGGER.info("Nah");
            return;
        }

        if (evt.getLeft().getItem() instanceof DiggerItem) {
            DiggerItem tool = (DiggerItem) evt.getLeft().getItem();
            if (tool.getTier().getRepairIngredient().test(evt.getRight())) {
                evt.getLeft().setRepairCost(0);
                evt.setCost(0);
            }
        }
    }
} public class ConcreteTweaks {
    public static ArrayList<Item> concreteBlocks = Lists.newArrayList(Blocks.WHITE_CONCRETE.asItem(),
            Blocks.LIGHT_GRAY_CONCRETE.asItem(), Blocks.GRAY_CONCRETE.asItem(), Blocks.BLACK_CONCRETE.asItem(),
            Blocks.RED_CONCRETE.asItem(), Blocks.ORANGE_CONCRETE.asItem(), Blocks.YELLOW_CONCRETE.asItem(),
            Blocks.LIME_CONCRETE.asItem(), Blocks.GREEN_CONCRETE.asItem(), Blocks.LIGHT_BLUE_CONCRETE.asItem(),
            Blocks.CYAN_CONCRETE.asItem(), Blocks.BLUE_CONCRETE.asItem(), Blocks.PURPLE_CONCRETE.asItem(),
            Blocks.MAGENTA_CONCRETE.asItem(), Blocks.PINK_CONCRETE.asItem(), Blocks.BROWN_CONCRETE.asItem());

    public static ArrayList<Item> powderBlocks = Lists.newArrayList(Blocks.WHITE_CONCRETE_POWDER.asItem(),
            Blocks.LIGHT_GRAY_CONCRETE_POWDER.asItem(), Blocks.GRAY_CONCRETE_POWDER.asItem(),
            Blocks.BLACK_CONCRETE_POWDER.asItem(), Blocks.RED_CONCRETE_POWDER.asItem(),
            Blocks.ORANGE_CONCRETE_POWDER.asItem(), Blocks.YELLOW_CONCRETE_POWDER.asItem(),
            Blocks.LIME_CONCRETE_POWDER.asItem(), Blocks.GREEN_CONCRETE_POWDER.asItem(),
            Blocks.LIGHT_BLUE_CONCRETE_POWDER.asItem(), Blocks.CYAN_CONCRETE_POWDER.asItem(),
            Blocks.BLUE_CONCRETE_POWDER.asItem(), Blocks.PURPLE_CONCRETE_POWDER.asItem(),
            Blocks.MAGENTA_CONCRETE_POWDER.asItem(), Blocks.PINK_CONCRETE_POWDER.asItem(),
            Blocks.BROWN_CONCRETE_POWDER.asItem());

    @SubscribeEvent
    public void registerTweak(ItemTossEvent event) {
        if (!ItemTweakConfig.ENABLE_CONCRETE_TWEAKS.get()) {
            return;
        }
        ItemEntity entItem = event.getEntityItem();
        if (entItem.getItem().getItem() instanceof BlockItem) {
            BlockItem itemBlock = (BlockItem) entItem.getItem().getItem();
            if (powderBlocks.contains(itemBlock)) {
                ItemEntityConcrete concrete = new ItemEntityConcrete(entItem);
                if (!concrete.level.isClientSide()) {
                    concrete.level.addFreshEntity(concrete);
                }
                event.setResult(Event.Result.DENY);
                event.setCanceled(true);
                entItem.discard();
            }
        }
    }

    /**
     * A Custom EntityItem that replaces concrete powder with concrete when in water
     */
    public static class ItemEntityConcrete extends ItemEntity {

        public ItemEntityConcrete(Level worldIn, double x, double y, double z, ItemStack stack) {
            super(worldIn, x, y, z, stack);
            this.setPickUpDelay(40);
        }

        public ItemEntityConcrete(ItemEntity item) {
            super(item.level, item.getX(), item.getY(), item.getZ(), item.getItem());
            this.setDeltaMovement(item.getDeltaMovement());
            this.setPickUpDelay(40);
        }

        @Override
        public void tick() {
            if (this.isInWater()) {
                String target = this.getItem().getItem().getRegistryName().toString().replace("_powder", "");
                Item replacement = ForgeRegistries.ITEMS.getValue(new ResourceLocation(target));
                if (replacement != null) {
                    this.setItem(new ItemStack(replacement, this.getItem().getCount()));
                }
            }
            super.tick();
        }
    }

    /**
     * Describes custom Dispenser functionality for concrete powder blocks
     */
    public static final DispenseItemBehavior CONCRETE_POWDER_BEHAVIOR_DISPENSE_ITEM = new DefaultDispenseItemBehavior() {
        @Override
        public ItemStack execute(BlockSource source, ItemStack stack) {
            Direction facing = source.getBlockState().getValue(DispenserBlock.FACING);
            Position pos = DispenserBlock.getDispensePosition(source);
            ItemStack itemstack = stack.split(1);
            this.dispense(source.getLevel(), itemstack, 6, facing, pos);
            return stack;
        }

        public void dispense(Level worldIn, ItemStack stack, int speed, Direction facing, Position position) {
            double d0 = position.x();
            double d1 = position.y();
            double d2 = position.z();

            if (facing.getAxis() == Direction.Axis.Y) {
                d1 = d1 - 0.125D;
            } else {
                d1 = d1 - 0.15625D;
            }

            ItemEntity entityitem = null;
            if (stack.getItem() instanceof BlockItem) {
                BlockItem itemBlock = (BlockItem) stack.getItem();
                if (powderBlocks.contains(itemBlock)) {
                    entityitem = new ItemEntityConcrete(worldIn, d0, d1, d2, stack);
                }
            } else {
                entityitem = new ItemEntity(worldIn, d0, d1, d2, stack);
            }
            double d3 = worldIn.getRandom().nextDouble() * 0.1D + 0.2D;
            double motX = (double) facing.getStepX() * d3;
            double motY = 0.20000000298023224D;
            double motZ = (double) facing.getStepZ() * d3;
            motX += worldIn.getRandom().nextGaussian() * 0.007499999832361937D * (double) speed;
            motY += worldIn.getRandom().nextGaussian() * 0.007499999832361937D * (double) speed;
            motZ += worldIn.getRandom().nextGaussian() * 0.007499999832361937D * (double) speed;
            entityitem.setDeltaMovement(motX, motY, motZ);

            // Dispensed items have no pickup delay so.....
            entityitem.setNoPickUpDelay();
            worldIn.addFreshEntity(entityitem);
        }
    };
} public class DropTweaks {

    @SubscribeEvent
    public void registerTweak(ItemExpireEvent event) {
        if (event.getEntityItem() == null || event.getEntityItem().getItem().isEmpty()) {
            return;
        }

        if (!event.getEntityItem().level.isClientSide) {
            return;
        }

        ItemEntity entItem = event.getEntityItem();
        Level world = entItem.level;
        ItemStack stack = entItem.getItem();

        // Handles egg hatching; configurable chance.
        if (ItemTweakConfig.ENABLE_EGG_HATCHING.get() && stack.getItem() == Items.EGG) {
            if (world.getRandom().nextInt(100) <= ItemTweakConfig.EGG_HATCING_CHANCE.get()) {
                if (!world.isClientSide()) {
                    Chicken chick = new Chicken(EntityType.CHICKEN, world);
                    chick.setAge(-24000);
                    chick.setPos(entItem.getX(), entItem.getY(), entItem.getZ());
                    chick.lerpHeadTo(entItem.getYRot(), 0);
                    world.addFreshEntity(chick);
                }
            }
        }
        // Handles sapling replanting; 100% chance
        else if (ItemTweakConfig.ENABLE_SAPLING_SELF_PLANTING.get()
                && ItemTags.SAPLINGS.contains(stack.getItem())) {
            BlockPos saplingPos = fromDouble(entItem.getX(), entItem.getY(), entItem.getZ());
            // Checks to see if where the sapling *will* be is air
            if (world.getBlockState(saplingPos).isAir() || world.getBlockState(saplingPos).getMaterial().isReplaceable()) {
                Item item = stack.getItem();
                if (item instanceof BlockItem) {
                    BlockPlaceContext context = new DirectionalPlaceContext(world, saplingPos, Direction.DOWN, stack,
                            Direction.UP);
                    ((BlockItem) item).place(context);
                }
            }
        }
        // Handles items that are supposed to never despawn
        else if (ItemTweakConfig.DESPAWN_TIME_OVERRIDE.get() == -1) {
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    }

    @SubscribeEvent
    public void registerTweak(ItemTossEvent event) {
        // Checks to see if the despawn time is -1. If it is, items won't despawn, so
        // nothing to do here.
        if (ItemTweakConfig.DESPAWN_TIME_OVERRIDE.get() == -1 || !ItemTweakConfig.ENABLE_DESPAWN_TIME_OVERRIDE.get()
                || event.getEntityItem() == null) {
            return;
        }

        ItemEntity entItem = event.getEntityItem();
        entItem.lifespan = ItemTweakConfig.DESPAWN_TIME_OVERRIDE.get();
    }

    private BlockPos fromDouble(double xIn, double yIn, double zIn) {
        int x = (xIn % 1) >= .5 ? (int) Math.ceil(xIn) : (int) Math.floor(xIn);
        int y = (yIn % 1) >= .5 ? (int) Math.ceil(yIn) : (int) Math.floor(yIn);
        int z = (zIn % 1) >= .5 ? (int) Math.ceil(zIn) : (int) Math.floor(zIn);
        return new BlockPos(x, y, z);
    }
} public class ChallengerMobs {
    private final ArrayList<ItemStack> challengerMobDrops = new ArrayList<>();

    @SubscribeEvent(priority = EventPriority.HIGHEST)
    public void registerEvent(LivingSpawnEvent event) {
        if (!MobTweakConfig.ENABLE_CHALLENGER_MOBS.get() || MobTweakConfig.CHALLENGER_MOBS_RARITY.get() <= 0) {
            return;
        }

        if (!event.getWorld().isClientSide()) {
            // Fix hand items being incorrect
            if (event.getEntity() instanceof Monster) {
                Monster monster = (Monster) event.getEntity();

                if (isChallengerMob(monster)) {
                    ChallengerMobType type = getChallengerMobType(monster);
                    if (monster.getMainHandItem().getItem() != type.getEquipment().getItem()) {
                        monster.setItemInHand(InteractionHand.MAIN_HAND, type.getEquipment());
                    }
                }
            }

            if (event.getWorld().getRandom().nextInt(100) <= MobTweakConfig.CHALLENGER_MOBS_RARITY.get()
                    && !event.getEntity().getPersistentData().getBoolean("challenger_mob_checked")) {
                final ChallengerMobType VARIANT = ChallengerMobType.values()[event.getWorld().getRandom().nextInt(8)];

                if (event.getEntity() != null && event.getEntity() instanceof Monster) {
                    if (event.getEntity() instanceof ZombifiedPiglin || isBlackListed(event.getEntity())) {
                        return;
                    }

                    Monster monster = (Monster) event.getEntity();

                    if (isChallengerMob(monster)) {
                        return;
                    }

                    monster.setItemSlot(EquipmentSlot.HEAD, ItemStack.EMPTY);
                    monster.setItemSlot(EquipmentSlot.CHEST, ItemStack.EMPTY);
                    monster.setItemSlot(EquipmentSlot.LEGS, ItemStack.EMPTY);
                    monster.setItemSlot(EquipmentSlot.FEET, ItemStack.EMPTY);
                    monster.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);

                    // Custom Name Tags, and infinite fire resistance to prevent cheesy kills
                    if (MobTweakConfig.ENABLE_CHALLENGER_MOBS_NAME.get()) {
                        monster.setCustomName(mobClassName(VARIANT, monster));
                    }

                    // Every challenger mob will have a main hand item. Done before any checks.
                    monster.setItemInHand(InteractionHand.MAIN_HAND, VARIANT.getEquipment());
                    monster.setDropChance(EquipmentSlot.MAINHAND, Float.MIN_VALUE);

                    monster.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(VARIANT.getSpeed());
                    monster.getAttribute(Attributes.MAX_HEALTH).setBaseValue(VARIANT.getHealth());
                    monster.setHealth(VARIANT.getHealth());

                    // Special Man Pants for Zistonian Mobs
                    if (VARIANT == ChallengerMobType.ZISTONIAN) {
                        ItemStack pants = new ItemStack(Items.GOLDEN_LEGGINGS);
                        pants.setHoverName(new TranslatableComponent("vtweaks.man.pants"));
                        pants.enchant(Utils.getEnchantment("minecraft", "blast_protection"), 5);
                        monster.setItemSlot(EquipmentSlot.LEGS, pants);
                    }

                    setChallengerTag(monster, VARIANT);
                }
            } else {
                event.getEntity().getPersistentData().putBoolean("challenger_mob_checked", true);
            }

        }
    }

    @SubscribeEvent
    public void registerEvent(LivingDropsEvent event) {
        if (!MobTweakConfig.ENABLE_CHALLENGER_MOBS.get() || challengerMobDrops.size() <= 0) {
            return;
        }

        if (event.getEntity() == null || !(event.getEntity() instanceof Monster)
                || !isChallengerMob((Monster) event.getEntity())) {
            return;
        }

        event.getDrops().add(getItem(event.getEntity().level, event.getEntity().getOnPos()));
    }

    @SubscribeEvent
    public void registerEvent(LivingHurtEvent event) {
        if (event.getEntityLiving() == null || event.getSource() == null) {
            return;
        }

        // Special attack features for challenger mobs
        if (event.getSource().getDirectEntity() instanceof Monster) {
            if (isChallengerMob((Monster) event.getSource().getDirectEntity())) {
                Monster monster = (Monster) event.getSource().getDirectEntity();

                ChallengerMobType type = getChallengerMobType(monster);
                if (type.getHitEffects() != null) {
                    for (MobEffectInstance effect : type.getHitEffects()) {
                        event.getEntityLiving().addEffect(effect);
                    }
                }
            }
        }
        // Prevent challenger mobs from being killed by fire
        else if (event.getEntity() instanceof Monster) {
            if (isChallengerMob((Monster) event.getEntity())) {
                if (event.getSource() == DamageSource.IN_FIRE || event.getSource() == DamageSource.ON_FIRE
                        || event.getSource() == DamageSource.LAVA) {
                    event.getEntity().setSecondsOnFire(0);
                    event.getEntity().setRemainingFireTicks(0);
                    event.setAmount(0F);
                    event.setCanceled(true);
                }
            }
        }
    }

    private void process() {
        challengerMobDrops.clear();

        MobTweakConfig.CHALLENGER_MOBS_LOOT.get().forEach((itemName) -> {
            String[] parts = itemName.split("[\\W]");

            if (parts.length != 2 && parts.length != 3) {
                VTweaks.getInstance().LOGGER
                        .error("{} does not conform to <modid:item> or <modid:item*quantity>. Skipping...", itemName);
            }

            Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(parts[0], parts[1]));

            if (item != null) {
                ItemStack i = new ItemStack(item, parts.length == 3 ? Integer.parseInt(parts[2]) : 1);
                VTweaks.getInstance().LOGGER.info("Added {} {} to Challenger Mobs Loot", i.getCount(), i.getItem());
                challengerMobDrops.add(i);
            } else {
                VTweaks.getInstance().LOGGER.error(
                        "{} has no syntax issues but could not be resolved to an item in-game. Skipping...", itemName);
            }
        });
    }

    @SubscribeEvent
    public void onServerStart(final FMLServerStartedEvent evt) {
        process();
    }

    @SubscribeEvent
    public void onSlashReload(AddReloadListenerEvent evt) {
        evt.addListener(new PreparableReloadListener() {
            @Override
            public CompletableFuture<Void> reload(PreparableReloadListener.PreparationBarrier p_10638_, ResourceManager p_10639_, ProfilerFiller p_10640_, ProfilerFiller p_10641_, Executor p_10642_, Executor p_10643_) {
                return CompletableFuture.runAsync(() -> {
                    process();
                }, p_10642_).thenCompose(p_10638_::wait);
            }
        });
    }

    private void setChallengerTag(Monster entity, ChallengerMobType variant) {
        CompoundTag comp = entity.getPersistentData();
        CompoundTag type = new CompoundTag();
        type.putString("variant", variant.getPrefix());
        comp.put("challenger_mob_data", type);
    }

    private boolean isBlackListed(Entity entity) {
        if (entity == null) {
            return true;
        }

        for (String str : MobTweakConfig.CHALLENGER_MOBS_BLACKLIST.get()) {
            if (new ResourceLocation(str).equals(entity.getType().getRegistryName())) {
                return true;
            }
        }

        return false;
    }

    private TranslatableComponent mobClassName(ChallengerMobType type, Monster mob) {
        return new TranslatableComponent("vtweaks." + type.getPrefix().toLowerCase() + ".challenger.mob",
                mob.getName());
    }

    private ItemEntity getItem(Level world, BlockPos pos) {
        int RNG = world.getRandom().nextInt(challengerMobDrops.size());
        return Utils.createItemEntity(world, pos, challengerMobDrops.get(RNG));
    }

    public static boolean isChallengerMob(Monster entity) {
        CompoundTag comp = entity.getPersistentData();
        return comp.contains("challenger_mob_data");
    }

    public static ChallengerMobType getChallengerMobType(Monster monster) {
        CompoundTag comp = monster.getPersistentData();

        if (comp.contains("challenger_mob_data")) {
            CompoundTag cmd = comp.getCompound("challenger_mob_data");
            String type = cmd.getString("variant");
            for (ChallengerMobType t : ChallengerMobType.values()) {
                if (t.getPrefix().equalsIgnoreCase(type)) {
                    return t;
                }
            }
        }
        return null;
    }
} public class ChallengerParticles {
    public static final String CHALLENGER_PARTICLE_KEY = "challenger_mobs_last_particle";

    @SubscribeEvent
    public void registerEvent(EntityEvent evt) {
        if (!MobTweakConfig.ENABLE_CHALLENGER_MOBS.get() || !ClientConfig.ENABLE_CHALLENGER_PARTICLES.get()) {
            return;
        }

        if (evt.getEntity() == null || !evt.getEntity().isAlive()) {
            return;
        }

        if (evt.getEntity() instanceof Monster) {
            if (ChallengerMobs.isChallengerMob((Monster) evt.getEntity())) {
                Monster monster = (Monster) evt.getEntity();
                ChallengerMobType type = ChallengerMobs.getChallengerMobType(monster);
                VTweaks.proxy.addChallengerMob(monster, type);
            }
        }
    }
} public class FeatherPlucker {
    @SubscribeEvent
    public void registerEvent(EntityInteract event) {
        // Checks if feature is enabled
        if (!MobTweakConfig.ENABLE_FEATHER_PLUCKING.get()) {
            return;
        }

        if (event.getTarget() == null || !(event.getTarget() instanceof Chicken)) {
            return;
        }

        Chicken chicken = (Chicken) event.getTarget();

        if (!(event.getEntityLiving() instanceof Player)) {
            return;
        }

        Player player = (Player) event.getEntityLiving();
        if (!chicken.isBaby()) {
            if (!player.getMainHandItem().isEmpty()
                    && player.getMainHandItem().getItem() instanceof ShearsItem) {
                if (!player.level.isClientSide() && chicken.getAge() == 0) {
                    player.level.addFreshEntity(
                            Utils.createItemEntity(player.level, event.getTarget().getOnPos(), Items.FEATHER));
                    chicken.hurt(DamageSource.GENERIC, 0.0F);
                    chicken.setAge(10000); // Used for a cooldown timer, essentially
                    if (!player.isCreative()) {
                        player.getMainHandItem().hurt(1, player.getRandom(), null);
                    }
                }
                player.swing(InteractionHand.MAIN_HAND);
            }
        }
    }
} public class NoPetFriendlyFire {
    @SubscribeEvent
    public void registerEvent(AttackEntityEvent evt) {
        if (MobTweakConfig.NO_PET_FRIENDLY_FIRE.get() == MobTweakConfig.NoPetFriendlyFire.DISABLED) {
            return;
        }

        if (evt.getPlayer() == null || evt.getTarget() == null) {
            return;
        }

        if (!(evt.getTarget() instanceof TamableAnimal)) {
            return;
        }

        TamableAnimal pet = (TamableAnimal) evt.getTarget();
        if (!pet.isTame()) {
            return;
        }

        boolean applyToAny = MobTweakConfig.NO_PET_FRIENDLY_FIRE.get() == MobTweakConfig.NoPetFriendlyFire.ALL;
        if (applyToAny || pet.getOwner() == evt.getPlayer()) {
            if (evt.isCancelable()) {
                evt.setCanceled(true);
            }
        }
    }

    /**
     * Prevents Auxilliary Damage to Pets
     */
    @SubscribeEvent
    public void registerEvent(LivingHurtEvent evt) {
        if (MobTweakConfig.NO_PET_FRIENDLY_FIRE.get() == MobTweakConfig.NoPetFriendlyFire.DISABLED) {
            return;
        }

        if (evt.getSource() == null || evt.getEntity() == null) {
            return;
        }

        // Check that the main target of pain is a pet
        if (!(evt.getEntity() instanceof TamableAnimal)) {
            return;
        }

        // Check if the main source of pain is a player
        if (!(evt.getSource().getDirectEntity() instanceof Player)) {
            return;
        }

        TamableAnimal pet = (TamableAnimal) evt.getEntity();
        Player player = (Player) evt.getSource().getDirectEntity();

        boolean applyToAny = MobTweakConfig.NO_PET_FRIENDLY_FIRE.get() == MobTweakConfig.NoPetFriendlyFire.ALL;

        if (applyToAny || pet.isOwnedBy(player)) {
            evt.setAmount(0);
            evt.setResult(Event.Result.DENY);
            if (evt.isCancelable()) {
                evt.setCanceled(true);
            }
        }
    }
} public class PeacefulSurface {
    @SubscribeEvent(priority = EventPriority.NORMAL)
    public void registerTweak(LivingSpawnEvent event) {
        if (!MobTweakConfig.ENABLE_PEACEFUL_SURFACE.get()) {
            return;
        }
        if (event.getEntity() == null || !(event.getEntity() instanceof Monster)) {
            return;
        }
        if (!(event.getWorld() instanceof ServerLevel)) {
            return;
        }
        ResourceLocation dimName = ((ServerLevel) event.getWorld()).dimension().location();
        for (String dimType : MobTweakConfig.PEACEFUL_SURFACE_BLACKLIST.get()) {
            if (dimName.toString().equals(dimType)) {
                return;
            }
        }

        Monster monster = (Monster) event.getEntity();

        if (event.getWorld() == null || ((Level) event.getWorld()).getServer() == null) {
            return;
        }

        int day = (int) (event.getWorld().getLevelData().getDayTime() / 24000L % 2147483647L);

        // Check for midnight
        if (!(day % 4 == 0 && day % 8 != 0)) {
            // Check if position is high enough
            if (event.getEntity().getY() >= MobTweakConfig.PEACEFUL_SURFACE_MIN_Y.get()) {
                // Check if it's a natural spawn
                CompoundTag comp = monster.getPersistentData();

                if (comp.contains("peacefulSurfaceRemove") && comp.getBoolean("peacefulSurfaceRemove")) {
                    event.setResult(Event.Result.DENY);
                }
            }
        }
    }

    @SubscribeEvent(priority = EventPriority.HIGHEST)
    public void registerTweak(LivingSpawnEvent.CheckSpawn event) {
        if (!MobTweakConfig.ENABLE_PEACEFUL_SURFACE.get()) {
            return;
        }
        if (event.getEntity() == null || !(event.getEntity() instanceof Monster)) {
            return;
        }
        if (!(event.getWorld() instanceof ServerLevel)) {
            return;
        }
        ResourceLocation dimName = ((ServerLevel) event.getWorld()).dimension().location();

        for (String dimType : MobTweakConfig.PEACEFUL_SURFACE_BLACKLIST.get()) {
            if (dimName.toString().equals(dimType)) {
                return;
            }
        }

        Monster monster = (Monster) event.getEntity();
        // Flag any natural mob spawns
        if (event.getSpawnReason() == MobSpawnType.NATURAL) {
            CompoundTag comp = monster.getPersistentData();

            if (!comp.contains("peacefulSurfaceRemove")) {
                comp.putBoolean("peacefulSurfaceRemove", true);
            }
        }
    }
} public class PetArmory {
    private static final String TAG = "vtweaks:lootPickupBackup";

    private void backupPriorSettings(TamableAnimal ent) {
        CompoundTag comp = ent.getPersistentData();
        if (!comp.contains(TAG)) {
            comp.putBoolean(TAG, ent.canPickUpLoot());
        }
    }

    private void restorePriorSettings(TamableAnimal ent) {
        CompoundTag comp = ent.getPersistentData();
        if (comp.contains(TAG)) {
            ent.setCanPickUpLoot(comp.getBoolean(TAG));
            comp.remove(TAG);
        }
    }


    /**
     * Allows newly tamed pets to pick up loot and drop it should they *gasp* die.
     */
    @SubscribeEvent
    public void registerEvent(AnimalTameEvent event) {
        if (MobTweakConfig.ENABLE_PET_ARMORY.get()) {
            if (event.getAnimal() instanceof TamableAnimal) {
                TamableAnimal pet = (TamableAnimal) event.getAnimal();
                backupPriorSettings(pet);
                for (EquipmentSlot slotType : EquipmentSlot.values()) {
                    pet.setDropChance(slotType, 1F);
                }
                pet.setCanPickUpLoot(true);
            }
        }
    }

    /**
     * Makes sure that existing pets are allowed to pick up things
     * if they weren't already
     */
    @SubscribeEvent
    public void registerEvent(EntityJoinWorldEvent event) {
        if (!(event.getEntity() instanceof TamableAnimal)) {
            return;
        }

        TamableAnimal pet = (TamableAnimal) event.getEntity();

        if (MobTweakConfig.ENABLE_PET_ARMORY.get()) {
            if (pet.isTame()) {
                for (EquipmentSlot slotType : EquipmentSlot.values()) {
                    pet.setDropChance(slotType, 1F);
                }
                pet.setCanPickUpLoot(true);
            }
        } else {
            restorePriorSettings(pet);
        }
    }

    @SubscribeEvent
    public void registerEvent(EntityInteract event) {
        // Checks that the feature is enabled
        if (!MobTweakConfig.ENABLE_PET_ARMORY.get()) {
            return;
        }
        // Confirms there's a target
        if (event.getTarget() == null) {
            return;
        }
        // Conirms the target is tamable!
        if (event.getTarget() instanceof TamableAnimal) {
            TamableAnimal pet = (TamableAnimal) event.getTarget();
            if (!(event.getEntityLiving() instanceof Player)) {
                return;
            }

            Player player = (Player) event.getEntityLiving();
            boolean strippedArmor = false;

            if (player.getMainHandItem().isEmpty() && player.isCrouching() && pet.isTame()
                    && pet.isOwnedBy(player)) {
                // Give the armor back
                for (EquipmentSlot slotType : EquipmentSlot.values()) {
                    ItemStack itemInSlot = pet.getItemBySlot(slotType);

                    if (!itemInSlot.isEmpty()) {
                        ItemHandlerHelper.giveItemToPlayer(player, itemInSlot.copy());
                        pet.setItemSlot(slotType, ItemStack.EMPTY);
                        strippedArmor = true;
                    }
                }
                if (strippedArmor) {
                    player.playSound(SoundEvents.HORSE_ARMOR, .5F, 0.85F);
                }
            }
        }
    }
} public class Constants {
    public static final String MODID = "vtweaks";
    public static final String MODNAME = "V-Tweaks";
} public class Recipes {
    @SubscribeEvent
    public void registerBookRecipes(AnvilUpdateEvent event) {
        if (EnchantmentConfig.ENABLE_LUMBERING.get()) {
            ItemStack book = Utils.getEnchantedBook(VTweaks.lumbering);

            if (event.getLeft().isEmpty() || event.getRight().isEmpty())
                return;

            boolean damaged = event.getRight().getDamageValue() > 0;

            if (event.getLeft().getItem() == Items.WRITABLE_BOOK && event.getRight().getItem() == Items.GOLDEN_AXE) {
                if (!damaged) {
                    event.setCost(EnchantmentConfig.LUMBERING_RECIPE_COST.get());
                    event.setOutput(book);
                } else {
                    event.setOutput(ItemStack.EMPTY);
                }
            }
        }

        if (EnchantmentConfig.ENABLE_IMPERISHABLE.get()) {
            ItemStack book = Utils.getEnchantedBook(VTweaks.imperishable);

            if (event.getLeft().isEmpty() || event.getRight().isEmpty())
                return;

            if (event.getLeft().getItem() == Items.ENCHANTED_BOOK
                    && event.getRight().getItem() == Items.ENCHANTED_BOOK) {
                if (Utils.bookHasEnchantment(event.getLeft(), new EnchantmentInstance(Enchantments.UNBREAKING, 3)) && Utils
                        .bookHasEnchantment(event.getRight(), new EnchantmentInstance(Enchantments.UNBREAKING, 3))) {
                    event.setCost(EnchantmentConfig.IMPERISHABLE_RECIPE_COST.get());
                    event.setOutput(book);
                }
            }
        }
    }
}
import com.oitsjustjose.vtweaks.client.ClientProxy;
import com.oitsjustjose.vtweaks.client.LowHealthSound;
import com.oitsjustjose.vtweaks.client.SmallBees;
import com.oitsjustjose.vtweaks.common.CommonProxy;
import com.oitsjustjose.vtweaks.common.config.ClientConfig;
import com.oitsjustjose.vtweaks.common.config.CommonConfig;
import com.oitsjustjose.vtweaks.common.config.EnchantmentConfig;
import com.oitsjustjose.vtweaks.common.enchantment.EnchantmentImperishable;
import com.oitsjustjose.vtweaks.common.enchantment.EnchantmentLumbering;
import com.oitsjustjose.vtweaks.common.enchantment.FeatherFallingTweak;
import com.oitsjustjose.vtweaks.common.enchantment.handler.EnchantmentImperishableHandler;
import com.oitsjustjose.vtweaks.common.enchantment.handler.EnchantmentLumberingHandler;
import com.oitsjustjose.vtweaks.common.event.DeathPoint;
import com.oitsjustjose.vtweaks.common.event.StormTweak;
import com.oitsjustjose.vtweaks.common.event.ToolTips;
import com.oitsjustjose.vtweaks.common.event.blocktweaks.BonemealTweaks;
import com.oitsjustjose.vtweaks.common.event.blocktweaks.CakeTweak;
import com.oitsjustjose.vtweaks.common.event.blocktweaks.ChopDown;
import com.oitsjustjose.vtweaks.common.event.blocktweaks.CropHelper;
import com.oitsjustjose.vtweaks.common.event.itemtweaks.AnvilRepairTweaks;
import com.oitsjustjose.vtweaks.common.event.itemtweaks.ConcreteTweaks;
import com.oitsjustjose.vtweaks.common.event.itemtweaks.DropTweaks;
import com.oitsjustjose.vtweaks.common.event.mobtweaks.ChallengerMobs;
import com.oitsjustjose.vtweaks.common.event.mobtweaks.ChallengerParticles;
import com.oitsjustjose.vtweaks.common.event.mobtweaks.FeatherPlucker;
import com.oitsjustjose.vtweaks.common.event.mobtweaks.NoPetFriendlyFire;
import com.oitsjustjose.vtweaks.common.event.mobtweaks.PeacefulSurface;
import com.oitsjustjose.vtweaks.common.event.mobtweaks.PetArmory;
import com.oitsjustjose.vtweaks.common.util.Constants;
import com.oitsjustjose.vtweaks.common.util.Recipes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig.Type;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLPaths;
package com.oitsjustjose.vtweaks;




@Mod(Constants.MODID)
public class VTweaks {
    private static VTweaks instance;
    public Logger LOGGER = LogManager.getLogger();
    public static CommonProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);

    public static Enchantment lumbering = new EnchantmentLumbering();
    public static Enchantment imperishable = new EnchantmentImperishable();

    public VTweaks() {
        instance = this;

        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        MinecraftForge.EVENT_BUS.register(this);

        this.configSetup();
    }

    public static VTweaks getInstance() {
        return instance;
    }

    public void setup(final FMLCommonSetupEvent event) {
        // Proxy init - sets up networking too
        proxy.init();

        // Enchantments
        MinecraftForge.EVENT_BUS.register(new Recipes());

        // Mob Tweaks
        MinecraftForge.EVENT_BUS.register(new PetArmory());
        MinecraftForge.EVENT_BUS.register(new NoPetFriendlyFire());
        MinecraftForge.EVENT_BUS.register(new SmallBees());
        MinecraftForge.EVENT_BUS.register(new FeatherPlucker());
        MinecraftForge.EVENT_BUS.register(new ChallengerMobs());
        MinecraftForge.EVENT_BUS.register(new ChallengerParticles());
        MinecraftForge.EVENT_BUS.register(new PeacefulSurface());

        // Block Tweaks
        MinecraftForge.EVENT_BUS.register(new CropHelper());
        MinecraftForge.EVENT_BUS.register(new BonemealTweaks());
        MinecraftForge.EVENT_BUS.register(new CakeTweak());
        MinecraftForge.EVENT_BUS.register(new ChopDown());

        // Item Tweaks
        MinecraftForge.EVENT_BUS.register(new DropTweaks());
        MinecraftForge.EVENT_BUS.register(new ConcreteTweaks());
        ConcreteTweaks.powderBlocks.forEach((item) -> {
            DispenserBlock.registerBehavior(item, ConcreteTweaks.CONCRETE_POWDER_BEHAVIOR_DISPENSE_ITEM);
        });

        // Miscellaneous Features
        MinecraftForge.EVENT_BUS.register(new ToolTips());
        MinecraftForge.EVENT_BUS.register(new StormTweak());
        MinecraftForge.EVENT_BUS.register(new DeathPoint());
        MinecraftForge.EVENT_BUS.register(new AnvilRepairTweaks());