<commit_before>package net.darkhax.darkutils.features.shulkerpearl;

import net.darkhax.bookshelf.item.ItemBlockBasic;
import net.darkhax.darkutils.DarkUtils;
import net.darkhax.darkutils.features.DUFeature;
import net.darkhax.darkutils.features.Feature;
import net.darkhax.darkutils.features.shulkerpearl.ShulkerDataHandler.ICustomData;
import net.minecraft.block.Block;
import net.minecraft.entity.monster.EntityShulker;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteract;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.oredict.OreDictionary;

@DUFeature(name = "Shulker Pearls", description = "Adds shulker pearls and related content")
public class FeatureShulkerPearlItem extends Feature {

    public static Item itemShulkerPearl;

    public static Block blockShulkerPearl;

    private boolean harvestablePearls = true;

    private int maxCooldown = 6000;

    @Override
    public void onPreInit () {

        itemShulkerPearl = DarkUtils.REGISTRY.registerItem(new ItemShulkerPearl(), "shulker_pearl");
        blockShulkerPearl = new BlockShulkerPearl();
        DarkUtils.REGISTRY.registerBlock(blockShulkerPearl, new ItemBlockBasic(blockShulkerPearl, BlockShulkerPearl.types, false), "pearl_block");

        if (this.harvestablePearls) {
            ShulkerDataHandler.init();
        }
    }

    @Override
    public void onInit () {

        OreDictionary.registerOre("blockPearl", new ItemStack(blockShulkerPearl, 1, OreDictionary.WILDCARD_VALUE));
        OreDictionary.registerOre("gemPearl", itemShulkerPearl);
    }

    @Override
    public void setupConfiguration (Configuration config) {

        this.harvestablePearls = config.getBoolean("Harvest Pearls", this.configName, true, "Should pearls be harvestable from shulkers?");
        this.maxCooldown = config.getInt("Shulker Cooldown", this.configName, 6000, 0, Integer.MAX_VALUE, "The pearl harvest cooldown tile, in ticks");
    }

    @Override
    public boolean usesEvents () {

        return true;
    }

    @SubscribeEvent
    public void onEntityInteract (EntityInteract event) {

        if (event.getSide().equals(Side.SERVER) && this.harvestablePearls && event.getTarget() instanceof EntityShulker) {
<commit_msg>Fixed shulkers not dropping pearls when they die.<commit_after>package net.darkhax.darkutils.features.shulkerpearl;

import net.darkhax.bookshelf.item.ItemBlockBasic;
import net.darkhax.darkutils.DarkUtils;
import net.darkhax.darkutils.features.DUFeature;
import net.darkhax.darkutils.features.Feature;
import net.darkhax.darkutils.features.shulkerpearl.ShulkerDataHandler.ICustomData;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityShulker;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteract;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.oredict.OreDictionary;

@DUFeature(name = "Shulker Pearls", description = "Adds shulker pearls and related content")
public class FeatureShulkerPearlItem extends Feature {

    public static Item itemShulkerPearl;

    public static Block blockShulkerPearl;

    private boolean harvestablePearls = true;

    private int maxCooldown = 6000;

    @Override
    public void onPreInit () {

        itemShulkerPearl = DarkUtils.REGISTRY.registerItem(new ItemShulkerPearl(), "shulker_pearl");
        blockShulkerPearl = new BlockShulkerPearl();
        DarkUtils.REGISTRY.registerBlock(blockShulkerPearl, new ItemBlockBasic(blockShulkerPearl, BlockShulkerPearl.types, false), "pearl_block");

        if (this.harvestablePearls) {
            ShulkerDataHandler.init();
        }
    }

    @Override
    public void onInit () {

        OreDictionary.registerOre("blockPearl", new ItemStack(blockShulkerPearl, 1, OreDictionary.WILDCARD_VALUE));
        OreDictionary.registerOre("gemPearl", itemShulkerPearl);
    }

    @Override
    public void setupConfiguration (Configuration config) {

        this.harvestablePearls = config.getBoolean("Harvest Pearls", this.configName, true, "Should pearls be harvestable from shulkers?");
        this.maxCooldown = config.getInt("Shulker Cooldown", this.configName, 6000, 0, Integer.MAX_VALUE, "The pearl harvest cooldown tile, in ticks");
    }

    @Override
    public boolean usesEvents () {

        return true;
    }

    @SubscribeEvent
    public void onLivingDrops (LivingDropsEvent event) {

        if (event.getEntity() instanceof EntityShulker) {

            final ICustomData data = ShulkerDataHandler.getData(event.getEntity());

            if (data != null && data.getCooldown() <= 0) {

                final Vec3d pos = event.getEntity().getPositionVector();
                event.getDrops().add(new EntityItem(event.getEntity().getEntityWorld(), pos.x, pos.y, pos.z, new ItemStack(itemShulkerPearl)));
                data.setCooldown(this.maxCooldown);
            }
        }
    }

    @SubscribeEvent
    public void onEntityInteract (EntityInteract event) {

        if (event.getSide().equals(Side.SERVER) && this.harvestablePearls && event.getTarget() instanceof EntityShulker) {

{'fraction_non_alphanumeric': 0.0957209142464341, 'fraction_numerical': 0.003952569169960474, 'mean_word_length': 4.319926873857404, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6444241', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1760, 'n_words': 330}