mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 15:22:57 +00:00
Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eaa087b2d | ||
|
|
277f97d86b | ||
|
|
376d83abc1 | ||
|
|
990e8158df | ||
|
|
73d95a043b | ||
|
|
ebfdf989cd | ||
|
|
414d7da5c0 | ||
|
|
01d40092f3 | ||
|
|
2c057d4854 | ||
|
|
96b8f60f87 | ||
|
|
a2a1f8eca9 | ||
|
|
f2e85073d3 | ||
|
|
0bd9a7978a | ||
|
|
e47fc90433 | ||
|
|
452064ef1d | ||
|
|
59c8c36520 | ||
|
|
ea1c4edae4 | ||
|
|
4c46626cdb | ||
|
|
d6fa8d8b74 | ||
|
|
704861b666 | ||
|
|
db25dcce48 |
No files matched your search
@@ -1,29 +0,0 @@
|
|||||||
How to submit a bug report to Forestry
|
|
||||||
====================================
|
|
||||||
Please make sure the bug has not already been reported by [searching the issues](https://github.com/ForestryMC/ForestryMC/issues?q=is%3Aissue).
|
|
||||||
|
|
||||||
If you can, see if the bug still happens with the latest unstable build.
|
|
||||||
[The latest unstable builds are available here](http://jenkins.ic2.player.to/job/Forestry_Dev/)
|
|
||||||
|
|
||||||
For crashes, you must post a link to the full crash report.
|
|
||||||
[gist.github.com](gist.github.com) or [pastebin.com](www.pastebin.com) are good places to upload them.
|
|
||||||
Full crash reports are located in [the minecraft data folder](http://hopper.minecraft.net/help/finding-minecraft-data-folder/), in "crash-reports".
|
|
||||||
|
|
||||||
Thank you for reporting bugs!
|
|
||||||
|
|
||||||
How to contribute to Forestry
|
|
||||||
====================================
|
|
||||||
|
|
||||||
### Contributor License Agreement
|
|
||||||
|
|
||||||
Before pull requests can be accepted, the contributor needs to sign a contributor license agreement. (Essentially giving a license for using his code and/or media and for re-licensing it, for details read the agreement linked below.)
|
|
||||||
|
|
||||||
### How do I sign?
|
|
||||||
|
|
||||||
To keep the hassle for everyone involved to a minimum, Forestry uses CLAHub to manage the agreements. To get started, <a href="https://www.clahub.com/agreements/ForestryMC/ForestryMC">sign the Contributor License Agreement</a>.
|
|
||||||
|
|
||||||
### Why is this needed?
|
|
||||||
|
|
||||||
Without CLAs it at some point becomes essentially impossible to change the license of a project which accepts contributions from third parties. Without an explicit agreement every contributor would still own the copyright to his code. So as long as it (or parts of it) remain in the code base, he would have to agree to every license change. If enough time has passed, there may be dozens, perhaps even hundreds of contributors involved and it will be very hard to track down each and every one of them and get them to agree on a new license.
|
|
||||||
|
|
||||||
This would make it impossible to change the license to a more permissive one at a later date, so the code would be locked into CC BY-NC-ND 3.0 until it passes into the public domain about a hundred years from now. This situation is to be avoided and that’s why you are being bothered with this CLA.
|
|
||||||
@@ -9,5 +9,6 @@ dependencies {
|
|||||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:api')
|
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:api')
|
||||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||||
compileOnly('curse.maven:craftguide-75557:2459320')
|
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')
|
devOnlyNonPublishable('net.xonich.mc:NoHotbarNeeded:0.0.3:dev')
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,8 @@ import forestry.plugins.PluginManager;
|
|||||||
+ "after:BiomesOPlenty;"
|
+ "after:BiomesOPlenty;"
|
||||||
+ "after:IC2@[2.0.140,);"
|
+ "after:IC2@[2.0.140,);"
|
||||||
+ "after:Natura@[2.2.0,);"
|
+ "after:Natura@[2.2.0,);"
|
||||||
+ "after:HardcoreEnderExpansion;")
|
+ "after:HardcoreEnderExpansion;"
|
||||||
|
+ "after:postea@[1.4.0,);")
|
||||||
public class Forestry {
|
public class Forestry {
|
||||||
|
|
||||||
@Mod.Instance(Constants.MOD)
|
@Mod.Instance(Constants.MOD)
|
||||||
|
|||||||
@@ -111,6 +111,14 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
|||||||
this.readFromNBT(data);
|
this.readFromNBT(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detachBlock(IMultiblockComponent part, boolean chunkUnloading) {
|
||||||
|
if (!chunkUnloading) {
|
||||||
|
inventory.dumpInventoryIntoWorld(this.worldObj, part.getCoordinates());
|
||||||
|
}
|
||||||
|
super.detachBlock(part, chunkUnloading);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBlockAdded(IMultiblockComponent newPart) {
|
protected void onBlockAdded(IMultiblockComponent newPart) {
|
||||||
if (newPart instanceof IAlvearyComponent) {
|
if (newPart instanceof IAlvearyComponent) {
|
||||||
@@ -159,8 +167,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
|||||||
activeComponents.remove(oldPart);
|
activeComponents.remove(oldPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.dumpInventoryIntoWorld(this.worldObj, oldPart.getCoordinates());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import net.minecraft.block.material.Material;
|
|||||||
import net.minecraft.client.particle.EffectRenderer;
|
import net.minecraft.client.particle.EffectRenderer;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@@ -72,7 +72,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public IIcon getIcon(int side, int meta) {
|
public IIcon getIcon(int side, int meta) {
|
||||||
return IconProviderWood.getPlankIcon(EnumWoodType.LARCH);
|
return IconProviderWood.getPlankIcon(EnumWoodType.VALUES[meta]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,7 +84,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack createStackedBlock(int meta) {
|
protected ItemStack createStackedBlock(int meta) {
|
||||||
return new ItemStack(Blocks.wooden_slab, 2, meta & 7);
|
Item item = Item.getItemFromBlock(this);
|
||||||
|
return item != null ? new ItemStack(item, 2, 0) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,6 +108,18 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
|||||||
return new TileWood();
|
return new TileWood();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||||
|
// Special case for double slabs placed by building mods (e.g., MatterManipulator)
|
||||||
|
if (stack == null) return;
|
||||||
|
int damage = stack.getItemDamage();
|
||||||
|
if (damage < 0 || damage >= EnumWoodType.VALUES.length) return;
|
||||||
|
TileWood tile = TileWood.getWoodTile(world, x, y, z);
|
||||||
|
if (tile != null) {
|
||||||
|
tile.setWoodType(EnumWoodType.VALUES[damage]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* PROPERTIES */
|
/* PROPERTIES */
|
||||||
@Override
|
@Override
|
||||||
public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||||
|
|||||||
@@ -202,7 +202,8 @@ public abstract class Genome implements IGenome {
|
|||||||
private static IChromosome[] getChromosomes(NBTTagCompound genomeNBT, ISpeciesRoot speciesRoot) {
|
private static IChromosome[] getChromosomes(NBTTagCompound genomeNBT, ISpeciesRoot speciesRoot) {
|
||||||
|
|
||||||
NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10);
|
NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10);
|
||||||
IChromosome[] chromosomes = new IChromosome[speciesRoot.getDefaultTemplate().length];
|
IAllele[] defaultTemplate = speciesRoot.getDefaultTemplate();
|
||||||
|
IChromosome[] chromosomes = new IChromosome[defaultTemplate.length];
|
||||||
|
|
||||||
for (int i = 0; i < chromosomesNBT.tagCount(); i++) {
|
for (int i = 0; i < chromosomesNBT.tagCount(); i++) {
|
||||||
NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(i);
|
NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(i);
|
||||||
@@ -213,7 +214,7 @@ public abstract class Genome implements IGenome {
|
|||||||
chromosomes[chromosomeOrdinal] = chromosome;
|
chromosomes[chromosomeOrdinal] = chromosome;
|
||||||
|
|
||||||
if (Config.clearInvalidChromosomes) {
|
if (Config.clearInvalidChromosomes) {
|
||||||
IAllele template = speciesRoot.getDefaultTemplate()[chromosomeOrdinal];
|
IAllele template = defaultTemplate[chromosomeOrdinal];
|
||||||
Class<? extends IAllele> chromosomeClass = speciesRoot.getKaryotype()[chromosomeOrdinal]
|
Class<? extends IAllele> chromosomeClass = speciesRoot.getKaryotype()[chromosomeOrdinal]
|
||||||
.getAlleleClass();
|
.getAlleleClass();
|
||||||
if (chromosome.overrideInvalidAlleles(template, chromosomeClass)) {
|
if (chromosome.overrideInvalidAlleles(template, chromosomeClass)) {
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ public class MutationConditionRequiresResource implements IMutationCondition {
|
|||||||
blockRequired = new ItemStack(block, 1, meta);
|
blockRequired = new ItemStack(block, 1, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack getBlockRequired() {
|
||||||
|
return blockRequired.copy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
||||||
IGenome genome1, IClimateProvider climate) {
|
IGenome genome1, IClimateProvider climate) {
|
||||||
|
|||||||
+4
@@ -39,6 +39,10 @@ public class MutationConditionRequiresResourceOreDict implements IMutationCondit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getOreDictId() {
|
||||||
|
return oreDictId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
||||||
IGenome genome1, IClimateProvider climate) {
|
IGenome genome1, IClimateProvider climate) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
|||||||
public boolean isParentItemEquipped() {
|
public boolean isParentItemEquipped() {
|
||||||
return switch (location.type()) {
|
return switch (location.type()) {
|
||||||
case HELD_BY_PLAYER, UNKNOWN -> isSameItemInventory(player.getCurrentEquippedItem(), parent);
|
case HELD_BY_PLAYER, UNKNOWN -> isSameItemInventory(player.getCurrentEquippedItem(), parent);
|
||||||
case PLAYER_INVENTORY -> true;
|
case PLAYER_INVENTORY -> isSameItemInventory(player.inventory.getStackInSlot(location.slotIdx()), parent);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +95,10 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemLocation getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isParentItemInventory(ItemStack itemStack) {
|
public boolean isParentItemInventory(ItemStack itemStack) {
|
||||||
ItemStack parent = getParent();
|
ItemStack parent = getParent();
|
||||||
return isSameItemInventory(parent, itemStack);
|
return isSameItemInventory(parent, itemStack);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public abstract class ItemWithGui extends ItemForestry implements IGuiHandlerIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void openGui(EntityPlayer entityplayer) {
|
protected void openGui(EntityPlayer entityplayer) {
|
||||||
GuiHandler.openGui(entityplayer, this);
|
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package forestry.core.utils;
|
||||||
|
|
||||||
|
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 versioned transformers.
|
||||||
|
///
|
||||||
|
/// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A copy of the stamps on a root read from disk, or null when it carries none or Postea is absent. Call after
|
||||||
|
/// [#transform].
|
||||||
|
public static NBTTagCompound savedStamps(NBTTagCompound root) {
|
||||||
|
return POSTEA ? Impl.savedStamps(root) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stamps a freshly built root about to be written to disk, keeping the stamps in `carried` (from [#savedStamps])
|
||||||
|
/// for transformers not registered now. `carried` may be null.
|
||||||
|
public static void stamp(NBTTagCompound root, NBTTagCompound carried) {
|
||||||
|
if (POSTEA) Impl.stamp(root, carried);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class Impl {
|
||||||
|
|
||||||
|
static void transform(String storageId, NBTTagCompound root) {
|
||||||
|
CustomDataReplacementManager.transform(storageId, root);
|
||||||
|
}
|
||||||
|
|
||||||
|
static NBTTagCompound savedStamps(NBTTagCompound root) {
|
||||||
|
return CustomDataReplacementManager.savedStamps(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void stamp(NBTTagCompound root, NBTTagCompound carried) {
|
||||||
|
CustomDataReplacementManager.stamp(root, carried);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,16 +25,22 @@ import forestry.plugins.PluginMail;
|
|||||||
public class LetterProperties {
|
public class LetterProperties {
|
||||||
|
|
||||||
private enum State {
|
private enum State {
|
||||||
|
|
||||||
FRESH,
|
FRESH,
|
||||||
STAMPED,
|
STAMPED,
|
||||||
OPENED,
|
OPENED,
|
||||||
EMPTIED
|
EMPTIED;
|
||||||
|
|
||||||
|
public static final State[] VALUES = values();
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Size {
|
private enum Size {
|
||||||
|
|
||||||
EMPTY,
|
EMPTY,
|
||||||
SMALL,
|
SMALL,
|
||||||
BIG
|
BIG;
|
||||||
|
|
||||||
|
public static final Size[] VALUES = values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack createStampedLetterStack(ILetter letter) {
|
public static ItemStack createStampedLetterStack(ILetter letter) {
|
||||||
@@ -98,8 +104,8 @@ public class LetterProperties {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void getSubItems(Item item, CreativeTabs tab, @SuppressWarnings("rawtypes") List list) {
|
public static void getSubItems(Item item, CreativeTabs tab, @SuppressWarnings("rawtypes") List list) {
|
||||||
for (State state : State.values()) {
|
for (State state : State.VALUES) {
|
||||||
for (Size size : Size.values()) {
|
for (Size size : Size.VALUES) {
|
||||||
int meta = encodeMeta(state, size);
|
int meta = encodeMeta(state, size);
|
||||||
ItemStack letter = new ItemStack(item, 1, meta);
|
ItemStack letter = new ItemStack(item, 1, meta);
|
||||||
list.add(letter);
|
list.add(letter);
|
||||||
@@ -117,7 +123,7 @@ public class LetterProperties {
|
|||||||
|
|
||||||
private static State getState(int meta) {
|
private static State getState(int meta) {
|
||||||
int ordinal = meta & 0x0f;
|
int ordinal = meta & 0x0f;
|
||||||
State[] values = State.values();
|
State[] values = State.VALUES;
|
||||||
if (ordinal >= values.length) {
|
if (ordinal >= values.length) {
|
||||||
ordinal = 0;
|
ordinal = 0;
|
||||||
}
|
}
|
||||||
@@ -126,7 +132,7 @@ public class LetterProperties {
|
|||||||
|
|
||||||
private static Size getSize(int meta) {
|
private static Size getSize(int meta) {
|
||||||
int ordinal = meta >> 4;
|
int ordinal = meta >> 4;
|
||||||
Size[] values = Size.values();
|
Size[] values = Size.VALUES;
|
||||||
if (ordinal >= values.length) {
|
if (ordinal >= values.length) {
|
||||||
ordinal = 0;
|
ordinal = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package forestry.mail;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.world.WorldSavedData;
|
||||||
|
|
||||||
|
import forestry.core.utils.PosteaCompat;
|
||||||
|
|
||||||
|
/// A mail storage in the world's `MapStorage`, with saved item stacks migrated through Postea under the storage id
|
||||||
|
/// `forestry:<mapName>`.
|
||||||
|
///
|
||||||
|
/// `MapStorage` swallows load exceptions and keeps the half-read storage. A storage whose migration failed is never
|
||||||
|
/// saved. [PostRegistry] rethrows the failure instead of serving the storage.
|
||||||
|
public abstract class MailSavedData extends WorldSavedData {
|
||||||
|
|
||||||
|
private RuntimeException loadFailure;
|
||||||
|
private NBTTagCompound savedStamps;
|
||||||
|
|
||||||
|
protected MailSavedData(String mapName) {
|
||||||
|
super(mapName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void readFromNBT(NBTTagCompound root) {
|
||||||
|
try {
|
||||||
|
PosteaCompat.transform("forestry:" + mapName, root);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
loadFailure = e;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
savedStamps = PosteaCompat.savedStamps(root);
|
||||||
|
readData(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void writeToNBT(NBTTagCompound root) {
|
||||||
|
writeData(root);
|
||||||
|
PosteaCompat.stamp(root, savedStamps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDirty() {
|
||||||
|
return loadFailure == null && super.isDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Throws the exception that failed this storage's migration, if one did.
|
||||||
|
void throwIfLoadFailed() {
|
||||||
|
if (loadFailure != null) throw loadFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void readData(NBTTagCompound root);
|
||||||
|
|
||||||
|
protected abstract void writeData(NBTTagCompound root);
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.WorldSavedData;
|
|
||||||
|
|
||||||
import forestry.api.mail.ILetter;
|
import forestry.api.mail.ILetter;
|
||||||
import forestry.api.mail.IMailAddress;
|
import forestry.api.mail.IMailAddress;
|
||||||
@@ -20,7 +19,7 @@ import forestry.api.mail.PostManager;
|
|||||||
import forestry.core.inventory.InventoryAdapter;
|
import forestry.core.inventory.InventoryAdapter;
|
||||||
import forestry.core.utils.InventoryUtil;
|
import forestry.core.utils.InventoryUtil;
|
||||||
|
|
||||||
public class POBox extends WorldSavedData implements IInventory {
|
public class POBox extends MailSavedData implements IInventory {
|
||||||
|
|
||||||
public static final String SAVE_NAME = "POBox_";
|
public static final String SAVE_NAME = "POBox_";
|
||||||
public static final short SLOT_SIZE = 84;
|
public static final short SLOT_SIZE = 84;
|
||||||
@@ -41,7 +40,7 @@ public class POBox extends WorldSavedData implements IInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
protected void readData(NBTTagCompound nbttagcompound) {
|
||||||
if (nbttagcompound.hasKey("address")) {
|
if (nbttagcompound.hasKey("address")) {
|
||||||
this.address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address"));
|
this.address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address"));
|
||||||
}
|
}
|
||||||
@@ -49,7 +48,7 @@ public class POBox extends WorldSavedData implements IInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
protected void writeData(NBTTagCompound nbttagcompound) {
|
||||||
if (this.address != null) {
|
if (this.address != null) {
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
this.address.writeToNBT(nbt);
|
this.address.writeToNBT(nbt);
|
||||||
|
|||||||
@@ -158,6 +158,8 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
|||||||
return EnumDeliveryState.NOT_MAILABLE;
|
return EnumDeliveryState.NOT_MAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadDeliveryTargets(world, letter, doLodge);
|
||||||
|
|
||||||
IPostalState state = EnumDeliveryState.NOT_MAILABLE;
|
IPostalState state = EnumDeliveryState.NOT_MAILABLE;
|
||||||
for (IMailAddress address : letter.getRecipients()) {
|
for (IMailAddress address : letter.getRecipients()) {
|
||||||
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType());
|
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType());
|
||||||
@@ -180,6 +182,16 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
|||||||
return EnumDeliveryState.OK;
|
return EnumDeliveryState.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Loads every storage a delivery of `letter` writes to, so a storage whose migration failed throws before the
|
||||||
|
/// delivery changes anything.
|
||||||
|
private static void loadDeliveryTargets(World world, ILetter letter, boolean doLodge) {
|
||||||
|
for (IMailAddress recipient : letter.getRecipients()) {
|
||||||
|
if (PostRegistry.loadMailStorage(world, recipient) instanceof TradeStation trade) {
|
||||||
|
trade.loadTradeTargets(world, letter, doLodge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectPostage(ItemStack[] stamps) {
|
public void collectPostage(ItemStack[] stamps) {
|
||||||
for (ItemStack stamp : stamps) {
|
for (ItemStack stamp : stamps) {
|
||||||
|
|||||||
@@ -57,11 +57,20 @@ public class PostRegistry implements IPostRegistry {
|
|||||||
|
|
||||||
POBox pobox = (POBox) world.loadItemData(POBox.class, POBox.SAVE_NAME + address);
|
POBox pobox = (POBox) world.loadItemData(POBox.class, POBox.SAVE_NAME + address);
|
||||||
if (pobox != null) {
|
if (pobox != null) {
|
||||||
|
pobox.throwIfLoadFailed();
|
||||||
cachedPOBoxes.put(address, pobox);
|
cachedPOBoxes.put(address, pobox);
|
||||||
}
|
}
|
||||||
return pobox;
|
return pobox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The post box or trade station at `address`, or null when none exists or the trade station is invalid.
|
||||||
|
static MailSavedData loadMailStorage(World world, IMailAddress address) {
|
||||||
|
if (address == null) return null;
|
||||||
|
if (address.isPlayer()) return getPOBox(world, address);
|
||||||
|
if (address.isTrader()) return (TradeStation) PostManager.postRegistry.getTradeStation(world, address);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static POBox getOrCreatePOBox(World world, IMailAddress address) {
|
public static POBox getOrCreatePOBox(World world, IMailAddress address) {
|
||||||
POBox pobox = getPOBox(world, address);
|
POBox pobox = getPOBox(world, address);
|
||||||
|
|
||||||
@@ -111,6 +120,9 @@ public class PostRegistry implements IPostRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TradeStation trade = (TradeStation) world.loadItemData(TradeStation.class, TradeStation.SAVE_NAME + address);
|
TradeStation trade = (TradeStation) world.loadItemData(TradeStation.class, TradeStation.SAVE_NAME + address);
|
||||||
|
if (trade != null) {
|
||||||
|
trade.throwIfLoadFailed();
|
||||||
|
}
|
||||||
|
|
||||||
// Only existing and valid mail orders are returned
|
// Only existing and valid mail orders are returned
|
||||||
if (trade != null && trade.isValid()) {
|
if (trade != null && trade.isValid()) {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldSavedData;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
@@ -37,7 +36,7 @@ import forestry.mail.inventory.InventoryTradeStation;
|
|||||||
import forestry.mail.items.EnumStampDefinition;
|
import forestry.mail.items.EnumStampDefinition;
|
||||||
import forestry.plugins.PluginMail;
|
import forestry.plugins.PluginMail;
|
||||||
|
|
||||||
public class TradeStation extends WorldSavedData implements ITradeStation, IInventoryAdapter {
|
public class TradeStation extends MailSavedData implements ITradeStation, IInventoryAdapter {
|
||||||
|
|
||||||
public static final String SAVE_NAME = "TradePO_";
|
public static final String SAVE_NAME = "TradePO_";
|
||||||
public static final short SLOT_TRADEGOOD = 0;
|
public static final short SLOT_TRADEGOOD = 0;
|
||||||
@@ -85,7 +84,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
|||||||
|
|
||||||
// / SAVING & LOADING
|
// / SAVING & LOADING
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
protected void readData(NBTTagCompound nbttagcompound) {
|
||||||
if (nbttagcompound.hasKey("owner")) {
|
if (nbttagcompound.hasKey("owner")) {
|
||||||
owner = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("owner"));
|
owner = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("owner"));
|
||||||
}
|
}
|
||||||
@@ -100,7 +99,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
protected void writeData(NBTTagCompound nbttagcompound) {
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
NBTUtil.func_152460_a(nbt, owner);
|
NBTUtil.func_152460_a(nbt, owner);
|
||||||
@@ -172,9 +171,10 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
|||||||
@Override
|
@Override
|
||||||
public IPostalState handleLetter(World world, IMailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
public IPostalState handleLetter(World world, IMailAddress recipient, ItemStack letterstack, boolean doLodge) {
|
||||||
|
|
||||||
boolean sendOwnerNotice = doLodge && owner != null;
|
boolean sendOwnerNotice = sendsOwnerNotice(doLodge);
|
||||||
|
|
||||||
ILetter letter = PostManager.postRegistry.getLetter(letterstack);
|
ILetter letter = PostManager.postRegistry.getLetter(letterstack);
|
||||||
|
loadTradeTargets(world, letter, doLodge);
|
||||||
|
|
||||||
if (!isVirtual() && !hasPaper(sendOwnerNotice ? 2 : 1)) {
|
if (!isVirtual() && !hasPaper(sendOwnerNotice ? 2 : 1)) {
|
||||||
return EnumStationState.INSUFFICIENT_PAPER;
|
return EnumStationState.INSUFFICIENT_PAPER;
|
||||||
@@ -310,6 +310,19 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
|||||||
return EnumDeliveryState.OK;
|
return EnumDeliveryState.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Loads the storages a trade with `letter` delivers to: the sender's, and the owner's post box when the trade
|
||||||
|
/// sends an owner notice.
|
||||||
|
void loadTradeTargets(World world, ILetter letter, boolean doLodge) {
|
||||||
|
PostRegistry.loadMailStorage(world, letter.getSender());
|
||||||
|
if (sendsOwnerNotice(doLodge)) {
|
||||||
|
PostRegistry.getPOBox(world, new MailAddress(owner));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean sendsOwnerNotice(boolean doLodge) {
|
||||||
|
return doLodge && owner != null;
|
||||||
|
}
|
||||||
|
|
||||||
/* TRADE LOGIC */
|
/* TRADE LOGIC */
|
||||||
private int countFillableOrders(int max, ItemStack tradegood) {
|
private int countFillableOrders(int max, ItemStack tradegood) {
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ public class ItemInventoryBackpackPaged extends ItemInventoryBackpack implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flipPage(EntityPlayer player, short page) {
|
public void flipPage(EntityPlayer player, short page) {
|
||||||
GuiHandler.openGui(player, backpackNaturalist, page);
|
ItemLocation loc = getLocation();
|
||||||
|
if (loc.type() == ItemLocation.Type.PLAYER_INVENTORY) {
|
||||||
|
GuiHandler.openGui(player, backpackNaturalist, page, loc.slotIdx());
|
||||||
|
} else {
|
||||||
|
GuiHandler.openGui(player, backpackNaturalist, page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ public class ItemBackpack extends ItemWithGui implements ActivatableFromInventor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void openGui(EntityPlayer entityplayer) {
|
protected void openGui(EntityPlayer entityplayer) {
|
||||||
GuiHandler.openGui(entityplayer, this, (short) type.ordinal());
|
GuiHandler.openGui(entityplayer, this, (short) type.ordinal(), entityplayer.inventory.currentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class ItemBackpackNaturalist extends ItemBackpack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void openGui(EntityPlayer entityplayer) {
|
protected void openGui(EntityPlayer entityplayer) {
|
||||||
GuiHandler.openGui(entityplayer, this);
|
GuiHandler.openGui(entityplayer, this, (short) 0, entityplayer.inventory.currentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -501,10 +501,10 @@ tile.for.log1=原木
|
|||||||
tile.for.log2=原木
|
tile.for.log2=原木
|
||||||
tile.for.log3=原木
|
tile.for.log3=原木
|
||||||
tile.for.log4=原木
|
tile.for.log4=原木
|
||||||
tile.for.planks=木材
|
tile.for.planks.name=木材
|
||||||
tile.for.slabs1=木材ハーフブロック
|
tile.for.slabs1=木材ハーフブロック
|
||||||
tile.for.slabs2=木材ハーフブロック
|
tile.for.slabs2=木材ハーフブロック
|
||||||
tile.for.fences=フェンス
|
tile.for.fences.name=フェンス
|
||||||
tile.harvester.0=伐採機
|
tile.harvester.0=伐採機
|
||||||
tile.harvester.1=収穫機
|
tile.harvester.1=収穫機
|
||||||
tile.harvester.2=ゴムの木収穫機
|
tile.harvester.2=ゴムの木収穫機
|
||||||
@@ -757,9 +757,11 @@ tile.candle.dyed.stump=Unlit Dyed Candle
|
|||||||
tile.candle.lit=Lit Candle
|
tile.candle.lit=Lit Candle
|
||||||
tile.candle.dyed.lit=Lit Dyed Candle
|
tile.candle.dyed.lit=Lit Dyed Candle
|
||||||
tile.stump.0=Candle Stump
|
tile.stump.0=Candle Stump
|
||||||
tile.for.apiculture.0=Apiary
|
tile.for.apiculture.name=養蜂箱
|
||||||
tile.for.apiculture.1=Apiarist's Chest
|
tile.for.apiculture.0.name=養蜂箱
|
||||||
tile.for.apiculture.2=Bee House
|
tile.for.apicultureChest.name=養蜂家のチェスト
|
||||||
|
tile.for.apicultureChest.0.name=養蜂家のチェスト
|
||||||
|
tile.for.apiculture.2.name=ビーハウス
|
||||||
item.for.beeQueenGE.name=Unknown Queen
|
item.for.beeQueenGE.name=Unknown Queen
|
||||||
|
|
||||||
####################
|
####################
|
||||||
@@ -808,7 +810,7 @@ tile.log=Wood
|
|||||||
tile.planks=Wood Planks
|
tile.planks=Wood Planks
|
||||||
tile.slab=Wood Slab
|
tile.slab=Wood Slab
|
||||||
tile.fences=Fence
|
tile.fences=Fence
|
||||||
tile.for.stairs=Stairs
|
tile.for.stairs.name=階段
|
||||||
wood.0=Larch
|
wood.0=Larch
|
||||||
wood.1=Teak
|
wood.1=Teak
|
||||||
wood.2=Acacia
|
wood.2=Acacia
|
||||||
@@ -833,7 +835,8 @@ wood.20=Pine
|
|||||||
wood.21=Plum
|
wood.21=Plum
|
||||||
wood.22=Maple
|
wood.22=Maple
|
||||||
wood.23=Citrus
|
wood.23=Citrus
|
||||||
tile.for.arboriculture.0=Arborist's Chest
|
tile.for.arboriculture.name=樹医のチェスト
|
||||||
|
tile.for.arboriculture.0.name=樹医のチェスト
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# FARMING
|
# FARMING
|
||||||
@@ -906,7 +909,8 @@ item.butterfly=Butterfly
|
|||||||
item.moth=Moth
|
item.moth=Moth
|
||||||
item.flutterlyzer=Flutterlyzer
|
item.flutterlyzer=Flutterlyzer
|
||||||
storage.backpack.lepidopterist=Lepidopterist's Backpack
|
storage.backpack.lepidopterist=Lepidopterist's Backpack
|
||||||
tile.for.lepidopterology.0=Lepidopterist's Chest
|
tile.for.lepidopterology.name=鱗翅類学者のチェスト
|
||||||
|
tile.for.lepidopterology.0.name=鱗翅類学者のチェスト
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# MAIL
|
# MAIL
|
||||||
|
|||||||
Reference in new issue
Block a user