Jump to content

HalestormXV

Forge Modder
  • Posts

    328
  • Joined

  • Last visited

Everything posted by HalestormXV

  1. Finally managed to get to testing this piece and it appears the above code segment crashes: https://pastebin.com/XN3CtnS1 Its throwing a null. Perhaps the LootPool is not named "main." not sure if the caps matter with the LootTables or not or if it is just a separate name? The crash triggers when attempting to log into the world. So I know it is not a registration issue.
  2. Oh I see, sorry I misunderstood you. So your basically just suggesting: private static LootEntry scryingOrb = new LootEntryItem(ItemInit.ITEM_SCRYING_ORB, 30, 15, new LootFunction[0], new LootCondition[0], Reference.MODID+":loot_scrying_orb"); private static LootEntry basicEssence = new LootEntryItem(ItemInit.RUNE_ESSENCE, 20, 10, new LootFunction[0], new LootCondition[0], Reference.MODID+":loot_basic_essence"); @SubscribeEvent public void onLootTableLoad(final LootTableLoadEvent event) { if(event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) { event.getTable().getPool("main").addEntry(scryingOrb); } event.getTable().getPool("main").addEntry(basicEssence); } } I'd imagine? And if so that being said what does the "qualityIn" refers to (third param of the LootEntryItem).
  3. What do you suggest may be a simple way to do that? Im hoping I dont have to generate a whole list and such. I'd imagine this would be built in?
  4. public class LootTableHandler { public static final ResourceLocation CULTIST = LootTableList.register(new ResourceLocation(Reference.MODID, "cultist")); private static LootEntry scryingOrb = new LootEntryItem(ItemInit.ITEM_SCRYING_ORB, 30, 15, new LootFunction[0], new LootCondition[0], Reference.MODID+":loot_scrying_orb"); private static LootEntry basicEssence = new LootEntryItem(ItemInit.RUNE_ESSENCE, 20, 10,new LootFunction[0], new LootCondition[0], Reference.MODID+":loot_basic_essence"); @SubscribeEvent public void onLootTableLoad(final LootTableLoadEvent event) { if(event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) { event.getTable().getPool("main").addEntry(scryingOrb); } if(event.getName().equals(LootTableList.getAll())) {event.getTable().getPool("main").addEntry(basicEssence);} } } Specifically talking about the yellow lines. I am imagining the .getAll() literally will add this to everything, which is fine and intentional. At the top where I am creating the entry I'm just curious as to what the "qualityIn" refers to (third param of the LootEntryItem).
  5. I have a relatively simple problem but I just am missing it so I need another set of eyes if anyone can help. I think it is just code fatigue. Here is my Slot: https://hastebin.com/ijuzelimoz.java Line 55 - the onCrafting. I have a few things set up where if the player has a potion effect you double the EXP otherwise just pull the EXP values from a list stored in the other class and that is fine. No issues. Down near the bottom, line 80 I have my reagentControl class which literally is a utility for me to check things in inventories, etc. etc. and it is looking to see if the player has a specific item in their inventory. If it has it, great the reagentControl does the heavy lifting and stored the exp into the Item. No problems no issues and it works fine. The problem I am facing is that this check is only being called half the time. So if there are two items that are removed from the slot it will run twice (as it should (not once) ). If there are three items in the slot (and you shift+right click or just drag them out) the check will only run twice and ignore the fact that a third item was in there. If there are 10 items in the slot and you take them all out, the check will run 5 times instead of the 10 times. So maybe I am halfing something somwhere and I am just missing it. Anyone mind taking a look at letting me know what or where I made the error. If you need any of the other classes let me know, although I don't think they are relvant to this but maybe that is why I can't see the issue, because the othe classes really are relevant to it. EDIT: Nvm I think I fixed it. I just needed a buffer int it seemed so that it can use that to store and calculate independently. https://hastebin.com/ekodujemed.java Looks like it is actually working now.
  6. I placed the wrong link. https://pastebin.com/sE4jZ6TH - Did - Done - Got It - Done - Alright now I understand. The code linked above in this post works just fine it seems. And to get this particular capability off this item I'd do: stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); right?
  7. Alright, so like above I created the ItemStackHandler in the constructor. So ItemStackHelper (which is what I have seen used in TileEntities) doesn't need to be used at all here to save the items. So then how do you save everything here: @Override public void deserializeNBT(NBTTagCompound nbt) { //Do your saving here if (nbt.hasKey("RunesStored")) { CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().readNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, handler, null, nbt.getTag("RunesStored")); } } Do you need to put everything into a List/Field? Or into something like that. Or am I a complete idiot and just having that is all I need? I'm beginning to think I am just a total idiot becasue I am testing with this code now:https://hastebin.com/ajakojucic.java and it seems to be working just fine. And is that what you mean @diesieben07 when you were saying I literally only needed the handler?
  8. - That was dumb, should have recognized it and have since changed it. - I don't quite follow? Do you mean that ItemStackHelper isn't to be used at all? Everything is done with the ItemStackHandler ? So, I'd have to cycle through the 4 slots etc. and add the items like that? I originally put the List<ItemStack> because I thought that is what is required by ItemStackHelper. - Alright https://hastebin.com/bikilixoca.java So that is the updated code. Better? Note I left the List<ItemStack> in there because I know that is still the outstanding issue now and it is simply a place holder at this point.
  9. Okay, so what would you suggest then. Like I said, this is a first time for me working with the pre-made Capabilities so I am shooting in the dark and just hoping for the best until I get and understand it.
  10. If anyone can maybe take a look at this and see what I am royally fucking up I'd appreciate it, because I have been at it for hours. I just want to open my GUI lol. Here is the relevant pieces of code: https://pastebin.com/dLrL2JDu (The Item) Something in there has to be screwed up somewhere. I just can't see it maybe because I have been working too long on it. According to the crash it looks like it is crashing when it attempts to open up the container as opposed to the GUI. I see that it is throwing a null but I don't quite understand why? The item exists, you need to actually right-click it, the slots are there in the container? Maybe I am injecting the capability into the item wrong? Maybe I forgot to register it somewhere? (although it is a forge pre-made cap which I think automatically registers with the annotation?) The report seems to point to adding slots? Which also doesn't seem to make much sense. So any help f would be greatly appreciated. I know there may be "inefficient" code in this but I am just trying to get this work at the moment and I can work with efficency later since this mod isn't released yet. EDIT: And yes I know this could be the completly wrong way to do this and thats fine. The http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ is where I was bascially copying from. If it is completly wrong to do it this way I understand but I still would like to know the correct way to do this. I created a few capabilities already and I know I could do the same for this, but if I can use a built in capability (which I have not tried yet hence why I am trying this) then why not. EDIT 2: Yeah apparently I did the whole capability thing wrong so I reworked the whole thing (I left the original pastebin link, but put a strikethrough) and here is the new version of the Item. I am stuck on how to just make sure it saves the entire inventory. Help is appreciated: https://pastebin.com/uaSan6C0 EDIT 3: I fixed the crashing (I made the stupidest mistake in my Container code), now I just need to figure out how to get the items to save correctly to the ItemStack. Please help with that if possible. I spoilered out the other links to the other pieces of code since they are no longer relevant for this issue.
  11. So I was reading over: https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ and if I am understanding this correctly, it is possible for me to create an item that has an inventory (that you can open with say a Shift+Right Click) and not need to create my own capability to take care of it right? I can just utilize the IItemHandler. Obviously I will have to create the GUI, and the Slots, etc. etc but it won't be required to create a whole new capability? I understand it may be relatively basic but this Item is literally supposed to have only a few slots and only hold certain items. Nothing overly complex is planned to be implemented into it. If I have to create my own capability for it that is fine, but if I can avoid it that is even better.
  12. Alright no biggie. Figured I'd ask. Thanks.
  13. Mainly I want to use it for the color and loot. It's really just a simple use and I'm curious about it. (I know you can change color of items via lang file)
  14. I think I saw this somewhere here on the forums but I can't seem to find it via any search (unless I'm just missing it). I'm looking to create my own rarities and I vaugly remember seeing that there is a built in EnumHelper or something like that? Is that was would need to be needed and placed into a class that extends the EnumRarities? Becasue I don't think you can just override the existing rarities right?
  15. Oh I didn't know you can put in the user name and password like that. Yeah InteliJ has the option to edit the run config. I may give that a try. Yeah NBT in thought is really simply, like this was one of the few things I knew EXACTLY what I wanted to do but just couldn't get it to work the way I wanted. Yes the NBT is working now thankfully. There is no issue, I have yet to test in an SMP environment but it shouldn't make much of a difference. I even managed to set up a packet that will allow the client to fetch the results on a keypress and display a list of what they know/have learned. However, the only thing which I may need to do next is figure out how to set up a Sync packet. Mainly, just to lay out the foundation if I plan to make a GUI or something like that in the future to display it in a more "fansy" way. I know there is the ByteBufUtils.writeTag(buf, nbt) and ByteBufUtils.readTag(buf) but to be quite honest I don't think I want to look at this specific SpellLearning code for a little while lol. However if you have any tips or suggestions or samples on how I would lay the packet out I am all ears. As i said it is not something I need right now to make this function but it would provide a solid base should I decide to do something like a GUI or something in the future.
  16. Well that about solves it then I guess. The only way a player in my mod will ever learn a spell is by a right click so that will automatically be handled. Well it has been a long and gruling "class" but I think it can be marked as solved. As bothersom as I have been to both you and @Draco18s and as frustrating it is dealing with someone who has never utilized what was needed in this particular instance I do appreciate the efforts and the "drill sergeant" methods that were employed as I won't soon forget what was learned in creating this.
  17. Yes, I have failed a copy-paste and thus is the result of staring at a piece of code too long and wanting to be done with it. Actually I take that back, the server in SMP is the one who knows about the capability data not the client so the client needs to fetch it from the server not vice versa. Right? But if I want to add something to the known spells with an item right click or something like that, then it would have to be sent from client to server?
  18. InteliJ is where I do the code and the @Override annotation is already there, it just wasn't pasted. Probably because I erased some notes before pasting to hastebin and the annotation might have been accidently deleted in the paste. Since I am still on this topic, and rather than making a whole new thread. Can this be Synced with ByteBufUtils.writeTag(buf, nbt) and ByteBufUtils.readTag(buf) in packets or does my Packet need to take apart the int[] and place them into bytes and reassemble the bytes into the int[]? as I want the player to be able to eventually open a GUI and see a list of spells or at least key-press and see the list in chat.
  19. 1) The setSpellList is useless at this point. I originally thought that I had to add everything all at once and that's why I originally made it. Right now it is completely useless since the learnedSpell can just be looped. (although a player will only get one spell at a time anyway) Unless I figure something out in the future. 2) Because i have been staring at this for way to long and got incredibly frustrated with it and should have just deleted it since it is not necessary. 3) The logging is just there for me to make sure it is working. I could use a system.out or whatever but I was just checking to see if it works and it is easier for me to see that in my console when the message appears. 4) InteliJ already is overriding it.
  20. Got it. Thanks. I've managed to get it working it would seem. Here is the code. I am not sure if this is where you were both trying to push me (i swear the two of you are like Yin&Yang which is quite awesome btw) but it is functioning as it should. Though is it correct? https://hastebin.com/ebutefejom.java
  21. Okay, so in other words, get rid of deserialize and serialized completely from the Functions class of this code. Leave it in the Provider. I only have to worry about the read and write functions? Which would coincide with what because I am not letting the Provider do its job since I am overwriting it within my functions. Correct? Like I said, I know this is probably simple and perhaps I am over-complicating this because I am trying to understand it so in the future I don't run into these issues. So I apologize for the ignorance but I do appreciate it.
  22. Alright. Yes I figured that part out already. But no matter which way I look at it or change it the results are still the same: https://hastebin.com/evupalutuv.java Data is stored and saved and once you log back in the tag data is erased but and an empty tag remains. Which leads me to believe that my deserializeNBT is the next place to work on? All it is simply doing as the code stands now is simply getting the array and doing nothing with it correct? So logic would say that the next step for the deserializeNBT is to take the array it retrieved and place it back into the List<Integer> knownSpells correct?
  23. Okay but a field is still needed (just not initialized) that is going to be holding the data right. Surely you can't do it all via local.
  24. Point one, because I forgot to backspace it out, quite literally I just forgot. I know it does nothing with this new code. Point two, so rather than have it be a field it should simply just be a local variable? Or don't use it at all and simply just use the Ints.toArray
  25. int[] convertedList = Ints.toArray(knownSpells); convertedList = nbt.getIntArray("LearnedSpells"); Actually a really simple answer for that one, I just didn't remove it yet. At this point it is just a placeholder until I write the getSpellList and setSpellList functions. Once I do that i will be able to get rid of the known spells entirely. EDIT: Well by making all the changes I am back to where I started. The int list stays and updates. So if I add spells 13, 2, 6 into the NBT tag they all stay there and if you open the NBT you can see that the capability is there and the data gets stored in the correct order. Then once you log out that data stays also. Once you log back in though and add a new ID to the list the old data gets erased and is replaced with an empty tag all over again just containing that ID. Perhaps this is because I am creating a new tag? https://hastebin.com/izajuwugum.java Once I get this functionality working properly i can work on proper naming and what not. Right now the issue seems to be the data is being overwritten each time I log back into the character. Which to me says soemthing is maybe(?) wrong with my read, write, serilize, and deserilize. Or maybe it is because instead of adding to an existing list I am simply "setting" a new list each time instead of adding to an existing if one does in fact exists? I can't seem to find something that would add an entry to the list instead of setting it each time.
×
×
  • Create New...

Important Information

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