mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Update for 1.11. Missing assets, unstable.
This commit is contained in:
1 parent
30d7365518
commit
9611ae08ae
1145 files changed
+15561
-18107
No files matched your search
@@ -15,6 +15,7 @@ import java.util.LinkedHashMap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
@@ -34,12 +35,14 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
// / CONSTANTS
|
||||
public static final String SAVE_NAME = "ForestryMail";
|
||||
private final int[] collectedPostage = new int[EnumPostage.values().length];
|
||||
private LinkedHashMap<IMailAddress, ITradeStation> activeTradeStations = new LinkedHashMap<>();
|
||||
|
||||
// CONSTRUCTORS
|
||||
public PostOffice() {
|
||||
super(SAVE_NAME);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public PostOffice(String s) {
|
||||
super(s);
|
||||
}
|
||||
@@ -66,7 +69,6 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
}
|
||||
|
||||
/* TRADE STATION MANAGMENT */
|
||||
private LinkedHashMap<IMailAddress, ITradeStation> activeTradeStations;
|
||||
|
||||
@Override
|
||||
public LinkedHashMap<IMailAddress, ITradeStation> getActiveTradeStations(World world) {
|
||||
@@ -75,19 +77,18 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
|
||||
private void refreshActiveTradeStations(World world) {
|
||||
activeTradeStations = new LinkedHashMap<>();
|
||||
if (world == null || world.getSaveHandler() == null) {
|
||||
return;
|
||||
}
|
||||
File worldSave = world.getSaveHandler().getMapFileFromName("dummy");
|
||||
if (worldSave == null) {
|
||||
return;
|
||||
}
|
||||
File file = worldSave.getParentFile();
|
||||
if (!file.exists() || !file.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String str : file.list()) {
|
||||
String[] list = file.list();
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String str : list) {
|
||||
if (!str.startsWith(TradeStation.SAVE_NAME)) {
|
||||
continue;
|
||||
}
|
||||
@@ -140,13 +141,16 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
// / DELIVERY
|
||||
@Override
|
||||
public IPostalState lodgeLetter(World world, ItemStack itemstack, boolean doLodge) {
|
||||
ILetter letter = PostManager.postRegistry.getLetter(itemstack);
|
||||
if (letter == null) {
|
||||
return EnumDeliveryState.NOT_MAILABLE;
|
||||
}
|
||||
|
||||
if (letter.isProcessed()) {
|
||||
return EnumDeliveryState.ALREADY_MAILED;
|
||||
@@ -161,14 +165,11 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
}
|
||||
|
||||
IPostalState state = EnumDeliveryState.NOT_MAILABLE;
|
||||
for (IMailAddress address : letter.getRecipients()) {
|
||||
IMailAddress address = letter.getRecipient();
|
||||
if (address != null) {
|
||||
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType());
|
||||
if (carrier == null) {
|
||||
continue;
|
||||
}
|
||||
state = carrier.deliverLetter(world, this, address, itemstack, doLodge);
|
||||
if (!state.isOk()) {
|
||||
break;
|
||||
if (carrier != null) {
|
||||
state = carrier.deliverLetter(world, this, address, itemstack, doLodge);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +185,7 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectPostage(ItemStack[] stamps) {
|
||||
public void collectPostage(NonNullList<ItemStack> stamps) {
|
||||
for (ItemStack stamp : stamps) {
|
||||
if (stamp == null) {
|
||||
continue;
|
||||
@@ -192,7 +193,7 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
|
||||
if (stamp.getItem() instanceof IStamps) {
|
||||
EnumPostage postage = ((IStamps) stamp.getItem()).getPostage(stamp);
|
||||
collectedPostage[postage.ordinal()] += stamp.stackSize;
|
||||
collectedPostage[postage.ordinal()] += stamp.getCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user