use of forestry.api.mail.IStamps in project ForestryMC by ForestryMC.
the class PostOffice method collectPostage.
@Override
public void collectPostage(NonNullList<ItemStack> stamps) {
for (ItemStack stamp : stamps) {
if (stamp == null) {
continue;
}
if (stamp.getItem() instanceof IStamps) {
EnumPostage postage = ((IStamps) stamp.getItem()).getPostage(stamp);
collectedPostage[postage.ordinal()] += stamp.getCount();
}
}
}
use of forestry.api.mail.IStamps in project ForestryMC by ForestryMC.
the class TileTrader method hasPostageMin.
public boolean hasPostageMin(int postage) {
int posted = 0;
IInventory tradeInventory = this.getInternalInventory();
for (int i = TradeStation.SLOT_STAMPS_1; i < TradeStation.SLOT_STAMPS_1 + TradeStation.SLOT_STAMPS_COUNT; i++) {
ItemStack stamp = tradeInventory.getStackInSlot(i);
if (!stamp.isEmpty()) {
if (stamp.getItem() instanceof IStamps) {
posted += ((IStamps) stamp.getItem()).getPostage(stamp).getValue() * stamp.getCount();
if (posted >= postage) {
return true;
}
}
}
}
return false;
}
use of forestry.api.mail.IStamps in project ForestryMC by ForestryMC.
the class TradeStation method removeStamps.
private void removeStamps(int[] stampCount) {
for (int i = 1; i < stampCount.length; i++) {
if (stampCount[i] <= 0) {
continue;
}
for (int j = SLOT_STAMPS_1; j < SLOT_STAMPS_1 + SLOT_STAMPS_COUNT; j++) {
if (stampCount[i] <= 0) {
continue;
}
ItemStack stamp = inventory.getStackInSlot(j);
if (stamp.isEmpty()) {
continue;
}
if (!(stamp.getItem() instanceof IStamps)) {
continue;
}
if (((IStamps) stamp.getItem()).getPostage(stamp) == EnumPostage.values()[i]) {
ItemStack decrease = inventory.decrStackSize(j, stampCount[i]);
stampCount[i] -= decrease.getCount();
}
}
}
}
use of forestry.api.mail.IStamps in project ForestryMC by ForestryMC.
the class TileStampCollector method updateServerSide.
@Override
public void updateServerSide() {
if (!updateOnInterval(20)) {
return;
}
ItemStack stamp = null;
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(InventoryStampCollector.SLOT_FILTER).isEmpty()) {
stamp = PostManager.postRegistry.getPostOffice(world).getAnyStamp(1);
} else {
ItemStack filter = inventory.getStackInSlot(InventoryStampCollector.SLOT_FILTER);
if (filter.getItem() instanceof IStamps) {
stamp = PostManager.postRegistry.getPostOffice(world).getAnyStamp(((IStamps) filter.getItem()).getPostage(filter), 1);
}
}
if (stamp == null) {
return;
}
// Store it.
InventoryUtil.stowInInventory(stamp, inventory, true, InventoryStampCollector.SLOT_BUFFER_1, InventoryStampCollector.SLOT_BUFFER_COUNT);
}
Aggregations