close wireless terminals if they run out of power instead of not working
This commit is contained in:
@@ -95,7 +95,14 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable implements I
|
|||||||
// drain 1 ae t
|
// drain 1 ae t
|
||||||
this.ticks++;
|
this.ticks++;
|
||||||
if (this.ticks > 10) {
|
if (this.ticks > 10) {
|
||||||
this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
double ext = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||||
|
if (ext < this.getPowerMultiplier() * this.ticks) {
|
||||||
|
if (Platform.isServer() && this.isValidContainer()) {
|
||||||
|
this.getPlayerInv().player.sendMessage(PlayerMessages.DeviceNotPowered.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setValidContainer(false);
|
||||||
|
}
|
||||||
this.ticks = 0;
|
this.ticks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-1
@@ -144,7 +144,14 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
|
|||||||
// drain 1 ae t
|
// drain 1 ae t
|
||||||
this.ticks++;
|
this.ticks++;
|
||||||
if (this.ticks > 10) {
|
if (this.ticks > 10) {
|
||||||
this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
double ext = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||||
|
if (ext < this.getPowerMultiplier() * this.ticks) {
|
||||||
|
if (Platform.isServer() && this.isValidContainer()) {
|
||||||
|
this.getPlayerInv().player.sendMessage(PlayerMessages.DeviceNotPowered.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setValidContainer(false);
|
||||||
|
}
|
||||||
this.ticks = 0;
|
this.ticks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package appeng.core.sync.packets;
|
package appeng.core.sync.packets;
|
||||||
|
|
||||||
import appeng.api.util.AEPartLocation;
|
import appeng.api.AEApi;
|
||||||
|
import appeng.api.features.ILocatable;
|
||||||
|
import appeng.api.features.IWirelessTermHandler;
|
||||||
|
import appeng.core.localization.PlayerMessages;
|
||||||
import appeng.core.sync.AppEngPacket;
|
import appeng.core.sync.AppEngPacket;
|
||||||
import appeng.core.sync.network.INetworkInfo;
|
import appeng.core.sync.network.INetworkInfo;
|
||||||
import appeng.items.tools.powered.Terminal;
|
import appeng.items.tools.powered.Terminal;
|
||||||
@@ -35,16 +38,43 @@ public class PacketTerminalUse extends AppEngPacket {
|
|||||||
for (int i = 0; i < mainInventory.size(); i++) {
|
for (int i = 0; i < mainInventory.size(); i++) {
|
||||||
ItemStack is = mainInventory.get(i);
|
ItemStack is = mainInventory.get(i);
|
||||||
if (terminal.getItemDefinition().isSameAs(is)) {
|
if (terminal.getItemDefinition().isSameAs(is)) {
|
||||||
Platform.openGUI(player, i, terminal.getBridge(), false);
|
openGui(is, i, player, false);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < BaublesApi.getBaublesHandler(player).getSlots(); i++) {
|
for (int i = 0; i < BaublesApi.getBaublesHandler(player).getSlots(); i++) {
|
||||||
ItemStack is = BaublesApi.getBaublesHandler(player).getStackInSlot(i);
|
ItemStack is = BaublesApi.getBaublesHandler(player).getStackInSlot(i);
|
||||||
if (terminal.getItemDefinition().isSameAs(is)) {
|
if (terminal.getItemDefinition().isSameAs(is)) {
|
||||||
Platform.openGUI(player, i, terminal.getBridge(), true);
|
openGui(is, i, player, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void openGui(ItemStack itemStack, int slotIdx, EntityPlayer player, boolean isBauble) {
|
||||||
|
final IWirelessTermHandler handler = AEApi.instance().registries().wireless().getWirelessTerminalHandler(itemStack);
|
||||||
|
if (handler == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String unparsedKey = handler.getEncryptionKey(itemStack);
|
||||||
|
if (unparsedKey.isEmpty()) {
|
||||||
|
player.sendMessage(PlayerMessages.DeviceNotLinked.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final long parsedKey = Long.parseLong(unparsedKey);
|
||||||
|
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
|
||||||
|
if (securityStation == null) {
|
||||||
|
player.sendMessage(PlayerMessages.StationCanNotBeLocated.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handler.hasPower(player, 0.5, itemStack)) {
|
||||||
|
Platform.openGUI(player, slotIdx, terminal.getBridge(), isBauble);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(PlayerMessages.DeviceNotPowered.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,9 +171,16 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAE
|
|||||||
// drain 1 ae t
|
// drain 1 ae t
|
||||||
this.ticks++;
|
this.ticks++;
|
||||||
if (this.ticks > 10) {
|
if (this.ticks > 10) {
|
||||||
double power = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
double ext = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||||
|
if (ext < this.getPowerMultiplier() * this.ticks) {
|
||||||
|
if (Platform.isServer() && this.isValidContainer()) {
|
||||||
|
this.getPlayerInv().player.sendMessage(PlayerMessages.DeviceNotPowered.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setValidContainer(false);
|
||||||
|
}
|
||||||
this.ticks = 0;
|
this.ticks = 0;
|
||||||
this.hasPower = power > 0.001;
|
this.hasPower = ext > 0.001;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
|
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user