mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-24 22:04:34 +00:00
1 parent
85b4071938
commit
987799d103
4 files changed
+21
-26
No files matched your search
@@ -40,17 +40,18 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
|
||||
// / CONSTANTS
|
||||
public static final String SAVE_NAME = "TradePO_";
|
||||
public static final short SLOT_SIZE = 39;
|
||||
public static final short SLOT_TRADEGOOD = 0;
|
||||
public static final short SLOT_TRADEGOOD_COUNT = 1;
|
||||
public static final short SLOT_EXCHANGE_1 = 1;
|
||||
public static final short SLOT_EXCHANGE_COUNT = 4;
|
||||
public static final short SLOT_LETTERS_1 = 5;
|
||||
public static final short SLOT_LETTERS_COUNT = 6;
|
||||
public static final short SLOT_STAMPS_1 = 11;
|
||||
public static final short SLOT_STAMPS_COUNT = 4;
|
||||
public static final short SLOT_INPUTBUF_1 = 15;
|
||||
public static final short SLOT_OUTPUTBUF_1 = 27;
|
||||
public static final short SLOT_BUFFER_COUNT = 12;
|
||||
public static final short SLOT_BUFFER = 15;
|
||||
public static final short SLOT_BUFFER_COUNT = 30;
|
||||
public static final short SLOT_SIZE = SLOT_TRADEGOOD_COUNT + SLOT_EXCHANGE_COUNT + SLOT_LETTERS_COUNT + SLOT_STAMPS_COUNT + SLOT_BUFFER_COUNT;
|
||||
|
||||
// / MEMBER
|
||||
private GameProfile owner;
|
||||
private MailAddress address;
|
||||
@@ -235,7 +236,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
inventory.tryAddStack(stack.copy(), SLOT_OUTPUTBUF_1, SLOT_BUFFER_COUNT, false);
|
||||
inventory.tryAddStack(stack.copy(), SLOT_BUFFER, SLOT_BUFFER_COUNT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +276,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
|
||||
// How many orders are fillable?
|
||||
int itemCount = 0;
|
||||
for (ItemStack stack : inventory.getStacks(SLOT_INPUTBUF_1, SLOT_BUFFER_COUNT)) {
|
||||
for (ItemStack stack : inventory.getStacks(SLOT_BUFFER, SLOT_BUFFER_COUNT)) {
|
||||
if (stack != null && stack.isItemEqual(tradegood) && ItemStack.areItemStackTagsEqual(stack, tradegood))
|
||||
itemCount += stack.stackSize;
|
||||
}
|
||||
@@ -302,7 +303,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
|
||||
for (int j = 0; j < filled; j++) {
|
||||
int toRemove = inventory.getStackInSlot(SLOT_TRADEGOOD).stackSize;
|
||||
for (int i = SLOT_INPUTBUF_1; i < SLOT_INPUTBUF_1 + SLOT_BUFFER_COUNT; i++) {
|
||||
for (int i = SLOT_BUFFER; i < SLOT_BUFFER + SLOT_BUFFER_COUNT; i++) {
|
||||
ItemStack buffer = inventory.getStackInSlot(i);
|
||||
if (buffer == null)
|
||||
continue;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class MachineTrader extends TileBase implements ISpecialInventory, ISided
|
||||
if (worldObj.getTotalWorldTime() % 40 * 10 != 0)
|
||||
return;
|
||||
|
||||
if (!hasPaperMin(0.0f) || !hasInputBufMin(0.0f)) {
|
||||
if (!hasPaperMin(0.0f) || !hasBufMin(0.0f)) {
|
||||
setErrorState(EnumErrorCode.NORESOURCE);
|
||||
return;
|
||||
}
|
||||
@@ -132,12 +132,8 @@ public class MachineTrader extends TileBase implements ISpecialInventory, ISided
|
||||
return percentOccupied(TradeStation.SLOT_LETTERS_1, TradeStation.SLOT_LETTERS_COUNT) > percentage;
|
||||
}
|
||||
|
||||
public boolean hasInputBufMin(float percentage) {
|
||||
return percentOccupied(TradeStation.SLOT_INPUTBUF_1, TradeStation.SLOT_BUFFER_COUNT) > percentage;
|
||||
}
|
||||
|
||||
public boolean hasOutputBufMin(float percentage) {
|
||||
return percentOccupied(TradeStation.SLOT_OUTPUTBUF_1, TradeStation.SLOT_BUFFER_COUNT) > percentage;
|
||||
public boolean hasBufMin(float percentage) {
|
||||
return percentOccupied(TradeStation.SLOT_BUFFER, TradeStation.SLOT_BUFFER_COUNT) > percentage;
|
||||
}
|
||||
|
||||
public boolean hasPostageMin(int postage) {
|
||||
@@ -231,7 +227,7 @@ public class MachineTrader extends TileBase implements ISpecialInventory, ISided
|
||||
if (!tradegood.isItemEqual(stack))
|
||||
return 0;
|
||||
|
||||
return StackUtils.addToInventory(stack, inventory, doAdd, TradeStation.SLOT_INPUTBUF_1, TradeStation.SLOT_BUFFER_COUNT);
|
||||
return StackUtils.addToInventory(stack, inventory, doAdd, TradeStation.SLOT_BUFFER, TradeStation.SLOT_BUFFER_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -242,7 +238,7 @@ public class MachineTrader extends TileBase implements ISpecialInventory, ISided
|
||||
|
||||
ItemStack product = null;
|
||||
IInventory inventory = getOrCreateTradeInventory();
|
||||
for (int i = TradeStation.SLOT_OUTPUTBUF_1; i < TradeStation.SLOT_OUTPUTBUF_1 + TradeStation.SLOT_BUFFER_COUNT; i++) {
|
||||
for (int i = TradeStation.SLOT_BUFFER; i < TradeStation.SLOT_BUFFER + TradeStation.SLOT_BUFFER_COUNT; i++) {
|
||||
ItemStack stackSlot = inventory.getStackInSlot(i);
|
||||
if (stackSlot == null)
|
||||
continue;
|
||||
@@ -278,7 +274,7 @@ public class MachineTrader extends TileBase implements ISpecialInventory, ISided
|
||||
if(!super.canTakeStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
if(slotIndex >= TradeStation.SLOT_OUTPUTBUF_1 && slotIndex < TradeStation.SLOT_OUTPUTBUF_1 + TradeStation.SLOT_BUFFER_COUNT)
|
||||
if(slotIndex >= TradeStation.SLOT_BUFFER && slotIndex < TradeStation.SLOT_BUFFER + TradeStation.SLOT_BUFFER_COUNT)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -298,7 +294,7 @@ public class MachineTrader extends TileBase implements ISpecialInventory, ISided
|
||||
return itemstack.getItem() instanceof IStamps;
|
||||
}
|
||||
|
||||
if (slotIndex >= TradeStation.SLOT_INPUTBUF_1 && slotIndex < TradeStation.SLOT_BUFFER_COUNT) {
|
||||
if (slotIndex >= TradeStation.SLOT_BUFFER && slotIndex < TradeStation.SLOT_BUFFER_COUNT) {
|
||||
IInventory inventory = getOrCreateTradeInventory();
|
||||
ItemStack tradegood = inventory.getStackInSlot(TradeStation.SLOT_TRADEGOOD);
|
||||
if(tradegood == null)
|
||||
|
||||
@@ -51,15 +51,13 @@ public class ContainerTrader extends ContainerForestry {
|
||||
for (int j = 0; j < 2; j++)
|
||||
addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, new Object[] { Items.paper }));
|
||||
|
||||
// Input buffer
|
||||
for (int i = 0; i < 6; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
addSlot(new Slot(inventory, TradeStation.SLOT_INPUTBUF_1 + j + i * 2, 123 + j * 18, 19 + i * 18));
|
||||
// Buffer
|
||||
final int bufRows = 6;
|
||||
final int bufCols = 5;
|
||||
for (int i = 0; i < bufRows; i++)
|
||||
for (int j = 0; j < bufCols; j++)
|
||||
addSlot(new Slot(inventory, TradeStation.SLOT_BUFFER + j + i * bufCols, 123 + j * 18, 19 + i * 18));
|
||||
|
||||
// Output buffer
|
||||
for (int i = 0; i < 6; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
addSlot(new SlotClosed(inventory, TradeStation.SLOT_OUTPUTBUF_1 + j + i * 2, 177 + j * 18, 19 + i * 18));
|
||||
|
||||
// Player inventory
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
||||
Reference in new issue
Block a user