Skip to content

Commit 786cfa7

Browse files
authored
Consume same power and follow same range limits as the Wireless Interface Terminal (#17)
1 parent 2bbedbe commit 786cfa7

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

src/main/java/com/cellterminal/container/ContainerCellTerminalBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ protected void addTerminalPosition(NBTTagCompound data) {
391391

392392
@Override
393393
public boolean canInteractWith(EntityPlayer player) {
394-
return true;
394+
return this.isValidContainer();
395395
}
396396

397397
/**

src/main/java/com/cellterminal/container/ContainerWirelessCellTerminal.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
package 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;
83
import net.minecraft.entity.player.EntityPlayer;
94
import net.minecraft.entity.player.InventoryPlayer;
105
import net.minecraft.item.ItemStack;
116
import net.minecraftforge.fml.common.Optional;
127

138
import appeng.api.AEApi;
9+
import appeng.api.config.Actionable;
10+
import appeng.api.config.PowerMultiplier;
1411
import appeng.api.features.IWirelessTermHandler;
1512
import appeng.core.AEConfig;
1613
import appeng.core.localization.PlayerMessages;
1714
import appeng.helpers.WirelessTerminalGuiObject;
1815

1916
import 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

Comments
 (0)