Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ protected void addTerminalPosition(NBTTagCompound data) {

@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
return this.isValidContainer();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package com.cellterminal.container;

import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import com.cellterminal.integration.AE2WUTIntegration;
import com.cellterminal.items.ItemWirelessCellTerminal;
import com.cellterminal.util.AE2OldVersionSupport;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Optional;

import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.features.IWirelessTermHandler;
import appeng.core.AEConfig;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject;

import baubles.api.BaublesApi;

import com.cellterminal.integration.AE2WUTIntegration;
import com.cellterminal.items.ItemWirelessCellTerminal;
import com.cellterminal.util.AE2OldVersionSupport;


/**
* Container for the Wireless Cell Terminal GUI.
Expand All @@ -29,7 +30,7 @@ public class ContainerWirelessCellTerminal extends ContainerCellTerminalBase {
private final WirelessTerminalGuiObject wirelessTerminalGuiObject;
private final int slot;
private final boolean isBauble;

private double powerMultiplier = 0.5;
private int ticks = 0;

public ContainerWirelessCellTerminal(InventoryPlayer ip, WirelessTerminalGuiObject wth) {
Expand Down Expand Up @@ -78,11 +79,10 @@ protected boolean canSendUpdates() {
// Drain power periodically (every 20 ticks = 1 second)
this.ticks++;
if (this.ticks >= 20) {
ItemWirelessCellTerminal terminal = (ItemWirelessCellTerminal) currentStack.getItem();
double powerDrain = AEConfig.instance().wireless_getDrainRate(0);
double extracted = terminal.extractAEPower(currentStack, powerDrain, Actionable.MODULATE);
double powerDrain = this.getPowerMultiplier() * this.ticks;
double powerUsed = this.wirelessTerminalGuiObject.extractAEPower(powerDrain, Actionable.MODULATE, PowerMultiplier.CONFIG);

if (extracted < powerDrain * 0.9) {
if (powerDrain != powerUsed) {
if (this.isValidContainer()) {
getPlayerInv().player.sendMessage(PlayerMessages.DeviceNotPowered.get());
}
Expand All @@ -93,6 +93,16 @@ protected boolean canSendUpdates() {
this.ticks = 0;
}

if (!this.wirelessTerminalGuiObject.rangeCheck()) {
if (this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}

this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGuiObject.getRange()));
}

// Check range (simplified - just check grid is still valid)
if (this.grid == null) {
if (this.isValidContainer()) {
Expand All @@ -105,4 +115,13 @@ protected boolean canSendUpdates() {

return true;
}


public double getPowerMultiplier() {
return powerMultiplier;
}

public void setPowerMultiplier(double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
}