Search in sources :

Example 21 with CoverBehavior

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

the class MetaTileEntity method writeInitialSyncData.

public void writeInitialSyncData(PacketBuffer buf) {
    buf.writeByte(this.frontFacing.getIndex());
    buf.writeInt(this.paintingColor);
    buf.writeShort(mteTraits.size());
    for (MTETrait trait : mteTraits) {
        buf.writeVarInt(trait.getNetworkID());
        trait.writeInitialData(buf);
    }
    for (EnumFacing coverSide : EnumFacing.VALUES) {
        CoverBehavior coverBehavior = getCoverAtSide(coverSide);
        if (coverBehavior != null) {
            int coverId = CoverDefinition.getNetworkIdForCover(coverBehavior.getCoverDefinition());
            buf.writeVarInt(coverId);
            coverBehavior.writeInitialSyncData(buf);
        } else {
            buf.writeVarInt(-1);
        }
    }
    buf.writeBoolean(isFragile);
}
Also used : CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 22 with CoverBehavior

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

the class MetaTileEntity method onCoverScrewdriverClick.

public final boolean onCoverScrewdriverClick(EntityPlayer playerIn, EnumHand hand, CuboidRayTraceResult result) {
    EnumFacing hitFacing = ICoverable.determineGridSideHit(result);
    boolean accessingActiveOutputSide = false;
    if (this.getCapability(GregtechTileCapabilities.CAPABILITY_ACTIVE_OUTPUT_SIDE, hitFacing) != null) {
        accessingActiveOutputSide = playerIn.isSneaking();
    }
    EnumFacing coverSide = ICoverable.traceCoverSide(result);
    CoverBehavior coverBehavior = coverSide == null ? null : getCoverAtSide(coverSide);
    EnumActionResult coverResult = coverBehavior == null ? EnumActionResult.PASS : accessingActiveOutputSide ? EnumActionResult.PASS : coverBehavior.onScrewdriverClick(playerIn, hand, result);
    if (coverResult != EnumActionResult.PASS) {
        return coverResult == EnumActionResult.SUCCESS;
    }
    return onScrewdriverClick(playerIn, hand, result.sideHit, result);
}
Also used : CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 23 with CoverBehavior

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

the class MetaTileEntity method getCoverCapability.

public final <T> T getCoverCapability(Capability<T> capability, EnumFacing side) {
    boolean isCoverable = capability == GregtechTileCapabilities.CAPABILITY_COVERABLE;
    CoverBehavior coverBehavior = side == null ? null : getCoverAtSide(side);
    T originalCapability = getCapability(capability, side);
    if (coverBehavior != null && !isCoverable) {
        return coverBehavior.getCapability(capability, originalCapability);
    }
    return originalCapability;
}
Also used : NBT(net.minecraftforge.common.util.Constants.NBT) CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 24 with CoverBehavior

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

the class MetaTileEntity method dropAllCovers.

public final void dropAllCovers() {
    for (EnumFacing coverSide : EnumFacing.VALUES) {
        CoverBehavior coverBehavior = coverBehaviors[coverSide.getIndex()];
        if (coverBehavior == null)
            continue;
        List<ItemStack> drops = coverBehavior.getDrops();
        coverBehavior.onRemoved();
        for (ItemStack dropStack : drops) {
            Block.spawnAsEntity(getWorld(), getPos(), dropStack);
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 25 with CoverBehavior

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

the class CoverMachineController method updateDisplayInventory.

private void updateDisplayInventory() {
    EnumFacing controlledSide = getControllerMode().side;
    ItemStack resultStack = ItemStack.EMPTY;
    if (controlledSide != null) {
        CoverBehavior coverBehavior = coverHolder.getCoverAtSide(controlledSide);
        if (coverBehavior != null) {
            resultStack = coverBehavior.getCoverDefinition().getDropItemStack();
        }
    }
    this.displayInventory.setStackInSlot(0, resultStack);
}
Also used : ItemStack(net.minecraft.item.ItemStack) 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