<commit_before>package io.github.elytra.copo.inventory;

import io.github.elytra.copo.tile.TileEntityInterface;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ClickType;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class ContainerInterface extends Container {
	public class SlotFake extends Slot {
		public SlotFake(int index, int xPosition, int yPosition) {
			super(null, index, xPosition, yPosition);
		}

		private ItemStack stack;

		@Override
		public ItemStack getStack() {
			return stack;
		}

		@Override
		public void putStack(ItemStack stack) {
			this.stack = stack;
			onSlotChanged();
		}

		@Override
		public ItemStack decrStackSize(int amount) {
			if (stack == null) return null;
			ItemStack split = stack.splitStack(amount);
			if (stack.stackSize <= 0) {
				stack = null;
			}
			onSlotChanged();
			return split;
		}

		@Override
		public int getItemStackLimit(ItemStack stack) {
			return 1;
		}

		@Override
		public boolean isHere(IInventory inv, int slotIn) {
			return false;
		}

		@Override
		public boolean canBeHovered() {
			return true;
		}

		@Override
		public boolean canTakeStack(EntityPlayer playerIn) {
			return false;
		}

		@Override
		public boolean isItemValid(ItemStack stack) {
			return true;
		}

		@Override
		public void onSlotChanged() {
		}
	}

	private TileEntityInterface te;
	private EntityPlayer player;

	public ContainerInterface(InventoryPlayer playerInventory, EntityPlayer player, TileEntityInterface te) {
		this.te = te;
		this.player = player;

		for (int i = 0; i < 9; i++) {
			addSlotToContainer(new Slot(te, i, 6+((i%3)*18), 18+((i/3)*18)));
		}

		for (int i = 0; i < 9; i++) {
			SlotFake slot = new SlotFake(i, 62+((i%3)*18), 18+((i/3)*18));
			slot.putStack(te.getOutputPrototype(i));
			addSlotToContainer(slot);
		}

		for (int i = 0; i < 9; i++) {
			addSlotToContainer(new Slot(te, i+9, 118+((i%3)*18), 18+((i/3)*18)));
		}

		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 9; ++j) {
				addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
			}
		}

		for (int i = 0; i < 9; ++i) {
			addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142));
		}
	}

	@Override
	public ItemStack transferStackInSlot(EntityPlayer player, int index) {
		ItemStack result = null;
		Slot slot = inventorySlots.get(index);

		if (slot != null && slot.getHasStack()) {
			ItemStack stack = slot.getStack();
			result = stack.copy();

			if (index < 27) {
				if (!mergeItemStack(stack, 27, inventorySlots.size(), true)) {
					return null;
				}
			} else if (!mergeItemStack(stack, 0, 9, false)) {
				return null;
			}

			if (stack.stackSize == 0) {
				slot.putStack(null);
			} else {
				slot.onSlotChanged();
			}
		}

		return result;
	}

	@Override
	public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
		if (slotId >= 1) {
			Slot slot = getSlot(slotId);
			if (slot instanceof SlotFake) {
				if (clickTypeIn == ClickType.PICKUP) {
					if (slot.getHasStack()) {
						slot.putStack(null);
						te.setOutputPrototype(slot.getSlotIndex(), null);
						return null;
					} else {
						ItemStack cursor = player.inventory.getItemStack();<commit_msg>Disable stack smearing in Interfaces. Fixes #28<commit_after>package io.github.elytra.copo.inventory;

import io.github.elytra.copo.tile.TileEntityInterface;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ClickType;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class ContainerInterface extends Container {
	public class SlotFake extends Slot {
		public SlotFake(int index, int xPosition, int yPosition) {
			super(null, index, xPosition, yPosition);
		}

		private ItemStack stack;

		@Override
		public ItemStack getStack() {
			return stack;
		}

		@Override
		public void putStack(ItemStack stack) {
			this.stack = stack;
			onSlotChanged();
		}

		@Override
		public ItemStack decrStackSize(int amount) {
			if (stack == null) return null;
			ItemStack split = stack.splitStack(amount);
			if (stack.stackSize <= 0) {
				stack = null;
			}
			onSlotChanged();
			return split;
		}

		@Override
		public int getItemStackLimit(ItemStack stack) {
			return 1;
		}

		@Override
		public boolean isHere(IInventory inv, int slotIn) {
			return false;
		}

		@Override
		public boolean canBeHovered() {
			return true;
		}

		@Override
		public boolean canTakeStack(EntityPlayer playerIn) {
			return false;
		}

		@Override
		public boolean isItemValid(ItemStack stack) {
			return true;
		}

		@Override
		public void onSlotChanged() {
		}
	}

	private TileEntityInterface te;
	private EntityPlayer player;

	public ContainerInterface(InventoryPlayer playerInventory, EntityPlayer player, TileEntityInterface te) {
		this.te = te;
		this.player = player;

		for (int i = 0; i < 9; i++) {
			addSlotToContainer(new Slot(te, i, 6+((i%3)*18), 18+((i/3)*18)));
		}

		for (int i = 0; i < 9; i++) {
			SlotFake slot = new SlotFake(i, 62+((i%3)*18), 18+((i/3)*18));
			slot.putStack(te.getOutputPrototype(i));
			addSlotToContainer(slot);
		}

		for (int i = 0; i < 9; i++) {
			addSlotToContainer(new Slot(te, i+9, 118+((i%3)*18), 18+((i/3)*18)));
		}

		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 9; ++j) {
				addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
			}
		}

		for (int i = 0; i < 9; ++i) {
			addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142));
		}
	}

	@Override
	public ItemStack transferStackInSlot(EntityPlayer player, int index) {
		ItemStack result = null;
		Slot slot = inventorySlots.get(index);

		if (slot != null && slot.getHasStack()) {
			ItemStack stack = slot.getStack();
			result = stack.copy();

			if (index < 27) {
				if (!mergeItemStack(stack, 27, inventorySlots.size(), true)) {
					return null;
				}
			} else if (!mergeItemStack(stack, 0, 9, false)) {
				return null;
			}

			if (stack.stackSize == 0) {
				slot.putStack(null);
			} else {
				slot.onSlotChanged();
			}
		}

		return result;
	}

	@Override
	public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
		if (clickTypeIn == ClickType.QUICK_CRAFT) return player.inventory.getItemStack();
		if (slotId >= 1) {
			Slot slot = getSlot(slotId);
			if (slot instanceof SlotFake) {
				if (clickTypeIn == ClickType.PICKUP) {
					if (slot.getHasStack()) {
						slot.putStack(null);
						te.setOutputPrototype(slot.getSlotIndex(), null);
						return null;
					} else {
						ItemStack cursor = player.inventory.getItemStack();
{'fraction_non_alphanumeric': 0.13085993672706356, 'fraction_numerical': 0.01984469370146678, 'mean_word_length': 3.548724656638326, 'pattern_counts': {'":': 0, '<': 19, '<?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': '1891474', 'n_tokens_mistral': 2849, 'n_tokens_neox': 2368, 'n_words': 602}