Add isActiveClientSide to controller
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user