Posted October 19, 20214 yr I have a loot modifier that updates all loot tables to drop specific items when using certain tools. Or at least I thought it did. It works on blocks, but not for entities. However I've tested it with the condition "killed_by_player" and that works for entities, the problem is testing these conditions together fails: Spoiler { "type": "mod_id:my_modifier", "conditions": [ { "condition": "minecraft:match_tool", "predicate": { "tag": "mod_id:my_tools" } }, { "condition": "minecraft:killed_by_player" } ] } So then I tried creating a custom ILootCondition, which registered fine but still failed: Spoiler public class MatchToolKilledByPlayer implements ILootCondition { private final ItemPredicate predicate; public MatchToolKilledByPlayer(ItemPredicate predicate) { this.predicate = predicate; } public LootConditionType getType() { return new LootConditionType(new MatchToolKilledByPlayer.Serializer()); } public Set<LootParameter<?>> getReferencedContextParams() { return ImmutableSet.of(LootParameters.TOOL, LootParameters.LAST_DAMAGE_PLAYER); } public boolean test(LootContext p_test_1_) { ItemStack itemstack = p_test_1_.getParamOrNull(LootParameters.TOOL); return itemstack != null && this.predicate.matches(itemstack) && p_test_1_.hasParam(LootParameters.LAST_DAMAGE_PLAYER); } public static class Serializer implements ILootSerializer<MatchToolKilledByPlayer> { public void serialize(JsonObject p_230424_1_, MatchToolKilledByPlayer p_230424_2_, JsonSerializationContext p_230424_3_) { p_230424_1_.add("predicate", p_230424_2_.predicate.serializeToJson()); } public MatchToolKilledByPlayer deserialize(JsonObject p_230423_1_, JsonDeserializationContext p_230423_2_) { ItemPredicate predicate = ItemPredicate.fromJson(p_230423_1_.get("predicate")); return new MatchToolKilledByPlayer(predicate); } } } If anyone has advice I'd be very appreciative. Edited October 19, 20214 yr by urbanxx001
October 19, 20214 yr Author Ah ok that makes sense, I should've looked closer at the list of loot conditions. Thanks!
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.