mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-10-27 06:43:57 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c057d4854 | ||
|
|
96b8f60f87 | ||
|
|
a2a1f8eca9 |
No files matched your search
@@ -9,5 +9,6 @@ dependencies {
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:api')
|
||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
compileOnly('curse.maven:craftguide-75557:2459320')
|
||||
compileOnly('com.github.GTNewHorizons:Postea:1.4.0-mu:dev')
|
||||
devOnlyNonPublishable('net.xonich.mc:NoHotbarNeeded:0.0.3:dev')
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import com.gtnewhorizons.postea.api.IVersionedTransformer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.gtnewhorizons.postea.api.CustomDataReplacementManager;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
/// Used to provide custom save data (like mail boxes) to Postea's [IVersionedTransformer]s.
|
||||
///
|
||||
/// These transformers allow other mods to change saved data based on their own version stamps. This compat flags,
|
||||
/// to those transformers, the times they should fire. [#transform] is used before consuming data, so the transformer
|
||||
/// can run, and [#stamp] is used for fresh data to ensure the transformer can add a stamp of its current version.
|
||||
public final class PosteaCompat {
|
||||
|
||||
private static final boolean POSTEA = Loader.isModLoaded("postea");
|
||||
|
||||
private PosteaCompat() {}
|
||||
|
||||
/// Transforms a root read from disk in place; call before consuming it.
|
||||
public static void transform(String storageId, NBTTagCompound root) {
|
||||
if (POSTEA) Impl.transform(storageId, root);
|
||||
}
|
||||
|
||||
/// Stamps a freshly built root about to be written to disk.
|
||||
public static void stamp(NBTTagCompound root) {
|
||||
if (POSTEA) Impl.stamp(root);
|
||||
}
|
||||
|
||||
private static final class Impl {
|
||||
|
||||
static void transform(String storageId, NBTTagCompound root) {
|
||||
CustomDataReplacementManager.transform(storageId, root);
|
||||
}
|
||||
|
||||
static void stamp(NBTTagCompound root) {
|
||||
CustomDataReplacementManager.stamp(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import forestry.api.mail.IMailAddress;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.PosteaCompat;
|
||||
|
||||
public class POBox extends WorldSavedData implements IInventory {
|
||||
|
||||
@@ -42,6 +43,7 @@ public class POBox extends WorldSavedData implements IInventory {
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
PosteaCompat.transform("forestry:" + mapName, nbttagcompound);
|
||||
if (nbttagcompound.hasKey("address")) {
|
||||
this.address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address"));
|
||||
}
|
||||
@@ -56,6 +58,7 @@ public class POBox extends WorldSavedData implements IInventory {
|
||||
nbttagcompound.setTag("address", nbt);
|
||||
}
|
||||
letters.writeToNBT(nbttagcompound);
|
||||
PosteaCompat.stamp(nbttagcompound);
|
||||
}
|
||||
|
||||
public boolean storeLetter(ItemStack letterstack) {
|
||||
|
||||
Reference in new issue
Block a user