Jump to content

1.12.2 item transfer without slots


Johnson1893

Recommended Posts

Hey! I apologize for the quality of the language - English is not my main language and I use a translator. I will be glad if you will correct me and speak simply.

 

For my purposes, to make a system like Applied Energystics, and at the moment I am solving the problem of the terminal GUI.

In similar mods, the storage grid GUI is made of slots, which seems to me not very attractive and crutch.

I just render GUI and stacks directly and capture mouse clicks.

When I click on an item, I send a packet to the server indicating the item and button. Further, the network puts the item for storage, and everything that it has not stored (or an empty stack) points to the player’s server representation and sends it to the client, where the client representation is similarly affixed.

Tell me, how bad is this method and what could I ignore?

 

PckGridTransfer (from client to server)
    override fun onMessage(message: PckGridTransfer, ctx: MessageContext): IMessage? {
        val player = ctx.serverHandler.player
        val world = player.world as WorldServer
        world.addScheduledTask {
            // todo! check player has this item as holded
            val host = ((player.openContainer as? AFactoryContainerNew<*>)?.tileEntity as? AFactoryTileGrid)?.host ?: return@addScheduledTask
            // todo! message.push
            val resultStack = host.storageProxy.putItemStackToStorage(message.stack, message.mouseButton)
            player.inventory.itemStack = resultStack
            TheMyMod.packetToPlayer(PckGridTransferResult(resultStack), player)
        }
        return null
    }

 

PckGridTransferResult (from server to client)
    override fun onMessage(message: PckGridTransferResult, ctx: MessageContext): IMessage? {
        Minecraft.getMinecraft().addScheduledTask {
            Minecraft.getMinecraft().player.inventory.itemStack = message.stack
        }
        return null
    }

 

Edited by Johnson1893
Link to comment
Share on other sites

Just because slots are crouch here. Terminals has no slots actually, and it not storing items in this fake-slots - AE2,RS and same mods actually stored it somewhere else, not in slots. They needed slots only for displaying stacks. Also they makes another crouches on this crouches to prevent sorting, and another type of container interaction by another mods (InventoryTweaks etc.).

So, if we not storing stacks in slots - we dont need slots, isnt it?

Edited by Johnson1893
Link to comment
Share on other sites

On closing the UI, give the player all the items "stored" in the TE.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.