mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-29 18:28:34 +01:00
Made the Slots in the ESD actual filter slots that don't consume Items because people were annoying me with it
This commit is contained in:
parent
367d1b3385
commit
d3b9d575ea
2 changed files with 50 additions and 12 deletions
|
@ -49,6 +49,15 @@ public class ContainerInputter extends Container{
|
||||||
return this.tileInputter.isUseableByPlayer(player);
|
return this.tileInputter.isUseableByPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer player){
|
||||||
|
if(par1 >= 0 && par1 < this.inventorySlots.size() && this.getSlot(par1) instanceof SlotFilter){
|
||||||
|
//Calls the Filter's SlotClick function
|
||||||
|
return ((SlotFilter)getSlot(par1)).slotClick(player, par2);
|
||||||
|
}
|
||||||
|
else return super.slotClick(par1, par2, par3, player);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
||||||
final int inventoryStart = this.isAdvanced ? 25 : 1;
|
final int inventoryStart = this.isAdvanced ? 25 : 1;
|
||||||
|
|
|
@ -1,17 +1,46 @@
|
||||||
package ellpeck.actuallyadditions.inventory.slot;
|
package ellpeck.actuallyadditions.inventory.slot;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class SlotFilter extends Slot{
|
public class SlotFilter extends Slot{
|
||||||
|
|
||||||
public SlotFilter(IInventory inventory, int id, int x, int y){
|
public SlotFilter(IInventory inv, int slot, int x, int y){
|
||||||
super(inventory, id, x, y);
|
super(inv, slot, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets called when the Filter Slot is clicked
|
||||||
|
* Needs to be called in slotClick() in the Container!
|
||||||
|
* @param player The player
|
||||||
|
* @param button The button pressed (1 is right mouse button!)
|
||||||
|
* @return Nothing, as the Item didn't really get "transferred"
|
||||||
|
*/
|
||||||
|
public ItemStack slotClick(EntityPlayer player, int button){
|
||||||
|
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
|
@Override
|
||||||
public int getSlotStackLimit(){
|
public void putStack(ItemStack stack){
|
||||||
return 1;
|
ItemStack theStack = (stack != null ? stack.copy() : null);
|
||||||
|
super.putStack(theStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue