Eilux Posted October 17, 2019 Posted October 17, 2019 I have tried the following code: @Mod.EventBusSubscriber public class HorseMeatDrops { @SubscribeEvent public void onLootTablesLoaded(LootTableLoadEvent event){ if (event.getName().equals(LootTableList.ENTITIES_HORSE)){ final LootPool main = event.getTable().getPool("main"); if (main != null) { new SetCount(new LootCondition[0],new RandomValueRange(1,3)); main.addEntry(new LootEntryItem(ModItems.RAW_HORSE, 10, 0, new LootFunction[0], new LootCondition[0], "loottable:rawhorse" )); } } } } It dose not seem to be working however any help would be appreciated. Quote
Draco18s Posted October 17, 2019 Posted October 17, 2019 44 minutes ago, Eilux said: new SetCount(new LootCondition[0],new RandomValueRange(1,3)); This is unused. You create a SetCount object and then immediately discard it. Also, you should definitely do this json-ly. https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderfarming/EventHandlers.java#L49-L57 https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/resources/data/harderfarming/loot_tables/entities/leather.json Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Eilux Posted October 17, 2019 Author Posted October 17, 2019 Some of the things like LootPool.builder() and TableLootEntry don't seem to be working is this because of different mappings? if so do you know the 1.12.2 equivalent (using mcp stable_39) Quote
SerpentDagger Posted October 17, 2019 Posted October 17, 2019 (edited) I don't think there's a LootPool builder in 1.12, so you have to set them up just with normal constructors*. What I've done is as follows: Declare a LootEntry object using new LootEntryTable(ResourceLocation tableIn, int weightIn, int qualityIn, LootCondition[] conditionsIn, String entryName), where the ResourceLocation points towards your json file. Declare a new LootPool using the LootEntry with new LootPool(LootEntry[] lootEntriesIn, LootCondition[] poolConditionsIn, RandomValueRange rollsIn, RandomValueRange bonusRollsIn, String name). Add the pool to the event's table *Unless I'm unaware of something here? Edited October 17, 2019 by SerpentDagger Formatting is a fickle beast Quote Fancy 3D Graphing Calculator mod, with many different coordinate systems. Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.
Eilux Posted October 18, 2019 Author Posted October 18, 2019 I'm having a bit of trouble getting this to work could you show me some kind of example? Quote
SerpentDagger Posted October 18, 2019 Posted October 18, 2019 34 minutes ago, Eilux said: could you show me some kind of example? This adds my custom loot, defined in the json file simple_chest, to all entries whose name contains "chests". @SubscribeEvent public void lootLoad(LootTableLoadEvent evt) { //Check for chest loot if (evt.getName().toString().contains("chests")) { //Declare entry LootEntry simpleDungeonEntry = new LootEntryTable(new ResourceLocation("artificialartificing:simple_chest"), 1, 0, new LootCondition[0], "artificialartificing:simple_chest_entry"); //Declare pool with entry inside LootPool simpleDungeonPool = new LootPool(new LootEntry[] {simpleDungeonEntry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "artificialartificing:simple_chest_pool"); //Add pool to chest loot evt.getTable().addPool(simpleDungeonPool); //Print table that loot is being added to System.out.println("AA loot added to table: " + evt.getName().toString()); } } simple_chest.json Quote Fancy 3D Graphing Calculator mod, with many different coordinate systems. Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.
Eilux Posted October 18, 2019 Author Posted October 18, 2019 It still don't seem to work here is my code: @Mod.EventBusSubscriber public class HorseMeatDrops { @SubscribeEvent public void onLootTablesLoaded(LootTableLoadEvent event){ if (event.getName().equals(LootTableList.ENTITIES_HORSE)){ LootEntry rawEntry = new LootEntryTable(new ResourceLocation("eatahorse:raw_horse"), 1, 0, new LootCondition[0], "eatahorse:raw_horse_entry"); LootPool rawPool = new LootPool(new LootEntry[] {rawEntry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "eatahorse:raw_horse_pool"); event.getTable().addPool(rawPool); } } } and here is the json file, the filepath to it is: resources/data/eatahorse/loot_tables/entities/raw_horse.json { "type": "minecraft:entity", "pools": [ { "rolls": 1, "entries": [ { "type": "minecraft:item", "functions": [ { "function": "minecraft:set_count", "count": { "min": 2.0, "max": 3.0, "type": "minecraft:uniform" } }, { "function": "minecraft:looting_enchant", "count": { "min": 0.0, "max": 1.0 } } ], "name": "eatahorse:raw_horse" } ] } ] } Quote
SerpentDagger Posted October 18, 2019 Posted October 18, 2019 (edited) As an aside, you've made sure that the methods run, right? lol Beyond that, though, I think your json should be placed in resources/assets/eatahorse/loot_tables/, unless you change the path accordingly. Your json file also has some differences in formatting from mine, which might or might not be fine (I'm not fabulous with loot jsons, so I'll leave that to someone else)*. *Edit: Here's a link to the loot table wiki. Tag structure is described in depth there. Edited October 18, 2019 by SerpentDagger Quote Fancy 3D Graphing Calculator mod, with many different coordinate systems. Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.
poopoodice Posted October 18, 2019 Posted October 18, 2019 Isn't name suppose to be in front of the rolls? Quote
poopoodice Posted October 18, 2019 Posted October 18, 2019 29 minutes ago, SerpentDagger said: As an aside, you've made sure that the methods run, right? lol Beyond that, though, I think your json should be placed in resources/assets/eatahorse/loot_tables/, unless you change the path accordingly. Your json file also has some differences in formatting from mine, which might or might not be fine (I'm not fabulous with loot jsons, so I'll leave that to someone else). Yeah you need to check if the class has been registered correctly, add some printlns to check is it actually being called Quote
poopoodice Posted October 18, 2019 Posted October 18, 2019 (edited) Also have a look at this Forge Doc It uses (evt.getName().toString().equals("minecraft:chests/simple_dungeon")) which means the way you are doing it might be wrong (event.getName().equals(LootTableList.ENTITIES_HORSE)) or at least add a println to check if it does work Edited October 18, 2019 by poopoodice Quote
Draco18s Posted October 18, 2019 Posted October 18, 2019 (edited) 6 hours ago, SerpentDagger said: 1.12 Oh. 1.12 Use this: https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/util/LootUtils.java Take that whole thing, put it in your project in (use your own package) and invoke its methods during the LootTableLoadEvent. (Yes, you can use it, its a utility class, I really don't care. I did a lot of futzing around figuring out how the stuff works so you don't have to) Example usagehttps://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/farming/FarmingEventHandler.java#L425 Edited October 18, 2019 by Draco18s Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Eilux Posted October 19, 2019 Author Posted October 19, 2019 I can't get it to work I created a test one that is very close to the example provided but it dose not seem to be doing anything. @Mod.EventBusSubscriber(modid = Main.MODID) public class HorseMeatDrops { @SubscribeEvent public void lootTableLoad(LootTableLoadEvent event) { //FamingBase.logger.log(Level.INFO, event.getName()); LootCondition[] chance; LootCondition[] lootingEnchant; LootFunction[] count; LootEntryItem[] item; LootPool newPool; LootTable loot = event.getTable(); if (event.getName().getPath().equals("entities/cow")) { LootUtils.removeLootFromTable(loot, Items.DIAMOND); LootUtils.addItemToTable(loot, Items.DIAMOND, 1, 2, 1, 2, 5, 0, 1, "minecraft:diamond", new LootUtils.IMethod() { @Override public void FunctionsCallback(ArrayList<LootFunction> lootfuncs) { LootCondition[] condition = {new EntityHasProperty(new EntityProperty[]{new EntityOnFire(true)}, LootContext.EntityTarget.THIS)}; LootFunction cooked = new Smelt(condition); lootfuncs.add(cooked); LootFunction looting = new LootingEnchantBonus(null, new RandomValueRange(1, 3), 0); lootfuncs.add(looting); } }); } } } Quote
Draco18s Posted October 19, 2019 Posted October 19, 2019 15 minutes ago, Eilux said: HorseMeatDrops 15 minutes ago, Eilux said: equals("entities/cow") You seem to be wanting to affect the horse, but you look for cow. 16 minutes ago, Eilux said: LootUtils.removeLootFromTable(loot, Items.DIAMOND); That item doesn't exist in that loot table, so I'm not sure why you're doing that. 17 minutes ago, Eilux said: LootUtils Hopefully you pulled in my LootUtils class, yes? Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Eilux Posted October 19, 2019 Author Posted October 19, 2019 It's name HorseMeatDrops because I wasn't sure what the filepath for horse was so i was testing it with the cow, and i do have the LootUtils class. Quote
Draco18s Posted October 19, 2019 Posted October 19, 2019 I'm not sure what's up, then. I pretty rigorously made sure I got things working when I updated stuff. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Eilux Posted October 20, 2019 Author Posted October 20, 2019 (edited) I've found the problem the method lootTableLoad was not static it is working fine now. Thank you for your help. Edited October 20, 2019 by Eilux Quote
Draco18s Posted October 20, 2019 Posted October 20, 2019 1 hour ago, Eilux said: was not static That'd do it. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.