Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Roboguy99

Members
  • Joined

  • Last visited

Everything posted by Roboguy99

  1. Ah ok, I thought that you didn't need packets with NBT. As for the settings, they're purely for client-side settings. Even if I do put any server-side values in, they won't be anything beyond the colour of an item or its name, so there's no real danger of exploits there.
  2. They are...inside GuiConfig. Sorry, I probably should have specified. See here: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/gui/GuiConfig.java#L96 And here: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/gui/GuiConfig.java#L205 And here: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/gui/GuiConfig.java#L229 I don't think I'm missing anything that stupid, am I?
  3. My aim is to save settings for an item on a per-item basis, and so I want to save the settings to NBT. The items have inventories, and the NBT data is saved fine and its working correctly, but I cannot get the settings to save (although they stay loaded even if you exit a world and load it again, if you restart the game everything is set to 0). Each of the variables is correct when writing to NBT, but no tag is actually created. Then, when it reads obviously no tag is found so the variable is set to 0. The NBT reading/writing code is here (and everything below that in that class): https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/inventory/BagInventory.java#L169 The class that handles the changing/saving/loading of settings to/from NBT is here: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/gui/GuiConfig.java
  4. Bump again. I've tried combining both write methods, and now the settings are stored for as long as the game is running, then lost when it restarts.
  5. There's things you can do that I can think of: Option 1: Create a config file allowing each ore to be turned on and off. Most mods just do this, as it's a lot easier and makes your mod a lot more compatible in modpacks (Every ore can be turned on/off so it'll work with any mod with that ore). http://www.minecraftforge.net/wiki/How_to_make_an_advanced_configuration_file Option 2: Use the @mod annotation to only run code if another mod is present. You could use this to set boolean fields to check if the mod is present. Or even better still, use both. This will maximise automation and compatibility.
  6. Right, this problem is still ongoing and I have literally no idea why it's happening. So my understanding of NBT is very limited, and I've never successfully managed to get it to work, with the exception of the itemstacks. I've taken the settings tags and put them into their own methods so the actual inventory contents isn't unnecessarily read/written every time. When I print the compound, everything is there and correct, however it seems to be saved to some void location and deleted. I tried printing one of the values just before they're set, as you can see, and it came out correct (the same as the value on the slider). Here's the NBT code: I know it's a bit of a mess at the moment and I could probably make it 4x shorter using a loop, but I just want to get it working first I'm fairly certain it's not a server/client sync problem because even when I've tried directly writing a string, nothing has happened. None of the compounds, or list exist. Any idea why this is?
  7. Ok yeah. I'll bear this in mind and play with it a bit, but if I can't easily get it working how I want it I'll just scrap the config file.
  8. The idea of the config was so players could change the defaults if they had a personal preference they would always use. I might as well keep it, because if I'm going to append missing values they need to come from somewhere (just set some constants to them, and use the constants when filling in missing NBT values). I think other than that I should be OK from here. In the likely scenario this is not the case I'll come back and beg for more help Thanks.
  9. Ok I mostly get what you're saying and I think I'm already doing most of it, but I'm a little bit confused. Do you mean save the config or something else? Is it actually possible to update a config in-game, because if so I can scrap most of the NBT code (keeping the name, but removing it from the config). I currently have 2 sets of values: Set 1 is the config file, which is the initial defaults for every new bag. Set 2 is the NBT, which is specific to that item. Because items have their own specific values, I still need to read the NBT data before turning to the config.
  10. Ah! So I forgot to explain that there are 2 GUIs - one handles the inventory and has a container, the other is the settings menu (GuiConfig) and does not have a container. I followed your tutorial to get the inventory GUI working.
  11. Ok so after printing the values I've found that although they're all zero when the GUI opens, and all 0 when reading/writing the NBT. The GUI is currently a GuiScreen so doesn't have a container, so I guess I'll have to change that. How come if items can be saved to NBT without a packet, integers and other raw data types do? Also something I didn't mention: When the data is loaded I want to prioritise the NBT, and then if the the tags are missing use the defaults from the config file.
  12. Sorry, I may not have been clear. The itemstacks are being saved to NBT absolutely fine. The issue lies with the values (such as the background colours etc.)
  13. What I want to do is have certain values about an item saved to the item using NBT. The item has its own inventory, so it seemed like a good idea to load/save the values after the inventory contents had been loaded/saved. As far as I can tell though, the NBT tags other than the list of items are not actually being saved anywhere (and so when loaded are empty). Below are the three classes linked to the process. ConfigGui handles the changing of these values, Config handles loading the default values (from a config file) and storing the current values in memory, and BagInventory unsurprisingly is where the inventory is saved/loaded (the NBT methods are right at the bottom). You may notice that in ConfigGui updateInventoryNBT() isn't actually being called: it was in initGui(), and both the button and slider listeners however caused some interesting problems where every value was set to 0 when the GUI was opened (and some of the sliders were actually set to < 0, which was a little odd). ConfigGui Config BagInventory As always, all help is appreciated.
  14. Turns out, you can do it very easily. To stop the mouse input, all you have to do is: Mouse.getDX(); Mouse.getDY(); this.minecraft.mouseHelper.deltaX = this.minecraft.mouseHelper.deltaY = 0; The mouse still interacts with the game, however does not move the player. I put it inside a RenderTick event handler, but I'd imagine it would work in several different places.
  15. This seems to be the case. I tried playing with a few event types, all of which yielded the same result. In which case, I need to either a) Do as you suggested and replace the camera entity at startup or b) Stop the mouse from actually trying to change rotation. Which one do you think would be easier, and how would I go about doing either of these?
  16. I want to stop a player from (preferably) moving their head, or completely stop them from moving altogether on key press, and unfreeze them when the key is released. The KeyBinding is already set up. I have tried, among several things which failed entirely, the code below: minecraft.thePlayer.rotationPitch = 0; minecraft.thePlayer.rotationYaw = 0; However this causes a jumping/stuttering effect as the head is teleported back to the same position every frame. It also means the head is kept in the neutral position constantly, whereas I'd like it to be kept in the same position it was when the button was pressed (Although I'm sure I could figure this bit out if I knew how to freeze it properly). Does anybody know how? Help is appreciated.
  17. Sorry to bump up an old thread, but I came back to this project after several months and I still can't solve the problem of having to press the button price. To re-iterate: -Button press 1 renders nothing, the game remains unfocused when you let go -Button press 2 renders correctly, the game goes back into focus (as intended) when you let go. Here's the code: EDIT: This seems to be due to the actual KeyBinding. Is/was this a known error (I'm on the recommended 1.7.10 src). EDIT 2: The problem does not occur in any other keybindings, however I have no code which actually changes the state of the key.
  18. I have a packet, designed to update both an item's inventory and the player's inventory by switching an item between both of them. Every time it's received (it's on the receiving end as far as I can tell), the world closes giving me a screen saying "A fatal error has occurred, this connection is terminated". I cannot for the life of me find out why this is happening (although I'm certain it's going to be something blatantly obvious), and I'm sure I've double-checked every line of code. The crash log suggests a problem initialising the packet class after code inside of it has been run. If anybody can find out what's going on I'd be very grateful. Here is the packet class: And where it is called from: And the main class, where it's registered: And here is the crash log:
  19. After fiddling around with many combinations of numbers, I've managed to get it to work. I've changed the offset and radians algorithms. double radiansPerSector = 2 * Math.PI / sectors; double offset = 0 - Math.PI / 2; if (inventoryContents.length % 2 == 0) offset = 0 - Math.PI / 2 + radiansPerSector / 2; for(int i = 0; i < inventoryContents.length; i++) // Draw icons { double radians = 0 - (offset + radiansPerSector * i); double itemX = this.ITEM_RADIUS * Math.cos(radians) + centreX - 8; // 8 = offset for texture centre double itemY = this.ITEM_RADIUS * Math.sin(radians) + centreY - 8; // TODO Switch 8 for constant this.renderItemIntoGUI(minecraft.fontRenderer, minecraft.getTextureManager(), inventoryContents[i], itemX, itemY, true); }
  20. So I have quite a weird situation as far as I can see - the positions of items around my circle are mirrored to where they should be, so when you select one thing you actually get the result above/below what you selected. Hopefully this is clearer with the pictures below: The first image shows how each item is switched (note the ones at the end i.e stick and emerald are in the correct places) and the second shows the order in which they should be in. Here is the rendering code: double radiansPerSector = 2 * Math.PI / sectors; double offset = 0; if (inventoryContents.length % 2 == 0) offset += radiansPerSector / 2; for(int i = 0; i < inventoryContents.length; i++) // Draw icons { double radians = offset + radiansPerSector * i - Math.PI / 2; double itemX = this.ITEM_RADIUS * Math.cos(radians) + centreX - 8; // 8 = offset for texture centre double itemY = this.ITEM_RADIUS * Math.sin(radians) + centreY - 8; // TODO Switch 8 for constant this.renderItemIntoGUI(minecraft.fontRenderer, minecraft.getTextureManager(), inventoryContents[i], itemX, itemY, true); } If you need to see anything else, I'll stick it on. Any help is appreciated.
  21. That sounds easy enough; I should be ok from here. Thanks
  22. Ok yeah, should have explained. I want to change the itemstack in a slot on the player's hotbar and the itemstack in an item's inventory (I can get the item's inventory as long as I have the player). All I'm doing is swapping the two stacks around.
  23. Ok, I've removed all references to the string, and the packet is successfully being received. If I update the inventory from here like I was before, will it work because it's server-side code. If not, how do I actually go about updating the inventory?

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.