<commit_before>package net.glowstone.entity.objects;

import com.flowpowered.networking.Message;
import net.glowstone.GlowChunk;
import net.glowstone.entity.GlowEntity;
import net.glowstone.entity.GlowPlayer;
import net.glowstone.entity.meta.MetadataIndex;
import net.glowstone.net.message.play.entity.EntityMetadataMessage;
import net.glowstone.net.message.play.entity.EntityTeleportMessage;
import net.glowstone.net.message.play.entity.SpawnObjectMessage;
import net.glowstone.net.message.play.player.InteractEntityMessage;
import net.glowstone.util.Position;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Rotation;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemFrame;
import org.bukkit.inventory.ItemStack;

import java.util.Arrays;
import java.util.List;


public final class GlowItemFrame extends GlowEntity implements ItemFrame {

    BlockFace face;
    Material itemInFrame;
    private int rot = 0;

    public GlowItemFrame(GlowPlayer player, Location location, BlockFace clickedface) {

        super(location);
        this.face = clickedface;
        if (player != null) { // could be Anvil loading....
            if (player.getGameMode() != GameMode.CREATIVE) {
                ItemStack is = player.getItemInHand();
                int amount = is.getAmount();
                is.setAmount(amount - 1);
                if (is.getAmount() <= 0) {
                    is = null;
                }
                player.setItemInHand(is);
            }

            metadata.set(MetadataIndex.ITEM_FRAME_ROTATION, 0);
            metadata.set(MetadataIndex.ITEM_FRAME_ITEM, new ItemStack(Material.AIR));
            metadata.set(MetadataIndex.AIR_TIME, 300);
            itemInFrame = Material.AIR;
        }
    }

    public void setIteminFrame(ItemStack is) {
        if (is == null) {
            is = new ItemStack(Material.AIR, 1);
        }
        is.setAmount(1);
        itemInFrame = is.getType();
        metadata.set(MetadataIndex.ITEM_FRAME_ITEM, is);
        metadata.set(MetadataIndex.ITEM_FRAME_ROTATION, 0);
    }

    public void setItemFrameRotation(int rotation) {
        metadata.set(MetadataIndex.ITEM_FRAME_ROTATION, (rotation));
    }

    // //////////////////////////////////////////////////////////////////////////
    // Overrides

    /**
     * Represents an item frame that is also an 0 = INTERACT, 1 = ATTACK, 2 =
     * INTERACT_AT (2 - Right/1- Left Click), 0 is always called with 1 or 2.
     */
    @Override
    public boolean entityInteract(GlowPlayer player, InteractEntityMessage message) {
        if (message.getAction() == 2) {
            if (itemInFrame == Material.AIR) {
                ItemStack isInHand = player.getItemInHand();
                if (isInHand != null) {
                    setIteminFrame(isInHand);
                    if (player.getGameMode() != GameMode.CREATIVE) {
                        int amount = player.getItemInHand().getAmount();
                        isInHand.setAmount(amount - 1);
                        if (isInHand.getAmount() <= 0) {
                            isInHand = null;
                        }
                        player.setItemInHand(isInHand);
                    }
                }
            } else {
                rot++;
                if (rot > 7) {
                    rot = 0;
                }
                setItemFrameRotation(rot);
            }
        }
        if (message.getAction() == 1) {
            if (isEmpty()) {
                remove();
            } else {
                setIteminFrame(new ItemStack(Material.AIR));
                rot = 0;
            }
        }
        return true;
    }

    @Override
    public void pulse() {
        super.pulse();

        if (ticksLived % (11) == 0) {
            if ((world.getBlockAt(new Location(getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ()))).getType() == Material.AIR) {
                //TODO: Uncomment once Glowstone supports entities/dropped items
                /*world.dropItemNaturally(location, new ItemStack(Material.ITEM_FRAME));
                if (!isEmpty()) {
                    world.dropItemNaturally(location, new ItemStack(itemInFrame));
                }*/
                remove();
            }
        }
    }

