Search in sources :

Example 31 with CoverBehavior

use of gregtech.api.cover.CoverBehavior 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)

Example 32 with CoverBehavior

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

the class PipeCoverableImplementation method transferDataTo.

public void transferDataTo(PipeCoverableImplementation destImpl) {
    for (EnumFacing coverSide : EnumFacing.VALUES) {
        CoverBehavior behavior = coverBehaviors[coverSide.getIndex()];
        if (behavior == null)
            continue;
        NBTTagCompound tagCompound = new NBTTagCompound();
        behavior.writeToNBT(tagCompound);
        CoverBehavior newBehavior = behavior.getCoverDefinition().createCoverBehavior(destImpl, coverSide);
        newBehavior.readFromNBT(tagCompound);
        destImpl.coverBehaviors[coverSide.getIndex()] = newBehavior;
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CoverBehavior(gregtech.api.cover.CoverBehavior)

Aggregations

CoverBehavior (gregtech.api.cover.CoverBehavior)32 EnumFacing (net.minecraft.util.EnumFacing)10 ItemStack (net.minecraft.item.ItemStack)6 CoverDefinition (gregtech.api.cover.CoverDefinition)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 NBTTagList (net.minecraft.nbt.NBTTagList)4 CuboidRayTraceResult (codechicken.lib.raytracer.CuboidRayTraceResult)2 CoverSideData (gregtech.api.cover.ICoverable.CoverSideData)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 NBT (net.minecraftforge.common.util.Constants.NBT)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)1 IScrewdriverItem (gregtech.api.capability.tool.IScrewdriverItem)1 IWrenchItem (gregtech.api.capability.tool.IWrenchItem)1 Nullable (javax.annotation.Nullable)1 ITickable (net.minecraft.util.ITickable)1