Added Copy Mode to the Cell Workbench.
This commit is contained in:
@@ -10,11 +10,13 @@ import net.minecraft.item.ItemStack;
|
|||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
import appeng.api.config.ActionItems;
|
import appeng.api.config.ActionItems;
|
||||||
|
import appeng.api.config.CopyMode;
|
||||||
import appeng.api.config.FuzzyMode;
|
import appeng.api.config.FuzzyMode;
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.config.Upgrades;
|
import appeng.api.config.Upgrades;
|
||||||
import appeng.api.implementations.items.IUpgradeModule;
|
import appeng.api.implementations.items.IUpgradeModule;
|
||||||
import appeng.client.gui.widgets.GuiImgButton;
|
import appeng.client.gui.widgets.GuiImgButton;
|
||||||
|
import appeng.client.gui.widgets.GuiToggleButton;
|
||||||
import appeng.container.implementations.ContainerCellWorkbench;
|
import appeng.container.implementations.ContainerCellWorkbench;
|
||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
@@ -30,6 +32,7 @@ public class GuiCellWorkbench extends GuiUpgradeable
|
|||||||
|
|
||||||
GuiImgButton clear;
|
GuiImgButton clear;
|
||||||
GuiImgButton partition;
|
GuiImgButton partition;
|
||||||
|
GuiToggleButton copyMode;
|
||||||
|
|
||||||
public GuiCellWorkbench(InventoryPlayer inventoryPlayer, TileCellWorkbench te) {
|
public GuiCellWorkbench(InventoryPlayer inventoryPlayer, TileCellWorkbench te) {
|
||||||
super( new ContainerCellWorkbench( inventoryPlayer, te ) );
|
super( new ContainerCellWorkbench( inventoryPlayer, te ) );
|
||||||
@@ -102,7 +105,11 @@ public class GuiCellWorkbench extends GuiUpgradeable
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( btn == partition )
|
if ( btn == copyMode )
|
||||||
|
{
|
||||||
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
|
||||||
|
}
|
||||||
|
else if ( btn == partition )
|
||||||
{
|
{
|
||||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
|
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
|
||||||
}
|
}
|
||||||
@@ -132,15 +139,19 @@ public class GuiCellWorkbench extends GuiUpgradeable
|
|||||||
{
|
{
|
||||||
clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
|
clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
|
||||||
partition = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
|
partition = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
|
||||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
copyMode = new GuiToggleButton( this.guiLeft - 18, guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc.getLocal() );
|
||||||
|
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||||
|
|
||||||
buttonList.add( fuzzyMode );
|
buttonList.add( fuzzyMode );
|
||||||
buttonList.add( partition );
|
buttonList.add( partition );
|
||||||
buttonList.add( clear );
|
buttonList.add( clear );
|
||||||
|
buttonList.add( copyMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleButtonVisiblity()
|
protected void handleButtonVisiblity()
|
||||||
{
|
{
|
||||||
|
copyMode.setState( ccwb.copyMode == CopyMode.CLEAR_ON_REMOVE );
|
||||||
|
|
||||||
boolean hasFuzzy = false;
|
boolean hasFuzzy = false;
|
||||||
IInventory inv = ccwb.getCellUpgradeInventory();
|
IInventory inv = ccwb.getCellUpgradeInventory();
|
||||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import net.minecraft.inventory.ICrafting;
|
|||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
|
import appeng.api.config.CopyMode;
|
||||||
import appeng.api.config.FuzzyMode;
|
import appeng.api.config.FuzzyMode;
|
||||||
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.storage.ICellWorkbenchItem;
|
import appeng.api.storage.ICellWorkbenchItem;
|
||||||
import appeng.api.storage.IMEInventory;
|
import appeng.api.storage.IMEInventory;
|
||||||
import appeng.api.storage.StorageChannel;
|
import appeng.api.storage.StorageChannel;
|
||||||
@@ -23,6 +25,8 @@ import appeng.tile.inventory.AppEngNullInventory;
|
|||||||
import appeng.tile.misc.TileCellWorkbench;
|
import appeng.tile.misc.TileCellWorkbench;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.iterators.NullIterator;
|
import appeng.util.iterators.NullIterator;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class ContainerCellWorkbench extends ContainerUpgradeable
|
public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||||
{
|
{
|
||||||
@@ -51,6 +55,16 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
|||||||
return FuzzyMode.IGNORE_ALL;
|
return FuzzyMode.IGNORE_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void nextCopyMode()
|
||||||
|
{
|
||||||
|
workBench.getConfigManager().putSetting( Settings.COPY_MODE, Platform.nextEnum( getCopyMode() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public CopyMode getCopyMode()
|
||||||
|
{
|
||||||
|
return (CopyMode) workBench.getConfigManager().getSetting( Settings.COPY_MODE );
|
||||||
|
}
|
||||||
|
|
||||||
class Upgrades implements IInventory
|
class Upgrades implements IInventory
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -144,6 +158,8 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
|||||||
ItemStack prevStack = null;
|
ItemStack prevStack = null;
|
||||||
int lastUpgrades = 0;
|
int lastUpgrades = 0;
|
||||||
|
|
||||||
|
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
|
||||||
|
|
||||||
public ContainerCellWorkbench(InventoryPlayer ip, TileCellWorkbench te) {
|
public ContainerCellWorkbench(InventoryPlayer ip, TileCellWorkbench te) {
|
||||||
super( ip, te );
|
super( ip, te );
|
||||||
workBench = te;
|
workBench = te;
|
||||||
@@ -212,6 +228,19 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
|||||||
|
|
||||||
ItemStack LastCell;
|
ItemStack LastCell;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void updateProgressBar(int idx, int value)
|
||||||
|
{
|
||||||
|
super.updateProgressBar( idx, value );
|
||||||
|
|
||||||
|
if ( idx == 2 )
|
||||||
|
{
|
||||||
|
this.copyMode = CopyMode.values()[value];
|
||||||
|
workBench.getConfigManager().putSetting( Settings.COPY_MODE, this.copyMode );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void detectAndSendChanges()
|
public void detectAndSendChanges()
|
||||||
{
|
{
|
||||||
@@ -222,6 +251,11 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
|||||||
{
|
{
|
||||||
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
||||||
|
|
||||||
|
if ( copyMode != getCopyMode() )
|
||||||
|
{
|
||||||
|
icrafting.sendProgressBarUpdate( this, 2, (int) getCopyMode().ordinal() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( this.fzMode != getFuzzyMode() )
|
if ( this.fzMode != getFuzzyMode() )
|
||||||
{
|
{
|
||||||
icrafting.sendProgressBarUpdate( this, 1, (int) getFuzzyMode().ordinal() );
|
icrafting.sendProgressBarUpdate( this, 1, (int) getFuzzyMode().ordinal() );
|
||||||
@@ -242,6 +276,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.copyMode = getCopyMode();
|
||||||
this.fzMode = (FuzzyMode) getFuzzyMode();
|
this.fzMode = (FuzzyMode) getFuzzyMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public enum GuiText
|
|||||||
|
|
||||||
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel, StoredSize,
|
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel, StoredSize,
|
||||||
|
|
||||||
StoredPower, MaxPower, RequiredPower, Efficiency;
|
StoredPower, MaxPower, RequiredPower, Efficiency, CopyMode, CopyModeDesc;
|
||||||
|
|
||||||
String root;
|
String root;
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,11 @@ public class PacketValueConfig extends AppEngPacket
|
|||||||
ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;
|
ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;
|
||||||
if ( Name.equals( "CellWorkbench.Action" ) )
|
if ( Name.equals( "CellWorkbench.Action" ) )
|
||||||
{
|
{
|
||||||
if ( Value.equals( "Partition" ) )
|
if ( Value.equals( "CopyMode" ) )
|
||||||
|
{
|
||||||
|
ccw.nextCopyMode();
|
||||||
|
}
|
||||||
|
else if ( Value.equals( "Partition" ) )
|
||||||
{
|
{
|
||||||
ccw.partition();
|
ccw.partition();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package appeng.tile.misc;
|
|||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import appeng.api.config.CopyMode;
|
||||||
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.config.Upgrades;
|
import appeng.api.config.Upgrades;
|
||||||
import appeng.api.implementations.IUpgradeableHost;
|
import appeng.api.implementations.IUpgradeableHost;
|
||||||
import appeng.api.storage.ICellWorkbenchItem;
|
import appeng.api.storage.ICellWorkbenchItem;
|
||||||
import appeng.api.util.IConfigManager;
|
import appeng.api.util.IConfigManager;
|
||||||
|
import appeng.api.util.IConfigureableObject;
|
||||||
import appeng.tile.AEBaseTile;
|
import appeng.tile.AEBaseTile;
|
||||||
import appeng.tile.events.AETileEventHandler;
|
import appeng.tile.events.AETileEventHandler;
|
||||||
import appeng.tile.events.TileEventType;
|
import appeng.tile.events.TileEventType;
|
||||||
@@ -14,12 +17,15 @@ import appeng.tile.inventory.AppEngInternalAEInventory;
|
|||||||
import appeng.tile.inventory.AppEngInternalInventory;
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
import appeng.tile.inventory.IAEAppEngInventory;
|
import appeng.tile.inventory.IAEAppEngInventory;
|
||||||
import appeng.tile.inventory.InvOperation;
|
import appeng.tile.inventory.InvOperation;
|
||||||
|
import appeng.util.ConfigManager;
|
||||||
|
import appeng.util.IConfigManagerHost;
|
||||||
|
|
||||||
public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory
|
public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory, IConfigureableObject, IConfigManagerHost
|
||||||
{
|
{
|
||||||
|
|
||||||
AppEngInternalInventory cell = new AppEngInternalInventory( this, 1 );
|
AppEngInternalInventory cell = new AppEngInternalInventory( this, 1 );
|
||||||
AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 63 );
|
AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 63 );
|
||||||
|
ConfigManager cm = new ConfigManager( this );
|
||||||
|
|
||||||
IInventory cacheUpgrades = null;
|
IInventory cacheUpgrades = null;
|
||||||
IInventory cacheConfig = null;
|
IInventory cacheConfig = null;
|
||||||
@@ -78,6 +84,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
|||||||
{
|
{
|
||||||
cell.writeToNBT( data, "cell" );
|
cell.writeToNBT( data, "cell" );
|
||||||
config.writeToNBT( data, "config" );
|
config.writeToNBT( data, "config" );
|
||||||
|
cm.writeToNBT( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,12 +92,14 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
|||||||
{
|
{
|
||||||
cell.readFromNBT( data, "cell" );
|
cell.readFromNBT( data, "cell" );
|
||||||
config.readFromNBT( data, "config" );
|
config.readFromNBT( data, "config" );
|
||||||
|
cm.readFromNBT( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileCellWorkbench() {
|
public TileCellWorkbench() {
|
||||||
addNewHandler( new TileCellWorkbenchHandler() );
|
addNewHandler( new TileCellWorkbenchHandler() );
|
||||||
|
cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||||
cell.enableClientEvents = true;
|
cell.enableClientEvents = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,9 +155,16 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
|||||||
{
|
{
|
||||||
for (int x = 0; x < config.getSizeInventory(); x++)
|
for (int x = 0; x < config.getSizeInventory(); x++)
|
||||||
c.setInventorySlotContents( x, config.getStackInSlot( x ) );
|
c.setInventorySlotContents( x, config.getStackInSlot( x ) );
|
||||||
|
|
||||||
c.markDirty();
|
c.markDirty();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if ( cm.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||||
|
{
|
||||||
|
for (int x = 0; x < config.getSizeInventory(); x++)
|
||||||
|
config.setInventorySlotContents( x, null );
|
||||||
|
|
||||||
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
locked = false;
|
locked = false;
|
||||||
@@ -160,6 +176,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
|||||||
{
|
{
|
||||||
for (int x = 0; x < config.getSizeInventory(); x++)
|
for (int x = 0; x < config.getSizeInventory(); x++)
|
||||||
c.setInventorySlotContents( x, config.getStackInSlot( x ) );
|
c.setInventorySlotContents( x, config.getStackInSlot( x ) );
|
||||||
|
|
||||||
c.markDirty();
|
c.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +196,13 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
|||||||
@Override
|
@Override
|
||||||
public IConfigManager getConfigManager()
|
public IConfigManager getConfigManager()
|
||||||
{
|
{
|
||||||
return null;
|
return cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||||
|
{
|
||||||
|
// nothing here..
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user