<commit_before>package com.ForgeEssentials.util;

//Depreciated
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockSaveable
{
	private int					x;
	private int					y;
	private int					z;
	private short				blockID;
	private byte				metadata;
	private NBTTagCompound		tile;

	/**
	 * generates the block from the world.
	 * @param world
	 * @param x
	 * @param y
	 * @param z
	 */
	public BlockSaveable(World world, int x, int y, int z)
	{
		this.x = x;
		this.y = y;
		this.z = z;
		blockID = (short) world.getBlockId(x, y, z);
		metadata = (byte) world.getBlockMetadata(x, y, z);

		TileEntity entity = world.getBlockTileEntity(x, y, z);
		if (entity != null)
		{
			try
			{
				NBTTagCompound compound = new NBTTagCompound();
				entity.writeToNBT(compound);
				tile = compound;
			}
			catch (Exception e)
			{
			}
		}
	}

	@Override
	public boolean equals(Object object)
	{
		if (object == null)
			return false;
		
		if (object instanceof BlockSaveable)
		{
			BlockSaveable block = (BlockSaveable) object;
			return blockID == block.blockID && metadata == block.metadata && tile.equals(block.tile);
		}
		return false;
	}

	/**
	 * @param world
	 * @return if the block was actually set.
	 */
	public boolean setinWorld(World world)
	{
		if (equals(new BlockSaveable(world, x, y, z)))
			return false;

		world.setBlock(x, y, z, blockID, metadata, 3);
		TileEntity entity = world.getBlockTileEntity(x, y, z);
		if (entity != null && tile != null)
		{
			entity.readFromNBT(tile);
		}

		return true;
	}

	public boolean isAir()
	{
		return blockID == 0;
	}
}<commit_msg>fixes #886<commit_after>package com.ForgeEssentials.util;

//Depreciated
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockSaveable
{
	private int					x;
	private int					y;
	private int					z;
	private short				blockID;
	private byte				metadata;
	private NBTTagCompound		tile;

	/**
	 * generates the block from the world.
	 * @param world
	 * @param x
	 * @param y
	 * @param z
	 */
	public BlockSaveable(World world, int x, int y, int z)
	{
		this.x = x;
		this.y = y;
		this.z = z;
		blockID = (short) world.getBlockId(x, y, z);
		metadata = (byte) world.getBlockMetadata(x, y, z);

		TileEntity entity = world.getBlockTileEntity(x, y, z);
		if (entity != null)
		{
			try
			{
				NBTTagCompound compound = new NBTTagCompound();
				entity.writeToNBT(compound);
				tile = compound;
			}
			catch (Exception e)
			{
			}
		}
	}

	@Override
	public boolean equals(Object object)
	{
		if (object == null)
			return false;
		
		if (object instanceof BlockSaveable)
		{
			BlockSaveable block = (BlockSaveable) object;
			
			// check NBT tag for equality
			boolean tileEqual = false;
			if (tile == null && block.tile == null)
				tileEqual = true;
			else if (tile != null && tile.equals(block.tile))
				tileEquals = true;
			
			// return full boolean that takes everything into account
			return blockID == block.blockID && metadata == block.metadata && tileEqual;
		}
		return false;
	}

	/**
	 * @param world
	 * @return if the block was actually set.
	 */
	public boolean setinWorld(World world)
	{
		if (equals(new BlockSaveable(world, x, y, z)))
			return false;

		world.setBlock(x, y, z, blockID, metadata, 3);
		TileEntity entity = world.getBlockTileEntity(x, y, z);
		if (entity != null && tile != null)
		{
			entity.readFromNBT(tile);
		}

		return true;
	}

	public boolean isAir()
	{
		return blockID == 0;
	}
}
{'fraction_non_alphanumeric': 0.11997767857142858, 'fraction_numerical': 0.001953125, 'mean_word_length': 3.064625850340136, 'pattern_counts': {'":': 0, '<': 3, '<?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': '826987', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1246, 'n_words': 351}