I've managed to get this working with blocks, but not with entities. The best I've managed to do is to get EntityHasProperty.test() to fire when I kill any mob, but the `target` property is null, which casues a `NullPointerException`.
Here's the data generation code:
public class ModGlobalLootModifierProvider extends GlobalLootModifierProvider {
public ModGlobalLootModifierProvider(DataGenerator gen) {
super(gen, Mod.MOD_ID);
}
@Override
protected void start() {
add("hoglin_meat_modifier", RegistryHandler.HOGLIN_MEAT_MODIFIER.get(), new HoglinMeatModifier(
new ILootCondition[] {
EntityHasProperty.builder(LootContext.EntityTarget.THIS, EntityPredicate.Builder.create().type(EntityType.HOGLIN)).build(),
}
));
}
}
which generates the following file:
{
"conditions": [
{
"condition": "minecraft:entity_properties",
"predicate": {
"type": "minecraft:hoglin"
},
"entity": "this"
}
],
"type": "modid:hoglin_meat_modifier"
}
As I said before, all this does is cause a NullPointerException when EntityHasProperty.test() is called. I can't figure out why, though, because I pass both parameters into EntityHasProperty.build(). Maybe something is going wrong when the file is deserialized? The EntityPredicate is correct at runtime, anyway.
I've forked the repo and have patched the link -- I'll update the rest of the documentation to match the example code it links to, then set up the pull request.