forked from RedServer/Hwyla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHUDHandlerTEGenerator.java
More file actions
78 lines (64 loc) · 2.73 KB
/
HUDHandlerTEGenerator.java
File metadata and controls
78 lines (64 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package mcp.mobius.waila.addons.ic2;
import mcp.mobius.waila.api.ITaggedList;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.cbcore.LangUtil;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.List;
public class HUDHandlerTEGenerator implements IWailaDataProvider {
static final IWailaDataProvider INSTANCE = new HUDHandlerTEGenerator();
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
double storage = accessor.getNBTData().getDouble("storage");
int production = accessor.getNBTData().getInteger("production");
long maxStorage = accessor.getNBTData().getLong("maxStorage");
String storedStr = LangUtil.translateG("hud.ic2.msg.stored");
String outputStr = LangUtil.translateG("hud.ic2.msg.output");
if (accessor.getTileEntity() == null) {
return currenttip;
}
/* EU Storage */
if (config.getConfig("ic2.storage"))
if (maxStorage > 0) {
((ITaggedList<String, String>) currenttip)
.add(String.format(
"%s §f%d§r / §f%d§r EU",
storedStr,
Math.round(Math.min(storage, maxStorage)),
maxStorage
), "IEnergyStorage");
}
if (config.getConfig("ic2.outputeu")) {
currenttip.add(String.format("%s §f%d §r EU/t", outputStr, production));
}
return currenttip;
}
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
double storage = -1;
int production = -1;
long maxStorage = -1;
try {
if (IC2Module.generator.isInstance(te)) {
storage = IC2Module.generatorStorage.getDouble(te);
production = IC2Module.generatorProduction.getInt(te);
maxStorage = IC2Module.generatorMaxStorage.getLong(te);
}
} catch (java.lang.Exception e) {
throw new RuntimeException(e);
}
tag.setDouble("storage", storage);
tag.setInteger("production", production);
tag.setLong("maxStorage", maxStorage);
return tag;
}
}