mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-22 04:52:26 +00:00
Fix #181: Letters sent to yourself disappear in Single Player
This commit is contained in:
1 parent
d459856852
commit
7f50c7e929
4 files changed
+17
-40
No files matched your search
@@ -18,6 +18,7 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -80,25 +81,15 @@ public class MachineMailbox extends TileBase implements IMailContainer, ISpecial
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
if (!isLinked) {
|
||||
getOrCreateMailInventory();
|
||||
getOrCreateMailInventory(worldObj, getOwnerProfile());
|
||||
isLinked = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* MAIL HANDLING */
|
||||
public IInventory getOrCreateMailInventory() {
|
||||
return getOrCreateMailInventory(null);
|
||||
}
|
||||
public IInventory getOrCreateMailInventory(EntityPlayer player) {
|
||||
|
||||
GameProfile playerProfile;
|
||||
if (player != null) {
|
||||
playerProfile = player.getGameProfile();
|
||||
} else {
|
||||
playerProfile = getOwnerProfile();
|
||||
}
|
||||
|
||||
if (playerProfile == null)
|
||||
public IInventory getOrCreateMailInventory(World world, GameProfile playerProfile) {
|
||||
if (!Proxies.common.isSimulating(world))
|
||||
return new InventoryAdapter(POBox.SLOT_SIZE, "Letters");
|
||||
|
||||
IMailAddress address = PostManager.postRegistry.getMailAddress(playerProfile);
|
||||
@@ -121,7 +112,7 @@ public class MachineMailbox extends TileBase implements IMailContainer, ISpecial
|
||||
@Override
|
||||
public boolean hasMail() {
|
||||
|
||||
IInventory mailInventory = getOrCreateMailInventory();
|
||||
IInventory mailInventory = getOrCreateMailInventory(worldObj, getOwnerProfile());
|
||||
for (int i = 0; i < mailInventory.getSizeInventory(); i++)
|
||||
if (mailInventory.getStackInSlot(i) != null)
|
||||
return true;
|
||||
@@ -137,19 +128,6 @@ public class MachineMailbox extends TileBase implements IMailContainer, ISpecial
|
||||
return res;
|
||||
}
|
||||
|
||||
/* ISIDEDINVENTORY */
|
||||
private static int[] slotIndices;
|
||||
|
||||
public int[] getSizeInventorySide(int side) {
|
||||
IInventory inventory = getOrCreateMailInventory();
|
||||
if(slotIndices == null) {
|
||||
slotIndices = new int[inventory.getSizeInventory()];
|
||||
for(int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
slotIndices[i] = i;
|
||||
}
|
||||
return slotIndices;
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
@Override
|
||||
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
|
||||
@@ -168,7 +146,7 @@ public class MachineMailbox extends TileBase implements IMailContainer, ISpecial
|
||||
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
|
||||
ItemStack product = null;
|
||||
IInventory mailInventory = getOrCreateMailInventory();
|
||||
IInventory mailInventory = getOrCreateMailInventory(worldObj, getOwnerProfile());
|
||||
|
||||
for (int i = 0; i < mailInventory.getSizeInventory(); i++) {
|
||||
ItemStack slotStack = mailInventory.getStackInSlot(i);
|
||||
|
||||
Reference in new issue
Block a user