But how do I get access to the GUI? I can't really pass it into the container's constructor (or can I?). I can't refer to the vanilla code either because everything there uses a tileentity. What do I do?
It's the other way round - the GUI accesses the Container. Although looking at your GUI again, you should probably have your boolean grid stored in your Container.
If you noticed, in you GUI constructor you pass the Container to the super constructor. If you follow that, you'll see that the container is saved to the variable "inventorySlots" in GuiContainer, so you can use that to access your container on the client side. This is where moving the grid to the Container may help.
Are TileEntity and IInventory similar in terms of using them in Containers?
A tile entity can implement IInventory (as seen in vanilla tile entities and my own in the examples I linked) and then used in the GUI/Container. However in this case, a tile entity is not being used and therefore the inventory is saved in the Container class.
It's the other way round - the GUI accesses the Container. Although looking at your GUI again, you should probably have your boolean grid stored in your Container.
If you noticed, in you GUI constructor you pass the Container to the super constructor. If you follow that, you'll see that the container is saved to the variable "inventorySlots" in GuiContainer, so you can use that to access your container on the client side. This is where moving the grid to the Container may help.
If you noticed I already have a grid in my container. I can't remove the grid from the GUI because I still need to draw the carving slots.
I don't fully understand the concept of updating GUI so could you elaborate a little more on that (examples appreciated).
If you noticed I already have a grid in my container. I can't remove the grid from the GUI because I still need to draw the carving slots.
I don't fully understand the concept of updating GUI so could you elaborate a little more on that (examples appreciated).
Ah right sorry, okay. Well you should be able to just access the grid in your Container directly using that variable. That way there's no need to update the GUI because it's getting it's information from the Container, which is being updated.
Ah right sorry, okay. Well you should be able to just access the grid in your Container directly using that variable. That way there's no need to update the GUI because it's getting it's information from the Container, which is being updated.
I see, but I can't access the grid variable in the gui because it's only Container type, while the grid is in ContainerRuneInscription. And for some reason I can't cast it to be ContainerRuneInscription. Maybe I'm not doing it properly?
Ah right sorry, okay. Well you should be able to just access the grid in your Container directly using that variable. That way there's no need to update the GUI because it's getting it's information from the Container, which is being updated.
Thank you so much! The reason of the item output glitching was because I had 2 methods for updating the output slot (item changed and grid change) which would overlap each other. By removing the packets and GUI grid completely I got rid of one of these methods and now everything is working perfectly!
You're heading straight to the list of credits!
But I have one more final problem. It seems that when I take out the output slot item it instantly disappears from the mouse (even when shift-clicking) and the input slot contents don't even decrease when they should.
EDIT:
If I add a print line to the update method, this is what is printed right after I take the item out:
[23:58:08] [Client thread/INFO] [STDOUT]: [melonslise.runicinscription.common.container.ContainerRuneInscription:onMatrixChanged:86]: Setting output to 1xitem.ItemRuneFirebolt@0 //THIS IS WHEN THE ITEM IS CRAFTED
[23:58:13] [Client thread/INFO] [STDOUT]: [melonslise.runicinscription.common.container.ContainerRuneInscription:onMatrixChanged:86]: Setting output to 1xitem.ItemRuneFirebolt@0 //THIS IS RIGHT AFTER I TAKE THE ITEM OUT AND IT DISAPPEARS
[23:58:13] [Client thread/INFO] [STDOUT]: [melonslise.runicinscription.common.container.ContainerRuneInscription:onMatrixChanged:86]: Setting output to null
I don't really understand what happens. I set all of the methods for changing slots to only check for recipes when the input slot is changed, not the output, but even then I don't understand why the item disappears even when I've taken it out.
Thank you so much! The reason of the item output glitching was because I had 2 methods for updating the output slot (item changed and grid change) which would overlap each other. By removing the packets and GUI grid completely I got rid of one of these methods and now everything is working perfectly!
You're heading straight to the list of credits!
Ah okay, well glad to hear you got that sorted Thanks!
But I have one more final problem. It seems that when I take out the output slot item it instantly disappears from the mouse (even when shift-clicking) and the input slot contents don't even decrease when they should.
EDIT:
If I add a print line to the update method, this is what is printed right after I take the item out:
[23:58:08] [Client thread/INFO] [STDOUT]: [melonslise.runicinscription.common.container.ContainerRuneInscription:onMatrixChanged:86]: Setting output to 1xitem.ItemRuneFirebolt@0 //THIS IS WHEN THE ITEM IS CRAFTED
[23:58:13] [Client thread/INFO] [STDOUT]: [melonslise.runicinscription.common.container.ContainerRuneInscription:onMatrixChanged:86]: Setting output to 1xitem.ItemRuneFirebolt@0 //THIS IS RIGHT AFTER I TAKE THE ITEM OUT AND IT DISAPPEARS
[23:58:13] [Client thread/INFO] [STDOUT]: [melonslise.runicinscription.common.container.ContainerRuneInscription:onMatrixChanged:86]: Setting output to null
I don't really understand what happens. I set all of the methods for changing slots to only check for recipes when the input slot is changed, not the output, but even then I don't understand why the item disappears even when I've taken it out.
Hmm can I see your most recent code for the GUI, container and slot? (I know some are back in past posts, but they're way back and I don't know if you've changed them :P)
Ah okay, well glad to hear you got that sorted Thanks!
Hmm can I see your most recent code for the GUI, container and slot? (I know some are back in past posts, but they're way back and I don't know if you've changed them :P)
Btw in your container, why are you setting all of your values in your grid to false? This is unnecessary as when you open the GUI again, it gets a new instance of the GUI so setting the values to false is redundant.
I've looked through your classes and have been comparing them to my own and I can't really find anything wrong unfortunately. I've probably overlooked something, but I do remember the difficulty I had when making my first custom crafting table, and I had strange issues like this. Unfortunately I don't remember the issues and how to fix them anymore, but I hope you manage to figure them out!
Perhaps someone else will have an answer - might be best to create a new thread and find out (nobody is going to try catch up on a 90 post long thread ;D).
The problem is that you are setting your output item only on the client side. So the server doesn't even know about it what will cause a lot of glitches. In your ContainerRuneInscription#onMatrixChanged you also wanna update the server side.
The problem is that you are setting your output item only on the client side. So the server doesn't even know about it what will cause a lot of glitches. In your ContainerRuneInscription#onMatrixChanged you also wanna update the server side.
Nice Greetings
TechMage66
That seems like a reason. But how I update it server side? I thought the container was server side already. And I thought that the setInventorySlotContents is server side compatible too.
EDIT:
The workbench code is doing mostly the same as I am. Or have I missed something?
You'll probably have to use a packet for that ... Actually I think its enough if you set the output item only on the server side, because the container will update the client on it's own (At least how far I know .... or are only TE's doing that)
The container is both sided. It should be only updated by the server side but can be accessed by the client as well.
I hope I don't mess something up with TE and Container ... has been a while since a last done some actual coding on minecraft ;(
You'll probably have to use a packet for that ... Actually I think its enough if you set the output item only on the server side, because the container will update the client on it's own (At least how far I know .... or are only TE's doing that)
The container is both sided. It should be only updated by the server side but can be accessed by the client as well.
I hope I don't mess something up with TE and Container ... has been a while since a last done some actual coding on minecraft ;(
Nice Greetings
TechMage66
Wait, so I'm kind of lost here. How do I set the item only on the server side? Throw a sideonly tag or something else?
In your GUI you are using this.containerInscription.grid[x][y] = true; to update the grid in your container. But this will only update your container on the client side (Because your GUI is only client side). So instead of using this you wanna send a packet to the server which will update the grid of your container and then call ContainerRuneInscription#onMatrixChanged to get your output item. As I said before the container should update it's server side on it's own.
In your GUI you are using this.containerInscription.grid[x][y] = true; to update the grid in your container. But this will only update your container on the client side (Because your GUI is only client side). So instead of using this you wanna send a packet to the server which will update the grid of your container and then call ContainerRuneInscription#onMatrixChanged to get your output item. As I said before the container should update it's server side on it's own.
If you need more info free feel to ask
Nice Greetings
TechMage66
Woah! So removing that packet was a bad idea. I re implemented a packet with some little changes (if anyone is interested I will upload the final working version to github).
EDIT:
There are no graphical gliches anymore, but I am getting two runes everytime I craft (they are not in one stack, but on top of each other).
I seem to have fixed the duplicate issue by removing the onMatrixChanged method from the inventory completely and adding it to the onSlotChanged method from my slot (also checked if slot number is 0). I don't understand why though.
Are TileEntity and IInventory similar in terms of using them in Containers?
Honestly, I don't know, but why does that matter? I'm trying to update the GUI, not the IInventory.
It's the other way round - the GUI accesses the Container. Although looking at your GUI again, you should probably have your boolean grid stored in your Container.
If you noticed, in you GUI constructor you pass the Container to the super constructor. If you follow that, you'll see that the container is saved to the variable "inventorySlots" in GuiContainer, so you can use that to access your container on the client side. This is where moving the grid to the Container may help.
A tile entity can implement IInventory (as seen in vanilla tile entities and my own in the examples I linked) and then used in the GUI/Container. However in this case, a tile entity is not being used and therefore the inventory is saved in the Container class.
If you noticed I already have a grid in my container. I can't remove the grid from the GUI because I still need to draw the carving slots.
I don't fully understand the concept of updating GUI so could you elaborate a little more on that (examples appreciated).
Ah right sorry, okay. Well you should be able to just access the grid in your Container directly using that variable. That way there's no need to update the GUI because it's getting it's information from the Container, which is being updated.
I see, but I can't access the grid variable in the gui because it's only Container type, while the grid is in ContainerRuneInscription. And for some reason I can't cast it to be ContainerRuneInscription. Maybe I'm not doing it properly?
Can't cast what?
Well, I can't do
so I tried casting it
Is is not possible or is it just my poor java knowledge?
EDIT:
Stupid me. I got it working by doing
Thank you so much! The reason of the item output glitching was because I had 2 methods for updating the output slot (item changed and grid change) which would overlap each other. By removing the packets and GUI grid completely I got rid of one of these methods and now everything is working perfectly!
You're heading straight to the list of credits!
But I have one more final problem. It seems that when I take out the output slot item it instantly disappears from the mouse (even when shift-clicking) and the input slot contents don't even decrease when they should.
EDIT:
If I add a print line to the update method, this is what is printed right after I take the item out:
I don't really understand what happens. I set all of the methods for changing slots to only check for recipes when the input slot is changed, not the output, but even then I don't understand why the item disappears even when I've taken it out.
Ah okay, well glad to hear you got that sorted Thanks!
Hmm can I see your most recent code for the GUI, container and slot? (I know some are back in past posts, but they're way back and I don't know if you've changed them :P)
Yeah, I've changed them quite a lot.
GUI
http://pastebin.com/HMwhRdCC
Container
http://pastebin.com/b5unUU7d
Inventory
http://pastebin.com/HEcH2Bsn
Slot (lol pastes ran out on pastebin)
http://hastebin.com/axebusigic.java
Btw in your container, why are you setting all of your values in your grid to false? This is unnecessary as when you open the GUI again, it gets a new instance of the GUI so setting the values to false is redundant.
I've looked through your classes and have been comparing them to my own and I can't really find anything wrong unfortunately. I've probably overlooked something, but I do remember the difficulty I had when making my first custom crafting table, and I had strange issues like this. Unfortunately I don't remember the issues and how to fix them anymore, but I hope you manage to figure them out!
Perhaps someone else will have an answer - might be best to create a new thread and find out (nobody is going to try catch up on a 90 post long thread ;D).
The problem is that you are setting your output item only on the client side. So the server doesn't even know about it what will cause a lot of glitches. In your ContainerRuneInscription#onMatrixChanged you also wanna update the server side.
Nice Greetings
TechMage66
That seems like a reason. But how I update it server side? I thought the container was server side already. And I thought that the setInventorySlotContents is server side compatible too.
EDIT:
The workbench code is doing mostly the same as I am. Or have I missed something?
You'll probably have to use a packet for that ... Actually I think its enough if you set the output item only on the server side, because the container will update the client on it's own (At least how far I know .... or are only TE's doing that)
The container is both sided. It should be only updated by the server side but can be accessed by the client as well.
I hope I don't mess something up with TE and Container ... has been a while since a last done some actual coding on minecraft ;(
Nice Greetings
TechMage66
Wait, so I'm kind of lost here. How do I set the item only on the server side? Throw a sideonly tag or something else?
In your GUI you are using this.containerInscription.grid[x][y] = true; to update the grid in your container. But this will only update your container on the client side (Because your GUI is only client side). So instead of using this you wanna send a packet to the server which will update the grid of your container and then call ContainerRuneInscription#onMatrixChanged to get your output item. As I said before the container should update it's server side on it's own.
If you need more info free feel to ask
Nice Greetings
TechMage66
Woah! So removing that packet was a bad idea. I re implemented a packet with some little changes (if anyone is interested I will upload the final working version to github).
EDIT:
There are no graphical gliches anymore, but I am getting two runes everytime I craft (they are not in one stack, but on top of each other).
EDIT:
GUI
http://hastebin.com/bafowehuri.java
Handler for packet:
http://hastebin.com/ehiloworam.java
EDIT:
I seem to have fixed the duplicate issue by removing the onMatrixChanged method from the inventory completely and adding it to the onSlotChanged method from my slot (also checked if slot number is 0). I don't understand why though.