Search in sources :

Example 6 with CoverDefinition

use of gregtech.api.cover.CoverDefinition in project GregTech by GregTechCE.

the class PipeCoverableImplementation method readFromNBT.

public void readFromNBT(NBTTagCompound data) {
    NBTTagList coversList = data.getTagList("Covers", NBT.TAG_COMPOUND);
    for (int index = 0; index < coversList.tagCount(); index++) {
        NBTTagCompound tagCompound = coversList.getCompoundTagAt(index);
        if (tagCompound.hasKey("CoverId", NBT.TAG_STRING)) {
            EnumFacing coverSide = EnumFacing.VALUES[tagCompound.getByte("Side")];
            ResourceLocation coverId = new ResourceLocation(tagCompound.getString("CoverId"));
            CoverDefinition coverDefinition = CoverDefinition.getCoverById(coverId);
            CoverBehavior coverBehavior = coverDefinition.createCoverBehavior(this, coverSide);
            coverBehavior.readFromNBT(tagCompound);
            this.coverBehaviors[coverSide.getIndex()] = coverBehavior;
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) EnumFacing(net.minecraft.util.EnumFacing) ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CoverBehavior(gregtech.api.cover.CoverBehavior) CoverDefinition(gregtech.api.cover.CoverDefinition)

Aggregations

CoverDefinition (gregtech.api.cover.CoverDefinition)6 CoverBehavior (gregtech.api.cover.CoverBehavior)5 EnumFacing (net.minecraft.util.EnumFacing)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 CoverPlaceBehavior (gregtech.common.items.behaviors.CoverPlaceBehavior)1 ResourceLocation (net.minecraft.util.ResourceLocation)1