Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The letter bug1.12--get unlimited item in server #2205

Open
Akr-on opened this issue Jul 25, 2018 · 5 comments
Open

The letter bug1.12--get unlimited item in server #2205

Akr-on opened this issue Jul 25, 2018 · 5 comments

Comments

@Akr-on
Copy link

Akr-on commented Jul 25, 2018

in the past,the bag and analyse machine in hand could get unlimited item by the fast switch in server.
if you switch to the B-bag during you open the A-bag,the item in A-bag may copy to B-bag and you can take..........
if the link delay was higher,the bug used easier
I know you had repair it ,but you forget the Letter---forestry:letter
the same bug with it in server
I hope it can be repaired, thanks

@Akr-on
Copy link
Author

Akr-on commented Jul 31, 2018

no ,all of that thing like bag have this bug。Haven't repaired

@Nedelosk
Copy link
Member

Nedelosk commented Mar 3, 2020

Could you please give more information about this bug?

@Nedelosk
Copy link
Member

Nedelosk commented Apr 1, 2020

Closed because of no response.

@Nedelosk Nedelosk closed this as completed Apr 1, 2020
@DBotThePony
Copy link

DBotThePony commented Apr 7, 2020

@Nedelosk Create several identical letters addressed one person with stamps and item payload. Then send them using mailbox. Sender will send letters one-by-one, while receiver will receive SUM(N, N - 1, N->0) letters (Example: Sender make and send 6 letters, receiver get 21 letter)

@DBotThePony
Copy link

Code analysis:

You do check letter send status, and if it is successfull, shrink item stack size by 1
https://github.com/ForestryMC/ForestryMC/blob/mc-1.12/src/main/java/forestry/mail/tiles/TileMailbox.java#L61-L68

But you pass full itemstack to tryDispatchLetter method, which pass itemstack to PostManager.postRegistry.getPostOffice(world).lodgeLetter, and it's code is

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;
}
if (!letter.isPostPaid()) {
return EnumDeliveryState.NOT_POSTPAID;
}
if (!letter.isMailable()) {
return EnumDeliveryState.NOT_MAILABLE;
}
IPostalState state = EnumDeliveryState.NOT_MAILABLE;
IMailAddress address = letter.getRecipient();
if (address != null) {
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType());
if (carrier != null) {
state = carrier.deliverLetter(world, this, address, itemstack, doLodge);
}
}
if (!state.isOk()) {
return state;
}
collectPostage(letter.getPostage());
markDirty();
return EnumDeliveryState.OK;
}

It call to
public IPostalState deliverLetter(World world, IPostOffice office, IMailAddress recipient, ItemStack letterStack, boolean doDeliver) {

which obviously call storeInPOBox
private static EnumDeliveryState storeInPOBox(World world, IMailAddress recipient, ItemStack letterStack) {

However, we copy original stack with full amount of letters in it

if (!pobox.storeLetter(letterStack.copy())) {

plz fix

@Nedelosk Nedelosk reopened this Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants