Search in sources :

Example 1 with ObjectLootTableAccess

use of net.moddingplayground.frame.impl.toymaker.ObjectLootTableAccess in project frame-fabric by moddingplayground.

the class AbstractLootTableGenerator method accept.

@SuppressWarnings("ConstantConditions")
@Override
public void accept(BiConsumer<Identifier, LootTable.Builder> biConsumer) {
    this.generate();
    Set<Identifier> set = Sets.newHashSet();
    Registry<T> registry = this.getRegistry();
    Iterable<T> objects = registry.stream().filter(obj -> registry.getId(obj).getNamespace().equals(this.modId))::iterator;
    for (T obj : objects) {
        Identifier id = ((ObjectLootTableAccess) obj).access_getLootTableId();
        this.testObject(id, obj);
        if (id != LootTables.EMPTY && set.add(id)) {
            LootTable.Builder builder = this.map.remove(id);
            if (builder == null) {
                throw new IllegalStateException(String.format("Missing loottable '%s' for '%s'", id, registry.getId(obj)));
            }
            biConsumer.accept(id, builder);
        }
    }
    this.map.forEach(biConsumer);
}
Also used : LootTable(net.minecraft.loot.LootTable) LootPoolEntry(net.minecraft.loot.entry.LootPoolEntry) UniformLootNumberProvider(net.minecraft.loot.provider.number.UniformLootNumberProvider) Function(java.util.function.Function) BoundedIntUnaryOperator(net.minecraft.loot.operator.BoundedIntUnaryOperator) Block(net.minecraft.block.Block) BinomialLootNumberProvider(net.minecraft.loot.provider.number.BinomialLootNumberProvider) BiConsumer(java.util.function.BiConsumer) ObjectLootTableAccess(net.moddingplayground.frame.impl.toymaker.ObjectLootTableAccess) StatePredicate(net.minecraft.predicate.StatePredicate) BlockStatePropertyLootCondition(net.minecraft.loot.condition.BlockStatePropertyLootCondition) LootCondition(net.minecraft.loot.condition.LootCondition) LootTables(net.minecraft.loot.LootTables) Property(net.minecraft.state.property.Property) AbstractGenerator(net.moddingplayground.frame.api.toymaker.v0.generator.AbstractGenerator) Set(java.util.Set) ConstantLootNumberProvider(net.minecraft.loot.provider.number.ConstantLootNumberProvider) ItemEntry(net.minecraft.loot.entry.ItemEntry) Sets(com.google.common.collect.Sets) Registry(net.minecraft.util.registry.Registry) RandomChanceLootCondition(net.minecraft.loot.condition.RandomChanceLootCondition) LootPool(net.minecraft.loot.LootPool) SetCountLootFunction(net.minecraft.loot.function.SetCountLootFunction) ItemConvertible(net.minecraft.item.ItemConvertible) Identifier(net.minecraft.util.Identifier) ConditionalLootFunction(net.minecraft.loot.function.ConditionalLootFunction) LootNumberProvider(net.minecraft.loot.provider.number.LootNumberProvider) LootTable(net.minecraft.loot.LootTable) ObjectLootTableAccess(net.moddingplayground.frame.impl.toymaker.ObjectLootTableAccess) Identifier(net.minecraft.util.Identifier)

Aggregations

Sets (com.google.common.collect.Sets)1 Set (java.util.Set)1 BiConsumer (java.util.function.BiConsumer)1 Function (java.util.function.Function)1 Block (net.minecraft.block.Block)1 ItemConvertible (net.minecraft.item.ItemConvertible)1 LootPool (net.minecraft.loot.LootPool)1 LootTable (net.minecraft.loot.LootTable)1 LootTables (net.minecraft.loot.LootTables)1 BlockStatePropertyLootCondition (net.minecraft.loot.condition.BlockStatePropertyLootCondition)1 LootCondition (net.minecraft.loot.condition.LootCondition)1 RandomChanceLootCondition (net.minecraft.loot.condition.RandomChanceLootCondition)1 ItemEntry (net.minecraft.loot.entry.ItemEntry)1 LootPoolEntry (net.minecraft.loot.entry.LootPoolEntry)1 ConditionalLootFunction (net.minecraft.loot.function.ConditionalLootFunction)1 SetCountLootFunction (net.minecraft.loot.function.SetCountLootFunction)1 BoundedIntUnaryOperator (net.minecraft.loot.operator.BoundedIntUnaryOperator)1 BinomialLootNumberProvider (net.minecraft.loot.provider.number.BinomialLootNumberProvider)1 ConstantLootNumberProvider (net.minecraft.loot.provider.number.ConstantLootNumberProvider)1 LootNumberProvider (net.minecraft.loot.provider.number.LootNumberProvider)1