Start implementing wireless terminals.
This commit is contained in:
@@ -26,6 +26,7 @@ import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.implementations.tiles.IWirelessAccessPoint;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -43,13 +44,18 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware {
|
||||
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware, IViewCellStorage, IAEAppEngInventory {
|
||||
|
||||
private final ItemStack effectiveItem;
|
||||
private final IWirelessTermHandler wth;
|
||||
@@ -63,6 +69,8 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
private double myRange = Double.MAX_VALUE;
|
||||
private final int inventorySlot;
|
||||
|
||||
private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5);
|
||||
|
||||
public WirelessTerminalGuiObject(final IWirelessTermHandler wh, final ItemStack is, final EntityPlayer ep, final World w, final int x, final int y, final int z) {
|
||||
this.encryptionKey = wh.getEncryptionKey(is);
|
||||
this.effectiveItem = is;
|
||||
@@ -91,6 +99,8 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.loadFromNBT();
|
||||
}
|
||||
|
||||
public double getRange() {
|
||||
@@ -286,4 +296,42 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getViewCellStorage() {
|
||||
NBTTagCompound data = effectiveItem.getTagCompound();
|
||||
if (data != null) {
|
||||
viewCell.readFromNBT(data, "viewCell");
|
||||
}
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
NBTTagCompound data = effectiveItem.getTagCompound();
|
||||
if (data == null) {
|
||||
data = new NBTTagCompound();
|
||||
}
|
||||
viewCell.writeToNBT(data, "viewCell");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges(NBTTagCompound data) {
|
||||
if (effectiveItem.getTagCompound() != null) {
|
||||
effectiveItem.getTagCompound().merge(data);
|
||||
} else {
|
||||
effectiveItem.setTagCompound(data);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFromNBT() {
|
||||
NBTTagCompound data = effectiveItem.getTagCompound();
|
||||
if (data != null) {
|
||||
viewCell.readFromNBT(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user