Work on Storage Bus.
This commit is contained in:
parent
594adc141c
commit
2e8ffc4a09
5 changed files with 218 additions and 4 deletions
85
client/gui/implementations/GuiStorageBus.java
Normal file
85
client/gui/implementations/GuiStorageBus.java
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
package appeng.client.gui.implementations;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import appeng.api.config.AccessRestriction;
|
||||||
|
import appeng.api.config.FuzzyMode;
|
||||||
|
import appeng.api.config.Settings;
|
||||||
|
import appeng.client.gui.widgets.GuiImgButton;
|
||||||
|
import appeng.container.implementations.ContainerStorageBus;
|
||||||
|
import appeng.core.localization.GuiText;
|
||||||
|
import appeng.core.sync.packets.PacketConfigButton;
|
||||||
|
import appeng.parts.misc.PartStorageBus;
|
||||||
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
|
|
||||||
|
public class GuiStorageBus extends GuiUpgradeable
|
||||||
|
{
|
||||||
|
|
||||||
|
GuiImgButton rwMode;
|
||||||
|
|
||||||
|
public GuiStorageBus(InventoryPlayer inventoryPlayer, PartStorageBus te) {
|
||||||
|
super( new ContainerStorageBus( inventoryPlayer, te ) );
|
||||||
|
this.ySize = 245;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
fontRenderer.drawString( GuiText.StorageBus.getLocal(), 8, 6, 4210752 );
|
||||||
|
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||||
|
|
||||||
|
if ( fuzzyMode != null )
|
||||||
|
fuzzyMode.set( cvb.fzMode );
|
||||||
|
|
||||||
|
if ( rwMode != null )
|
||||||
|
rwMode.set( ((ContainerStorageBus) cvb).rwMode );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addButtons()
|
||||||
|
{
|
||||||
|
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||||
|
rwMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||||
|
|
||||||
|
buttonList.add( fuzzyMode );
|
||||||
|
buttonList.add( rwMode );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton btn)
|
||||||
|
{
|
||||||
|
super.actionPerformed( btn );
|
||||||
|
|
||||||
|
boolean backwards = Mouse.isButtonDown( 1 );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( btn == fuzzyMode )
|
||||||
|
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( fuzzyMode.getSetting(), backwards )).getPacket() );
|
||||||
|
|
||||||
|
if ( btn == rwMode )
|
||||||
|
PacketDispatcher.sendPacketToServer( (new PacketConfigButton( rwMode.getSetting(), backwards )).getPacket() );
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getBackground()
|
||||||
|
{
|
||||||
|
return "guis/storagebus.png";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
95
container/implementations/ContainerStorageBus.java
Normal file
95
container/implementations/ContainerStorageBus.java
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
package appeng.container.implementations;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.ICrafting;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import appeng.api.config.AccessRestriction;
|
||||||
|
import appeng.api.config.FuzzyMode;
|
||||||
|
import appeng.api.config.Settings;
|
||||||
|
import appeng.container.slot.SlotRestrictedInput;
|
||||||
|
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||||
|
import appeng.parts.misc.PartStorageBus;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
public class ContainerStorageBus extends ContainerUpgradeable
|
||||||
|
{
|
||||||
|
|
||||||
|
PartStorageBus storageBus;
|
||||||
|
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
|
||||||
|
|
||||||
|
public ContainerStorageBus(InventoryPlayer ip, PartStorageBus te) {
|
||||||
|
super( ip, te );
|
||||||
|
storageBus = te;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getHeight()
|
||||||
|
{
|
||||||
|
return 245;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int availableUpgrades()
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportCapacity()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupConfig()
|
||||||
|
{
|
||||||
|
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
||||||
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0 )).setNotDraggable() );
|
||||||
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1 )).setNotDraggable() );
|
||||||
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2 )).setNotDraggable() );
|
||||||
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3 )).setNotDraggable() );
|
||||||
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4 )).setNotDraggable() );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detectAndSendChanges()
|
||||||
|
{
|
||||||
|
if ( Platform.isServer() )
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this.crafters.size(); ++i)
|
||||||
|
{
|
||||||
|
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
||||||
|
|
||||||
|
if ( this.rwMode != this.myte.getConfigManager().getSetting( Settings.ACCESS ) )
|
||||||
|
{
|
||||||
|
icrafting.sendProgressBarUpdate( this, 3, (int) this.myte.getConfigManager().getSetting( Settings.ACCESS ).ordinal() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( this.fzMode != this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ) )
|
||||||
|
{
|
||||||
|
icrafting.sendProgressBarUpdate( this, 4, (int) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ).ordinal() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||||
|
this.rwMode = (AccessRestriction) this.myte.getConfigManager().getSetting( Settings.ACCESS );
|
||||||
|
}
|
||||||
|
|
||||||
|
standardDetectAndSendChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateProgressBar(int idx, int value)
|
||||||
|
{
|
||||||
|
super.updateProgressBar( idx, value );
|
||||||
|
|
||||||
|
if ( idx == 3 )
|
||||||
|
this.rwMode = AccessRestriction.values()[value];
|
||||||
|
|
||||||
|
if ( idx == 4 )
|
||||||
|
this.fzMode = FuzzyMode.values()[value];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,7 +17,9 @@ public enum GuiText
|
||||||
|
|
||||||
IOPort, BytesUsed, Types, QuantumLinkChamber, PortableCell,
|
IOPort, BytesUsed, Types, QuantumLinkChamber, PortableCell,
|
||||||
|
|
||||||
NetworkTool, PowerUsageRate, PowerInputRate, Installed, EnergyDrain;
|
NetworkTool, PowerUsageRate, PowerInputRate, Installed, EnergyDrain,
|
||||||
|
|
||||||
|
StorageBus;
|
||||||
|
|
||||||
String root;
|
String root;
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import appeng.api.exceptions.AppEngException;
|
import appeng.api.exceptions.AppEngException;
|
||||||
import appeng.api.implementations.IUpgradeableHost;
|
import appeng.api.implementations.IUpgradeableHost;
|
||||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
|
||||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||||
|
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||||
import appeng.api.parts.IPart;
|
import appeng.api.parts.IPart;
|
||||||
import appeng.api.parts.IPartHost;
|
import appeng.api.parts.IPartHost;
|
||||||
import appeng.api.storage.IStorageMonitorable;
|
import appeng.api.storage.IStorageMonitorable;
|
||||||
|
@ -31,10 +31,12 @@ import appeng.container.implementations.ContainerMEPortableCell;
|
||||||
import appeng.container.implementations.ContainerNetworkStatus;
|
import appeng.container.implementations.ContainerNetworkStatus;
|
||||||
import appeng.container.implementations.ContainerNetworkTool;
|
import appeng.container.implementations.ContainerNetworkTool;
|
||||||
import appeng.container.implementations.ContainerQNB;
|
import appeng.container.implementations.ContainerQNB;
|
||||||
|
import appeng.container.implementations.ContainerStorageBus;
|
||||||
import appeng.container.implementations.ContainerUpgradeable;
|
import appeng.container.implementations.ContainerUpgradeable;
|
||||||
import appeng.container.implementations.ContainerVibrationChamber;
|
import appeng.container.implementations.ContainerVibrationChamber;
|
||||||
import appeng.helpers.IInterfaceHost;
|
import appeng.helpers.IInterfaceHost;
|
||||||
import appeng.parts.automation.PartLevelEmitter;
|
import appeng.parts.automation.PartLevelEmitter;
|
||||||
|
import appeng.parts.misc.PartStorageBus;
|
||||||
import appeng.tile.grindstone.TileGrinder;
|
import appeng.tile.grindstone.TileGrinder;
|
||||||
import appeng.tile.misc.TileCellWorkbench;
|
import appeng.tile.misc.TileCellWorkbench;
|
||||||
import appeng.tile.misc.TileCondenser;
|
import appeng.tile.misc.TileCondenser;
|
||||||
|
@ -77,6 +79,8 @@ public enum GuiBridge implements IGuiHandler
|
||||||
|
|
||||||
GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, false),
|
GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, false),
|
||||||
|
|
||||||
|
GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, false),
|
||||||
|
|
||||||
// extends (Container/Gui) + Bus
|
// extends (Container/Gui) + Bus
|
||||||
GUI_LEVELEMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, false),
|
GUI_LEVELEMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, false),
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,16 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
|
import appeng.api.config.AccessRestriction;
|
||||||
|
import appeng.api.config.FuzzyMode;
|
||||||
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
|
@ -28,10 +33,11 @@ import appeng.api.storage.IMEMonitorHandlerReciever;
|
||||||
import appeng.api.storage.StorageChannel;
|
import appeng.api.storage.StorageChannel;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.client.texture.CableBusTextures;
|
import appeng.client.texture.CableBusTextures;
|
||||||
|
import appeng.core.sync.GuiBridge;
|
||||||
import appeng.me.GridAccessException;
|
import appeng.me.GridAccessException;
|
||||||
import appeng.me.storage.MEInventoryHandler;
|
import appeng.me.storage.MEInventoryHandler;
|
||||||
import appeng.me.storage.MEMonitorIInventory;
|
import appeng.me.storage.MEMonitorIInventory;
|
||||||
import appeng.parts.PartBasicState;
|
import appeng.parts.automation.PartUpgradeable;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import buildcraft.api.transport.IPipeConnection;
|
import buildcraft.api.transport.IPipeConnection;
|
||||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||||
|
@ -39,7 +45,7 @@ import cpw.mods.fml.common.Optional.Interface;
|
||||||
import cpw.mods.fml.common.Optional.Method;
|
import cpw.mods.fml.common.Optional.Method;
|
||||||
|
|
||||||
@Interface(modid = "BuildCraft|Transport", iface = "buildcraft.api.transport.IPipeConnection")
|
@Interface(modid = "BuildCraft|Transport", iface = "buildcraft.api.transport.IPipeConnection")
|
||||||
public class PartStorageBus extends PartBasicState implements IGridTickable, ICellContainer, IMEMonitorHandlerReciever<IAEItemStack>, IPipeConnection
|
public class PartStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IMEMonitorHandlerReciever<IAEItemStack>, IPipeConnection
|
||||||
{
|
{
|
||||||
|
|
||||||
int priority = 0;
|
int priority = 0;
|
||||||
|
@ -47,6 +53,8 @@ public class PartStorageBus extends PartBasicState implements IGridTickable, ICe
|
||||||
|
|
||||||
public PartStorageBus(ItemStack is) {
|
public PartStorageBus(ItemStack is) {
|
||||||
super( PartStorageBus.class, is );
|
super( PartStorageBus.class, is );
|
||||||
|
getConfigManager().registerSetting( Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||||
|
getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||||
mySrc = new MachineSource( this );
|
mySrc = new MachineSource( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +64,26 @@ public class PartStorageBus extends PartBasicState implements IGridTickable, ICe
|
||||||
|
|
||||||
int handlerHash = 0;
|
int handlerHash = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onActivate(EntityPlayer player, Vec3 pos)
|
||||||
|
{
|
||||||
|
if ( !player.isSneaking() )
|
||||||
|
{
|
||||||
|
if ( Platform.isClient() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Platform.openGUI( player, getHost().getTile(), side, GuiBridge.GUI_STORAGEBUS );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getUpgradeSlots()
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Object verificationToken)
|
public boolean isValid(Object verificationToken)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue