<commit_before>package openblocks.common.tileentity;

import java.util.List;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;

import openblocks.OpenBlocks;
import openblocks.client.gui.GuiClayStainer;
import openblocks.common.GenericInventory;
import openblocks.common.api.IActivateAwareTile;
import openblocks.common.api.IHasGui;
import openblocks.common.block.BlockSpecialStainedClay;
import openblocks.common.container.ContainerClayStainer;
import openblocks.sync.ISyncableObject;
import openblocks.sync.SyncableInt;

public class TileEntityClayStainer extends SyncedTileEntity implements IInventory, IHasGui, IActivateAwareTile {

	public static final ItemStack SPECIAL_CLAY_STACK = new ItemStack(OpenBlocks.Blocks.specialStainedClay);
	
	public static enum Slots {
		input,
		dyeRed,
		dyeGreen,
		dyeBlue
	}
	
	private GenericInventory inventory = new GenericInventory("claystainer", true, 4);
	
	private SyncableInt color;
	private SyncableInt tone;
	
	@Override
	protected void createSyncedFields() {
		color = new SyncableInt();
		tone = new SyncableInt();
	}
	
	public SyncableInt getColor() {
		return color;
	}

	public SyncableInt getTone() {
		return tone;
	}
	
	@Override
	public boolean onBlockActivated(EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
		if (player.isSneaking()) { return false; }
		if (!worldObj.isRemote) {
			openGui(player);
		}
		return true;
	}

	public void onSync() {
		setColorOnItemStack();
	}
	
	public void setColorOnItemStack() {
		ItemStack inputStack = inventory.getStackInSlot(Slots.input);
		if (inputStack != null && inputStack.isItemEqual(SPECIAL_CLAY_STACK)) {
			BlockSpecialStainedClay.writeColorToNBT(inputStack, color.getValue());
		}
	}
	
	@Override
	public void onSynced(List<ISyncableObject> changes) {
		setColorOnItemStack();
	}

	@Override
	public int getSizeInventory() {
		return inventory.getSizeInventory();
	}

	@Override
	public ItemStack getStackInSlot(int i) {
		return inventory.getStackInSlot(i);
	}

	@Override
	public ItemStack decrStackSize(int i, int j) {
		return inventory.decrStackSize(i, j);
	}

	@Override
	public ItemStack getStackInSlotOnClosing(int i) {
		return inventory.getStackInSlotOnClosing(i);
	}

	@Override
	public void setInventorySlotContents(int i, ItemStack itemstack) {
		inventory.setInventorySlotContents(i, itemstack);
	}

	@Override
	public String getInvName() {
		return inventory.getInvName();
	}

	@Override
	public boolean isInvNameLocalized() {
		return inventory.isInvNameLocalized();
	}
<commit_msg>auto-convert stained/hardened clay to special clay when they enter the inventory<commit_after>package openblocks.common.tileentity;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import openblocks.OpenBlocks;
import openblocks.client.gui.GuiClayStainer;
import openblocks.common.GenericInventory;
import openblocks.common.api.IActivateAwareTile;
import openblocks.common.api.IHasGui;
import openblocks.common.block.BlockSpecialStainedClay;
import openblocks.common.container.ContainerClayStainer;
import openblocks.sync.ISyncableObject;
import openblocks.sync.SyncableInt;

public class TileEntityClayStainer extends SyncedTileEntity implements IInventory, IHasGui, IActivateAwareTile {

	public static final ItemStack HARDENED_CLAY = new ItemStack(Block.hardenedClay);
	public static final ItemStack STAINED_CLAY = new ItemStack(Block.stainedClay);
	public static final ItemStack SPECIAL_STAINED_CLAY = new ItemStack(OpenBlocks.Blocks.specialStainedClay);
	
	public static enum Slots {
		input,
		dyeRed,
		dyeGreen,
		dyeBlue
	}
	
	private GenericInventory inventory = new GenericInventory("claystainer", true, 4);
	
	private SyncableInt color;
	private SyncableInt tone;
	
	@Override
	protected void createSyncedFields() {
		color = new SyncableInt();
		tone = new SyncableInt();
	}
	
	public SyncableInt getColor() {
		return color;
	}

	public SyncableInt getTone() {
		return tone;
	}
	
	@Override
	public boolean onBlockActivated(EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
		if (player.isSneaking()) { return false; }
		if (!worldObj.isRemote) {
			openGui(player);
		}
		return true;
	}

	public void onSync() {
		setColorOnItemStack();
	}
	
	public void setColorOnItemStack() {
		ItemStack inputStack = inventory.getStackInSlot(Slots.input);
		if (inputStack != null && inputStack.isItemEqual(SPECIAL_STAINED_CLAY)) {
			BlockSpecialStainedClay.writeColorToNBT(inputStack, color.getValue());
		}
	}
	
	@Override
	public void onSynced(List<ISyncableObject> changes) {
		setColorOnItemStack();
	}

	@Override
	public int getSizeInventory() {
		return inventory.getSizeInventory();
	}

	@Override
	public ItemStack getStackInSlot(int i) {
		return inventory.getStackInSlot(i);
	}

	@Override
	public ItemStack decrStackSize(int i, int j) {
		return inventory.decrStackSize(i, j);
	}

	@Override
	public ItemStack getStackInSlotOnClosing(int i) {
		return inventory.getStackInSlotOnClosing(i);
	}

	@Override
	public void setInventorySlotContents(int i, ItemStack itemstack) {
		setColorOnItemStack();
		if (itemstack != null) {

			Item item = itemstack.getItem();
			if (item != null && item.equals(HARDENED_CLAY.getItem()) || item.equals(STAINED_CLAY.getItem())) {
				int size = itemstack.stackSize;
				itemstack = SPECIAL_STAINED_CLAY.copy();
				itemstack.stackSize = size;
			}
		}
		inventory.setInventorySlotContents(i, itemstack);
	}

	@Override
	public String getInvName() {
		return inventory.getInvName();
	}

	@Override
	public boolean isInvNameLocalized() {
		return inventory.isInvNameLocalized();
	}

{'fraction_non_alphanumeric': 0.09376071306136441, 'fraction_numerical': 0.00034281796366129587, 'mean_word_length': 5.356209150326797, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4821658', 'n_tokens_mistral': 2016, 'n_tokens_neox': 1888, 'n_words': 407}