|
| 1 | +package com.gregtechceu.gtceu.integration.jade.provider; |
| 2 | + |
| 3 | +import com.gregtechceu.gtceu.GTCEu; |
| 4 | +import com.gregtechceu.gtceu.api.machine.MetaMachine; |
| 5 | +import com.gregtechceu.gtceu.integration.ae2.machine.feature.IGridConnectedMachine; |
| 6 | + |
| 7 | +import net.minecraft.nbt.CompoundTag; |
| 8 | +import net.minecraft.network.chat.Component; |
| 9 | +import net.minecraft.world.entity.player.Player; |
| 10 | +import net.minecraft.world.level.block.entity.BlockEntity; |
| 11 | + |
| 12 | +import snownee.jade.api.BlockAccessor; |
| 13 | +import snownee.jade.api.ITooltip; |
| 14 | +import snownee.jade.api.config.IPluginConfig; |
| 15 | + |
| 16 | +public class MEGridConnectedProvider extends MachineInfoProvider<MetaMachine, CompoundTag> { |
| 17 | + |
| 18 | + public MEGridConnectedProvider() { |
| 19 | + super(GTCEu.id("me_grid_connected"), MetaMachine.class); |
| 20 | + } |
| 21 | + |
| 22 | + @Override |
| 23 | + protected CompoundTag write(MetaMachine machine) { |
| 24 | + var tag = new CompoundTag(); |
| 25 | + if (!(machine instanceof IGridConnectedMachine gridConnectedMachine)) return tag; |
| 26 | + |
| 27 | + tag.putBoolean("online", gridConnectedMachine.isOnline()); |
| 28 | + return tag; |
| 29 | + } |
| 30 | + |
| 31 | + @Override |
| 32 | + protected void addTooltip(CompoundTag data, ITooltip tooltip, Player player, BlockAccessor block, |
| 33 | + BlockEntity blockEntity, IPluginConfig config) { |
| 34 | + if (!data.contains("online")) return; |
| 35 | + |
| 36 | + var online = data.getBoolean("online"); |
| 37 | + var component = online ? Component.translatable("gtceu.gui.me_network.online") : |
| 38 | + Component.translatable("gtceu.gui.me_network.offline"); |
| 39 | + tooltip.add(component); |
| 40 | + } |
| 41 | +} |
0 commit comments