compare btns on storage guis
This commit is contained in:
@@ -4,8 +4,10 @@ import com.google.common.primitives.Ints;
|
||||
import java.io.IOException;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import storagecraft.container.ContainerStorage;
|
||||
import storagecraft.gui.sidebutton.SideButtonCompare;
|
||||
import storagecraft.gui.sidebutton.SideButtonRedstoneMode;
|
||||
import storagecraft.storage.IStorageGui;
|
||||
import storagecraft.util.InventoryUtils;
|
||||
|
||||
public class GuiStorage extends GuiBase
|
||||
{
|
||||
@@ -33,6 +35,12 @@ public class GuiStorage extends GuiBase
|
||||
addSideButton(new SideButtonRedstoneMode(gui.getRedstoneModeSetting()));
|
||||
}
|
||||
|
||||
if (gui.getCompareSetting() != null)
|
||||
{
|
||||
addSideButton(new SideButtonCompare(gui.getCompareSetting(), InventoryUtils.COMPARE_DAMAGE));
|
||||
addSideButton(new SideButtonCompare(gui.getCompareSetting(), InventoryUtils.COMPARE_NBT));
|
||||
}
|
||||
|
||||
priorityField = new GuiTextField(0, fontRendererObj, x + 116 + 1, y + 54 + 1, 25, fontRendererObj.FONT_HEIGHT);
|
||||
priorityField.setText(String.valueOf(gui.getStorage().getPriority()));
|
||||
priorityField.setEnableBackgroundDrawing(false);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package storagecraft.storage;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import storagecraft.tile.ICompareSetting;
|
||||
import storagecraft.tile.IRedstoneModeSetting;
|
||||
|
||||
public interface IStorageGui
|
||||
@@ -18,6 +19,8 @@ public interface IStorageGui
|
||||
|
||||
public IRedstoneModeSetting getRedstoneModeSetting();
|
||||
|
||||
public ICompareSetting getCompareSetting();
|
||||
|
||||
public int getStored();
|
||||
|
||||
public int getCapacity();
|
||||
|
@@ -17,13 +17,15 @@ import storagecraft.storage.IStorageProvider;
|
||||
import storagecraft.storage.StorageItem;
|
||||
import storagecraft.util.InventoryUtils;
|
||||
|
||||
public class TileExternalStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui
|
||||
public class TileExternalStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui, ICompareSetting
|
||||
{
|
||||
public static final String NBT_PRIORITY = "Priority";
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("external_storage", 9);
|
||||
|
||||
private int priority = 0;
|
||||
private int compare = 0;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private int stored = 0;
|
||||
@@ -142,6 +144,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
|
||||
buf.writeInt(priority);
|
||||
buf.writeInt(getConnectedInventory() == null ? 0 : InventoryUtils.getInventoryItems(getConnectedInventory()));
|
||||
buf.writeInt(compare);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,6 +154,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
|
||||
priority = buf.readInt();
|
||||
stored = buf.readInt();
|
||||
compare = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,6 +168,11 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
{
|
||||
priority = nbt.getInteger(NBT_PRIORITY);
|
||||
}
|
||||
|
||||
if (nbt.hasKey(NBT_COMPARE))
|
||||
{
|
||||
compare = nbt.getInteger(NBT_COMPARE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,6 +183,19 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
InventoryUtils.saveInventory(inventory, nbt);
|
||||
|
||||
nbt.setInteger(NBT_PRIORITY, priority);
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompare()
|
||||
{
|
||||
return compare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompare(int compare)
|
||||
{
|
||||
this.compare = compare;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -211,6 +233,12 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompareSetting getCompareSetting()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored()
|
||||
{
|
||||
|
@@ -19,16 +19,18 @@ import storagecraft.storage.NBTStorage;
|
||||
import storagecraft.storage.StorageItem;
|
||||
import storagecraft.util.InventoryUtils;
|
||||
|
||||
public class TileStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui
|
||||
public class TileStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui, ICompareSetting
|
||||
{
|
||||
public static final String NBT_STORAGE = "Storage";
|
||||
public static final String NBT_PRIORITY = "Priority";
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("storage", 9);
|
||||
|
||||
private NBTTagCompound tag = NBTStorage.getBaseNBT();
|
||||
|
||||
private int priority = 0;
|
||||
private int compare = 0;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private int stored;
|
||||
@@ -66,6 +68,11 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
{
|
||||
priority = nbt.getInteger(NBT_PRIORITY);
|
||||
}
|
||||
|
||||
if (nbt.hasKey(NBT_COMPARE))
|
||||
{
|
||||
compare = nbt.getInteger(NBT_COMPARE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,6 +84,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
|
||||
nbt.setTag(NBT_STORAGE, tag);
|
||||
nbt.setInteger(NBT_PRIORITY, priority);
|
||||
nbt.setInteger(NBT_COMPARE, compare);
|
||||
}
|
||||
|
||||
public EnumStorageType getType()
|
||||
@@ -91,6 +99,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
|
||||
buf.writeInt(NBTStorage.getStored(tag));
|
||||
buf.writeInt(priority);
|
||||
buf.writeInt(compare);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,6 +109,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
|
||||
stored = buf.readInt();
|
||||
priority = buf.readInt();
|
||||
compare = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,6 +144,18 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
return getStorage().canPush(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompare()
|
||||
{
|
||||
return compare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompare(int compare)
|
||||
{
|
||||
this.compare = compare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
@@ -152,6 +174,12 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompareSetting getCompareSetting()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPriorityHandler getPriorityHandler()
|
||||
{
|
||||
|
Reference in New Issue
Block a user