    @Override
    public List<Message> createSpawnMessage() {

        int xoffset = 0;
        int zoffset = 0;
        int yaw = 0;
        switch (getFacingNumber(face)) {
            case 1:
                xoffset = -1;
                yaw = 64;
                break;
            case 2:
                zoffset = -1;
                yaw = -128;
                break;
            case 3:
                xoffset = 1;
                yaw = -64;
                break;
            case 0:
                zoffset = 1;
                yaw = 0;<commit_msg>Remove commented out code<commit_after>package net.glowstone.entity.objects;

import com.flowpowered.networking.Message;
import net.glowstone.GlowChunk;
import net.glowstone.entity.GlowEntity;
import net.glowstone.entity.GlowPlayer;
import net.glowstone.entity.meta.MetadataIndex;
import net.glowstone.net.message.play.entity.EntityMetadataMessage;
import net.glowstone.net.message.play.entity.EntityTeleportMessage;
import net.glowstone.net.message.play.entity.SpawnObjectMessage;
import net.glowstone.net.message.play.player.InteractEntityMessage;
import net.glowstone.util.Position;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Rotation;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemFrame;
import org.bukkit.inventory.ItemStack;

import java.util.Arrays;
import java.util.List;


public final class GlowItemFrame extends GlowEntity implements ItemFrame {

    BlockFace face;
    Material itemInFrame;
    private int rot = 0;

    public GlowItemFrame(GlowPlayer player, Location location, BlockFace clickedface) {

        super(location);
        this.face = clickedface;
        if (player != null) { // could be Anvil loading....
            if (player.getGameMode() != GameMode.CREATIVE) {
                ItemStack is = player.getItemInHand();
                int amount = is.getAmount();
                is.setAmount(amount - 1);
                if (is.getAmount() <= 0) {
                    is = null;
                }
                player.setItemInHand(is);
            }

            metadata.set(MetadataIndex.ITEM_FRAME_ROTATION, 0);
            metadata.set(MetadataIndex.ITEM_FRAME_ITEM, new ItemStack(Material.AIR));
            metadata.set(MetadataIndex.AIR_TIME, 300);
            itemInFrame = Material.AIR;
        }
    }

    public void setIteminFrame(ItemStack is) {
        if (is == null) {
            is = new ItemStack(Material.AIR, 1);
        }
        is.setAmount(1);
        itemInFrame = is.getType();
        metadata.set(MetadataIndex.ITEM_FRAME_ITEM, is);
        metadata.set(MetadataIndex.ITEM_FRAME_ROTATION, 0);
    }

    public void setItemFrameRotation(int rotation) {
        metadata.set(MetadataIndex.ITEM_FRAME_ROTATION, (rotation));
    }

    // //////////////////////////////////////////////////////////////////////////
    // Overrides

    /**
     * Represents an item frame that is also an 0 = INTERACT, 1 = ATTACK, 2 =
     * INTERACT_AT (2 - Right/1- Left Click), 0 is always called with 1 or 2.
     */
    @Override
    public boolean entityInteract(GlowPlayer player, InteractEntityMessage message) {
        if (message.getAction() == 2) {
            if (itemInFrame == Material.AIR) {
                ItemStack isInHand = player.getItemInHand();
                if (isInHand != null) {
                    setIteminFrame(isInHand);
                    if (player.getGameMode() != GameMode.CREATIVE) {
                        int amount = player.getItemInHand().getAmount();
                        isInHand.setAmount(amount - 1);
                        if (isInHand.getAmount() <= 0) {
                            isInHand = null;
                        }
                        player.setItemInHand(isInHand);
                    }
                }
            } else {
                rot++;
                if (rot > 7) {
                    rot = 0;
                }
                setItemFrameRotation(rot);
            }
        }
        if (message.getAction() == 1) {
            if (isEmpty()) {
                remove();
            } else {
                setIteminFrame(new ItemStack(Material.AIR));
                rot = 0;
            }
        }
        return true;
    }

    @Override
    public void pulse() {
        super.pulse();

        if (ticksLived % (11) == 0) {
            if ((world.getBlockAt(new Location(getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ()))).getType() == Material.AIR) {
                world.dropItemNaturally(location, new ItemStack(Material.ITEM_FRAME));
                if (!isEmpty()) {
                    world.dropItemNaturally(location, new ItemStack(itemInFrame));
                }
                remove();
            }
        }
    }

    @Override
    public List<Message> createSpawnMessage() {

        int xoffset = 0;
        int zoffset = 0;
        int yaw = 0;
        switch (getFacingNumber(face)) {
            case 1:
                xoffset = -1;
                yaw = 64;
                break;
            case 2:
                zoffset = -1;
                yaw = -128;
                break;
            case 3:
                xoffset = 1;
                yaw = -64;
                break;
            case 0:
                zoffset = 1;
                yaw = 0;
{'fraction_non_alphanumeric': 0.1166751657317695, 'fraction_numerical': 0.00958694543600204, 'mean_word_length': 1.5983041865394807, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '3018390', 'n_tokens_mistral': 2863, 'n_tokens_neox': 2662, 'n_words': 557}