Search in sources :

Example 1 with LookingAtElement

use of mekanism.common.integration.lookingat.LookingAtElement 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;
    }
}
Also used : FluidElement(mekanism.common.integration.lookingat.FluidElement) ListNBT(net.minecraft.nbt.ListNBT) ChemicalElement(mekanism.common.integration.lookingat.ChemicalElement) EnergyElement(mekanism.common.integration.lookingat.EnergyElement) CompoundNBT(net.minecraft.nbt.CompoundNBT) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) LookingAtElement(mekanism.common.integration.lookingat.LookingAtElement) ITextComponent(net.minecraft.util.text.ITextComponent) ChemicalStack(mekanism.api.chemical.ChemicalStack)

Aggregations

MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 ChemicalStack (mekanism.api.chemical.ChemicalStack)1 ChemicalElement (mekanism.common.integration.lookingat.ChemicalElement)1 EnergyElement (mekanism.common.integration.lookingat.EnergyElement)1 FluidElement (mekanism.common.integration.lookingat.FluidElement)1 LookingAtElement (mekanism.common.integration.lookingat.LookingAtElement)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 ListNBT (net.minecraft.nbt.ListNBT)1 ITextComponent (net.minecraft.util.text.ITextComponent)1