<commit_before>package mytown.handlers;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import mytown.MyTown;
import mytown.entities.Plot;
import mytown.entities.Resident;
import mytown.entities.Town;
import mytown.entities.TownBlock;
import mytown.util.MyTownUtils;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.server.MinecraftServer;

import java.util.*;

public class VisualsTickHandler {

    private static VisualsTickHandler instance = new VisualsTickHandler();
    public static VisualsTickHandler getInstance() {
        if(instance == null)
            instance = new VisualsTickHandler();
        return instance;
    }

    public Map<Object, List<BlockCoords>> markedBlocks = new HashMap<Object, List<BlockCoords>>();

    @SubscribeEvent
    public void tick(TickEvent.ServerTickEvent ev) {
        if (ev.side != Side.SERVER || ev.phase != TickEvent.Phase.START) return;

        if (markedBlocks.size() != 0) {
            for(Map.Entry<Object, List<BlockCoords>> set : markedBlocks.entrySet()) {
                Iterator<BlockCoords> iterator = set.getValue().iterator();
                while (iterator.hasNext()) {
                    BlockCoords coord = iterator.next();
                    if (!coord.packetSent) {
                        S23PacketBlockChange packet = new S23PacketBlockChange(coord.x, coord.y, coord.z, MinecraftServer.getServer().worldServerForDimension(coord.dim));
                        packet.field_148883_d = coord.block;
                        FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet);

                        coord.packetSent = true;
                    }
                    if (coord.deleted) {
                        S23PacketBlockChange packet = new S23PacketBlockChange(coord.x, coord.y, coord.z, MinecraftServer.getServer().worldServerForDimension(coord.dim));
                        packet.field_148883_d = MinecraftServer.getServer().worldServerForDimension(coord.dim).getBlock(coord.x, coord.y, coord.z);
                        packet.field_148884_e = MinecraftServer.getServer().worldServerForDimension(coord.dim).getBlockMetadata(coord.x, coord.y, coord.z);
                        FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet);

                        iterator.remove();
                    }
                }
                //if(set.getValue().size() == 0)
                //    markedBlocks.remove(set.getKey());
            }
        }
    }

    public void markBlock(int x, int y, int z, int dim, Block block, Object key) {
        if(markedBlocks.get(key) == null) {
            markedBlocks.put(key, new ArrayList<BlockCoords>());
        }
        markedBlocks.get(key).add(new BlockCoords(x, y, z, dim, block));
    }

    public boolean unmarkBlock(int x, int y, int z, int dim) {
        if (markedBlocks.size() == 0)
            return false;
        for(List<BlockCoords> coordsList : markedBlocks.values()) {
            for (BlockCoords coord : coordsList) {
                if (coord.x == x && coord.y == y && coord.z == z && coord.dim == dim) {
                        coord.deleted = true;
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * Unmarks all the blocks that are linked to the object key.
     */
    public boolean unmarkBlocks(Object key) {
        if(markedBlocks.get(key) == null)<commit_msg>Fixed issue with showing blocks in VisualsTickHandler<commit_after>package mytown.handlers;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import mytown.MyTown;
import mytown.entities.Plot;
import mytown.entities.Resident;
import mytown.entities.Town;
import mytown.entities.TownBlock;
import mytown.util.MyTownUtils;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.server.MinecraftServer;

import java.util.*;

public class VisualsTickHandler {

    private static VisualsTickHandler instance = new VisualsTickHandler();
    public static VisualsTickHandler getInstance() {
        if(instance == null)
            instance = new VisualsTickHandler();
        return instance;
    }

    public Map<Object, List<BlockCoords>> markedBlocks = new HashMap<Object, List<BlockCoords>>();

    @SubscribeEvent
    public void tick(TickEvent.ServerTickEvent ev) {
        if (ev.side != Side.SERVER || ev.phase != TickEvent.Phase.START) return;

        if (markedBlocks.size() != 0) {
            for(Map.Entry<Object, List<BlockCoords>> set : markedBlocks.entrySet()) {
                Iterator<BlockCoords> iterator = set.getValue().iterator();
                while (iterator.hasNext()) {
                    BlockCoords coord = iterator.next();
                    if (!coord.packetSent) {
                        S23PacketBlockChange packet = new S23PacketBlockChange(coord.x, coord.y, coord.z, MinecraftServer.getServer().worldServerForDimension(coord.dim));
                        packet.field_148883_d = coord.block;
                        FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet);

                        coord.packetSent = true;
                    }
                    if (coord.deleted) {
                        S23PacketBlockChange packet = new S23PacketBlockChange(coord.x, coord.y, coord.z, MinecraftServer.getServer().worldServerForDimension(coord.dim));
                        packet.field_148883_d = MinecraftServer.getServer().worldServerForDimension(coord.dim).getBlock(coord.x, coord.y, coord.z);
                        packet.field_148884_e = MinecraftServer.getServer().worldServerForDimension(coord.dim).getBlockMetadata(coord.x, coord.y, coord.z);
                        FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet);

                        iterator.remove();
                    }
                }
            }
        }
    }

    public void markBlock(int x, int y, int z, int dim, Block block, Object key) {
        if(markedBlocks.get(key) == null) {
            markedBlocks.put(key, new ArrayList<BlockCoords>());
        }
        markedBlocks.get(key).add(new BlockCoords(x, y, z, dim, block));
    }

    public boolean unmarkBlock(int x, int y, int z, int dim) {
        if (markedBlocks.size() == 0)
            return false;
        for(List<BlockCoords> coordsList : markedBlocks.values()) {
            for (BlockCoords coord : coordsList) {
                if (coord.x == x && coord.y == y && coord.z == z && coord.dim == dim) {
                        coord.deleted = true;
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * Unmarks all the blocks that are linked to the object key.
     */
    public boolean unmarkBlocks(Object key) {
        if(markedBlocks.get(key) == null)
{'fraction_non_alphanumeric': 0.10921088068946944, 'fraction_numerical': 0.008214381901427417, 'mean_word_length': 2.3682539682539683, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '6956177', 'n_tokens_mistral': 2130, 'n_tokens_neox': 2032, 'n_words': 402}