Added Copy Mode to the Cell Workbench.

This commit is contained in:
AlgorithmX2
2014-04-06 18:05:09 -05:00
parent ee42c53f89
commit 13b3555d01
5 changed files with 79 additions and 6 deletions
@@ -10,11 +10,13 @@ import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import appeng.api.config.ActionItems;
import appeng.api.config.CopyMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerCellWorkbench;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
@@ -30,6 +32,7 @@ public class GuiCellWorkbench extends GuiUpgradeable
GuiImgButton clear;
GuiImgButton partition;
GuiToggleButton copyMode;
public GuiCellWorkbench(InventoryPlayer inventoryPlayer, TileCellWorkbench te) {
super( new ContainerCellWorkbench( inventoryPlayer, te ) );
@@ -102,7 +105,11 @@ public class GuiCellWorkbench extends GuiUpgradeable
{
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" ) );
}
@@ -132,15 +139,19 @@ public class GuiCellWorkbench extends GuiUpgradeable
{
clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
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( partition );
buttonList.add( clear );
buttonList.add( copyMode );
}
protected void handleButtonVisiblity()
{
copyMode.setState( ccwb.copyMode == CopyMode.CLEAR_ON_REMOVE );
boolean hasFuzzy = false;
IInventory inv = ccwb.getCellUpgradeInventory();
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.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.CopyMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.storage.ICellWorkbenchItem;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
@@ -23,6 +25,8 @@ import appeng.tile.inventory.AppEngNullInventory;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerCellWorkbench extends ContainerUpgradeable
{
@@ -51,6 +55,16 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
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
{
@@ -144,6 +158,8 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
ItemStack prevStack = null;
int lastUpgrades = 0;
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
public ContainerCellWorkbench(InventoryPlayer ip, TileCellWorkbench te) {
super( ip, te );
workBench = te;
@@ -212,6 +228,19 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
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
public void detectAndSendChanges()
{
@@ -222,6 +251,11 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( copyMode != getCopyMode() )
{
icrafting.sendProgressBarUpdate( this, 2, (int) getCopyMode().ordinal() );
}
if ( this.fzMode != getFuzzyMode() )
{
icrafting.sendProgressBarUpdate( this, 1, (int) getFuzzyMode().ordinal() );
@@ -242,6 +276,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
}
}
this.copyMode = getCopyMode();
this.fzMode = (FuzzyMode) getFuzzyMode();
}
+1 -1
View File
@@ -26,7 +26,7 @@ public enum GuiText
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel, StoredSize,
StoredPower, MaxPower, RequiredPower, Efficiency;
StoredPower, MaxPower, RequiredPower, Efficiency, CopyMode, CopyModeDesc;
String root;
+5 -1
View File
@@ -71,7 +71,11 @@ public class PacketValueConfig extends AppEngPacket
ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;
if ( Name.equals( "CellWorkbench.Action" ) )
{
if ( Value.equals( "Partition" ) )
if ( Value.equals( "CopyMode" ) )
{
ccw.nextCopyMode();
}
else if ( Value.equals( "Partition" ) )
{
ccw.partition();
}
+25 -2
View File
@@ -3,10 +3,13 @@ package appeng.tile.misc;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.CopyMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.storage.ICellWorkbenchItem;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigureableObject;
import appeng.tile.AEBaseTile;
import appeng.tile.events.AETileEventHandler;
import appeng.tile.events.TileEventType;
@@ -14,12 +17,15 @@ import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
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 );
AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 63 );
ConfigManager cm = new ConfigManager( this );
IInventory cacheUpgrades = null;
IInventory cacheConfig = null;
@@ -78,6 +84,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
{
cell.writeToNBT( data, "cell" );
config.writeToNBT( data, "config" );
cm.writeToNBT( data );
}
@Override
@@ -85,12 +92,14 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
{
cell.readFromNBT( data, "cell" );
config.readFromNBT( data, "config" );
cm.readFromNBT( data );
}
}
public TileCellWorkbench() {
addNewHandler( new TileCellWorkbenchHandler() );
cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
cell.enableClientEvents = true;
}
@@ -146,9 +155,16 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
{
for (int x = 0; x < config.getSizeInventory(); x++)
c.setInventorySlotContents( x, config.getStackInSlot( x ) );
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;
@@ -160,6 +176,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
{
for (int x = 0; x < config.getSizeInventory(); x++)
c.setInventorySlotContents( x, config.getStackInSlot( x ) );
c.markDirty();
}
}
@@ -179,7 +196,13 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
@Override
public IConfigManager getConfigManager()
{
return null;
return cm;
}
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
{
// nothing here..
}
}