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);
}
}
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;
}
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());
}
Aggregations