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

magnet work behavior not as expected. #238

Closed
thefatwhale opened this issue Sep 4, 2024 · 9 comments
Closed

magnet work behavior not as expected. #238

thefatwhale opened this issue Sep 4, 2024 · 9 comments
Labels
question Requesting setup or usage information

Comments

@thefatwhale
Copy link

LWC Version (/lwc admin version):

/lwc admin version
Main plugin: 2.4.0

Server version (/version):

/version
This server is running Paper version git-Paper-497 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: d8d54d9 on ver/1.20.4)

Short five word summary of issue:

magnet work behavior not as expected.

Detailed description of problem:

Dropped items for multiple nearby containers with the magnet flag turned on always try to deposit into one of them, even if that container is full and the others are empty.

To reproduce this.

  1. Place 2 barrel blocks on the ground (next to each other).
  2. Use /cmagnet on to turn on magnet flag for this 2 blocks.
  3. Drop items to barrel block, make sure it full. And another is empty.
  4. Continue drop item on the ground, next to this 2 barrel block, Item try to enter the full barrel, not the empty one.

This doesn't match my expected behaviour, so should this be a bug or is it a deliberate?

I'm trying to modify this part of the code, but I'm having some problems.Would you mind helping me if it's not too much trouble?

My English is not very good, some sentences may be problematic, I use translation software, forgive me!

Thanks!

@pop4959
Copy link
Owner

pop4959 commented Sep 4, 2024

I'm not aware of this bug but if you make a PR I would accept it. Your expected behavior aligns with what I would expect here.

Keep in mind that of course, the item must be within the configured magnet distance to the barrel. So if it is "out of range" of the second barrel, it will not enter that barrel.

@pop4959 pop4959 added the problem label Sep 4, 2024
@thefatwhale
Copy link
Author

thefatwhale commented Sep 4, 2024

Thanks for your reply.

I'm confused by some of the code,

In src\main\java\com\griefcraft\lwc\LWC.java file
depositItems method Line 465.

if (inventory.getItem(0) != null && inventory.getItem(1) != null) {
    if (inventory.getItem(0).getType() == itemStack.getType()
            && inventory.getItem(0)
            .getMaxStackSize() >= (inventory.getItem(0).getAmount() + itemStack.getAmount())) {
        // ItemStack fits on Slot 0
    } else if (inventory.getItem(1).getType() == itemStack.getType()
            && inventory.getItem(1)
            .getMaxStackSize() >= (inventory.getItem(1).getAmount() + itemStack.getAmount())) {
        // ItemStack fits on Slot 1
    } else {
        return null;
    }
}

why returning null instead of empty may? what is the sepcial meaning?

And if source slot has 2 iron ore, fuel slot has some coal. Player Drop iron ore * 64 on the ground. this will ignore and return null. But I think iron ores can stack deposit into source slot.

I'm a little confused about this part of the code, what's the special meaning of null? please help me, thanks!

Resolved, null means that no item has been deposit in the container and the drop should remain as it is.

@thefatwhale
Copy link
Author

thefatwhale commented Sep 4, 2024

Another thing I don't understand is about /lwc mode droptransfer feature.
this two feature use same method, I'm considering whether modifying the code will affect this feature execution of this function

In file src\main\java\com\griefcraft\modules\modes\DropTransferModule.java
method onDropItem line 138

if (remaining == null || remaining.size() > 0) {
    lwc.sendLocale(player, "lwc.dropxfer.chestfull");
    event.getEvent().setCancelled(true);
}

is clearly not told how many remaining items to return to the player, but it can be returned correctly.
How it works?
Thanks.

Resolved, the amount returned is related to the amount of Itemstacks in the context. Even if no parameters are passed explicitly

@pop4959 pop4959 added question Requesting setup or usage information and removed problem labels Sep 4, 2024
@pop4959
Copy link
Owner

pop4959 commented Sep 4, 2024

The feature works as intended. I'm not sure why you need to modify it if it's working correctly.

@pop4959 pop4959 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2024
@thefatwhale
Copy link
Author

I mean the droptransfer feature in command /lwc mode droptransfer not magnet feature.
droptransfer can work well on the amount of items refunded to the player. but I don't know why.
Both feature use the same method, so I would like to ask. Make sure I don't break anything

I'm just trying to figure it out so that I can modify it without unexpected problems.
I apologize for any misunderstanding. I will try to resolve it myself.

@rautamiekka
Copy link

Mod 2.4.0 explicitly says it only works on game 1.20.6-1.21.x but you're on 1.20.4.

@thefatwhale
Copy link
Author

thefatwhale commented Sep 4, 2024

Mod 2.4.0 explicitly says it only works on game 1.20.6-1.21.x but you're on 1.20.4.

It updated it two days ago (API version), In theory, in the new version, it is not possible to work as expected. You might as well test it.

Maybe in the update two days ago, the author forgot to change the version number. It still 2.4.0.

@pop4959

@thefatwhale
Copy link
Author

Other bugs about the magnet feature

  1. magnet on furnace-like Incorrect storage behavior (Fill the fuel slot with non-fuel items, and fill the result slot with items)
  2. magnet flag can turn on on all protection block,Even if it doesn't a container type(such as composter,doors;gates;trapdoors,sign and the block locked by sign)

thefatwhale added a commit to thefatwhale/LWCX that referenced this issue Sep 6, 2024
- magnet flag can turn on, on non-container block.
- magnet feature behavior is incorrect with mult container.
- magnet feature behavior is incorrect with furnace-like.

- droptransfer feature can bind with non-container block.
- droptransfer feature cleared item when bind a non-container block.
- droptransfer feature can nested shulker box.
@thefatwhale
Copy link
Author

A pull request is created.

#240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Requesting setup or usage information
Projects
None yet
Development

No branches or pull requests

3 participants