Jump to content

Recommended Posts

Posted

I am trying to use the functions that SlotCrafting/ItemBucket use, namely addItemStackToInventory (in InventoryPlayer) and dropPlayerItem (in EntityPlayer). I'm trying to do so from the right-click handler of an Item, passing the EntityPlayer provided in that call.

 

On both the integrated and dedicated servers, addItemStackToInventory will add the items to the inventory in appearance, but when thrown or selected will revert the inventory to its previous state, and dropPlayerItem seems to do nothing at all. The uses of these functions in SlotCrafting and ItemBucket work just fine, though.

 

What I'm trying to do is, on right-clicking of the item on particular blocks, decrement the stack size of the item and add a new item to the inventory based on what block was clicked.

 

Where/how is the client/server inventory synchronization occurring, and how can I manually invoke it?

Posted

I don't know how/where it is done in vanilla code, but you can always try sending packets. This is as far as my knowledge about packets goes though, so you might want to wait for other people to help you with that.

Posted

I've considered a packet solution, but it got needlessly complicated very quickly, in that I have to send a packet that says "Current player used item X in hotbar slot Y on block Z" and the server has to 1) check for and consume one of the item in that hotbar slot if present, 2) try to find the item elsewhere in the inventory if it's changed in between sending the packet, 3) fail the operation (and somehow notify the client of this failure, which by the time it's happened could involve altered client state) if the item is not in the server inventory, then generate the new item in the server-side inventory, then send a packet back to the client about where the item (should have) ended up.

 

It's nuts. I had a look at Forestry which recently came out for 1.3, and his code for un-crating an item on right-click doesn't do any of this, but then again, I can't seem to actually make a crated item to test with, so maybe that hasn't been updated yet.

 

There has to be some better way than this around-the-world journey.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • i was playing a custom modpack and i cant open the world anymore.  here are the logs :  [15:28:31] [Server thread/ERROR]:Encountered an unexpected exception net.minecraftforge.fml.config.ConfigFileTypeHandler$ConfigLoadingException: Failed loading config file jei-server.toml of type SERVER for modid jei at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:47) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] at net.minecraftforge.fml.config.ConfigTracker.openConfig(ConfigTracker.java:60) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] at net.minecraftforge.fml.config.ConfigTracker.lambda$loadConfigs$1(ConfigTracker.java:50) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2131) ~[?:?] at net.minecraftforge.fml.config.ConfigTracker.loadConfigs(ConfigTracker.java:50) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] at net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(ServerLifecycleHooks.java:96) ~[forge-1.20.1-47.4.0-universal.jar%23309!/:?] at net.minecraft.client.server.IntegratedServer.m_7038_(IntegratedServer.java:62) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:634) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at java.lang.Thread.run(Thread.java:840) ~[?:?] Caused by: com.electronwill.nightconfig.core.io.ParsingException: Not enough data available at com.electronwill.nightconfig.core.io.ParsingException.notEnoughData(ParsingException.java:22) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.ReaderInput.directReadChar(ReaderInput.java:36) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.AbstractInput.readChar(AbstractInput.java:49) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.AbstractInput.readCharsUntil(AbstractInput.java:123) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.toml.TableParser.parseKey(TableParser.java:166) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:145) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.file.WriteSyncFileConfig.load(WriteSyncFileConfig.java:73) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.file.AutosaveCommentedFileConfig.load(AutosaveCommentedFileConfig.java:85) ~[core-3.6.4.jar%2393!/:?] at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:43) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] ... 10 more [15:28:31] [Server thread/FATAL]:Preparing crash report with UUID 2a3982ea-90f2-492d-85e7-f1cb63906dcb [15:28:31] [Server thread/ERROR]:This crash report has been saved to: C:\Users\gueri\curseforge\minecraft\Instances\modpack je sais pas\crash-reports\crash-2025-05-29_15.28.31-server.txt [15:28:31] [Server thread/INFO]:Stopping server [15:28:31] [Server thread/INFO]:Saving players [15:28:31] [Server thread/INFO]:Saving worlds [15:28:31] [Server thread/ERROR]:Exception stopping the server java.lang.NullPointerException: Cannot invoke "net.minecraft.server.level.ServerLevel.m_6857_()" because "serverlevel2" is null at net.minecraft.server.MinecraftServer.m_129885_(MinecraftServer.java:513) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_7041_(MinecraftServer.java:584) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.client.server.IntegratedServer.m_7041_(IntegratedServer.java:187) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:689) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at java.lang.Thread.run(Thread.java:840) ~[?:?]
    • Add the crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here  
    • I recently updated my mods for prominence 2 and instead of opening like usual it just crashes. I already disable any incompatible mods and I don't know what to do. If anyone could help that would be nice. Thanks Latest log:https://mclo.gs/jsuIlZX
    • I dont know how I can elaborate more, just every time I try to create a new instance where its forge, its 1.20.1 and the forge version is 47.4.1 it doesnt work. Im really confused because it works for my friend he even showed it to me. This is on modrinth btw
  • Topics

×
×
  • Create New...

Important Information

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