11package com .cellterminal .container ;
22
3- import appeng .api .config .Actionable ;
4- import appeng .api .config .PowerMultiplier ;
5- import com .cellterminal .integration .AE2WUTIntegration ;
6- import com .cellterminal .items .ItemWirelessCellTerminal ;
7- import com .cellterminal .util .AE2OldVersionSupport ;
83import net .minecraft .entity .player .EntityPlayer ;
94import net .minecraft .entity .player .InventoryPlayer ;
105import net .minecraft .item .ItemStack ;
116import net .minecraftforge .fml .common .Optional ;
127
138import appeng .api .AEApi ;
9+ import appeng .api .config .Actionable ;
10+ import appeng .api .config .PowerMultiplier ;
1411import appeng .api .features .IWirelessTermHandler ;
1512import appeng .core .AEConfig ;
1613import appeng .core .localization .PlayerMessages ;
1714import appeng .helpers .WirelessTerminalGuiObject ;
1815
1916import baubles .api .BaublesApi ;
2017
18+ import com .cellterminal .integration .AE2WUTIntegration ;
19+ import com .cellterminal .items .ItemWirelessCellTerminal ;
20+ import com .cellterminal .util .AE2OldVersionSupport ;
21+
2122
2223/**
2324 * Container for the Wireless Cell Terminal GUI.
@@ -29,7 +30,7 @@ public class ContainerWirelessCellTerminal extends ContainerCellTerminalBase {
2930 private final WirelessTerminalGuiObject wirelessTerminalGuiObject ;
3031 private final int slot ;
3132 private final boolean isBauble ;
32-
33+ private double powerMultiplier = 0.5 ;
3334 private int ticks = 0 ;
3435
3536 public ContainerWirelessCellTerminal (InventoryPlayer ip , WirelessTerminalGuiObject wth ) {
@@ -78,11 +79,10 @@ protected boolean canSendUpdates() {
7879 // Drain power periodically (every 20 ticks = 1 second)
7980 this .ticks ++;
8081 if (this .ticks >= 20 ) {
81- ItemWirelessCellTerminal terminal = (ItemWirelessCellTerminal ) currentStack .getItem ();
82- double powerDrain = AEConfig .instance ().wireless_getDrainRate (0 );
83- double extracted = terminal .extractAEPower (currentStack , powerDrain , Actionable .MODULATE );
82+ double powerDrain = this .getPowerMultiplier () * this .ticks ;
83+ double powerUsed = this .wirelessTerminalGuiObject .extractAEPower (powerDrain , Actionable .MODULATE , PowerMultiplier .CONFIG );
8484
85- if (extracted < powerDrain * 0.9 ) {
85+ if (powerDrain != powerUsed ) {
8686 if (this .isValidContainer ()) {
8787 getPlayerInv ().player .sendMessage (PlayerMessages .DeviceNotPowered .get ());
8888 }
@@ -93,6 +93,16 @@ protected boolean canSendUpdates() {
9393 this .ticks = 0 ;
9494 }
9595
96+ if (!this .wirelessTerminalGuiObject .rangeCheck ()) {
97+ if (this .isValidContainer ()) {
98+ this .getPlayerInv ().player .sendMessage (PlayerMessages .OutOfRange .get ());
99+ }
100+
101+ this .setValidContainer (false );
102+ } else {
103+ this .setPowerMultiplier (AEConfig .instance ().wireless_getDrainRate (this .wirelessTerminalGuiObject .getRange ()));
104+ }
105+
96106 // Check range (simplified - just check grid is still valid)
97107 if (this .grid == null ) {
98108 if (this .isValidContainer ()) {
@@ -105,4 +115,13 @@ protected boolean canSendUpdates() {
105115
106116 return true ;
107117 }
118+
119+
120+ public double getPowerMultiplier () {
121+ return powerMultiplier ;
122+ }
123+
124+ public void setPowerMultiplier (double powerMultiplier ) {
125+ this .powerMultiplier = powerMultiplier ;
126+ }
108127}
0 commit comments