save upgrades

This commit is contained in:
PrototypeTrousers
2023-01-30 20:40:16 -03:00
parent 9dee7f6c0e
commit d7e1554e41
6 changed files with 179 additions and 102 deletions
@@ -27,19 +27,26 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.localization.PlayerMessages; import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject; import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.automation.StackUpgradeInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
public class ContainerMEPortableCell extends ContainerMEMonitorable implements IUpgradeableCellContainer { public class ContainerMEPortableCell extends ContainerMEMonitorable implements IUpgradeableCellContainer, IAEAppEngInventory {
protected final WirelessTerminalGuiObject wirelessTerminalGUIObject; protected final WirelessTerminalGuiObject wirelessTerminalGUIObject;
private final int slot; private final int slot;
private double powerMultiplier = 0.5; private double powerMultiplier = 0.5;
private int ticks = 0; private int ticks = 0;
protected AppEngInternalInventory upgrades;
public ContainerMEPortableCell(InventoryPlayer ip, WirelessTerminalGuiObject monitorable, boolean bindInventory) { public ContainerMEPortableCell(InventoryPlayer ip, WirelessTerminalGuiObject monitorable, boolean bindInventory) {
super(ip, monitorable, bindInventory); super(ip, monitorable, bindInventory);
@@ -52,44 +59,51 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable implements I
this.lockPlayerInventorySlot(ip.currentItem); this.lockPlayerInventorySlot(ip.currentItem);
} }
this.wirelessTerminalGUIObject = monitorable; this.wirelessTerminalGUIObject = monitorable;
this.upgrades = new StackUpgradeInventory(wirelessTerminalGUIObject.getItemStack(), this, 2);
this.loadFromNBT();
if (bindInventory) { if (bindInventory) {
this.bindPlayerInventory(ip, 0, 0); this.bindPlayerInventory(ip, 0, 0);
} }
this.setupUpgrades(); this.setupUpgrades();
} }
@Override @Override
public void detectAndSendChanges() { public void detectAndSendChanges() {
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot); if (Platform.isServer()) {
if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) { final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
this.setValidContainer(false);
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) { if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
} else {
this.setValidContainer(false); this.setValidContainer(false);
} } else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
} if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
// drain 1 ae t } else {
this.ticks++; this.setValidContainer(false);
if (this.ticks > 10) { }
this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.ticks = 0;
}
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
} }
this.setValidContainer(false); // drain 1 ae t
} else { this.ticks++;
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange())); if (this.ticks > 10) {
} this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.ticks = 0;
}
super.detectAndSendChanges(); if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
}
super.detectAndSendChanges();
}
} }
private double getPowerMultiplier() { private double getPowerMultiplier() {
@@ -107,7 +121,6 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable implements I
@Override @Override
public void setupUpgrades() { public void setupUpgrades() {
if (wirelessTerminalGUIObject != null) { if (wirelessTerminalGUIObject != null) {
final IItemHandler upgrades = wirelessTerminalGUIObject.getInventoryByName("upgrades");
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) { for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.addSlotToContainer( this.addSlotToContainer(
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 187, upgradeSlot * 18, this.getInventoryPlayer())) (new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 187, upgradeSlot * 18, this.getInventoryPlayer()))
@@ -116,4 +129,30 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable implements I
} }
} }
@Override
public void onSlotChange(Slot s) {
super.detectAndSendChanges();
}
@Override
public void saveChanges() {
if (Platform.isServer()) {
NBTTagCompound tag = new NBTTagCompound();
this.upgrades.writeToNBT(tag, "upgrades");
this.wirelessTerminalGUIObject.saveChanges(tag);
}
}
private void loadFromNBT() {
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
if (data != null) {
upgrades.readFromNBT(wirelessTerminalGUIObject.getItemStack().getTagCompound().getCompoundTag("upgrades"));
}
}
@Override
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
}
} }
@@ -22,8 +22,6 @@ package appeng.container.implementations;
import appeng.container.ContainerNull; import appeng.container.ContainerNull;
import appeng.container.slot.SlotCraftingMatrix; import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotCraftingTerm; import appeng.container.slot.SlotCraftingTerm;
import appeng.core.AEConfig;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.IContainerCraftingPacket; import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.WirelessTerminalGuiObject; import appeng.helpers.WirelessTerminalGuiObject;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
@@ -58,6 +56,8 @@ public class ContainerWirelessCraftingTerminal extends ContainerMEPortableCell i
super(ip, gui, false); super(ip, gui, false);
this.wirelessTerminalGUIObject = gui; this.wirelessTerminalGUIObject = gui;
this.loadFromNBT();
final IItemHandler crafting = this.craftingGrid; final IItemHandler crafting = this.craftingGrid;
for (int y = 0; y < 3; y++) { for (int y = 0; y < 3; y++) {
@@ -70,7 +70,6 @@ public class ContainerWirelessCraftingTerminal extends ContainerMEPortableCell i
.getPowerSource(), this.wirelessTerminalGUIObject, crafting, crafting, this.output, 131, -72 + 18, this)); .getPowerSource(), this.wirelessTerminalGUIObject, crafting, crafting, this.output, 131, -72 + 18, this));
this.bindPlayerInventory(ip, 0, 0); this.bindPlayerInventory(ip, 0, 0);
this.loadFromNBT();
this.onCraftMatrixChanged(new WrapperInvItemHandler(crafting)); this.onCraftMatrixChanged(new WrapperInvItemHandler(crafting));
} }
@@ -102,14 +101,17 @@ public class ContainerWirelessCraftingTerminal extends ContainerMEPortableCell i
if (Platform.isServer()) { if (Platform.isServer()) {
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
this.craftingGrid.writeToNBT(tag, "craftingGrid"); this.craftingGrid.writeToNBT(tag, "craftingGrid");
this.upgrades.writeToNBT(tag, "upgrades");
this.wirelessTerminalGUIObject.saveChanges(tag); this.wirelessTerminalGUIObject.saveChanges(tag);
} }
} }
private void loadFromNBT() { protected void loadFromNBT() {
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound(); NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
if (data != null) { if (data != null) {
this.craftingGrid.readFromNBT(data, "craftingGrid"); this.craftingGrid.readFromNBT(data, "craftingGrid");
upgrades.readFromNBT(wirelessTerminalGUIObject.getItemStack().getTagCompound().getCompoundTag("upgrades"));
} }
} }
@@ -33,6 +33,7 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.localization.PlayerMessages; import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject; import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.automation.StackUpgradeInventory;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
@@ -51,6 +52,8 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
private final int slot; private final int slot;
protected AppEngInternalInventory output; protected AppEngInternalInventory output;
protected AppEngInternalInventory pattern; protected AppEngInternalInventory pattern;
protected AppEngInternalInventory upgrades;
private double powerMultiplier = 0.5; private double powerMultiplier = 0.5;
private int ticks = 0; private int ticks = 0;
@@ -73,6 +76,7 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
this.lockPlayerInventorySlot(ip.currentItem); this.lockPlayerInventorySlot(ip.currentItem);
} }
this.wirelessTerminalGUIObject = gui; this.wirelessTerminalGUIObject = gui;
upgrades = new StackUpgradeInventory(wirelessTerminalGUIObject.getItemStack(), this, 2);
this.loadFromNBT(); this.loadFromNBT();
@@ -110,36 +114,39 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
@Override @Override
public void detectAndSendChanges() { public void detectAndSendChanges() {
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot); if (Platform.isServer()) {
if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) { final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
this.setValidContainer(false);
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) { if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
} else {
this.setValidContainer(false); this.setValidContainer(false);
} } else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
} if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
// drain 1 ae t } else {
this.ticks++; this.setValidContainer(false);
if (this.ticks > 10) { }
this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.ticks = 0;
}
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
} }
this.setValidContainer(false); // drain 1 ae t
} else { this.ticks++;
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange())); if (this.ticks > 10) {
} this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.ticks = 0;
}
super.detectAndSendChanges(); if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
}
super.detectAndSendChanges();
}
} }
private double getPowerMultiplier() { private double getPowerMultiplier() {
@@ -178,6 +185,8 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
this.output.writeToNBT(tag, "output"); this.output.writeToNBT(tag, "output");
this.pattern.writeToNBT(tag, "patterns"); this.pattern.writeToNBT(tag, "patterns");
this.upgrades.writeToNBT(tag, "upgrades");
this.wirelessTerminalGUIObject.saveChanges(tag); this.wirelessTerminalGUIObject.saveChanges(tag);
} }
} }
@@ -188,6 +197,7 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
((AppEngInternalInventory) crafting).readFromNBT(data, "craftingGrid"); ((AppEngInternalInventory) crafting).readFromNBT(data, "craftingGrid");
this.output.readFromNBT(data, "output"); this.output.readFromNBT(data, "output");
this.pattern.readFromNBT(data, "patterns"); this.pattern.readFromNBT(data, "patterns");
upgrades.readFromNBT(wirelessTerminalGUIObject.getItemStack().getTagCompound().getCompoundTag("upgrades"));
} }
} }
@@ -238,7 +248,6 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
@Override @Override
public void setupUpgrades() { public void setupUpgrades() {
if (wirelessTerminalGUIObject != null) { if (wirelessTerminalGUIObject != null) {
final IItemHandler upgrades = wirelessTerminalGUIObject.getInventoryByName("upgrades");
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) { for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.addSlotToContainer( this.addSlotToContainer(
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 187, upgradeSlot * 18 - 2, this.getInventoryPlayer())) (new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 187, upgradeSlot * 18 - 2, this.getInventoryPlayer()))
@@ -1,7 +1,12 @@
package appeng.fluids.container; package appeng.fluids.container;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.*; import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.implementations.IUpgradeableCellContainer; import appeng.api.implementations.IUpgradeableCellContainer;
import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
@@ -36,6 +41,8 @@ import appeng.core.sync.packets.PacketValueConfig;
import appeng.fluids.util.AEFluidStack; import appeng.fluids.util.AEFluidStack;
import appeng.helpers.InventoryAction; import appeng.helpers.InventoryAction;
import appeng.helpers.WirelessTerminalGuiObject; import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.automation.StackUpgradeInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.ConfigManager; import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
import appeng.util.Platform; import appeng.util.Platform;
@@ -45,7 +52,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandlerItem; import net.minecraftforge.fluids.capability.IFluidHandlerItem;
@@ -74,6 +83,8 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAE
private int ticks = 0; private int ticks = 0;
private final int slot; private final int slot;
protected AppEngInternalInventory upgrades;
public ContainerMEPortableFluidCell(final InventoryPlayer ip, final IPortableCell monitorable) { public ContainerMEPortableFluidCell(final InventoryPlayer ip, final IPortableCell monitorable) {
this(ip, monitorable, null, true); this(ip, monitorable, null, true);
} }
@@ -129,43 +140,45 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAE
this.bindPlayerInventory(ip, 0, 140); this.bindPlayerInventory(ip, 0, 140);
} }
hasPower = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier(), Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.001; hasPower = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier(), Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.001;
upgrades = new StackUpgradeInventory(wirelessTerminalGUIObject.getItemStack(), this, 2);
this.loadFromNBT();
this.setupUpgrades(); this.setupUpgrades();
} }
@Override @Override
public void detectAndSendChanges() { public void detectAndSendChanges() {
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) {
this.setValidContainer(false);
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
} else {
this.setValidContainer(false);
}
}
// drain 1 ae t
this.ticks++;
if (this.ticks > 10) {
double power = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.ticks = 0;
this.hasPower = power > 0.001;
}
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
}
if (Platform.isServer()) { if (Platform.isServer()) {
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) {
this.setValidContainer(false);
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
} else {
this.setValidContainer(false);
}
}
// drain 1 ae t
this.ticks++;
if (this.ticks > 10) {
double power = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.ticks = 0;
this.hasPower = power > 0.001;
}
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
}
if (this.monitor != this.terminal.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class))) { if (this.monitor != this.terminal.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class))) {
this.setValidContainer(false); this.setValidContainer(false);
} }
@@ -218,9 +231,7 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAE
} }
} }
//this.updatePowerStatus(); //this.updatePowerStatus();
} }
super.detectAndSendChanges();
} }
@Override @Override
@@ -453,6 +464,11 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAE
} }
} }
@Override
public void onSlotChange(Slot s) {
detectAndSendChanges();
}
private void queueInventory(final IContainerListener c) { private void queueInventory(final IContainerListener c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) { if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
try { try {
@@ -527,7 +543,6 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAE
@Override @Override
public void setupUpgrades() { public void setupUpgrades() {
if (wirelessTerminalGUIObject != null) { if (wirelessTerminalGUIObject != null) {
final IItemHandler upgrades = wirelessTerminalGUIObject.getInventoryByName("upgrades");
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) { for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.addSlotToContainer( this.addSlotToContainer(
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 187, 139 + upgradeSlot * 18, this.getInventoryPlayer())) (new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 187, 139 + upgradeSlot * 18, this.getInventoryPlayer()))
@@ -536,14 +551,24 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAE
} }
} }
@Override @Override
public void saveChanges() { public void saveChanges() {
if (Platform.isServer()) {
NBTTagCompound tag = new NBTTagCompound();
this.upgrades.writeToNBT(tag, "upgrades");
this.wirelessTerminalGUIObject.saveChanges(tag);
}
}
private void loadFromNBT() {
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
if (data != null) {
upgrades.readFromNBT(wirelessTerminalGUIObject.getItemStack().getTagCompound().getCompoundTag("upgrades"));
}
} }
@Override @Override
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) { public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
} }
} }
@@ -37,16 +37,18 @@ public class ContainerWirelessFluidTerminal extends ContainerMEPortableFluidCell
@Override @Override
public void detectAndSendChanges() { public void detectAndSendChanges() {
super.detectAndSendChanges(); if (Platform.isServer()) {
super.detectAndSendChanges();
if (!this.wirelessTerminalGUIObject.rangeCheck()) { if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) { if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get()); this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
} }
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
} }
} }
} }
@@ -331,7 +331,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
} }
} }
private void loadFromNBT() { public void loadFromNBT() {
NBTTagCompound data = effectiveItem.getTagCompound(); NBTTagCompound data = effectiveItem.getTagCompound();
if (data != null) { if (data != null) {
viewCell.readFromNBT(data); viewCell.readFromNBT(data);