Jump to content

HalestormXV

Forge Modder
  • Posts

    328
  • Joined

  • Last visited

Everything posted by HalestormXV

  1. Alright so I have a custom generator to generate ores. When testing the client, the ore generation works perfectly with no issue. All my ores spawn wonderfully right where they should. When I go to test on the Server the server crashes on startup with this message: http://pastebin.com/6aQq0kFL Now it is telling me the issue is in my E_AngWorldGen.class and my Main.class So chances are I am probably registering my generator on the client which is why it works no problem if the client launches with the mod. However, I am probably not registering on the server side, which is why it crashes when trying to launch a server. Or maybe I am totally wrong. I do know one thing for certain, it is a noob mistake because I have made world generators/ore generators before and have had no issue with them. Odds are the mistake popped up because I am trying this "new style" of coding which seems to be the way most people are doing things now. Here are the two classes: MainClass: http://pastebin.com/rL8rAxTv WorldGen/OreGen Class: http://pastebin.com/2xtg1Hj6 Perhaps it is even simpler and I just have them in the wrong order. Like I said, I know it is a noob/rookie mistake but I just can't see it.
  2. Oh wow, that works perfectly. Lol thank you again good sir. I also have a real nice example of a 1.10.2 network wrapper in there to learn from. The one I used in my 1.7.10 was great but I don't often use many packets so became an encumbrance. I greatly appreciate it.
  3. Ahhh I see. Excellent. Makes sense with the way it is done now. I thank you. By the way. I have finished the Cards file by applying the help everyone in this thread gave me and it works exactly as it should. So, thank you to all who helped me in this thread. Here is the full code: http://pastebin.com/6St33JY2 One final little tid-bit that has popped up is if a player holds down the right-mouse button and doesnt have the proper reagents, the chat log SPAMS with the error message. Or if they player is not sneaking (which is a requirement to "cast an order") it will spam that error message. Now I know I can fix this by writing a cooldown into the NBT of the item. But before I do that can anyone thing of or know of any other methods to do this so that the error message doesn't spam? I really can only think of writing a cooldown into the NBT of the item but perhaps someone has a better idea?
  4. Thank you both for the tips and Draco i will study that the best I can. Last question I have rather than create a whole new thread for it is what is the new way to do potions now? It appears the old method is no longer in practice or has been changed? I used to use the: player.addPotionEffect(new PotionEffect(Potion.waterBreathing.getId(), 300, 10)); What is the new method? EDIT: In parsing through the code it seems that all potion effects are now stored in something called MobEffects. So, unfortunately I am not at my computer to test this atm, but just going from that will the "new" potion method to apply effects to armor and entities be the following? Or did I miss something? entityPlayer.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 300, 3)); I'm not looking to create new effects yet or new potions for that matter. Just looking to recycle the vanilla ones atm.
  5. Yes I had the other thread a few months back, i couldn't find it and plus it wasn't 1.10.2. Then summer happened so I stepped out of the field for a bit. Little did I know that 1.9.2 and later --> 1.10.2 carried over perfectly. With respect to your reply/suggestion/advice, do you have any guides or tutorials that show actual implementation of this? Or perhaps know of any OpenSource projects that I can peak at to learn? The card system is in its infant stages at the moment and does only basic things, however I would for sure like to expand on it. Granted the way I am doing it now works fine so far. But I always like to improve myself.
  6. I made them as metadata values, this way in the future adding more cards will be much simpler. As I automated the registration and name generation process. Yes I could handle them all in the base class and that's what it looks like I am going to do. I was trying to avoid that and I was just wondering if there is another way to do it to make the code look neater so I don't have a ton in one class. But in going over the code a number of times it really looks like there is no other way. Granted commenting it neatly will make the code easily readable, however I was mainly just thinking sheer amount of scrolling through the base class lol. Mainly I got the idea because in my 1.7.10 mod I used reflection to create unique living entities on the fly specific to how a player used them. But it seems no such luck with items. However, I suppose I can make some helper functions in another class and just call out to them generate the lists (of like enemies, or potion effects, etc.) and stuff like that to tidy things up significantly in the base class file.
  7. Nailed it. I don't know how I didn't see that one. I blame staring at it for too long. So now that it works properly here is the next question which once again I feel like is just me being an idiot and not thinking straight. As may see from the pastebin. This class is a base class and other classes extend from it because they have subTypes and each SubType does something different. in other words. The base class is "cards" and "card_Lightning" extends "cards" So in the base class in order to make sure the right "class" is being called to execute the code. (IE using the lighting card to do this effect) how should I go about doing that? Should I go with: if stack.getItemDamage() == 1 (subType of Lighting) Do the lightning function that I made above that is now working? Or is there another way to do this? Hopefully that makes sense. Here is the code: http://pastebin.com/jZhEtnK0 - This is the base class that just handles all of the registering of the names and snazzy client side only text etc. etc. http://pastebin.com/CB1Uddtu - This is the lightning code that we just worked on above and is now working (when tested alone). What i need to do is call that from the base class. So that if the person is using: (stack.getItemDamage() == 3) - the lighting will happen. I know it sounds like rudimentary Java and to be honest it probably is. But my brain seems to be in freeze mode atm.
  8. That actually helped quite a bit. I managed to get significantly further. Here is the new code now: http://pastebin.com/N2gzJ7bF However, it generates this crash. http://pastebin.com/z1K6VrZ1 I know it means I am getting a null so I messed something up, but what am I doing wrong? This code is actually pulled right from my 1.7.10 and works perfectly there and it seems that none of those have changed significantly, or does it have something to do with the LivingBase? EDIT: I have tried EntityPlayerMP also.
  9. I've tried BOW and BLOCK and still the same result. Nothing happens.
  10. I know they have for sure. Actually here is the 1.10.2 code: http://pastebin.com/rEtUR9jM Not a single error and the code compiles fine and the items registers just fine. But right clicking it does nothing. Doesnt charge it doesn't indicate it is being charged. And no errors thrown out either. I know that code is probably still super wrong, but ideally all i am trying to do is utilzie the item like a bow that you hold down right click on but instead of shoot an arrow it strikes lightning on entities in a certain range around you. It honestly sounds quite simple and is exactly how it worked in my 1.7.10 version of the code but I dont know how to convert it to the 1.10.2 version. Examples would be great because that is how I learn. I am not just looking for answers. I am actually trying to learn how to do it in the new versions.
  11. What?! Forge doesn't support editing base classes. Not the class. My copy pasted version ModItemBow. In other words I copied the code i needed from ItemBow class and edited it for my class. EDITED my first post for clarity.
  12. Hello. So I am trying to upgrade and recreate a new mod for 1.10.2. I have run into a bit of a snag. One of the items I used in my 1.7.10 mod was actually one that I worked quite hard on and got it to work EXACTLY how I wanted. I seem to run into a snag though. I can't quite figure out how to update my item and convert it for 1.10.2 purposes. Mainly because of the whole item rework. Maybe you can all help me out. Honestly I kind of just need this shove so that I can start moving my items over as they all work in the same way. Quite literally because I am so pleased with how they turned out in 1.7.10 i want to literally move them over into my 1.10.2 mod under different names. This is the 1.7.10 Code: http://pastebin.com/APkiV6M4 I am trying to convert the exact functionality of this code to 1.10.2 and quite frankly....I am lost. All I really did thus far in the 1.10.2 code was copy paste the Bow class and slightly edit the new ModItemBow class. I know how to create items in 1.10.2 and weapons and tools etc (and have moved a chunk of my items over). But this particular item (likely because it is bow based) is giving me a hard time. I really ask if anyone could help or point me into the direction of where I can go to see. I know updating from 1.7.10 --> 1.10.2 is totally different but I know it is for certain possible.
  13. Bumping This Please. I fixed up the code a bit: Here is the main card class: http://pastebin.com/yXAWD09R Here is the specific class I am trying to call out to http://pastebin.com/g3LLPJTG Ideally I need the onStoppedUsing Item method to be called. Like I said above, I know i can probably do this all in separate item classes registering the cards as separate items but that is not what I am looking to do unless I have no other choice.
  14. Bumping This Please. I fixed up the code a bit: Here is the main card class: http://pastebin.com/yXAWD09R Here is the specific class I am trying to call out to http://pastebin.com/g3LLPJTG Ideally I need the onStoppedUsing Item method to be called. Like I said above, I know i can probably do this all in separate item classes registering the cards as separate items but that is not what I am looking to do unless I have no other choice.
  15. Alright, so I know I am screwing something up. I just don't know how or what to do to fix it. The idea is really simple. One class which handles this particular type of my items, and uses metadata to store the different variants of that item. Other classes that handles the effects of using those items. Each item is meant to act like a bow, you can "charge" it. Then, upon onPlayerStoppedUsing whatever that item is supposed to do gets executed. So I have my code, and everything runs and compiles fine. However my items are not "acting" like a bow. Here is the main item class code: http://pastebin.com/BjyvcakQ What that code does is registers the items for me, gives them their models, etc. etc. As you can see at the top I am storing the class that are to be called in an array and upon using the item it will cycle through the array and is supposed to call the proper class based on the items metadata. So now here is the class for array position 0 or O_card_Fire http://pastebin.com/Kf9aYHBr I did something very similar to this in 1.7.10 with my Celestial Keys and each key called out to a class that spawned an entity. The concept is the same except it is called out to an itemclass instead of an entityclass. Granted, I know I can probably do this by creating a specific item class for each card and attach it specifically to its respective item class as opposed to using Metadata like I am currently doing, but that isn't what I am going for. If there is no other option and I don't have a choice well I will do it, but my objective here is to better myself with java and 1.9.4 by trying to do things differently. So for anyone that may ask "Why are you doing it this way" it is simply because I am trying to learn and want to better myself. So what am I doing wrong with the new 1.9 style? Is it my main card class? Is it my O_Fire_Card class? Or is it just totally wrong and needs to be completly rewritten? Any help and guidance with some example is greatly appreciated. EDIT: Yes I know that adding the information and what not should probably be done in the main item class since I am really only making those other separate classed for and I plan to change that. I am more concerned with the actual functionality of the item.
  16. Alright, so I know I am screwing something up. I just don't know how or what to do to fix it. The idea is really simple. One class which handles this particular type of my items, and uses metadata to store the different variants of that item. Other classes that handles the effects of using those items. Each item is meant to act like a bow, you can "charge" it. Then, upon onPlayerStoppedUsing whatever that item is supposed to do gets executed. So I have my code, and everything runs and compiles fine. However my items are not "acting" like a bow. Here is the main item class code: http://pastebin.com/BjyvcakQ What that code does is registers the items for me, gives them their models, etc. etc. As you can see at the top I am storing the class that are to be called in an array and upon using the item it will cycle through the array and is supposed to call the proper class based on the items metadata. So now here is the class for array position 0 or O_card_Fire http://pastebin.com/Kf9aYHBr I did something very similar to this in 1.7.10 with my Celestial Keys and each key called out to a class that spawned an entity. The concept is the same except it is called out to an itemclass instead of an entityclass. Granted, I know I can probably do this by creating a specific item class for each card and attach it specifically to its respective item class as opposed to using Metadata like I am currently doing, but that isn't what I am going for. If there is no other option and I don't have a choice well I will do it, but my objective here is to better myself with java and 1.9.4 by trying to do things differently. So for anyone that may ask "Why are you doing it this way" it is simply because I am trying to learn and want to better myself. So what am I doing wrong with the new 1.9 style? Is it my main card class? Is it my O_Fire_Card class? Or is it just totally wrong and needs to be completly rewritten? Any help and guidance with some example is greatly appreciated. EDIT: Yes I know that adding the information and what not should probably be done in the main item class since I am really only making those other separate classed for and I plan to change that. I am more concerned with the actual functionality of the item.
  17. Thanks for all that. I knew what doing the static meant. It makes it the same across all instances, that's why I said my gut tells me it isn't going to work. I was wrapped in the thinking that I couldn't just pass my variable into the ContainerKeypouch constructor for some reason even though I have done it with some of my other classes. Everything works as it should now after making the changes. No more ghost items, and no more moving of the pouch while it is opened. (Either by rightclick or by Hotkey) All that is left is to adjust my keyHandler which I am sure using Jabelar's tutorial (http://jabelarminecraft.blogspot.com/p/minecraft-forge-1721710-keybinding.html) will be easily applied. Thank you again for all the help and making me realize my silly mistakes lol. I am going to have to review over some of those oracle tuts in more detail. At least I know and admit I have a weakness lol
  18. Alright so I think i fixed it, however I don't know if this method is SMP compatible. I pass the "X" via the packet to the Container Constructor Portion of PacketCode System.out.println("Congratulations you finally created a frigen packet that works!"); ContainerCelestialKeypouch.lockDown = i; player.openGui(MainRegistry.modInstance, message.id, player.worldObj, i, 0, 0); break; That packet sends the slotID to the Container and stores it in the container as: public static int lockDown; Then I changed the lockDown code to this: @Override public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) { // this will prevent the player from interacting with the item that opened the inventory: System.out.println("The lockdown is currently: " +lockDown); if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getSlotIndex() == lockDown) { return null; } return super.slotClick(slot, button, flag, player); This method seems to work however I can only test it on single player. It also prints out the correct index of the slot to indicate that it is correct. What I am going to do is add the same code to the itemClass itself so that the itemClass also pass the "x" to the container constructor. That will take care of the issue that will pop up if the user happens to OpenGUI with Y -> Proceed to Move Bag to Hotbar -> RightClick to open the bag. This will not "lockdown" the bag because packet which updates the "slotID" has not been sent as they are bypassing the packet process. Granted, next time they open the bag wit hteh hotkey it will update itself, but rather than do that I figured it be better just to pass the value via the itemclass onRightClick function. Here is my concern. Is this an efficient way to do this? In other words I know the lockDown int is static and as static this would make it the same across all instances, will that cause issues on SMP? My gut tells me it will especially since the int can and will change between each player. If that is the case then I could resolve that by simply creating a method within the container class that "fetches" the lockDown value each time, correct? Or hell, might it be even easier to simply store the slotID in the NBT tag and just pull from that, since it write NBT everytime you open it since it stores all its contents in the NBT data, why not store its own slotINdex? Or even better add in the item's onUpdate just write the item's current slotID to the NBT if it has changed.
  19. How did I miss that one. I swear I didn't realize I missed it. I go back to me looking at this code too much and not giving my eyes a rest from it. Alright, so it appears the shift click issue is resolved....The only one that remains is the issue in which when you open the inventory with the Keybind and the item is not selected. You "pick up" the item and can't place it in any other slot and have to drop it on the floor and re-pick it up. However, if you open the inventory with the Y key while you are holding the item it properly locks the item in place and any other items you are dragging around in your inventory can be placed elsewhere in the inventory with the exception of the Container for the keyPouch. Now in an effort to try and figure this out on my own I though that maybe it has to do with this line in the Container class. @Override public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) { // this will prevent the player from interacting with the item that opened the inventory: if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) { return null; } return super.slotClick(slot, button, flag, player); } Is that the correct hunch and is the issue that it is checking to see player.getHeldItem() hence why it works properly when you are "holding the item." And would I be correct in assuming I have to do the same think i did in the GUIHandler and get the slotID that has been passed to X to correct that? Or something to that effect? Or at the very least if not anything to do with getting the slot ID change that code somehow.
  20. Yes I misunderstood and honestly looking at it, that was a totally amateur mistake on my part which I should have realized with my prior experience even though it isn't in Java. I blame the fact that I have been trying to get this thing working since I learned how to make my first packet lol since all my users have been bugging me about it and I want to get it for them lol. But nevertheless still a careless mistake that I really shouldn't have made, especially since I have other checks just like that in other parts of my code. So that is resolved, and the packet only gets sent once now and the loop properly breaks. However here is a clip of the still existing original error: https://dl.dropboxusercontent.com/u/5221303/Error.mp4 The GUI isn't opening a ridiculous amount of times anymore, so that has been ruled out. Here is the code: http://pastebin.com/h404yYjv (Inventory) http://pastebin.com/bJzCS88i (Container) http://pastebin.com/wyGwaZem (Slot) I am currently using Jabelar's tutorial to rework the keybinding issue that you mentioned. But it appears that is not the source of this error as it is just a keypress that sends the packet.
  21. Alright, I optimized the packet according to your prior post. It works fine: public static class Handler extends AbstractServerMessageHandler<OpenGuiPacketAlt> { @Override public IMessage handleServerMessage(EntityPlayer player, OpenGuiPacketAlt message, MessageContext ctx) { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { if (player.inventory.getStackInSlot(i) != null) { if (i != player.inventory.currentItem) { System.out.println("Congratulations you finally created a frigen packet that works!"); player.openGui(MainRegistry.modInstance, message.id, player.worldObj, i, 0, 0); }else if (i == player.inventory.currentItem) { player.openGui(MainRegistry.modInstance, message.id, player.worldObj, player.inventory.currentItem, 0, 0); } } } return null; } } I know I am going to break the loop once we get to the slot that contains the item? So I know HOW to break the loop with the "break;" and I know the break will be in my for loop so that we don't cycle. But to only send the packet "when its needed" is where I am stuck. How would I go about doing that? Would I need an addition nested if in that for loop somewhere? EDIT: Ignore that else if - I didn't recognize it until I posted it here. I changed it to a regular else. ><
  22. Actually, yes. They do print out lol (and it is quite funny to see my own code message insult myself). And yes they print out what appears to be 36 times on point. Oopsy lol Could that actually be why? Because it is being sent so many times that a number of GUIs are "opening on top" of each other on the code side of things? Here is the dispatcher I created from your tutorial: http://pastebin.com/UR8HafKd
  23. Here is the KeyHandler code. It is relatively simple. I just followed a YouTube tutorial on it: http://pastebin.com/JMEcau60 With respect to the code optimization, yes I know for sure I need to work on it. I plan to work on that significantly. I have prior coding experience in C++, Lua, and PhP but for some ridiculous reason Java and I struggle. But it is for sure something I know I need to work on and I do plan on addressing it. I do appreciate the tutorial links and will look into them for sure.
  24. Ahhh, alright I see. That makes sense. I didn't think of it like that. Awesome. I think all that remains is the "ghost items" with the SHIFT+CLICK and the fact that when I open the inventory with the "Y" key and pick up an item in my inventory I can't place the item back down in any inventory slots and have to drop the item and re-pick it back up. Yet when I right click the item open, it works fine, however the ghost item still persists no matter how I open the inventory. Here is the ContainerClass: http://pastebin.com/ziQuBPUg (with the override) Here is the Inventory Class: http://pastebin.com/Ltvir5FJ And I took your advice in the tutorial and created a custom slot as I want only my keys to be storeable in that bag and not the actual bag itself: http://pastebin.com/tsw3tnH4
  25. Understood, I see I made my edit (i just reedited it now to change the color) right before your post. I had it working in the edited version but I just changed it to your suggestion and it works as well. However I am curious, for my own knowledge sake and for proper coding practice, what do you mean by "safer?"
×
×
  • Create New...

Important Information

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