use of mekanism.common.integration.lookingat.EnergyElement in project Mekanism by mekanism.
the class HwylaTooltipRenderer method draw.
@Override
public void draw(CompoundNBT data, ICommonAccessor accessor, int x, int y) {
ListNBT list = data.getList(NBTConstants.MEK_DATA, NBT.TAG_COMPOUND);
MatrixStack matrix = new MatrixStack();
int currentX = x + 1;
int currentY = y + 1;
for (int i = 0; i < list.size(); i++) {
CompoundNBT elementData = list.getCompound(i);
LookingAtElement element;
if (elementData.contains(MekanismHwylaPlugin.TEXT, NBT.TAG_STRING)) {
ITextComponent text = ITextComponent.Serializer.fromJson(elementData.getString(MekanismHwylaPlugin.TEXT));
if (text != null) {
LookingAtElement.renderScaledText(Minecraft.getInstance(), matrix, currentX + 4, currentY + 3, 0xFFFFFF, 92, text);
currentY += 15;
}
continue;
} else if (elementData.contains(NBTConstants.ENERGY_STORED, NBT.TAG_STRING)) {
element = new EnergyElement(FloatingLong.parseFloatingLong(elementData.getString(NBTConstants.ENERGY_STORED), true), FloatingLong.parseFloatingLong(elementData.getString(NBTConstants.MAX), true));
} else if (elementData.contains(NBTConstants.FLUID_STORED, NBT.TAG_COMPOUND)) {
element = new FluidElement(FluidStack.loadFluidStackFromNBT(elementData.getCompound(NBTConstants.FLUID_STORED)), elementData.getInt(NBTConstants.MAX));
} else if (elementData.contains(MekanismHwylaPlugin.CHEMICAL_STACK, NBT.TAG_COMPOUND)) {
ChemicalStack<?> chemicalStack;
CompoundNBT chemicalData = elementData.getCompound(MekanismHwylaPlugin.CHEMICAL_STACK);
if (chemicalData.contains(NBTConstants.GAS_NAME, NBT.TAG_STRING)) {
chemicalStack = GasStack.readFromNBT(chemicalData);
} else if (chemicalData.contains(NBTConstants.INFUSE_TYPE_NAME, NBT.TAG_STRING)) {
chemicalStack = InfusionStack.readFromNBT(chemicalData);
} else if (chemicalData.contains(NBTConstants.PIGMENT_NAME, NBT.TAG_STRING)) {
chemicalStack = PigmentStack.readFromNBT(chemicalData);
} else if (chemicalData.contains(NBTConstants.SLURRY_NAME, NBT.TAG_STRING)) {
chemicalStack = SlurryStack.readFromNBT(chemicalData);
} else {
// Unknown chemical
continue;
}
element = new ChemicalElement(chemicalStack, elementData.getLong(NBTConstants.MAX));
} else {
// Skip
continue;
}
element.render(matrix, currentX, currentY);
currentY += 15;
}
}
Aggregations