Add isActiveClientSide to controller

This commit is contained in:
Raoul Van den Berge
2016-04-01 02:22:24 +02:00
parent 5e5d2c9e35
commit 4d9e6b02b9
4 changed files with 19 additions and 10 deletions

View File

@@ -119,7 +119,10 @@ public class GuiController extends GuiBase {
}
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) {
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_usage", controller.getEnergyUsage()) + "\n" + t("misc.refinedstorage:energy_stored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null)));
String message = t("misc.refinedstorage:energy_usage", controller.isActiveClientSide() ? controller.getEnergyUsage() : 0);
message += "\n" + t("misc.refinedstorage:energy_stored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null));
drawTooltip(mouseX, mouseY, message);
}
}

View File

@@ -74,7 +74,7 @@ public class ItemWirelessGrid extends ItemBase {
if (tile instanceof TileController) {
((TileController) tile).onOpenWirelessGrid(player, hand);
return new ActionResult(EnumActionResult.PASS, stack);
return new ActionResult(EnumActionResult.SUCCESS, stack);
} else {
player.addChatComponentMessage(new TextComponentString(I18n.translateToLocal("misc.refinedstorage:wireless_grid.not_found")));
}
@@ -84,11 +84,9 @@ public class ItemWirelessGrid extends ItemBase {
} else {
player.addChatComponentMessage(new TextComponentString(I18n.translateToLocal("misc.refinedstorage:wireless_grid.not_found")));
}
return new ActionResult(EnumActionResult.FAIL, stack);
} else {
return new ActionResult(EnumActionResult.PASS, stack);
}
return new ActionResult(EnumActionResult.PASS, stack);
}
public static int getX(ItemStack stack) {

View File

@@ -41,6 +41,8 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
private EnergyStorage energy = new EnergyStorage(32000);
private int energyUsage;
private boolean activeClientSide;
private boolean destroyed = false;
@Override
@@ -347,6 +349,10 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
return energy.getEnergyStored() >= getEnergyUsage() && redstoneMode.isEnabled(worldObj, pos);
}
public boolean isActiveClientSide() {
return activeClientSide;
}
@Override
public RedstoneMode getRedstoneMode() {
return redstoneMode;
@@ -371,6 +377,8 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
@Override
public void fromBytes(ByteBuf buf) {
activeClientSide = buf.readBoolean();
int lastEnergy = energy.getEnergyStored();
energy.setEnergyStored(buf.readInt());
@@ -406,8 +414,10 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
@Override
public void toBytes(ByteBuf buf) {
buf.writeBoolean(isActive());
buf.writeInt(energy.getEnergyStored());
buf.writeInt(isActive() ? energyUsage : 0);
buf.writeInt(energyUsage);
buf.writeInt(redstoneMode.id);

View File

@@ -81,9 +81,7 @@ public class WirelessGrid implements IGrid {
@Override
public boolean isConnected() {
// Since getController().isActive() doesn't do anything clientside
// we just check if the energy usage is above 0.
return getController() instanceof TileController && getController().getEnergyUsage() > 0;
return getController() instanceof TileController && getController().isActiveClientSide();
}
@Override