use of net.minecraft.world.level.storage.loot.LootPool in project MinecraftForge by MinecraftForge.
the class ForgeLootTableProvider method findAndReplaceInLootTableBuilder.
private boolean findAndReplaceInLootTableBuilder(LootTable.Builder builder, Item from, ToolAction toolAction) {
List<LootPool> lootPools = ObfuscationReflectionHelper.getPrivateValue(LootTable.Builder.class, builder, "f_7915" + "6_");
boolean found = false;
if (lootPools == null) {
throw new IllegalStateException(LootTable.Builder.class.getName() + " is missing field f_7915" + "6_");
}
for (LootPool lootPool : lootPools) {
if (findAndReplaceInLootPool(lootPool, from, toolAction)) {
found = true;
}
}
return found;
}
use of net.minecraft.world.level.storage.loot.LootPool in project MinecraftForge by MinecraftForge.
the class ForgeLootTableProvider method findAndReplaceInLootPool.
private boolean findAndReplaceInLootPool(LootPool lootPool, Item from, ToolAction toolAction) {
LootPoolEntryContainer[] lootEntries = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "f_7902" + "3_");
LootItemCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "f_7902" + "4_");
boolean found = false;
if (lootEntries == null) {
throw new IllegalStateException(LootPool.class.getName() + " is missing field f_7902" + "3_");
}
for (LootPoolEntryContainer lootEntry : lootEntries) {
if (findAndReplaceInLootEntry(lootEntry, from, toolAction)) {
found = true;
}
if (lootEntry instanceof CompositeEntryBase) {
if (findAndReplaceInParentedLootEntry((CompositeEntryBase) lootEntry, from, toolAction)) {
found = true;
}
}
}
if (lootConditions == null) {
throw new IllegalStateException(LootPool.class.getName() + " is missing field f_7902" + "4_");
}
for (int i = 0; i < lootConditions.length; i++) {
LootItemCondition lootCondition = lootConditions[i];
if (lootCondition instanceof MatchTool && checkMatchTool((MatchTool) lootCondition, from)) {
lootConditions[i] = CanToolPerformAction.canToolPerformAction(toolAction).build();
found = true;
} else if (lootCondition instanceof InvertedLootItemCondition) {
LootItemCondition invLootCondition = ObfuscationReflectionHelper.getPrivateValue(InvertedLootItemCondition.class, (InvertedLootItemCondition) lootCondition, "f_8168" + "1_");
if (invLootCondition instanceof MatchTool && checkMatchTool((MatchTool) invLootCondition, from)) {
lootConditions[i] = InvertedLootItemCondition.invert(CanToolPerformAction.canToolPerformAction(toolAction)).build();
found = true;
} else if (invLootCondition instanceof AlternativeLootItemCondition && findAndReplaceInAlternative((AlternativeLootItemCondition) invLootCondition, from, toolAction)) {
found = true;
}
}
}
return found;
}
Aggregations