Test with stuff + Forestry potential support
This commit is contained in:
parent
5b05cf651b
commit
bd26e441cb
174 changed files with 5602 additions and 0 deletions
15
BM_src/forestry/api/mail/EnumPostage.java
Normal file
15
BM_src/forestry/api/mail/EnumPostage.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
public enum EnumPostage {
|
||||
P_0(0), P_1(1), P_2(2), P_5(5), P_10(10), P_20(20), P_50(50), P_100(100), P_200(200);
|
||||
|
||||
private final int value;
|
||||
|
||||
private EnumPostage(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
53
BM_src/forestry/api/mail/ILetter.java
Normal file
53
BM_src/forestry/api/mail/ILetter.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public interface ILetter extends IInventory, INBTTagable {
|
||||
|
||||
ItemStack[] getPostage();
|
||||
|
||||
void setProcessed(boolean flag);
|
||||
|
||||
boolean isProcessed();
|
||||
|
||||
boolean isMailable();
|
||||
|
||||
void setSender(MailAddress address);
|
||||
|
||||
MailAddress getSender();
|
||||
|
||||
boolean hasRecipient();
|
||||
|
||||
void setRecipient(MailAddress address);
|
||||
|
||||
MailAddress[] getRecipients();
|
||||
|
||||
String getRecipientString();
|
||||
|
||||
void setText(String text);
|
||||
|
||||
String getText();
|
||||
|
||||
void addTooltip(List list);
|
||||
|
||||
boolean isPostPaid();
|
||||
|
||||
int requiredPostage();
|
||||
|
||||
void invalidatePostage();
|
||||
|
||||
ItemStack[] getAttachments();
|
||||
|
||||
void addAttachment(ItemStack itemstack);
|
||||
|
||||
void addAttachments(ItemStack[] itemstacks);
|
||||
|
||||
int countAttachments();
|
||||
|
||||
void addStamps(ItemStack stamps);
|
||||
|
||||
}
|
8
BM_src/forestry/api/mail/ILetterHandler.java
Normal file
8
BM_src/forestry/api/mail/ILetterHandler.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ILetterHandler {
|
||||
IPostalState handleLetter(World world, String recipient, ItemStack letterStack, boolean doLodge);
|
||||
}
|
25
BM_src/forestry/api/mail/IPostOffice.java
Normal file
25
BM_src/forestry/api/mail/IPostOffice.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IPostOffice {
|
||||
|
||||
void collectPostage(ItemStack[] stamps);
|
||||
|
||||
IPostalState lodgeLetter(World world, ItemStack itemstack, boolean doLodge);
|
||||
|
||||
ItemStack getAnyStamp(int max);
|
||||
|
||||
ItemStack getAnyStamp(EnumPostage postage, int max);
|
||||
|
||||
ItemStack getAnyStamp(EnumPostage[] postages, int max);
|
||||
|
||||
void registerTradeStation(ITradeStation trade);
|
||||
|
||||
void deregisterTradeStation(ITradeStation trade);
|
||||
|
||||
Map<String, ITradeStation> getActiveTradeStations(World world);
|
||||
}
|
47
BM_src/forestry/api/mail/IPostRegistry.java
Normal file
47
BM_src/forestry/api/mail/IPostRegistry.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IPostRegistry {
|
||||
|
||||
/* POST OFFICE */
|
||||
IPostOffice getPostOffice(World world);
|
||||
|
||||
/* LETTERS */
|
||||
boolean isLetter(ItemStack itemstack);
|
||||
|
||||
ILetter createLetter(MailAddress sender, MailAddress recipient);
|
||||
|
||||
ILetter getLetter(ItemStack itemstack);
|
||||
|
||||
ItemStack createLetterStack(ILetter letter);
|
||||
|
||||
/* CARRIERS */
|
||||
/**
|
||||
* Registers a new {@link IPostalCarrier}. See {@link IPostalCarrier} for details.
|
||||
* @param carrier {@link IPostalCarrier} to register.
|
||||
*/
|
||||
void registerCarrier(IPostalCarrier carrier);
|
||||
|
||||
IPostalCarrier getCarrier(String uid);
|
||||
|
||||
Map<String, IPostalCarrier> getRegisteredCarriers();
|
||||
|
||||
/* TRADE STATIONS */
|
||||
void deleteTradeStation(World world, String moniker);
|
||||
|
||||
ITradeStation getOrCreateTradeStation(World world, String owner, String moniker);
|
||||
|
||||
ITradeStation getTradeStation(World world, String moniker);
|
||||
|
||||
boolean isAvailableTradeMoniker(World world, String moniker);
|
||||
|
||||
boolean isValidTradeMoniker(World world, String moniker);
|
||||
|
||||
/* PO BOXES */
|
||||
boolean isValidPOBox(World world, String username);
|
||||
|
||||
}
|
42
BM_src/forestry/api/mail/IPostalCarrier.java
Normal file
42
BM_src/forestry/api/mail/IPostalCarrier.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Postal Carriers are systems which can be hooked into Forestry's mail system to handle mail delivery.
|
||||
*
|
||||
* The two available carriers in vanilla Forestry are
|
||||
* "player" - Delivers mail to individual players.
|
||||
* "trader" - Handles mail addressed to trade stations.
|
||||
*/
|
||||
public interface IPostalCarrier {
|
||||
|
||||
/**
|
||||
* @return A lower-case identifier without spaces.
|
||||
*/
|
||||
String getUID();
|
||||
|
||||
/**
|
||||
* @return A human-readable name for this carrier.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
Icon getIcon();
|
||||
|
||||
/**
|
||||
* Handle delivery of a letter addressed to this carrier.
|
||||
* @param world The world the {@link IPostOffice} handles.
|
||||
* @param office {link @IPostOffice} which received this letter and handed it to the carrier.
|
||||
* @param recipient An identifier for the recipient as typed by the player into the address field.
|
||||
* @param letterstack ItemStack representing the letter. See {@link IPostRegistry} for helper functions to validate and extract it.
|
||||
* @param doDeliver Whether or not the letter is supposed to actually be delivered or if delivery is only to be simulated.
|
||||
* @return {link IPostalState} holding information on success or failure for delivery.
|
||||
*/
|
||||
IPostalState deliverLetter(World world, IPostOffice office, String recipient, ItemStack letterstack, boolean doDeliver);
|
||||
|
||||
}
|
9
BM_src/forestry/api/mail/IPostalState.java
Normal file
9
BM_src/forestry/api/mail/IPostalState.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
public interface IPostalState {
|
||||
boolean isOk();
|
||||
|
||||
String getIdentifier();
|
||||
|
||||
int ordinal();
|
||||
}
|
9
BM_src/forestry/api/mail/IStamps.java
Normal file
9
BM_src/forestry/api/mail/IStamps.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IStamps {
|
||||
|
||||
EnumPostage getPostage(ItemStack itemstack);
|
||||
|
||||
}
|
19
BM_src/forestry/api/mail/ITradeStation.java
Normal file
19
BM_src/forestry/api/mail/ITradeStation.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public interface ITradeStation extends ILetterHandler, IInventory {
|
||||
|
||||
String getMoniker();
|
||||
|
||||
boolean isValid();
|
||||
|
||||
void invalidate();
|
||||
|
||||
void setVirtual(boolean isVirtual);
|
||||
|
||||
boolean isVirtual();
|
||||
|
||||
TradeStationInfo getTradeInfo();
|
||||
|
||||
}
|
54
BM_src/forestry/api/mail/MailAddress.java
Normal file
54
BM_src/forestry/api/mail/MailAddress.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public class MailAddress implements INBTTagable {
|
||||
private String type;
|
||||
private String identifier;
|
||||
|
||||
private MailAddress() {
|
||||
}
|
||||
|
||||
public MailAddress(String identifier) {
|
||||
this(identifier, "player");
|
||||
}
|
||||
|
||||
public MailAddress(String identifier, String type) {
|
||||
this.identifier = identifier;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public boolean isPlayer() {
|
||||
return "player".equals(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
if(nbttagcompound.hasKey("TP"))
|
||||
type = nbttagcompound.getString("TP");
|
||||
else
|
||||
type = nbttagcompound.getShort("TYP") == 0 ? "player" : "trader";
|
||||
identifier = nbttagcompound.getString("ID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setString("TP", type);
|
||||
nbttagcompound.setString("ID", identifier);
|
||||
}
|
||||
|
||||
public static MailAddress loadFromNBT(NBTTagCompound nbttagcompound) {
|
||||
MailAddress address = new MailAddress();
|
||||
address.readFromNBT(nbttagcompound);
|
||||
return address;
|
||||
}
|
||||
}
|
6
BM_src/forestry/api/mail/PostManager.java
Normal file
6
BM_src/forestry/api/mail/PostManager.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
|
||||
public class PostManager {
|
||||
public static IPostRegistry postRegistry;
|
||||
}
|
19
BM_src/forestry/api/mail/TradeStationInfo.java
Normal file
19
BM_src/forestry/api/mail/TradeStationInfo.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package forestry.api.mail;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TradeStationInfo {
|
||||
public final String moniker;
|
||||
public final String owner;
|
||||
public final ItemStack tradegood;
|
||||
public final ItemStack[] required;
|
||||
public final IPostalState state;
|
||||
|
||||
public TradeStationInfo(String moniker, String owner, ItemStack tradegood, ItemStack[] required, IPostalState state) {
|
||||
this.moniker = moniker;
|
||||
this.owner = owner;
|
||||
this.tradegood = tradegood;
|
||||
this.required = required;
|
||||
this.state = state;
|
||||
}
|
||||
}
|
3
BM_src/forestry/api/mail/package-info.java
Normal file
3
BM_src/forestry/api/mail/package-info.java
Normal file
|
@ -0,0 +1,3 @@
|
|||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|mail")
|
||||
package forestry.api.mail;
|
||||
import cpw.mods.fml.common.API;
|
Loading…
Add table
Add a link
Reference in a new issue