Jump to content

theishiopian

Members
  • Posts

    150
  • Joined

  • Last visited

Everything posted by theishiopian

  1. I'm running on java 8, forge-1.12.2-14.23.5.2768. I'll have the stacktrace and such shortly.
  2. I'm trying to build a fresh mod from the forge MDK, but I'm running into a problem. Whenever I run setupDecompWorkspace, it says: FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\Andrew\Coding\Minecraft\Forge\UsefulPotionArrows\build.gradle' line: 24 * What went wrong: A problem occurred evaluating root project 'UsefulPotionArrows'. > No such version exists! * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED I haven't tampered with the build.gradle file in any way, or anything else in the folder. Its all fresh from the zipped mdk download from the forge website.
  3. Huh, ill probably do that once i get it working with just blocks.
  4. I know it has a foragetable. I think the foragetables are getting set to null somewhere. I hadnt considered using blockstates. Do they have a string representation like blocks do? (eg minecraft:dirt)
  5. Thanks for the tip. Im going to massively refactor this tomorrow. Ill also step through it with the debugger. I think it has to do with the way im creating the forage pools from json. Which is odd because it worked before. If i have any more issues tommorow, ill create a new thread. Night all.
  6. Ok, this is very bizzare. Whenever I try to reference my hashtable, I get a null pointer exception. But whenever I do a null check on it, it returns false.
  7. Also, what did you mean by "instantiated into an instance"? Do you mean initilized as an object? If so, I'm already doing that. ForageTable table = ForageCraftMod.ForageDict.get(event.getState().getBlock());
  8. Ok, good to know. For some reason, my list is becoming null. The weird thing is that I can call from it elsewhere and get the correct result. Anyways, thanks for the clarification, that really helps narrow it down.
  9. SO, for clarification, are there no problems with using for loops in event handlers?
  10. It seems you are right, just calling table.getPools(); crashes the game. Whats perplexing is its just a simple return function. public List<ForagePool> getPools() { return this.table; } this.table is a list of foragetables.
  11. Line 33 is the for loop.
  12. Also, heres the crash log, if it helps: Pastebin Link
  13. @SubscribeEvent public void blockBreak(HarvestDropsEvent event) { World world = event.getWorld(); if(!world.isRemote) { ForageTable table = ForageCraftMod.ForageDict.get(event.getState().getBlock()); java.util.List<ForagePool> pools = table.getPools(); for(int i = 0; i != pools.size(); i++) { ForagePool pool = table.getPool(i); if(CHANCE.nextFloat()<pool.getChance()) { event.getDrops().add(new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation(pool.getItem())), pool.getAmount())); } } } } ForageDict is a hashtable using blocks as keys and returning a foragetable object. foragetables are containers for lists of foragepools, which hold a set of primitive values for use in this code, which adds new drops to blocks via json files.
  14. I need to loop through a list in an event handler (specifically for the HarvestDropsEvent), but when I use a for loop it throws a ticking world exception. Is there an accepted way of looping in event handlers?
  15. That works. Additionally, I was trying to run this in preinit, and that was also contributing to the problem, as the items didnt exist yet. Thanks.
  16. I'm trying to get an item using its registry name, which I'm representing as a string. This works fine with vanilla items, like minecraft:dirt, but not with modded ones like foragecraft:leek. Is there a different method I should use?
  17. I've followed this rabbit hole for days, I can't find anything. I've narrowed the problem down to the resource location, or possibly the loot context, but I can't find anything wrong with either, based on similar usages of the code in other projects.
  18. I've looked at that method before, and I can't see the problem. Since vanilla uses it all the time, I know it works.
  19. I apologize if I'm missing something terribly obvious, I've never used loot tables before.
  20. I assume you mean generateLootForPools?
  21. Yes, I know that. What I want to know is why.
  22. [19:30:41] [Server thread/INFO] [STDOUT]: [com.theishiopian.foragecraft.handler.BlockForageHandler:blockBreak:31]: net.minecraft.world.storage.loot.LootTable@58554c7e [19:30:41] [Server thread/INFO] [STDOUT]: [com.theishiopian.foragecraft.handler.BlockForageHandler:blockBreak:44]: []
  23. I'm trying to make a system that allows you to define loot tables for blocks. To do this, I'm using the method shown in the forge docs, but it doesnt seem to work for me. The list that stores the resulting itemstacks never gets populated, and the block drops nothing. Here's the event handler I'm using: https://pastebin.com/1Q5JSC7H And heres the table, which is located at src/main/resources/assets/foragecraft/loot_tables/dirt.json: https://pastebin.com/tZQhZfHn
  24. I think he means the JSON itself is invalid. Check it with this: http://jsonlint.com/#
  25. I've been trying to use a loot table to define the drops for a block, but I'm having trouble reading the loot table. I have confirmed that the ResourceLocation is pointing to the right table, but generateLootForPools is spitting out an empty list. Here is my code: https://pastebin.com/1Hf6nnxC And here's the loot table I'm using: https://pastebin.com/LtFrh9Ra I have a sneaking suspicion that the problem is with the loot context thing, but I have no idea what that is or what it does, even after studying the source code. Is that the problem, or is there something else I'm missing?
×
×
  • Create New...

Important Information

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