Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Titmar

  • Rank
    Tree Puncher


  • Gender

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I probably should do that, yeah. Works fine now!
  2. Okay, I am at a loss - once again. Somehow resetting the container.inventorySlots field does not work as intended. When the MarketContainer is created it is starting out with the first inventory in the list and displays that. If that is a single chest and i switch to a double chest and back i get thrown the ioob exception. If the first inventory is a double chest and I switch to a single chest, it keeps showing the second part of the double chest but when i click one of those slots i still get the ioob exception. I uploaded it to my github, because I cant even get close to where the issue
  3. Nvm, the error does not seem to come from the slot by itself but from somwhere else. Currently investigating.
  4. Yeah but I need to give the slot an object of IInventory (in this case the chestTE) which for some reason only sees the single inventory. I could override the slot class to use IItemHandler instead of IInventory but that seems a bit overkill. Or is there a way to get the slot to use the IItemHandler that I dont see?
  5. I am currently trying to display the contents of a double chest in the container of a different block. For single chests and barrels it works perfectly fine. The problem is, when adding Slots to the container it uses the IInventory vanilla implementation. So when looping over the chest contents with the ItemHandler capability i get thrown indexoutofbound exceptions since vanilla handles double chests quite weirdly. The capability shows me the full 54 size but vanilla thinks its only 27. Anyways, I tried getting around that by switching the IInventory of the newly generated Slot to the second p
  6. Alright, I got it all working now. In the end it was easy after finding out abut the player.openContainer field... On Button press, send a custom packet. This custom packet tells the server to update the players openContainer like so: Nothing else to do afterwards. Vanilla takes care of the rest apparently. At least for now I havent found any bugs, though I only tested it with a single player and only on a single player world.
  7. Titmar


    Do you know basic java and how to capture Events? Pseudo code: public static void catchEvent(GuiOpenEvent even) { WorkBenchContainer con = new WorkBenchContainer(id, playerInventory); CraftingScreen screen = new CraftingScreen(con, playerInventory, title); event.setGUI(screen); } id and playerInventory should be readable from the old screen. Check out the classes how to access those.
  8. Titmar


    You would need to give it an Object of CraftingScreen which in itself needs a WorkbenchContainer, the playerInventory and a title. You just pass the CraftingScreen object to the setGUI method
  9. Okay so I had a bit of a deeper look into the syncing of containers. Vanilla is using the Container::detectAndSendChanges method which in turn uses a list of private listeners it sends those changes to. My current code You see I am resetting the slots and recreate them for the new Inventory which makes the vanilla method unable to detect any changes. Reason being that I would like to be able to support custom sized inventories. Of course I could set a maximum size for the inventory and just clear all slots before refilling them. But that is just limiting functionality. Now I cant o
  10. I do have said block which you can register inventory blocks to, i call it market. When opening its GUI I have a bunch of buttons which are connected to those registered inventories. When pressing a button i want to show the inventory of its connected block until i chose another (similar to the selection of an active trade with a villager). Now I could of course set some global variable such that it shows the same inventory for every player. But I would like it independent such that every player can browse independently from others.
  11. I know how to send from client to server via the SimpleChannel Network but I have no idea how to send packets the other way. As in, I could send a request to the server from the client but how would I answer it? How do i send backwards?
  12. okay, so even with the capability i wouldnt be able to get the inventory clientside i suppose. How would i sync from server to client in this case? Because apparently private void changeInventory(LockableLootTileEntity te) { IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); if(handler == null) return; this.activeInventory = NonNullList.create(); for(int i = 0; i < handler.getSlots(); i++) { this.activeInventory.add(handler.getStackInSlot(i)); } } does not resolve the issue
  13. I thought there would be a forge way to get access to the inventory. I havent yet fully wrapped my head around the capability system which is probably why I didnt think of it. I will get back to you if I cant figure it out by myself. The above code is located in the screen class of my "controler" block. Im using the inventory there in order to just render the ItemStacks. For now I dont plan to add other functionality in the screen. Later on I would want to add a villager interaction but thats some time away. As a side question: This forum is not yet switched over to the
  14. I am currently wokring on a block which lets you register and see the inventory of registered blocks. I.e. i want to display what is inside a chest which could be 10 blocks away. I am not looking to change its inventory, just look at it. Since i can't just use the LockableLootTileEntity::getItems method I have to set with recreating the inventory by looping through with LockableLootTileEntity::getStackInSlot. Problem is I only get an empty ItemStack (1 air block) from that method. No matter which index. For reference: private void changeInventory(LockableLootTileEntity te) { int size = t
  15. Ahh, it has been the markDirty part. I knew i missed some crucial part that calls the read/write. As for the HashSet, this is subject to change anyway. In the future i will need to store way more data alongside the position. For now I just wanted to get a proof of concept which I can expand on. I guess I was using the wrong nethod there, it should be getTileData(). The idea was to check if anything has been writen onto the NBTTag. Because if anything has been writen in there and it still didnt work the problem would have been in the read method. As we know now neither was the case.
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.