Jump to content

HalestormXV

Forge Modder
  • Posts

    328
  • Joined

  • Last visited

Everything posted by HalestormXV

  1. Here is the item code: http://pastebin.com/xPDRG7dq And yes I limited my stack size to 1 to answer your prior question, and I am actually using that link you posted as the Shift+click code. Most of what I learn is from your tutorials lol and I piece through each part. This item actually happens to be based off your tutorial. Should I do the same slot check i did in the GUI handler here and maybe that will resolve it? EDIT: Figured it out I think. I changed the line in the item code to this: player.openGui(MainRegistry.instance, CelestialCraft_items.guiIDKeyPouch, world, player.inventory.currentItem, 0, 0); Because in the item code it was opening a "new" gui and not using the parameters I passed when the NBT data was written I guess when I pressed Y? So by changing it to the currentItem it made sure it was the EXACT same as when you are pressing the Y key? Or am I totally wrong lol. But it seems to work now? Unless that is because shut down the client and logged back in and it read the data?
  2. Thanks I will have a look. I just edited my post to add another issue that just creeped up. now that I don't crash anymore, I realize however that if I have the item currently equipped and right click it the inventory is not stored and it is (the container) empty. However if I press Y while having the bag equipped I see the inventory inside it. Is this a sync issue or is this because I am calling a "new instance" of the container with my check? If that is the case, how can I make sure I am calling the same container/inventory?
  3. Nailed it! Thank you so much everyone! I have 2 remaining issues that seems to have popped up lol. (Please don't hate me, I am literally learning so damn much from this it is incredible lol). I do however know what is causing it I think. But first here is the new code: (btw I keep posting the new code so others can learn from this as many of you who know me I like to learn and share what i learn) GUI Handler: http://pastebin.com/wcrb2v8L Packet: http://pastebin.com/RNumzySi The first issue is now that I don't crash anymore, I realize however that if I have the item currently equipped and right click it the inventory is not stored and it is (the container) empty. However if I press Y while having the bag equipped I see the inventory inside it. Is this a sync issue or is this because I am calling a "new instance" of the container with my check? ===================== Now the last remaining issue I think has to do with Shift Clicking. What it appears is going on is when you have the inventory open and you shift click items into it (you are only allowed a certain type of item, and that part is working fine) it leave a "ghost" duplicate of the item in your inventory and puts the real one in the bag. The ghost duplicate item can't be picked up, dragged, or anything. It just sits there in the inventory. If you try to right click the item it disappears. This only happens when shift clicking the item into the bag. If you actually click and drag it into the bag it doesn't leave any "ghost" items or anything like that. Here is the inventory: http://pastebin.com/g9Em0XVc Here is the container class: http://pastebin.com/6mPtXky0 What I am curious about is this what that "desync" issue is that you guys said might occur? Or is this just something wrong in the Shift+Click code? Once again, coolAlias and Uber your both awesome and thank you for helping me out with this. Please know that I am not just "getting help" your both genuinely teaching me about this and I am learning and I am willing to keep working at it. Just like I did with the packets. At the start of this thread I didn't know a damn thing about them lol.
  4. Ahhh, I see, i didn't think i could pass the InventoryKeyPouch(stack) like that. Sneaky and genius at the same time lol. So basically what is happening in my packet I create the loop like so: public static class Handler extends AbstractServerMessageHandler<OpenGuiPacketAlt> { @Override public IMessage handleServerMessage(EntityPlayer player, OpenGuiPacketAlt message, MessageContext ctx) { for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) { if (player.inventory.getStackInSlot(slot) != null) { if (player.inventory.getStackInSlot(slot).getItem() == CelestialCraft_items.keyPouch) { System.out.println("Congratulations you finally created a frigen packet that works!"); player.openGui(MainRegistry.modInstance, message.id, player.worldObj, slot, 0, 0); } } } return null; } } So what this essentially doing is taking the X variable that is required by the openGUI method and just storing the SlotID in it, instead of an X coord. I was TOTALLY restricting myself thinking that the X HAD to be a coord or a 0, when really it is just an integer in the code language. Once we dispatch this packet the SlotID is stored with it so it gets passed with it in there. Then all we are simply doing in the GUI handler is saying to fetch the slotID or the "X" (since it is going to be the same that we passed via the packet) Thanks uber for the nullCheck tip. Brilliant! And of course upon looking at it like that and coding it as such. Guess what, it works lol. Here is the new OpenGUIPacket code: http://pastebin.com/FPKGukRD Here is the GUI Handler Code: http://pastebin.com/U0QKijJG (specifically line 44, 45, 72 and 73 handle the backpack) Here is the InventoryKeyPouch class: http://pastebin.com/uzF6B9a7 I only have what appears to be one more issue. A new error has cropped up with my changes. The game will now crash if I right-click to open the bag with it selected. However if I press Y with the bag selected it will open fine. I imagine this is a simple error on my part that can be easily fixed? Hopefully. Help? lol Here is the new error: http://pastebin.com/gcsedduq Thank you again for all the help to everyone!!
  5. Alright, I totally didn't understand that post or at least I don't think I understood it the way it was supposed to be understood. Sorry about that. In other words, in my OpenGuiPacketAlt: http://pastebin.com/VChbFb8G I am going to create a loop check (I am opting for option 2) in the public IMessage handleServerMessage? It is basically going to go like this? That would be the first part? Or is this check going into my GUI handler? I think that is where I am getting confused. Like I get it. My GUI handler is using that getItemHeld() (is that even needed?) and that is why the Hotkey works if you have the item in your hand. But if you aren't holding it is crashes because it is looking for the backpack and nothing is there (being held). So I understand that part but I guess I am just confused as to where I am lopping the inventory and then passing my slotID indicating that the item is indeed somewhere in the inventory. Or would it go something like run that loop in the GUIhandler, collect the slot and then use that slotID in the: return new GuiCelestialKeyPouch((ContainerCelestialKeypouch) new ContainerCelestialKeypouch(player, player.inventory, new InventoryKeyPouch(player.getHeldItem()))); of the GUIhander instead of the player.getHeldItem
  6. Gotcha, but if you are in SMP world (which is what I was testing it on) that doesn't crash however spits out that error, but because the client thread stopped it boots you so you have to reconnect, is that correct?
  7. I linked the old packet in the above post accidentally (I since changed it). This is the correct one I am using: http://pastebin.com/MXDpVYAU And here is the implementation of IGuiHandler: http://pastebin.com/p1meeccz That is where I handle all my GUIs, and yes I am returning null as that is what I did for all the GUIs. I suppose I am supposed to be returning the itemstack? Here is the Inventory which implements IInventory: http://pastebin.com/G52kbWkK And with respect to the looping of the inventory I can essentially do that within the packet correct? Ideally I am only executing this: player.openGui(MainRegistry.modInstance, message.id, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); if that particular inventory item is in the player's inventory, so essentially I can just write the check over there? And if we don't have the item in the inventory we will never send that player.openGui
  8. Yeah, your right lol. I made that post at 2:30 in the morning I guess what i meant was that the client doesn't shutdown, it just boots you from the server and the server just throws that error. Here is the class: http://pastebin.com/NMkgK7TY I followed coolAlias's tut (also at 2:30 in the morning) so perhaps I missed something when making my changes? It appears that the error gets thrown right as it tries to create a Compound/read from it. What makes this odd is that it seems to happen when items are in the inventory and you press the shortcutkey o_O So something is wrong in that class somewhere or in my packet? Perhaps it tried to read the NBT that was non-existent and skipped over the check where if it doesn't exist to set it? It appears the only time it happens is if there are items in the inventory and then you use the hotkey to open the bag. Otherwise when you open it with a right click there is no issue with or without items in it. Perhaps I have to have the packet read from the NBT as well and not just attempt to open the GUI? Since in my mind trying to open the GUI via packet and you don't let the packet know that there is NBT data in there it might throw that null? Where as when you simply right click it knows there is NBT in there? Here is the packet: http://pastebin.com/MXDpVYAU ============= ============= @UberAffe: That makes sense. How would I go about doing that exactly? I know how we check using the worldRemote, but how would i check if the item is serverside and in the player's inventory? I know typically for items i use the onUpdate to add "permanent" buffs while it is in the inventory.
  9. Outstanding. Yeah I register everything in one MainClass and utilize functions to register other classes all at once. I plan to change to a more universal style once I do another mod. I won't change it now though because I am so deep into it that it doesn't pay. So using the if check worked wonderfully and the server boots up without a problem. I think I have one other issue. I bound my HotKey packet "openInventory" to a keypress that is supposed to be attached to an item. It is basically a backpack. What it does is really simple since I just wanted to learn how packets work. By pressing the "Y" key you open a custom inventory which works flawlessly. However on a server if you press the Y key and you are not holding the Backpack item the client crashes with a Fatal Exeception. Here is the Exception the server spits out: http://pastebin.com/WDh4rMXR So once again it is a Fatal Exception, not a crash. This only happens on a server which to my understanding means it is packet related. Now to be quite honest I really don't know which class is causing this, although whatever it is shouldn't be attempting to open that inventory to begin with unless that Backpack is somewhere in your inventory. Now I know I likely didn't tell the code this since I am just learning. Ultimately if the backpack isn't anywhere in your inventory and you press the Y key, nothing should happen. But I don't know where I would put that check or how to make that check as the key pressing occurs in the KeyHandler, and there is nothing in there to get the player. And I truly am most appreciative of all the help I am getting. It is amazing how far I have come from the start of this thread to now at the time of this post. Tackling the packets has been quite fun, and I am enjoying all the knowledge and tips very much, so thank you.
  10. Well, it is likely because I am a fool and over-complicate things especially when I am trying to learn them lol (backwards logic). However this method was part of a YouTube tutorial and was explained in detail, so I managed to get an understanding of what each piece did. I actually looked at your SimpleNetwork handler first and quite honestly want to try both lol. I am not sure if you can have two network handlers though. But as it stands now, I only have the one I posted above. Although in reading through your tutorial I see you make a notation stating: Which if I am correct, is exactly what is happening in my code. EDIT: Alright I bite - i followed your tutorial coolAlias as they have and this community has basically been my guiding light to learning modding lol and edited my handler and packets to fit your tutorial. And it works fine. I start my world up and when I press the Y key it outputs the message indicating that it works correctly and the packet was indeed sent and received. However, I run into this issue when I try to launch a server test: http://pastebin.com/6yJniY81 In trying to parse and understand this error code it appears that on server load we are attempted to load a client side only function which does make sense. As keybindings are strictly ClientSide. Here is the KeyHandler.class: http://pastebin.com/gd2m7JUQ Do I simply need to add a server side check so that it ignores that when the Server is starting up? And if so, how could I go about doing that? I imagine it isn't as simple as isRemote. Or am I totally wrong and it is something much different.
  11. yay! I made my first packet handler! But I screwed something up and have no idea what i did. Anyone tell me exactly where I screwed up? PacketHandler: http://pastebin.com/jPN9Z1zR AbstractPacket: http://pastebin.com/RNHeqCXP ClientProxy Snippet: http://pastebin.com/ZbAU2spi KeyHandler: http://pastebin.com/gd2m7JUQ OpenGUIPacket: http://pastebin.com/LQzj1YzW And lastly the Main where it is being registered: (I only posted the relevant parts since it is quite large) So this loads up fine on the SinglePlayer but the packet doesn't actually work. When I press "Y" the message does not display at all. However the even more serious issue is that if trying to start up a Server it crashes the server entirely and I have no idea why. Here is the crash report from the server: http://pastebin.com/W2wZuNFS So forgive me if it is starting me in the face. But this is my first swing at packets. I specifically chose not to do the SimpleNetwork wrapper way because I want to get more control over the packets and I feel like this way does that.
  12. All calculations are done via built in methods of adding, subtracting, multiplying, and dividing the player XP level with math. Here is actually the itemOnUse code: http://pastebin.com/aAdV3RSJ The two arrays at the top are what will be configurable. So no displays are actually shown. So if I follow what you guys are saying correctly packets won't be needed. (As no information is being displayed, just being calculated) Also the snippet at the top in the OP is part of the entity onUpdate class which also uses standard XP calculations which merely subtracts the EXP level from the player based on the formula which is set at the top (which will be configurable). If however, I want to display spell costs (which sounds like an awesome idea coolAlias, thank you for that) then I will need packets. (Granted I know I can just test and see and I plan to but the more knowledge I gather and learn the better)
  13. Okay, that actually makes sense to me. I can kinda envision how it would look also. However, one thing I noticed mentioned quite a few times in this topic is "display." Now I know that when dealing with Particles, GUIs, Custom Mana Bars, etc. these all play into account and packets are needed. However, with me all of these calculations the server does are directly added and subtracted from the players experience bar. My whole system utilizes the player's experience as power. And the experience is added and subtracted from directly, which is actually why I questioned packets to begin with because I thought all Experience gains and losses are handled strictly server side and automatically kept in sync, which in turn led me to beleive that all calculations pertaining to these adjustments to experience are only handled server side right out the gate. Does that make any difference with respect to syncing and potential desyncing issues? Or can this be classified as more of a "use the packets to be safe" situation. Granted, whatever the answer is, I still plan on using these packets as they are something I need to learn and this thread has provided a wealth of information regardless.
  14. Thanks to everyone. I am starting to grasp this and it is making sense now. I am going to create a handler I think (rather than use the simple wrapper). And @Draco18s, yes I wouldn't want to overwrite the values. So I think the last hurdle that I have to clear is this in "non-code" terms. Server Config File -> Has the Values I Want -> Store them in Packet? -> Do I just need to send that packet to the players once? How to I make sure that the packet is storing the "Server's Values?" Is it just as simple as doing a server side check when the player logs in? I don't know if I was being clear on that or not. If I am not please just let me know and I will try to clarify.
  15. Alright so I can essentially store each of these arrays in its own packet: public static int SpiritCostBase[] = new int[]{8, 14, 11, 13, 12, 9, 6, 8, 10, 7, 9, 12}; public static int SpiritCostFormula[] = new int[]{7, 9, 9, 12, 10, 3, 12, 6, 8, 12, 6, 5}; And then when the player logs in have that array sent to them and have it alter their configurations? And I can populate that array with values being pulled from my config handler like: new int[]{config.getInt1, config.getInt2, . . .
  16. Alright that does make sense. So I guess now the answer is painfully obvious. I am going to need a packet to hold that data in the server configs and have it sent to the client configs. Ideally I would only need to send this packet once when the player logs in, correct? Since those values don't actually change (the values that the formula uses.) Kinda like how EnderIo sends its configs on login (I always see the message on my server ederio.configmanger.sendconfigs once a player logs in)? So forgive my noobishness, as now I have to make it a point to dabble in packets. Would each value need its own packet?
  17. Thanks for that. I am actually using the onUpdate of EntityTameable and the onItemUse of the Item.
  18. Yeah I know it is something I will inevitably have to work with. The tutorials are great that is true but it is one of those situations where I guess if I can avoid it, I want to lol. However, with respect to the original question, would that data need to be synced? Since the calculations are performed by the server anyway and are dynamic? Yes the values used in the formula are not dynamic but the result is, and ultimately the result is what the server reads. So would I still need to sync the server values into the client config values? Or would the mod just read the values in the server config file and calculate them disregarding whatever the client has set since once again all of this is done on the server anyway. (Using the item, spawning the entity, calculating the cost of the entity, etc. etc.)
  19. So in my mod there is a cost to utilize items. The cost is a formula that take the Current XP level of a player and divides it by a set number, then to keep things nice and tidy, rounds it so we don't have any annoying decimals floating around and such. Now a number of people have offered me feedback and asked that I make these formula's configurable. Which is fine, as I don't see any problems with setting the numbers in a configuration file as opposed to hard-coded in. However, this has presented me with a this problem. If this mod is used on a server and the Server Admin has set the formula numbers to one number and the client has their configs set to another number, which takes precedent? Would the Server Config files automatically take priority since it is calculating numbers and making changes to the player's experience level? Here is an example of the code that uses the formula used in one of my entity classes. private int aquariusSummonCost = 3; public void onUpdate() { super.onUpdate(); /////////////////Cost Handler\\\\\\\\\\\\\\\\\\\\\ aquariusCounter += 1; if (aquariusCounter == 80) { EntityLivingBase owner = this.getOwner(); aquariusCounter = 0; if (owner instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) owner; player.addExperienceLevel(-aquariusSummonCost); if (player.experienceTotal < aquariusSummonCost) { ExtendedPlayer instance = ExtendedPlayer.get(player); instance.setSummoned(AQUARIUS_ID, false); this.worldObj.removeEntity(this); } } } And that is perfect, it works exactly as it should. If however I want to make that private int aquariusSummonCost a configurable value and the server config files have a different value then the client config files what could potentially happen? Or would nothing happen, and since this calculation is all server-side anyway the server config files will overrule whatever the client has set? The same question also applies to my item class which has a formula that reaches into an array of numbers to make the calculations: public static int SpiritCostBase[] = new int[]{8, 14, 11, 13, 12, 9, 6, 8, 10, 7, 9, 12}; public static int SpiritCostFormula[] = new int[]{7, 9, 9, 12, 10, 3, 12, 6, 8, 12, 6, 5}; The code will reach into the position in both arrays appropriate to what item is being used and then use those value to calculate a cost to utilize the item. Could i make each of those numbers in the array configurable and would Server Configs override Client Configs? In summary what I am really hoping for is that I don't have to dabble in packet handling (yes I know eventually this is inevitable lol) because despite all of the seriously awesome tutorials out there from Debian, and CoolAlias, and such I can't for the life of me figure out how to utilize packets to make sure a client's configs values (like DimensionIDs) are in sync with the server's configs. And I know in some cases like DimensionIDs they HAVE to be in Sync or you will crash but I wasn't sure if this is the same principle with formula calculations.
  20. Alright that is helpful. Now is implementing the NEI API (or any API) different in 1.7.10 or is this tutorial (judging by the date of the post I imagine that actually was for 1.7.x? Or at least universal): http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571434-tutorial-modding-with-apis still an accurate way to do it. I haven't used an API for anything yet so forgive what would seem like a rudimentary question.
  21. So one huge request I keep getting is to add NEI into my mod so that the Crafting Recipe's that are created in my custom crafting manager show up in NEI. It is a pretty basic crafting manager that uses 5x5 and I have a custom smelting manager. I want to be able to answer my community and give them what they are asking (we can't always do this but I figure NEI is beneficial anyway). Problem is I cannot find anything with how to integrate NEI into your mod. Anyone have any starting points I can jump off of? I haven't started any of the code yet, so i am at the VERY beginning stages of it but it is something being sought highly by my community, and like any mod author I want to try and give them what i can. And I know I can do this, but I just need to learn how.
  22. So my clients are getting a crash when they enter into a certain area on my server. Here is the crash report: http://pastebin.com/6jXp6tut The reason I am posting this in this section is because I cannot seem to track down what mod is causing that, as you can see there are quite a few in this modpack. In reading the log it appears painfully obvious something is reaching outside of an index cap. But I am posting it here because maybe I am reading this wrong and someone else can better understand it or better yet understand what exactly is causing it. If it is something as simple as a potionID conflict that is not a problem, but I fear it probably isn't that easy. If at all possible I would also like to know exactly how you may have read this to come to the conclusion that you did. I don't simply want answers but I would also like to learn how to properly read this in the event I am reading it incorrectly. I rarely see these types of crash reports. Generally the crash report makes it totally obvious as to what mod may be causing it or better yet what in general is causing it. Kind Regards
  23. I'm afraid I don't know what you mean? I am not looking to create a circle around me. I am simply looking to have explosions be created in a circle around me with a radius of what I define. For example if you are familiar with the Botania mod the Gaia fight, you click on an item and a circle within a certain radius is created around you (of particle effects) and it essentially forms an arena around you. I am trying to do the same thing here except not form an arena of particles. Simply create explosions. As I said, this is my first time even venturing to work with this type of code so perhaps an example?
  24. Wohoo, getting somewhere now. I thank you for all the help by the way to the both of you. Circles and forming them along with fomring rings around the player is something once I get down, I can think of tons of things to do with them. Here is the new code with the modification off adding in the radius calculation: http://pastebin.com/PEsUzhnh And it works as expected. The radius which is defined at the top of my class as an int. When using the item it no longer creates the explosion at my feet, but at the proper radius. However the only problem that remains is that it is only in one direction (the x-coord), what adjustments do I have to make so that once you use this item explosions are created in all directions around the player within the specified radius. Also, shouldn't the Y coordinate be used somewhere in here? Ideally, think of mods that add an item that when you click it a ring of fire gets created around you in a certain radius. So like an arena of fire is created around you 6 blocks or 10 blocks out and the whole inside is your "fighting ground". Gaia Guardian from botania for example where once you activate the beacon the wall of particles surround you and you can only fight within that wall. I am looking for the same effect but obviously much simpler where explosions are just created around you.
  25. Alright I changed it up a bit and it. It looks like this now: http://pastebin.com/n4nehdvd This doesn't lag and seems to work fine. However the only problem remaining is that it is not "around" the player in a ring. It is just where the player is standing.
×
×
  • Create New...

Important Information

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