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

Introspection module voids items when player is offline #85

Open
lexi-the-cute opened this issue Jan 15, 2024 · 8 comments
Open

Introspection module voids items when player is offline #85

lexi-the-cute opened this issue Jan 15, 2024 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@lexi-the-cute
Copy link

lexi-the-cute commented Jan 15, 2024

When logging off on a server, items from the introspected chest inventory slot get voided

Reproduce:

  • download debug-server.zip

  • install fabric, etc...

  • fill up the chest inventory to full after filling up the player inventory

  • drop an item from the introspected player inventory slot on the floor

  • log off

  • after about 30 seconds to 5 minutes, log onto the server

  • check the chest inventory

Server Info:

  • Minecraft: 1.20.1
  • Fabric Loader: 0.15.4

Mods:

Relevant Information (also included in debug-server.zip):

function main()
    -- todo: implement way of detecting existing slots to top up
    -- todo: implement multi user support
    term.clear()
    print('"Item Shadowing" Running...')

    status, inv = xpcall(getInventory, errorHandler)
    while not status do
        status, inv = xpcall(getInventory, errorHandler)
        sleep(1)
    end

    while true do
        -- call function with error handler
        status = xpcall(shadowItems, errorHandler)

        -- sleep for 1 second
        sleep(1)
    end
end

function getInventory()
    local introspector = peripheral.wrap("top")
    return introspector.getInventory()
end

function shadowItems()
    -- chicken
    inv.pullItems("left", 1, 64, 9)

    -- rockets
    --inv.pullItems("right", 1, 64, 8)
end

function errorHandler(err)
    -- most likely the player went offline
    -- print("Error: " .. err)
end

main()
@Lemmmy
Copy link
Member

Lemmmy commented Jan 15, 2024

Duplicate/regression of #31

@Lemmmy
Copy link
Member

Lemmmy commented Jan 15, 2024

Can you share the code you used to reproduce as a code snippet in the issue?

@Lemmmy Lemmmy changed the title [Critical Bug]: Introspection Module Voids Items When Player is Offline Introspection module voids items when player is offline Jan 15, 2024
@Lemmmy
Copy link
Member

Lemmmy commented Mar 12, 2024

I know that a few players have run into this on SwitchCraft (especially recently), but I still can't reproduce this at all. Your world download isn't working for me, can you think of any other steps that might be involved?

This is the code I'm testing with:

local chest = peripheral.wrap("right")
local manip = peripheral.wrap("left")

sleep(5)

local status, inv = pcall(manip.getInventory)
while not status do
  status, inv = pcall(manip.getInventory)
  sleep(1)
end

while true do
  local ok, count = pcall(inv.pullItems, "right", 1, 64, 1)
  print("transferred", ok, count)
  sleep(1)
end

I've tried following your steps exactly. I've also tried logging off before getInventory is called, I've tried logging off after getInventory is called, I've tried logging off at different times, I've tried not dropping an item, I've tried having an empty inventory, I've tried saving after dropping but before logging off, I've tried saving after logging off.

In all my test cases, the game is correctly throwing "The entity is no longer there" when the player is offline, and not transferring/voiding any items.

@Lemmmy Lemmmy added help wanted Extra attention is needed bug Something isn't working labels Mar 12, 2024
@scmcgowen
Copy link

If you have a backup of my computer before I made the fix, you can use the program for that. it is known to trigger the bug

@Lemmmy
Copy link
Member

Lemmmy commented Mar 12, 2024

An isolated case would be more helpful if possible

@scmcgowen
Copy link

if you could send me the file, I'll cut out anything that isn't related to my autofeeder. I wiped the computer before installing hopper.lua

@scmcgowen
Copy link

scmcgowen commented Mar 12, 2024

local function handleBaseSlot()
    while true do
        sleep(0.5)
        local lst = inv.list()
        --if lst[36] then
          --  inv.pushItems("left",36)
        --end
        if not lst[18] or lst[18].count < 64 then
            inv.pullItems("ender_storage_6461",1,64,18)
        end

    end
end

is the code, make sure the chunk this is running on is loaded

@Lemmmy
Copy link
Member

Lemmmy commented Mar 13, 2024

Update from conversation on Discord: still no luck with the above program. Also tried ender storages, rebooting the computer instead of pcalling, far away chunks that weren't spawn loaded, partial slots (having half a stack before logging off)

This test program:

startup.lua

while true do
  parallel.waitForAny(function() shell.run("main.lua") end)
  sleep(2)
end

main.lua

local chest = peripheral.wrap("right")
local manip = peripheral.wrap("left")

local inv = manip.getInventory()

while true do
  sleep(0.5)
  local lst = inv.list()
  if not lst[18] or lst[18].count < 64 then
    inv.pullItems("right", 1, 64, 18)
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants