Posted August 8, 20205 yr I'm having issues modifying the loot table specifically for the coral blocks. I have a global loot modifier set up that works for other blocks (cobblestone, gravel, etc), however it does not work on the coral blocks. I assume that it has something to do with the conditions already set in the loot table. I notice that when I mine coral blocks with a silk touch pickaxe my loot modifier is run, but when attempting to mine it with a custom item (my hammer) it does not work. I attempted to modify the table as follows: { "type": "minecraft:block", "pools": [ { "rolls": 1, "entries": [ { "type": "minecraft:alternatives", "children": [ { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:alternative", "terms": [ { "condition": "minecraft:match_tool", "predicate": { "tag": "exnihilosequentia:hammer" } }, { "condition": "minecraft:match_tool", "predicate": { "enchantments": [ { "enchantment": "minecraft:silk_touch", "levels": { "min": 1 } } ] } } ] } ], "name": "minecraft:tube_coral_block" }, { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:survives_explosion" } ], "name": "minecraft:dead_tube_coral_block" } ] } ] } ] } For the predicate that I added, I did add the tag I specified and my items are registered to that tag. What am I missing to get this to work? (Also, sorry about the big code block, I've forgotten how to do spoilers....)
August 8, 20205 yr You aren't supposed to modify the original loot table json when using Loot Modifiers. 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.
August 9, 20205 yr Author So then how would I go about modifying the loot drops of coral blocks? My modifier will fire when the block is broken with a silk touch pickaxe, but not with my custom tool.
August 9, 20205 yr Then your modifier is broken, as even an empty loot drop list will still invoke all modifiers. 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.
August 10, 20205 yr Author Ok, so my modifier looks like the following: public class UseHammerModifier extends LootModifier { public UseHammerModifier(ILootCondition[] conditionsIn) { super(conditionsIn); } @Nonnull @Override public List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { LogUtil.info("Fired Modifier"); ItemStack tool = context.get(LootParameters.TOOL); BlockState blockState = context.get(LootParameters.BLOCK_STATE); if (tool != null && blockState != null) { if (tool.getItem() instanceof HammerBaseItem) { List<ItemStack> newLoot = new ArrayList<>(); Block returnBlock = ModRegistries.HAMMER .getResult(blockState.getBlock().getRegistryName()); newLoot.add(new ItemStack(returnBlock)); return newLoot; } } return generatedLoot; } public static class Serializer extends GlobalLootModifierSerializer<UseHammerModifier> { @Override public UseHammerModifier read(ResourceLocation location, JsonObject object, ILootCondition[] ailootcondition) { LogUtil.info("UseHammerModifier.Serializer.read"); return new UseHammerModifier(ailootcondition); } } } I have a file under data/<mymodid>/loot_modifiers that looks like: { "type": "exnihilosequentia:use_hammer", "conditions": [ { "condition": "minecraft:alternative", "terms": [ { "condition": "minecraft:block_state_property", "block": "minecraft:cobblestone" }, { "condition": "minecraft:block_state_property", "block": "minecraft:gravel" }, { "condition": "minecraft:block_state_property", "block": "minecraft:sand" }, { "condition": "minecraft:block_state_property", "block": "minecraft:andesite" }, { "condition": "minecraft:block_state_property", "block": "minecraft:diorite" }, { "condition": "minecraft:block_state_property", "block": "minecraft:granite" }, { "condition": "minecraft:block_state_property", "block": "minecraft:netherrack" }, { "condition": "minecraft:block_state_property", "block": "minecraft:end_stone" }, { "condition": "minecraft:block_state_property", "block": "minecraft:tube_coral_block" }, { "condition": "minecraft:block_state_property", "block": "minecraft:brain_coral_block" }, { "condition": "minecraft:block_state_property", "block": "minecraft:bubble_coral_block" }, { "condition": "minecraft:block_state_property", "block": "minecraft:fire_coral_block" }, { "condition": "minecraft:block_state_property", "block": "minecraft:horn_coral_block" } ] } ] } The modifier is fired for all the blocks in the list, except for the coral blocks. What is wrong with my modifier to cause it to only fire with those blocks? You said that it should fire even when an empty drop happens, but that's not the case here.
August 10, 20205 yr Author I've updated the file in data/<mymodid>/loot_modifiers to the following and still get the same result: { "type": "exnihilosequentia:use_hammer", "conditions": [ { "condition": "minecraft:match_tool", "predicate": { "tag": "exnihilosequentia:hammer" } } ] } A tag file does exist and the modifier still fires for the same blocks in the previous post, except for coral blocks.
August 11, 20205 yr Go into the ForgeHooks class (net.minecraftforge.common) and drop a breakpoint all the way down towards the bottom inside the modifyLoot method and use the debugger to see what's going on. 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.
August 11, 20205 yr Author Dropped a breakpoint in that method (ForgeHooks:1192). Breaking coral blocks does not cause it to break there. Just to check, I broke another block and it did break there. Edited August 11, 20205 yr by Tikaji
August 11, 20205 yr Nothing I can see in the Coral block class indicates that it should bypass that method. Its called directly from the LootTable class 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.
August 11, 20205 yr Author I used a pickaxe on a coral block and that method is called. So for whatever reason, my custom tool will cause modifyLoot to be called on blocks other than coral blocks.
August 11, 20205 yr That's very strange. 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.
August 11, 20205 yr Author Figured it out. I did some digging and figured out that it was calling the base Item class' canHarvestBlock which has to be true in order for the block drops to be generated. So, my loot modifier works just fine, but the tool has to return that it can harvest the block you're mining.
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.