Cleaned up buffer code a bit.
Just headers and stuff, and moved one of the slots out of the container because it might be useful for other stuff.
This commit is contained in:
parent
370c33ee70
commit
88b98d044b
4 changed files with 75 additions and 29 deletions
29
common/buildcraft/core/gui/slots/SlotValidated.java
Normal file
29
common/buildcraft/core/gui/slots/SlotValidated.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) CovertJaguar, 2011 http://railcraft.info
|
||||
*
|
||||
* This code is the property of CovertJaguar
|
||||
* and may only be used with explicit written
|
||||
* permission unless otherwise specified on the
|
||||
* license page at railcraft.wikispaces.com.
|
||||
*/
|
||||
package buildcraft.core.gui.slots;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author SandGrainOne
|
||||
*/
|
||||
public class SlotValidated extends Slot {
|
||||
|
||||
public SlotValidated(IInventory inv, int id, int x, int y) {
|
||||
super(inv, id, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return inventory.isStackValidForSlot(this.getSlotIndex(), itemStack);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -17,6 +24,10 @@ import buildcraft.core.GuiIds;
|
|||
import buildcraft.core.IItemPipe;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author SandGrainOne
|
||||
*/
|
||||
public class BlockFilteredBuffer extends BlockBuildCraft {
|
||||
|
||||
private static Icon blockTexture;
|
||||
|
@ -32,9 +43,9 @@ public class BlockFilteredBuffer extends BlockBuildCraft {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer,
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer,
|
||||
int par6, float par7, float par8, float par9) {
|
||||
|
||||
|
||||
super.onBlockActivated(world, x, y, z, entityplayer, par6, par7, par8, par9);
|
||||
|
||||
if (entityplayer.isSneaking()) {
|
||||
|
@ -54,7 +65,7 @@ public class BlockFilteredBuffer extends BlockBuildCraft {
|
|||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
itemList.add(new ItemStack(this));
|
||||
|
|
|
@ -1,46 +1,41 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.gui;
|
||||
|
||||
import buildcraft.core.gui.slots.SlotValidated;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
import buildcraft.core.gui.slots.SlotPhantom;
|
||||
import buildcraft.transport.TileFilteredBuffer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author SandGrainOne
|
||||
*/
|
||||
public class ContainerFilteredBuffer extends BuildCraftContainer {
|
||||
|
||||
private class SlotFiltered extends Slot
|
||||
{
|
||||
final TileFilteredBuffer filteredBuffer;
|
||||
|
||||
public SlotFiltered(TileFilteredBuffer filteredBuffer, int par2, int par3, int par4) {
|
||||
super(filteredBuffer, par2, par3, par4);
|
||||
this.filteredBuffer = filteredBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return filteredBuffer.isStackValidForSlot(this.getSlotIndex(), itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotPhantomLockable extends SlotPhantom
|
||||
{
|
||||
private class SlotPhantomLockable extends SlotPhantom {
|
||||
|
||||
final IInventory locks;
|
||||
|
||||
|
||||
public SlotPhantomLockable(IInventory storage, IInventory locks, int par2, int par3, int par4) {
|
||||
super(storage, par2, par3, par4);
|
||||
this.locks = locks;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canAdjust() {
|
||||
return locks.getStackInSlot(this.getSlotIndex()) == null;
|
||||
}
|
||||
}
|
||||
|
||||
IInventory playerInventory;
|
||||
TileFilteredBuffer filteredBuffer;
|
||||
|
||||
|
@ -51,14 +46,14 @@ public class ContainerFilteredBuffer extends BuildCraftContainer {
|
|||
this.filteredBuffer = tile;
|
||||
|
||||
IInventory filters = tile.getFilters();
|
||||
|
||||
|
||||
for (int col = 0; col < 9; col++) {
|
||||
// Filtered Buffer filter slots
|
||||
addSlotToContainer(new SlotPhantomLockable(filters, tile, col, 8 + col * 18, 27));
|
||||
// Filtered Buffer inventory slots
|
||||
addSlotToContainer(new SlotFiltered(tile, col, 8 + col * 18, 61));
|
||||
addSlotToContainer(new SlotValidated(tile, col, 8 + col * 18, 61));
|
||||
}
|
||||
|
||||
|
||||
// Player inventory
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k1 = 0; k1 < 9; k1++) {
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -8,6 +15,10 @@ import net.minecraft.client.gui.inventory.GuiContainer;
|
|||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author SandGrainOne
|
||||
*/
|
||||
public class GuiFilteredBuffer extends GuiContainer {
|
||||
|
||||
IInventory playerInventory;
|
||||
|
@ -31,11 +42,11 @@ public class GuiFilteredBuffer extends GuiContainer {
|
|||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
|
||||
|
||||
|
||||
IInventory filters = filteredBuffer.getFilters();
|
||||
|
||||
for (int col = 0; col < filters.getSizeInventory(); col++) {
|
||||
if(filters.getStackInSlot(col) == null) {
|
||||
if (filters.getStackInSlot(col) == null) {
|
||||
drawTexturedModalRect(cornerX + 7 + col * 18, cornerY + 60, 176, 0, 18, 18);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue