ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java

66 lines
1.8 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
* This file ("SlotFilter.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-01-03 16:05:51 +01:00
* http://ellpeck.de/actaddlicense/
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-01-03 16:05:51 +01:00
* © 2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.inventory.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotFilter extends Slot{
public SlotFilter(IInventory inv, int slot, int x, int y){
super(inv, slot, x, y);
}
/**
* Gets called when the Filter Slot is clicked
* Needs to be called in slotClick() in the Container!
2015-10-02 16:48:01 +02:00
*
* @param player The player
* @return Nothing, as the Item didn't really get "transferred"
*/
2015-10-10 02:52:53 +02:00
public ItemStack slotClick(EntityPlayer player){
ItemStack heldStack = player.inventory.getItemStack();
//Delete the stack in the inventory
if(this.getStack() != null && heldStack == null){
this.putStack(null);
}
//Put the current Item as a filter
else{
if(heldStack != null){
ItemStack stack = heldStack.copy();
stack.stackSize = 1;
this.putStack(stack);
}
}
return null;
}
@Override
2015-10-10 02:52:53 +02:00
public boolean isItemValid(ItemStack stack){
return false;
}
2015-10-10 02:51:06 +02:00
@Override
2015-10-10 02:52:53 +02:00
public void putStack(ItemStack stack){
ItemStack theStack = (stack != null ? stack.copy() : null);
super.putStack(theStack);
2015-10-10 02:51:06 +02:00
}
@Override
public boolean canTakeStack(EntityPlayer player){
return false;
}
}