use of net.minecraft.data.DirectoryCache in project iChunUtil by iChun.
the class LootTableGen method act.
@Override
public void act(DirectoryCache cache) {
Map<ResourceLocation, LootTable> map = Maps.newHashMap();
TriConsumer<LootParameterSet, ResourceLocation, LootTable.Builder> consumer = (set, key, builder) -> {
if (map.put(key, builder.setParameterSet(set).build()) != null)
throw new IllegalStateException("Duplicate loot table " + key);
};
for (Data data : sets) {
data.accept((key, builder) -> consumer.accept(data.lootSet(), key, builder));
}
map.forEach((key, table) -> {
Path target = this.gen.getOutputFolder().resolve("data/" + key.getNamespace() + "/loot_tables/" + key.getPath() + ".json");
try {
IDataProvider.save(GSON, cache, LootTableManager.toJson(table), target);
iChunUtil.LOGGER.info("Saved loot table {}", target);
} catch (IOException ioexception) {
iChunUtil.LOGGER.error("Couldn't save loot table {}", target, ioexception);
}
});
}
use of net.minecraft.data.DirectoryCache in project some-assembly-required by ochotonida.
the class Advancements method act.
@Override
public void act(DirectoryCache cache) {
Set<ResourceLocation> set = Sets.newHashSet();
Consumer<Advancement> consumer = (advancement) -> {
if (!set.add(advancement.getId())) {
throw new IllegalStateException("Duplicate advancement " + advancement.getId());
} else {
Path path1 = getPath(PATH, advancement);
try {
IDataProvider.save((new GsonBuilder()).setPrettyPrinting().create(), cache, advancement.copy().serialize(), path1);
} catch (IOException ioexception) {
SomeAssemblyRequired.LOGGER.error("Couldn't save advancement {}", path1, ioexception);
}
}
};
new SomeAssemblyRequiredAdvancements().accept(consumer);
}
use of net.minecraft.data.DirectoryCache in project bioplethora by AquexTheSeal.
the class BioAdvancementProvider method run.
@Override
public void run(DirectoryCache cache) {
Path path = this.datagen.getOutputFolder();
Set<ResourceLocation> set = Sets.newHashSet();
Consumer<Advancement> consumer = (advancement) -> {
if (!set.add(advancement.getId())) {
throw new IllegalStateException("Duplicate advancement " + advancement.getId());
} else {
Path path1 = getPath(path, advancement);
try {
IDataProvider.save(GSON, cache, advancement.deconstruct().serializeToJson(), path1);
} catch (IOException e) {
Bioplethora.LOGGER.error("Couldn't save advancement {}", path1, e);
}
}
};
this.register(consumer);
}
use of net.minecraft.data.DirectoryCache in project ChaosAwakens by ChaosAwakens.
the class CAAdvancementProvider method run.
@Override
public void run(DirectoryCache cache) {
Path path = this.generator.getOutputFolder();
Set<ResourceLocation> set = Sets.newHashSet();
Consumer<Advancement> consumer = (advancement) -> {
if (!set.add(advancement.getId())) {
throw new IllegalStateException("Duplicate advancement " + advancement.getId());
} else {
Path path1 = getPath(path, advancement);
try {
IDataProvider.save(GSON, cache, advancement.deconstruct().serializeToJson(), path1);
} catch (IOException e) {
ChaosAwakens.LOGGER.error("Couldn't save advancement {}", path1, e);
}
}
};
this.register(consumer);
}
use of net.minecraft.data.DirectoryCache in project AntimatterAPI by GregTech-Intergalactical.
the class AntimatterAdvancementProvider method act.
@Override
public void act(@Nonnull DirectoryCache cache) {
Path folder = this.gen.getOutputFolder();
Set<ResourceLocation> locs = new ObjectOpenHashSet<>();
Consumer<Advancement> consumer = a -> {
if (!locs.add(a.getId()))
throw new IllegalStateException("Duplicate advancement " + a.getId());
else {
Path path = getPath(folder, a);
try {
IDataProvider.save(Ref.GSON, cache, a.copy().serialize(), path);
} catch (IOException e) {
LOGGER.error("Couldn't save advancement {}", path, e);
}
}
};
advancements.forEach(a -> a.accept(consumer));
}
Aggregations