Search in sources :

Example 1 with IPostalCarrier

use of forestry.api.mail.IPostalCarrier in project ForestryMC by ForestryMC.

the class AddresseeSlot method draw.

@Override
public void draw(int startX, int startY) {
    IPostalCarrier carrier = PostManager.postRegistry.getCarrier(containerLetter.getCarrierType());
    if (carrier != null) {
        GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0F);
        TextureManagerForestry.getInstance().bindGuiTextureMap();
        manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, carrier.getSprite(), 32, 32);
    }
}
Also used : IPostalCarrier(forestry.api.mail.IPostalCarrier)

Example 2 with IPostalCarrier

use of forestry.api.mail.IPostalCarrier in project ForestryMC by ForestryMC.

the class PostOffice method lodgeLetter.

// / DELIVERY
@Override
public IPostalState lodgeLetter(World world, ItemStack itemstack, boolean doLodge) {
    ILetter letter = PostManager.postRegistry.getLetter(itemstack);
    if (letter == null) {
        return EnumDeliveryState.NOT_MAILABLE;
    }
    if (letter.isProcessed()) {
        return EnumDeliveryState.ALREADY_MAILED;
    }
    if (!letter.isPostPaid()) {
        return EnumDeliveryState.NOT_POSTPAID;
    }
    if (!letter.isMailable()) {
        return EnumDeliveryState.NOT_MAILABLE;
    }
    IPostalState state = EnumDeliveryState.NOT_MAILABLE;
    IMailAddress address = letter.getRecipient();
    if (address != null) {
        IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType());
        if (carrier != null) {
            state = carrier.deliverLetter(world, this, address, itemstack, doLodge);
        }
    }
    if (!state.isOk()) {
        return state;
    }
    collectPostage(letter.getPostage());
    markDirty();
    return EnumDeliveryState.OK;
}
Also used : IPostalState(forestry.api.mail.IPostalState) IMailAddress(forestry.api.mail.IMailAddress) ILetter(forestry.api.mail.ILetter) IPostalCarrier(forestry.api.mail.IPostalCarrier)

Example 3 with IPostalCarrier

use of forestry.api.mail.IPostalCarrier in project ForestryMC by ForestryMC.

the class ContainerLetter method advanceCarrierType.

public void advanceCarrierType() {
    Iterator<IPostalCarrier> it = PostManager.postRegistry.getRegisteredCarriers().values().iterator();
    while (it.hasNext()) {
        if (it.next().getType().equals(carrierType)) {
            break;
        }
    }
    IPostalCarrier postal;
    if (it.hasNext()) {
        postal = it.next();
    } else {
        postal = PostManager.postRegistry.getRegisteredCarriers().values().iterator().next();
    }
    setCarrierType(postal.getType());
}
Also used : IPostalCarrier(forestry.api.mail.IPostalCarrier)

Aggregations

IPostalCarrier (forestry.api.mail.IPostalCarrier)3 ILetter (forestry.api.mail.ILetter)1 IMailAddress (forestry.api.mail.IMailAddress)1 IPostalState (forestry.api.mail.IPostalState)1