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