mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48: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
|
@ -22,12 +22,12 @@ public class ContainerInputter extends Container{
|
||||||
this.tileInputter = (TileEntityInputter)tile;
|
this.tileInputter = (TileEntityInputter)tile;
|
||||||
this.isAdvanced = isAdvanced;
|
this.isAdvanced = isAdvanced;
|
||||||
|
|
||||||
this.addSlotToContainer(new Slot(this.tileInputter, 0, 80, 21 + (isAdvanced ? 12 : 0)));
|
this.addSlotToContainer(new Slot(this.tileInputter, 0, 80, 21+(isAdvanced ? 12 : 0)));
|
||||||
|
|
||||||
if(isAdvanced){
|
if(isAdvanced){
|
||||||
for(int i = 0; i < 2; i++){
|
for(int i = 0; i < 2; i++){
|
||||||
for(int x = 0; x < 3; x++){
|
for(int x = 0; x < 3; x++){
|
||||||
for(int y = 0;y < 4; y++){
|
for(int y = 0; y < 4; y++){
|
||||||
this.addSlotToContainer(new SlotFilter(this.tileInputter, 1+y+x*4+i*12, 20+i*84+x*18, 6+y*18));
|
this.addSlotToContainer(new SlotFilter(this.tileInputter, 1+y+x*4+i*12, 20+i*84+x*18, 6+y*18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,12 @@ public class ContainerInputter extends Container{
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for (int j = 0; j < 9; j++){
|
for(int j = 0; j < 9; j++){
|
||||||
this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18 + (isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0)));
|
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18+(isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i = 0; i < 9; i++){
|
for(int i = 0; i < 9; i++){
|
||||||
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155 + (isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0)));
|
this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155+(isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -58,7 +67,7 @@ public class ContainerInputter extends Container{
|
||||||
|
|
||||||
Slot theSlot = (Slot)this.inventorySlots.get(slot);
|
Slot theSlot = (Slot)this.inventorySlots.get(slot);
|
||||||
|
|
||||||
if (theSlot != null && theSlot.getHasStack()){
|
if(theSlot != null && theSlot.getHasStack()){
|
||||||
ItemStack newStack = theSlot.getStack();
|
ItemStack newStack = theSlot.getStack();
|
||||||
ItemStack currentStack = newStack.copy();
|
ItemStack currentStack = newStack.copy();
|
||||||
|
|
||||||
|
@ -76,10 +85,10 @@ public class ContainerInputter extends Container{
|
||||||
}
|
}
|
||||||
else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)) return null;
|
else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)) return null;
|
||||||
|
|
||||||
if (newStack.stackSize == 0) theSlot.putStack(null);
|
if(newStack.stackSize == 0) theSlot.putStack(null);
|
||||||
else theSlot.onSlotChanged();
|
else theSlot.onSlotChanged();
|
||||||
|
|
||||||
if (newStack.stackSize == currentStack.stackSize) return null;
|
if(newStack.stackSize == currentStack.stackSize) return null;
|
||||||
theSlot.onPickupFromSlot(player, newStack);
|
theSlot.onPickupFromSlot(player, newStack);
|
||||||
|
|
||||||
return currentStack;
|
return currentStack;
|
||||||
|
|
|
@ -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