Search in sources :

Example 11 with CoverBehavior

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

the class MetaTileEntity method writeToNBT.

public NBTTagCompound writeToNBT(NBTTagCompound data) {
    data.setInteger("FrontFacing", frontFacing.getIndex());
    data.setInteger(TAG_KEY_PAINTING_COLOR, paintingColor);
    data.setInteger("CachedLightValue", cachedLightValue);
    if (shouldSerializeInventories()) {
        GTUtility.writeItems(importItems, "ImportInventory", data);
        GTUtility.writeItems(exportItems, "ExportInventory", data);
        data.setTag("ImportFluidInventory", importFluids.serializeNBT());
        data.setTag("ExportFluidInventory", exportFluids.serializeNBT());
    }
    for (MTETrait mteTrait : this.mteTraits) {
        data.setTag(mteTrait.getName(), mteTrait.serializeNBT());
    }
    NBTTagList coversList = new NBTTagList();
    for (EnumFacing coverSide : EnumFacing.VALUES) {
        CoverBehavior coverBehavior = coverBehaviors[coverSide.getIndex()];
        if (coverBehavior != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            ResourceLocation coverId = coverBehavior.getCoverDefinition().getCoverId();
            tagCompound.setString("CoverId", coverId.toString());
            tagCompound.setByte("Side", (byte) coverSide.getIndex());
            coverBehavior.writeToNBT(tagCompound);
            coversList.appendTag(tagCompound);
        }
    }
    data.setTag("Covers", coversList);
    data.setBoolean(TAG_KEY_FRAGILE, isFragile);
    return data;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 12 with CoverBehavior

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

the class MetaTileEntity method getOutputRedstoneSignal.

public final int getOutputRedstoneSignal(@Nullable EnumFacing side) {
    if (side == null) {
        return getHighestOutputRedstoneSignal();
    }
    CoverBehavior behavior = getCoverAtSide(side);
    int sidedOutput = sidedRedstoneOutput[side.getIndex()];
    return behavior == null ? sidedOutput : behavior.getRedstoneSignalOutput();
}
Also used : CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 13 with CoverBehavior

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

the class TileEntityPipeBase method getCapability.

@Nullable
@Override
public final <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    boolean isCoverable = capability == GregtechTileCapabilities.CAPABILITY_COVERABLE;
    CoverBehavior coverBehavior = facing == null ? null : coverableImplementation.getCoverAtSide(facing);
    T defaultValue = getCapabilityInternal(capability, facing);
    if (isCoverable) {
        return defaultValue;
    }
    if (coverBehavior == null && facing != null) {
        boolean isBlocked = (getBlockedConnections() & 1 << facing.getIndex()) > 0;
        return isBlocked ? null : defaultValue;
    }
    if (coverBehavior != null) {
        return coverBehavior.getCapability(capability, defaultValue);
    }
    return defaultValue;
}
Also used : NBT(net.minecraftforge.common.util.Constants.NBT) CoverBehavior(gregtech.api.cover.CoverBehavior) Nullable(javax.annotation.Nullable)

Example 14 with CoverBehavior

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

the class BlockPipe method onBlockClicked.

@Override
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) {
    IPipeTile<PipeType, NodeDataType> pipeTile = getPipeTileEntity(worldIn, pos);
    CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos);
    if (pipeTile == null || rayTraceResult == null) {
        return;
    }
    EnumFacing coverSide = ICoverable.traceCoverSide(rayTraceResult);
    CoverBehavior coverBehavior = coverSide == null ? null : pipeTile.getCoverableImplementation().getCoverAtSide(coverSide);
    if (coverBehavior != null) {
        coverBehavior.onLeftClick(playerIn, rayTraceResult);
    }
}
Also used : CuboidRayTraceResult(codechicken.lib.raytracer.CuboidRayTraceResult) CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 15 with CoverBehavior

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

the class MetaTileEntityTank method recheckBlockedSides.

private void recheckBlockedSides() {
    this.blockedSides = 0;
    for (EnumFacing side : EnumFacing.VALUES) {
        CoverBehavior coverBehavior = getCoverAtSide(side);
        if (coverBehavior == null)
            continue;
        if (coverBehavior.canPipePassThrough())
            continue;
        this.blockedSides |= 1 << side.getIndex();
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) 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