mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-10 20:11:35 +01:00
The last lang merge
- Add CreateRegistrate#addLangPostprocessor to arbitrarily transform lang entry map generated by Registrate - Remove all uses of and deprecate LangMerger and LangPartial - Move additional tag definitions from TagGen to CreateRegistrateTags - Move GatherDataEvent handler to CreateDatagen class - Move some Create-specific datagen classes to infrastructure package
This commit is contained in:
parent
e5e0477b49
commit
0ee8e18587
21 changed files with 3481 additions and 3643 deletions
|
@ -52,7 +52,6 @@ minecraft {
|
|||
client {
|
||||
workingDirectory project.file('run')
|
||||
arg '-mixin.config=create.mixins.json'
|
||||
arg '-mixin.config=flywheel.mixins.json'
|
||||
//jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling
|
||||
property 'forge.logging.console.level', 'info'
|
||||
mods {
|
||||
|
@ -81,6 +80,7 @@ minecraft {
|
|||
|
||||
data {
|
||||
workingDirectory project.file('run')
|
||||
arg '-mixin.config=create.mixins.json'
|
||||
property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP'
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
args '--mod', 'create', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
|
||||
|
|
|
@ -583,7 +583,7 @@ bf2b0310500213ff853c748c236eb5d01f61658e assets/create/blockstates/yellow_toolbo
|
|||
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
|
||||
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
|
||||
4fd8347dfb20e6e5752b8b905850762a88c88c02 assets/create/lang/en_ud.json
|
||||
4e84e9d171ca389a372fda7e30a73ddc7d41185a assets/create/lang/en_us.json
|
||||
a78f92c3e08c454aba650ef5dda97d8d9a494689 assets/create/lang/en_us.json
|
||||
487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json
|
||||
b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json
|
||||
3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
@ -318,12 +319,10 @@ public class AllSoundEvents {
|
|||
entry.register(registry);
|
||||
}
|
||||
|
||||
public static JsonObject provideLangEntries() {
|
||||
JsonObject object = new JsonObject();
|
||||
public static void consumeLang(BiConsumer<String, String> consumer) {
|
||||
for (SoundEntry entry : ALL.values())
|
||||
if (entry.hasSubtitle())
|
||||
object.addProperty(entry.getSubtitleKey(), entry.getSubtitle());
|
||||
return object;
|
||||
consumer.accept(entry.getSubtitleKey(), entry.getSubtitle());
|
||||
}
|
||||
|
||||
public static SoundEntryProvider provider(DataGenerator generator) {
|
||||
|
|
|
@ -27,15 +27,7 @@ import com.simibubi.create.content.trains.bogey.BogeySizes;
|
|||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||
import com.simibubi.create.foundation.block.CopperRegistries;
|
||||
import com.simibubi.create.foundation.data.AllLangPartials;
|
||||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||
import com.simibubi.create.foundation.data.LangMerger;
|
||||
import com.simibubi.create.foundation.data.RecipeSerializerTagGen;
|
||||
import com.simibubi.create.foundation.data.TagGen;
|
||||
import com.simibubi.create.foundation.data.recipe.MechanicalCraftingRecipeGen;
|
||||
import com.simibubi.create.foundation.data.recipe.ProcessingRecipeGen;
|
||||
import com.simibubi.create.foundation.data.recipe.SequencedAssemblyRecipeGen;
|
||||
import com.simibubi.create.foundation.data.recipe.StandardRecipeGen;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
import com.simibubi.create.foundation.item.KineticStats;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper.Palette;
|
||||
|
@ -43,12 +35,12 @@ import com.simibubi.create.foundation.item.TooltipModifier;
|
|||
import com.simibubi.create.foundation.utility.AttachedRegistry;
|
||||
import com.simibubi.create.infrastructure.command.ServerLagger;
|
||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||
import com.simibubi.create.infrastructure.data.CreateDatagen;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllFeatures;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllOreFeatureConfigEntries;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllPlacementModifiers;
|
||||
import com.simibubi.create.infrastructure.worldgen.BuiltinRegistration;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -63,7 +55,6 @@ import net.minecraftforge.fml.ModLoadingContext;
|
|||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
|
||||
|
||||
@Mod(Create.ID)
|
||||
public class Create {
|
||||
|
@ -151,7 +142,7 @@ public class Create {
|
|||
CopperRegistries.inject();
|
||||
|
||||
modEventBus.addListener(Create::init);
|
||||
modEventBus.addListener(EventPriority.LOWEST, Create::gatherData);
|
||||
modEventBus.addListener(EventPriority.LOWEST, CreateDatagen::gatherData);
|
||||
modEventBus.addGenericListener(SoundEvent.class, AllSoundEvents::register);
|
||||
|
||||
forgeEventBus.addListener(EventPriority.HIGH, SlidingDoorBlock::stopItQuark);
|
||||
|
@ -177,24 +168,6 @@ public class Create {
|
|||
});
|
||||
}
|
||||
|
||||
public static void gatherData(GatherDataEvent event) {
|
||||
TagGen.datagen();
|
||||
DataGenerator gen = event.getGenerator();
|
||||
if (event.includeClient()) {
|
||||
gen.addProvider(new LangMerger(gen, ID, NAME, AllLangPartials.values()));
|
||||
gen.addProvider(AllSoundEvents.provider(gen));
|
||||
}
|
||||
if (event.includeServer()) {
|
||||
gen.addProvider(new RecipeSerializerTagGen(gen, event.getExistingFileHelper()));
|
||||
gen.addProvider(new AllAdvancements(gen));
|
||||
gen.addProvider(new StandardRecipeGen(gen));
|
||||
gen.addProvider(new MechanicalCraftingRecipeGen(gen));
|
||||
gen.addProvider(new SequencedAssemblyRecipeGen(gen));
|
||||
ProcessingRecipeGen.registerAll(gen);
|
||||
// AllOreFeatureConfigEntries.gatherData(event);
|
||||
}
|
||||
}
|
||||
|
||||
public static ResourceLocation asResource(String path) {
|
||||
return new ResourceLocation(ID, path);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.nio.file.Path;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
|
@ -18,7 +19,6 @@ import org.slf4j.Logger;
|
|||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllFluids;
|
||||
|
@ -656,11 +656,9 @@ public class AllAdvancements implements DataProvider {
|
|||
return "Create's Advancements";
|
||||
}
|
||||
|
||||
public static JsonObject provideLangEntries() {
|
||||
JsonObject object = new JsonObject();
|
||||
public static void consumeLang(BiConsumer<String, String> consumer) {
|
||||
for (CreateAdvancement advancement : ENTRIES)
|
||||
advancement.appendToLang(object);
|
||||
return object;
|
||||
advancement.consumeLang(consumer);
|
||||
}
|
||||
|
||||
public static void register() {}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.simibubi.create.foundation.advancement;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.utility.Components;
|
||||
import com.tterrag.registrate.util.entry.ItemProviderEntry;
|
||||
|
@ -30,7 +30,7 @@ public class CreateAdvancement {
|
|||
|
||||
static final ResourceLocation BACKGROUND = Create.asResource("textures/gui/advancements.png");
|
||||
static final String LANG = "advancement." + Create.ID + ".";
|
||||
static final String SECRET_SUFFIX = "\u00A77\n(Hidden Advancement)";
|
||||
static final String SECRET_SUFFIX = "\n\u00A77(Hidden Advancement)";
|
||||
|
||||
private Advancement.Builder builder;
|
||||
private SimpleCreateTrigger builtinTrigger;
|
||||
|
@ -101,9 +101,9 @@ public class CreateAdvancement {
|
|||
.toString());
|
||||
}
|
||||
|
||||
void appendToLang(JsonObject object) {
|
||||
object.addProperty(titleKey(), title);
|
||||
object.addProperty(descriptionKey(), description);
|
||||
void consumeLang(BiConsumer<String, String> consumer) {
|
||||
consumer.accept(titleKey(), title);
|
||||
consumer.accept(descriptionKey(), description);
|
||||
}
|
||||
|
||||
static enum TaskType {
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package com.simibubi.create.foundation.data;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.ponder.PonderLocalization;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
public enum AllLangPartials implements LangPartial {
|
||||
|
||||
ADVANCEMENTS("Advancements", AllAdvancements::provideLangEntries),
|
||||
INTERFACE("UI & Messages"),
|
||||
SUBTITLES("Subtitles", AllSoundEvents::provideLangEntries),
|
||||
TOOLTIPS("Item Descriptions"),
|
||||
PONDER("Ponder Content", PonderLocalization::provideLangEntries),
|
||||
|
||||
;
|
||||
|
||||
private final String displayName;
|
||||
private final Supplier<JsonElement> provider;
|
||||
|
||||
private AllLangPartials(String displayName) {
|
||||
this.displayName = displayName;
|
||||
String fileName = Lang.asId(name());
|
||||
this.provider = () -> LangPartial.fromResource(Create.ID, fileName);
|
||||
}
|
||||
|
||||
private AllLangPartials(String displayName, Supplier<JsonElement> provider) {
|
||||
this.displayName = displayName;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement provide() {
|
||||
return provider.get();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,10 +2,12 @@ package com.simibubi.create.foundation.data;
|
|||
|
||||
import static com.simibubi.create.foundation.data.TagGen.pickaxeOnly;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -22,6 +24,7 @@ import com.tterrag.registrate.builders.BlockBuilder;
|
|||
import com.tterrag.registrate.builders.BlockEntityBuilder.BlockEntityFactory;
|
||||
import com.tterrag.registrate.builders.Builder;
|
||||
import com.tterrag.registrate.builders.FluidBuilder;
|
||||
import com.tterrag.registrate.providers.ProviderType;
|
||||
import com.tterrag.registrate.util.entry.RegistryEntry;
|
||||
import com.tterrag.registrate.util.nullness.NonNullBiFunction;
|
||||
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||
|
@ -43,16 +46,24 @@ import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
|
|||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.data.loading.DatagenModLoader;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
||||
protected final NonNullSupplier<Boolean> doDatagen = NonNullSupplier.lazy(DatagenModLoader::isRunningDataGen);
|
||||
|
||||
@Nullable
|
||||
protected Function<Item, TooltipModifier> currentTooltipModifierFactory;
|
||||
@Nullable
|
||||
protected UnaryOperator<Map<String, String>> deferredLangPostprocessor;
|
||||
|
||||
protected boolean hasDataProvider = false;
|
||||
|
||||
protected CreateRegistrate(String modid) {
|
||||
super(modid);
|
||||
|
@ -72,11 +83,39 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
|||
return currentTooltipModifierFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>Use {@link #addRawLang(String, String)} instead where possible!</b>
|
||||
*/
|
||||
public void addLangPostprocessor(UnaryOperator<Map<String, String>> langPostprocessor) {
|
||||
if (!doDatagen.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasDataProvider) {
|
||||
((LanguageProviderExtension) getDataProvider(ProviderType.LANG).orElseThrow()).create$addPostprocessor(langPostprocessor);
|
||||
} else {
|
||||
if (this.deferredLangPostprocessor == null) {
|
||||
this.deferredLangPostprocessor = langPostprocessor;
|
||||
} else {
|
||||
UnaryOperator<Map<String, String>> current = this.deferredLangPostprocessor;
|
||||
this.deferredLangPostprocessor = entries -> langPostprocessor.apply(current.apply(entries));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateRegistrate registerEventListeners(IEventBus bus) {
|
||||
return super.registerEventListeners(bus);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onData(GatherDataEvent event) {
|
||||
super.onData(event);
|
||||
hasDataProvider = true;
|
||||
((LanguageProviderExtension) getDataProvider(ProviderType.LANG).orElseThrow()).create$addPostprocessor(deferredLangPostprocessor);
|
||||
deferredLangPostprocessor = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <R extends IForgeRegistryEntry<R>, T extends R> RegistryEntry<T> accept(String name, ResourceKey<? extends Registry<R>> type, Builder<R, T, ?, ?> builder, NonNullSupplier<? extends T> creator, NonNullFunction<RegistryObject<T>, ? extends RegistryEntry<T>> entryFactory) {
|
||||
RegistryEntry<T> entry = super.accept(name, type, builder, creator, entryFactory);
|
||||
|
|
|
@ -16,12 +16,17 @@ import com.google.gson.GsonBuilder;
|
|||
import com.google.gson.JsonObject;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.ponder.PonderScene;
|
||||
import com.tterrag.registrate.AbstractRegistrate;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.HashCache;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link AbstractRegistrate#addRawLang} or, if absolutely necessary, {@link CreateRegistrate#addLangPostprocessor} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class LangMerger implements DataProvider {
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting()
|
||||
|
|
|
@ -2,7 +2,12 @@ package com.simibubi.create.foundation.data;
|
|||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.simibubi.create.foundation.utility.FilesHelper;
|
||||
import com.tterrag.registrate.AbstractRegistrate;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link AbstractRegistrate#addRawLang} or, if absolutely necessary, {@link CreateRegistrate#addLangPostprocessor} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface LangPartial {
|
||||
String getDisplayName();
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.simibubi.create.foundation.data;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public interface LanguageProviderExtension {
|
||||
void create$addPostprocessor(UnaryOperator<Map<String, String>> postprocessor);
|
||||
}
|
|
@ -1,30 +1,15 @@
|
|||
package com.simibubi.create.foundation.data;
|
||||
|
||||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.AllTags.AllBlockTags;
|
||||
import com.simibubi.create.AllTags.AllEntityTags;
|
||||
import com.simibubi.create.AllTags.AllFluidTags;
|
||||
import com.simibubi.create.AllTags.AllItemTags;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.data.recipe.Mods;
|
||||
import com.tterrag.registrate.builders.BlockBuilder;
|
||||
import com.tterrag.registrate.builders.ItemBuilder;
|
||||
import com.tterrag.registrate.providers.ProviderType;
|
||||
import com.tterrag.registrate.providers.RegistrateTagsProvider;
|
||||
import com.tterrag.registrate.util.nullness.NonNullFunction;
|
||||
|
||||
import net.minecraft.data.tags.TagsProvider.TagAppender;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraftforge.common.Tags;
|
||||
|
||||
public class TagGen {
|
||||
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuilder<T, P>> axeOrPickaxe() {
|
||||
|
@ -63,200 +48,4 @@ public class TagGen {
|
|||
}
|
||||
return appender;
|
||||
}
|
||||
|
||||
public static void datagen() {
|
||||
Create.REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, TagGen::genBlockTags);
|
||||
Create.REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, TagGen::genItemTags);
|
||||
Create.REGISTRATE.addDataGenerator(ProviderType.FLUID_TAGS, TagGen::genFluidTags);
|
||||
Create.REGISTRATE.addDataGenerator(ProviderType.ENTITY_TAGS, TagGen::genEntityTags);
|
||||
}
|
||||
|
||||
private static void genBlockTags(RegistrateTagsProvider<Block> prov) {
|
||||
prov.tag(AllBlockTags.BRITTLE.tag)
|
||||
.add(Blocks.BELL, Blocks.COCOA, Blocks.FLOWER_POT)
|
||||
.addTag(BlockTags.BEDS)
|
||||
.addTag(BlockTags.DOORS);
|
||||
|
||||
prov.tag(AllBlockTags.MOVABLE_EMPTY_COLLIDER.tag)
|
||||
.add(Blocks.COBWEB, Blocks.POWDER_SNOW, Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK)
|
||||
.addTag(BlockTags.FENCE_GATES);
|
||||
|
||||
prov.tag(AllBlockTags.FAN_TRANSPARENT.tag)
|
||||
.add(Blocks.IRON_BARS)
|
||||
.addTag(BlockTags.CAMPFIRES)
|
||||
.addTag(BlockTags.FENCES)
|
||||
.addTag(BlockTags.LEAVES);
|
||||
|
||||
prov.tag(AllBlockTags.ORE_OVERRIDE_STONE.tag)
|
||||
.addTag(BlockTags.STONE_ORE_REPLACEABLES);
|
||||
|
||||
prov.tag(AllBlockTags.PASSIVE_BOILER_HEATERS.tag)
|
||||
.add(Blocks.MAGMA_BLOCK, Blocks.LAVA)
|
||||
.addTag(BlockTags.CAMPFIRES)
|
||||
.addTag(BlockTags.FIRE);
|
||||
|
||||
prov.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.addTag(BlockTags.BANNERS)
|
||||
.addTag(BlockTags.SIGNS);
|
||||
|
||||
prov.tag(AllBlockTags.TREE_ATTACHMENTS.tag)
|
||||
.add(Blocks.BEE_NEST, Blocks.COCOA, Blocks.MOSS_CARPET, Blocks.SHROOMLIGHT, Blocks.VINE);
|
||||
|
||||
prov.tag(AllBlockTags.WINDMILL_SAILS.tag)
|
||||
.addTag(BlockTags.WOOL);
|
||||
|
||||
prov.tag(AllBlockTags.WRENCH_PICKUP.tag)
|
||||
.add(Blocks.REDSTONE_WIRE, Blocks.REDSTONE_TORCH, Blocks.REPEATER, Blocks.LEVER,
|
||||
Blocks.COMPARATOR, Blocks.OBSERVER, Blocks.REDSTONE_WALL_TORCH, Blocks.PISTON, Blocks.STICKY_PISTON,
|
||||
Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK, Blocks.DAYLIGHT_DETECTOR, Blocks.TARGET, Blocks.HOPPER)
|
||||
.addTag(BlockTags.BUTTONS)
|
||||
.addTag(BlockTags.PRESSURE_PLATES)
|
||||
.addTag(BlockTags.RAILS);
|
||||
|
||||
prov.tag(AllBlockTags.COPYCAT_ALLOW.tag)
|
||||
.add(Blocks.BARREL);
|
||||
prov.tag(AllBlockTags.COPYCAT_DENY.tag)
|
||||
.addTag(BlockTags.CAULDRONS)
|
||||
.addTag(BlockTags.SAPLINGS)
|
||||
.addTag(BlockTags.CLIMBABLE);
|
||||
|
||||
// COMPAT
|
||||
|
||||
addOptional(prov.tag(AllBlockTags.NON_MOVABLE.tag), Mods.IE,
|
||||
"connector_lv", "connector_lv_relay", "connector_mv", "connector_mv_relay",
|
||||
"connector_hv", "connector_hv_relay", "connector_bundled", "connector_structural",
|
||||
"connector_redstone", "connector_probe", "breaker_switch");
|
||||
|
||||
// VALIDATE
|
||||
|
||||
for (AllBlockTags tag : AllBlockTags.values()) {
|
||||
if (tag.alwaysDatagen) {
|
||||
prov.getOrCreateRawBuilder(tag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void genItemTags(RegistrateTagsProvider<Item> prov) {
|
||||
prov.tag(AllItemTags.SLEEPERS.tag)
|
||||
.add(Items.STONE_SLAB, Items.SMOOTH_STONE_SLAB, Items.ANDESITE_SLAB);
|
||||
|
||||
prov.tag(AllItemTags.STRIPPED_LOGS.tag)
|
||||
.addTag(AllItemTags.VANILLA_STRIPPED_LOGS.tag)
|
||||
.addTag(AllItemTags.MODDED_STRIPPED_LOGS.tag);
|
||||
|
||||
prov.tag(AllItemTags.STRIPPED_WOOD.tag)
|
||||
.addTag(AllItemTags.VANILLA_STRIPPED_WOOD.tag)
|
||||
.addTag(AllItemTags.MODDED_STRIPPED_WOOD.tag);
|
||||
|
||||
prov.tag(AllItemTags.DEPLOYABLE_DRINK.tag)
|
||||
.add(Items.MILK_BUCKET, Items.POTION);
|
||||
|
||||
prov.tag(AllItemTags.UPRIGHT_ON_BELT.tag)
|
||||
.add(Items.GLASS_BOTTLE, Items.POTION, Items.SPLASH_POTION, Items.LINGERING_POTION,
|
||||
Items.HONEY_BOTTLE, Items.CAKE);
|
||||
|
||||
prov.tag(AllItemTags.CONTRAPTION_CONTROLLED.tag)
|
||||
.add(Items.BELL, Items.CAMPFIRE, Items.SOUL_CAMPFIRE, Items.DISPENSER, Items.DROPPER);
|
||||
|
||||
prov.tag(AllItemTags.VANILLA_STRIPPED_LOGS.tag)
|
||||
.add(Items.STRIPPED_ACACIA_LOG, Items.STRIPPED_BIRCH_LOG, Items.STRIPPED_CRIMSON_STEM,
|
||||
Items.STRIPPED_DARK_OAK_LOG, Items.STRIPPED_JUNGLE_LOG, Items.STRIPPED_OAK_LOG,
|
||||
Items.STRIPPED_SPRUCE_LOG, Items.STRIPPED_WARPED_STEM);
|
||||
|
||||
prov.tag(AllItemTags.VANILLA_STRIPPED_WOOD.tag)
|
||||
.add(Items.STRIPPED_ACACIA_WOOD, Items.STRIPPED_BIRCH_WOOD,
|
||||
Items.STRIPPED_CRIMSON_HYPHAE, Items.STRIPPED_DARK_OAK_WOOD, Items.STRIPPED_JUNGLE_WOOD,
|
||||
Items.STRIPPED_OAK_WOOD, Items.STRIPPED_SPRUCE_WOOD, Items.STRIPPED_WARPED_HYPHAE);
|
||||
|
||||
prov.tag(ItemTags.BEACON_PAYMENT_ITEMS)
|
||||
.addTag(AllItemTags.CREATE_INGOTS.tag);
|
||||
|
||||
prov.tag(Tags.Items.INGOTS)
|
||||
.addTag(AllItemTags.CREATE_INGOTS.tag);
|
||||
|
||||
// COMPAT
|
||||
|
||||
genStrippedWood(prov);
|
||||
|
||||
// VALIDATE
|
||||
|
||||
for (AllItemTags tag : AllItemTags.values()) {
|
||||
if (tag.alwaysDatagen) {
|
||||
prov.getOrCreateRawBuilder(tag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void genStrippedWood(RegistrateTagsProvider<Item> prov) {
|
||||
TagAppender<Item> logAppender = prov.tag(AllItemTags.MODDED_STRIPPED_LOGS.tag);
|
||||
TagAppender<Item> woodAppender = prov.tag(AllItemTags.MODDED_STRIPPED_WOOD.tag);
|
||||
StrippedWoodHelper helper = new StrippedWoodHelper(logAppender, woodAppender);
|
||||
|
||||
helper.add(Mods.ARS_N, "blue_archwood", "purple_archwood", "green_archwood", "red_archwood");
|
||||
helper.add(Mods.BTN, "livingwood", "dreamwood");
|
||||
helper.add(Mods.FA, "cherrywood", "mysterywood");
|
||||
helper.add(Mods.HEX, "akashic");
|
||||
helper.add(Mods.ID, "menril");
|
||||
helper.add(Mods.BYG, "aspen", "baobab", "enchanted", "cherry", "cika", "cypress", "ebony", "ether",
|
||||
"fir", "green_enchanted", "holly", "jacaranda", "lament", "mahogany", "mangrove", "maple", "nightshade",
|
||||
"palm", "palo_verde", "pine", "rainbow_eucalyptus", "redwood", "skyris", "willow", "witch_hazel",
|
||||
"zelkova");
|
||||
helper.add(Mods.SG, "netherwood");
|
||||
helper.add(Mods.TF, "twilight_oak", "canopy", "mangrove", "dark", "time", "transformation", "mining",
|
||||
"sorting");
|
||||
helper.add(Mods.TIC, "greenheart", "skyroot", "bloodshroom");
|
||||
helper.add(Mods.AP, "twisted");
|
||||
helper.add(Mods.Q, "azalea", "blossom");
|
||||
helper.add(Mods.ECO, "coconut", "walnut", "azalea");
|
||||
helper.add(Mods.BOP, "fir", "redwood", "cherry", "mahogany", "jacaranda", "palm", "willow", "dead",
|
||||
"magic", "umbran", "hellbark");
|
||||
helper.add(Mods.BSK, "bluebright", "starlit", "frostbright", "lunar", "dusk", "maple", "cherry");
|
||||
|
||||
addOptional(logAppender, Mods.BYG, "stripped_bulbis_stem");
|
||||
addOptional(woodAppender, Mods.BYG, "stripped_bulbis_wood");
|
||||
}
|
||||
|
||||
private static void genFluidTags(RegistrateTagsProvider<Fluid> prov) {
|
||||
prov.tag(AllFluidTags.BOTTOMLESS_ALLOW.tag)
|
||||
.add(Fluids.WATER, Fluids.LAVA);
|
||||
|
||||
// VALIDATE
|
||||
|
||||
for (AllFluidTags tag : AllFluidTags.values()) {
|
||||
if (tag.alwaysDatagen) {
|
||||
prov.getOrCreateRawBuilder(tag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void genEntityTags(RegistrateTagsProvider<EntityType<?>> prov) {
|
||||
|
||||
// VALIDATE
|
||||
|
||||
for (AllEntityTags tag : AllEntityTags.values()) {
|
||||
if (tag.alwaysDatagen) {
|
||||
prov.getOrCreateRawBuilder(tag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class StrippedWoodHelper {
|
||||
protected final TagAppender<Item> logAppender;
|
||||
protected final TagAppender<Item> woodAppender;
|
||||
|
||||
public StrippedWoodHelper(TagAppender<Item> logAppender, TagAppender<Item> woodAppender) {
|
||||
this.logAppender = logAppender;
|
||||
this.woodAppender = woodAppender;
|
||||
}
|
||||
|
||||
public void add(Mods mod, String... woodTypes) {
|
||||
for (String type : woodTypes) {
|
||||
String strippedPre = mod.strippedIsSuffix ? "" : "stripped_";
|
||||
String strippedPost = mod.strippedIsSuffix ? "_stripped" : "";
|
||||
addOptional(logAppender, mod, strippedPre + type + "_log" + strippedPost);
|
||||
addOptional(woodAppender, mod, strippedPre + type + (mod.omitWoodSuffix ? "" : "_wood") + strippedPost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package com.simibubi.create.foundation.mixin;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.simibubi.create.foundation.data.LanguageProviderExtension;
|
||||
|
||||
import net.minecraftforge.common.data.LanguageProvider;
|
||||
|
||||
@Mixin(LanguageProvider.class)
|
||||
public class LanguageProviderMixin implements LanguageProviderExtension {
|
||||
@Shadow
|
||||
@Final
|
||||
@Mutable
|
||||
private Map<String, String> data;
|
||||
|
||||
@Unique
|
||||
@Nullable
|
||||
private UnaryOperator<Map<String, String>> postprocessor;
|
||||
|
||||
@Override
|
||||
public void create$addPostprocessor(UnaryOperator<Map<String, String>> postprocessor) {
|
||||
if (this.postprocessor == null) {
|
||||
this.postprocessor = postprocessor;
|
||||
} else {
|
||||
UnaryOperator<Map<String, String>> current = this.postprocessor;
|
||||
this.postprocessor = entries -> postprocessor.apply(current.apply(entries));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/common/data/LanguageProvider;addTranslations()V", shift = Shift.AFTER, remap = false))
|
||||
private void create$afterAddTranslations(CallbackInfo ci) {
|
||||
if (postprocessor != null) {
|
||||
data = postprocessor.apply(data);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,24 +2,17 @@ package com.simibubi.create.foundation.ponder;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.ponder.ui.PonderTagIndexScreen;
|
||||
import com.simibubi.create.foundation.ponder.ui.PonderTagScreen;
|
||||
import com.simibubi.create.foundation.ponder.ui.PonderUI;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
import com.simibubi.create.infrastructure.ponder.AllPonderTags;
|
||||
import com.simibubi.create.infrastructure.ponder.PonderIndex;
|
||||
import com.simibubi.create.infrastructure.ponder.SharedText;
|
||||
import com.tterrag.registrate.AbstractRegistrate;
|
||||
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class PonderLocalization {
|
||||
|
||||
static final Map<ResourceLocation, String> SHARED = new HashMap<>();
|
||||
static final Map<ResourceLocation, Couple<String>> TAG = new HashMap<>();
|
||||
static final Map<ResourceLocation, String> CHAPTER = new HashMap<>();
|
||||
|
@ -46,6 +39,30 @@ public class PonderLocalization {
|
|||
|
||||
//
|
||||
|
||||
public static final String LANG_PREFIX = "ponder.";
|
||||
|
||||
protected static String langKeyForShared(ResourceLocation k) {
|
||||
return k.getNamespace() + "." + LANG_PREFIX + "shared." + k.getPath();
|
||||
}
|
||||
|
||||
protected static String langKeyForTag(ResourceLocation k) {
|
||||
return k.getNamespace() + "." + LANG_PREFIX + "tag." + k.getPath();
|
||||
}
|
||||
|
||||
protected static String langKeyForTagDescription(ResourceLocation k) {
|
||||
return k.getNamespace() + "." + LANG_PREFIX + "tag." + k.getPath() + ".description";
|
||||
}
|
||||
|
||||
protected static String langKeyForChapter(ResourceLocation k) {
|
||||
return k.getNamespace() + "." + LANG_PREFIX + "chapter." + k.getPath();
|
||||
}
|
||||
|
||||
protected static String langKeyForSpecific(ResourceLocation sceneId, String k) {
|
||||
return sceneId.getNamespace() + "." + LANG_PREFIX + sceneId.getPath() + "." + k;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public static String getShared(ResourceLocation key) {
|
||||
if (PonderIndex.editingModeActive())
|
||||
return SHARED.containsKey(key) ? SHARED.get(key) : ("unregistered shared entry: " + key);
|
||||
|
@ -81,25 +98,37 @@ public class PonderLocalization {
|
|||
|
||||
//
|
||||
|
||||
public static final String LANG_PREFIX = "ponder.";
|
||||
private static boolean sceneLangGenerated = false;
|
||||
|
||||
public static void record(String namespace, JsonObject object) {
|
||||
public static void generateSceneLang() {
|
||||
if (sceneLangGenerated) {
|
||||
return;
|
||||
}
|
||||
|
||||
sceneLangGenerated = true;
|
||||
PonderRegistry.ALL.forEach((id, list) -> {
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
PonderRegistry.compileScene(i, list.get(i), null);
|
||||
});
|
||||
}
|
||||
|
||||
public static void consumeLang(String namespace, BiConsumer<String, String> consumer) {
|
||||
SHARED.forEach((k, v) -> {
|
||||
if (k.getNamespace().equals(namespace)) {
|
||||
object.addProperty(langKeyForShared(k), v);
|
||||
consumer.accept(langKeyForShared(k), v);
|
||||
}
|
||||
});
|
||||
|
||||
TAG.forEach((k, v) -> {
|
||||
if (k.getNamespace().equals(namespace)) {
|
||||
object.addProperty(langKeyForTag(k), v.getFirst());
|
||||
object.addProperty(langKeyForTagDescription(k), v.getSecond());
|
||||
consumer.accept(langKeyForTag(k), v.getFirst());
|
||||
consumer.accept(langKeyForTagDescription(k), v.getSecond());
|
||||
}
|
||||
});
|
||||
|
||||
CHAPTER.forEach((k, v) -> {
|
||||
if (k.getNamespace().equals(namespace)) {
|
||||
object.addProperty(langKeyForChapter(k), v);
|
||||
consumer.accept(langKeyForChapter(k), v);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -112,93 +141,18 @@ public class PonderLocalization {
|
|||
.entrySet()
|
||||
.stream()
|
||||
.sorted(Map.Entry.comparingByKey())
|
||||
.forEach(subEntry -> object.addProperty(
|
||||
.forEach(subEntry -> consumer.accept(
|
||||
langKeyForSpecific(entry.getKey(), subEntry.getKey()), subEntry.getValue()));
|
||||
});
|
||||
}
|
||||
|
||||
private static void recordGeneral(JsonObject object) {
|
||||
addGeneral(object, PonderTooltipHandler.HOLD_TO_PONDER, "Hold [%1$s] to Ponder");
|
||||
addGeneral(object, PonderTooltipHandler.SUBJECT, "Subject of this scene");
|
||||
addGeneral(object, PonderUI.PONDERING, "Pondering about...");
|
||||
addGeneral(object, PonderUI.IDENTIFY_MODE, "Identify mode active.\nUnpause with [%1$s]");
|
||||
addGeneral(object, PonderTagScreen.ASSOCIATED, "Associated Entries");
|
||||
|
||||
addGeneral(object, PonderUI.CLOSE, "Close");
|
||||
addGeneral(object, PonderUI.IDENTIFY, "Identify");
|
||||
addGeneral(object, PonderUI.NEXT, "Next Scene");
|
||||
addGeneral(object, PonderUI.NEXT_UP, "Up Next:");
|
||||
addGeneral(object, PonderUI.PREVIOUS, "Previous Scene");
|
||||
addGeneral(object, PonderUI.REPLAY, "Replay");
|
||||
addGeneral(object, PonderUI.THINK_BACK, "Think Back");
|
||||
addGeneral(object, PonderUI.SLOW_TEXT, "Comfy Reading");
|
||||
|
||||
addGeneral(object, PonderTagIndexScreen.EXIT, "Exit");
|
||||
addGeneral(object, PonderTagIndexScreen.WELCOME, "Welcome to Ponder");
|
||||
addGeneral(object, PonderTagIndexScreen.CATEGORIES, "Available Categories in Create");
|
||||
addGeneral(object, PonderTagIndexScreen.DESCRIPTION,
|
||||
"Click one of the icons to learn about its associated Items and Blocks");
|
||||
addGeneral(object, PonderTagIndexScreen.TITLE, "Ponder Index");
|
||||
}
|
||||
|
||||
private static void addGeneral(JsonObject json, String key, String enUS) {
|
||||
json.addProperty(Create.ID + "." + key, enUS);
|
||||
}
|
||||
|
||||
public static void generateSceneLang() {
|
||||
PonderRegistry.ALL.forEach((id, list) -> {
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
PonderRegistry.compileScene(i, list.get(i), null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal use only.
|
||||
*/
|
||||
public static JsonObject provideLangEntries() {
|
||||
SharedText.gatherText();
|
||||
AllPonderTags.register();
|
||||
PonderIndex.register();
|
||||
|
||||
generateSceneLang();
|
||||
|
||||
JsonObject object = new JsonObject();
|
||||
recordGeneral(object);
|
||||
record(Create.ID, object);
|
||||
return object;
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void record(String namespace, JsonObject object) {
|
||||
consumeLang(namespace, object::addProperty);
|
||||
}
|
||||
|
||||
public static void provideRegistrateLang(AbstractRegistrate<?> registrate) {
|
||||
generateSceneLang();
|
||||
|
||||
JsonObject object = new JsonObject();
|
||||
record(registrate.getModid(), object);
|
||||
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
registrate.addRawLang(entry.getKey(), entry.getValue().getAsString());
|
||||
}
|
||||
consumeLang(registrate.getModid(), registrate::addRawLang);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
protected static String langKeyForShared(ResourceLocation k) {
|
||||
return k.getNamespace() + "." + LANG_PREFIX + "shared." + k.getPath();
|
||||
}
|
||||
|
||||
protected static String langKeyForTag(ResourceLocation k) {
|
||||
return k.getNamespace() + "." + LANG_PREFIX + "tag." + k.getPath();
|
||||
}
|
||||
|
||||
protected static String langKeyForTagDescription(ResourceLocation k) {
|
||||
return k.getNamespace() + "." + LANG_PREFIX + "tag." + k.getPath() + ".description";
|
||||
}
|
||||
|
||||
protected static String langKeyForChapter(ResourceLocation k) {
|
||||
return k.getNamespace() + "." + LANG_PREFIX + "chapter." + k.getPath();
|
||||
}
|
||||
|
||||
protected static String langKeyForSpecific(ResourceLocation sceneId, String k) {
|
||||
return sceneId.getNamespace() + "." + LANG_PREFIX + sceneId.getPath() + "." + k;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
package com.simibubi.create.infrastructure.data;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.data.recipe.MechanicalCraftingRecipeGen;
|
||||
import com.simibubi.create.foundation.data.recipe.ProcessingRecipeGen;
|
||||
import com.simibubi.create.foundation.data.recipe.SequencedAssemblyRecipeGen;
|
||||
import com.simibubi.create.foundation.data.recipe.StandardRecipeGen;
|
||||
import com.simibubi.create.foundation.ponder.PonderLocalization;
|
||||
import com.simibubi.create.foundation.utility.FilesHelper;
|
||||
import com.simibubi.create.infrastructure.ponder.AllPonderTags;
|
||||
import com.simibubi.create.infrastructure.ponder.GeneralText;
|
||||
import com.simibubi.create.infrastructure.ponder.PonderIndex;
|
||||
import com.simibubi.create.infrastructure.ponder.SharedText;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
|
||||
|
||||
public class CreateDatagen {
|
||||
public static void gatherData(GatherDataEvent event) {
|
||||
addExtraRegistrateData();
|
||||
|
||||
DataGenerator generator = event.getGenerator();
|
||||
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
|
||||
|
||||
if (event.includeClient()) {
|
||||
generator.addProvider(AllSoundEvents.provider(generator));
|
||||
}
|
||||
|
||||
if (event.includeServer()) {
|
||||
generator.addProvider(new CreateRecipeSerializerTagsProvider(generator, existingFileHelper));
|
||||
|
||||
generator.addProvider(new AllAdvancements(generator));
|
||||
|
||||
generator.addProvider(new StandardRecipeGen(generator));
|
||||
generator.addProvider(new MechanicalCraftingRecipeGen(generator));
|
||||
generator.addProvider(new SequencedAssemblyRecipeGen(generator));
|
||||
ProcessingRecipeGen.registerAll(generator);
|
||||
|
||||
// AllOreFeatureConfigEntries.gatherData(event);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addExtraRegistrateData() {
|
||||
CreateRegistrateTags.addGenerators();
|
||||
|
||||
// Really all additional lang entries should be added using AbstractRegistrate#addRawLang,
|
||||
// but doing so would change the generated lang entry order and potentially mess up Crowndin.
|
||||
Create.REGISTRATE.addLangPostprocessor(entries -> {
|
||||
Map<String, String> newEntries = new LinkedHashMap<>(entries);
|
||||
BiConsumer<String, String> langConsumer = (key, value) -> {
|
||||
String oldValue = newEntries.put(key, value);
|
||||
if (oldValue != null) {
|
||||
Create.LOGGER.warn("Value of lang key '" + key + "' was overridden!");
|
||||
}
|
||||
};
|
||||
|
||||
AllAdvancements.consumeLang(langConsumer);
|
||||
consumeDefaultLang("interface", langConsumer);
|
||||
AllSoundEvents.consumeLang(langConsumer);
|
||||
consumeDefaultLang("tooltips", langConsumer);
|
||||
consumePonderLang(langConsumer);
|
||||
|
||||
return newEntries;
|
||||
});
|
||||
}
|
||||
|
||||
private static void consumeDefaultLang(String fileName, BiConsumer<String, String> consumer) {
|
||||
String path = "assets/create/lang/default/" + fileName + ".json";
|
||||
JsonElement jsonElement = FilesHelper.loadJsonResource(path);
|
||||
if (jsonElement == null) {
|
||||
throw new IllegalStateException(String.format("Could not find default lang file: %s", path));
|
||||
}
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
for (Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue().getAsString();
|
||||
consumer.accept(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void consumePonderLang(BiConsumer<String, String> consumer) {
|
||||
// Register these since FMLClientSetupEvent does not run during datagen
|
||||
AllPonderTags.register();
|
||||
PonderIndex.register();
|
||||
|
||||
SharedText.gatherText();
|
||||
PonderLocalization.generateSceneLang();
|
||||
|
||||
GeneralText.consumeLang(consumer);
|
||||
PonderLocalization.consumeLang(Create.ID, consumer);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.simibubi.create.foundation.data;
|
||||
package com.simibubi.create.infrastructure.data;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -12,20 +12,28 @@ import net.minecraft.data.tags.TagsProvider;
|
|||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
public class RecipeSerializerTagGen extends TagsProvider<RecipeSerializer<?>> {
|
||||
public RecipeSerializerTagGen(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) {
|
||||
public class CreateRecipeSerializerTagsProvider extends TagsProvider<RecipeSerializer<?>> {
|
||||
public CreateRecipeSerializerTagsProvider(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) {
|
||||
super(generator, Registry.RECIPE_SERIALIZER, Create.ID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags() {
|
||||
tag(AllRecipeSerializerTags.AUTOMATION_IGNORE.tag)
|
||||
.addOptional(Mods.OCCULTISM.rl("spirit_trade"))
|
||||
.addOptional(Mods.OCCULTISM.rl("ritual"));
|
||||
|
||||
// VALIDATE
|
||||
|
||||
for (AllRecipeSerializerTags tag : AllRecipeSerializerTags.values()) {
|
||||
if (tag.alwaysDatagen) {
|
||||
getOrCreateRawBuilder(tag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Create's Recipe Serializer Tags";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags() {
|
||||
this.tag(AllRecipeSerializerTags.AUTOMATION_IGNORE.tag)
|
||||
.addOptional(Mods.OCCULTISM.rl("spirit_trade"))
|
||||
.addOptional(Mods.OCCULTISM.rl("ritual"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
package com.simibubi.create.infrastructure.data;
|
||||
|
||||
import com.simibubi.create.AllTags.AllBlockTags;
|
||||
import com.simibubi.create.AllTags.AllEntityTags;
|
||||
import com.simibubi.create.AllTags.AllFluidTags;
|
||||
import com.simibubi.create.AllTags.AllItemTags;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.data.TagGen;
|
||||
import com.simibubi.create.foundation.data.recipe.Mods;
|
||||
import com.tterrag.registrate.providers.ProviderType;
|
||||
import com.tterrag.registrate.providers.RegistrateTagsProvider;
|
||||
|
||||
import net.minecraft.data.tags.TagsProvider.TagAppender;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraftforge.common.Tags;
|
||||
|
||||
public class CreateRegistrateTags {
|
||||
public static void addGenerators() {
|
||||
Create.REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, CreateRegistrateTags::genBlockTags);
|
||||
Create.REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, CreateRegistrateTags::genItemTags);
|
||||
Create.REGISTRATE.addDataGenerator(ProviderType.FLUID_TAGS, CreateRegistrateTags::genFluidTags);
|
||||
Create.REGISTRATE.addDataGenerator(ProviderType.ENTITY_TAGS, CreateRegistrateTags::genEntityTags);
|
||||
}
|
||||
|
||||
private static void genBlockTags(RegistrateTagsProvider<Block> prov) {
|
||||
prov.tag(AllBlockTags.BRITTLE.tag)
|
||||
.add(Blocks.BELL, Blocks.COCOA, Blocks.FLOWER_POT)
|
||||
.addTag(BlockTags.BEDS)
|
||||
.addTag(BlockTags.DOORS);
|
||||
|
||||
prov.tag(AllBlockTags.MOVABLE_EMPTY_COLLIDER.tag)
|
||||
.add(Blocks.COBWEB, Blocks.POWDER_SNOW, Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK)
|
||||
.addTag(BlockTags.FENCE_GATES);
|
||||
|
||||
prov.tag(AllBlockTags.FAN_TRANSPARENT.tag)
|
||||
.add(Blocks.IRON_BARS)
|
||||
.addTag(BlockTags.CAMPFIRES)
|
||||
.addTag(BlockTags.FENCES)
|
||||
.addTag(BlockTags.LEAVES);
|
||||
|
||||
prov.tag(AllBlockTags.ORE_OVERRIDE_STONE.tag)
|
||||
.addTag(BlockTags.STONE_ORE_REPLACEABLES);
|
||||
|
||||
prov.tag(AllBlockTags.PASSIVE_BOILER_HEATERS.tag)
|
||||
.add(Blocks.MAGMA_BLOCK, Blocks.LAVA)
|
||||
.addTag(BlockTags.CAMPFIRES)
|
||||
.addTag(BlockTags.FIRE);
|
||||
|
||||
prov.tag(AllBlockTags.SAFE_NBT.tag)
|
||||
.addTag(BlockTags.BANNERS)
|
||||
.addTag(BlockTags.SIGNS);
|
||||
|
||||
prov.tag(AllBlockTags.TREE_ATTACHMENTS.tag)
|
||||
.add(Blocks.BEE_NEST, Blocks.COCOA, Blocks.MOSS_CARPET, Blocks.SHROOMLIGHT, Blocks.VINE);
|
||||
|
||||
prov.tag(AllBlockTags.WINDMILL_SAILS.tag)
|
||||
.addTag(BlockTags.WOOL);
|
||||
|
||||
prov.tag(AllBlockTags.WRENCH_PICKUP.tag)
|
||||
.add(Blocks.REDSTONE_WIRE, Blocks.REDSTONE_TORCH, Blocks.REPEATER, Blocks.LEVER,
|
||||
Blocks.COMPARATOR, Blocks.OBSERVER, Blocks.REDSTONE_WALL_TORCH, Blocks.PISTON, Blocks.STICKY_PISTON,
|
||||
Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK, Blocks.DAYLIGHT_DETECTOR, Blocks.TARGET, Blocks.HOPPER)
|
||||
.addTag(BlockTags.BUTTONS)
|
||||
.addTag(BlockTags.PRESSURE_PLATES)
|
||||
.addTag(BlockTags.RAILS);
|
||||
|
||||
prov.tag(AllBlockTags.COPYCAT_ALLOW.tag)
|
||||
.add(Blocks.BARREL);
|
||||
prov.tag(AllBlockTags.COPYCAT_DENY.tag)
|
||||
.addTag(BlockTags.CAULDRONS)
|
||||
.addTag(BlockTags.SAPLINGS)
|
||||
.addTag(BlockTags.CLIMBABLE);
|
||||
|
||||
// COMPAT
|
||||
|
||||
TagGen.addOptional(prov.tag(AllBlockTags.NON_MOVABLE.tag), Mods.IE,
|
||||
"connector_lv", "connector_lv_relay", "connector_mv", "connector_mv_relay",
|
||||
"connector_hv", "connector_hv_relay", "connector_bundled", "connector_structural",
|
||||
"connector_redstone", "connector_probe", "breaker_switch");
|
||||
|
||||
// VALIDATE
|
||||
|
||||
for (AllBlockTags tag : AllBlockTags.values()) {
|
||||
if (tag.alwaysDatagen) {
|
||||
prov.getOrCreateRawBuilder(tag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void genItemTags(RegistrateTagsProvider<Item> prov) {
|
||||
prov.tag(AllItemTags.SLEEPERS.tag)
|
||||
.add(Items.STONE_SLAB, Items.SMOOTH_STONE_SLAB, Items.ANDESITE_SLAB);
|
||||
|
||||
prov.tag(AllItemTags.STRIPPED_LOGS.tag)
|
||||
.addTag(AllItemTags.VANILLA_STRIPPED_LOGS.tag)
|
||||
.addTag(AllItemTags.MODDED_STRIPPED_LOGS.tag);
|
||||
|
||||
prov.tag(AllItemTags.STRIPPED_WOOD.tag)
|
||||
.addTag(AllItemTags.VANILLA_STRIPPED_WOOD.tag)
|
||||
.addTag(AllItemTags.MODDED_STRIPPED_WOOD.tag);
|
||||
|
||||
prov.tag(AllItemTags.DEPLOYABLE_DRINK.tag)
|
||||
.add(Items.MILK_BUCKET, Items.POTION);
|
||||
|
||||
prov.tag(AllItemTags.UPRIGHT_ON_BELT.tag)
|
||||
.add(Items.GLASS_BOTTLE, Items.POTION, Items.SPLASH_POTION, Items.LINGERING_POTION,
|
||||
Items.HONEY_BOTTLE, Items.CAKE);
|
||||
|
||||
prov.tag(AllItemTags.CONTRAPTION_CONTROLLED.tag)
|
||||
.add(Items.BELL, Items.CAMPFIRE, Items.SOUL_CAMPFIRE, Items.DISPENSER, Items.DROPPER);
|
||||
|
||||
prov.tag(AllItemTags.VANILLA_STRIPPED_LOGS.tag)
|
||||
.add(Items.STRIPPED_ACACIA_LOG, Items.STRIPPED_BIRCH_LOG, Items.STRIPPED_CRIMSON_STEM,
|
||||
Items.STRIPPED_DARK_OAK_LOG, Items.STRIPPED_JUNGLE_LOG, Items.STRIPPED_OAK_LOG,
|
||||
Items.STRIPPED_SPRUCE_LOG, Items.STRIPPED_WARPED_STEM);
|
||||
|
||||
prov.tag(AllItemTags.VANILLA_STRIPPED_WOOD.tag)
|
||||
.add(Items.STRIPPED_ACACIA_WOOD, Items.STRIPPED_BIRCH_WOOD,
|
||||
Items.STRIPPED_CRIMSON_HYPHAE, Items.STRIPPED_DARK_OAK_WOOD, Items.STRIPPED_JUNGLE_WOOD,
|
||||
Items.STRIPPED_OAK_WOOD, Items.STRIPPED_SPRUCE_WOOD, Items.STRIPPED_WARPED_HYPHAE);
|
||||
|
||||
prov.tag(ItemTags.BEACON_PAYMENT_ITEMS)
|
||||
.addTag(AllItemTags.CREATE_INGOTS.tag);
|
||||
|
||||
prov.tag(Tags.Items.INGOTS)
|
||||
.addTag(AllItemTags.CREATE_INGOTS.tag);
|
||||
|
||||
// COMPAT
|
||||
|
||||
genStrippedWoodItemTags(prov);
|
||||
|
||||
// VALIDATE
|
||||
|
||||
for (AllItemTags tag : AllItemTags.values()) {
|
||||
if (tag.alwaysDatagen) {
|
||||
prov.getOrCreateRawBuilder(tag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void genStrippedWoodItemTags(RegistrateTagsProvider<Item> prov) {
|
||||
TagAppender<Item> logAppender = prov.tag(AllItemTags.MODDED_STRIPPED_LOGS.tag);
|
||||
TagAppender<Item> woodAppender = prov.tag(AllItemTags.MODDED_STRIPPED_WOOD.tag);
|
||||
StrippedWoodHelper helper = new StrippedWoodHelper(logAppender, woodAppender);
|
||||
|
||||
helper.add(Mods.ARS_N, "blue_archwood", "purple_archwood", "green_archwood", "red_archwood");
|
||||
helper.add(Mods.BTN, "livingwood", "dreamwood");
|
||||
helper.add(Mods.FA, "cherrywood", "mysterywood");
|
||||
helper.add(Mods.HEX, "akashic");
|
||||
helper.add(Mods.ID, "menril");
|
||||
helper.add(Mods.BYG, "aspen", "baobab", "enchanted", "cherry", "cika", "cypress", "ebony", "ether",
|
||||
"fir", "green_enchanted", "holly", "jacaranda", "lament", "mahogany", "mangrove", "maple", "nightshade",
|
||||
"palm", "palo_verde", "pine", "rainbow_eucalyptus", "redwood", "skyris", "willow", "witch_hazel",
|
||||
"zelkova");
|
||||
helper.add(Mods.SG, "netherwood");
|
||||
helper.add(Mods.TF, "twilight_oak", "canopy", "mangrove", "dark", "time", "transformation", "mining",
|
||||
"sorting");
|
||||
helper.add(Mods.TIC, "greenheart", "skyroot", "bloodshroom");
|
||||
helper.add(Mods.AP, "twisted");
|
||||
helper.add(Mods.Q, "azalea", "blossom");
|
||||
helper.add(Mods.ECO, "coconut", "walnut", "azalea");
|
||||
helper.add(Mods.BOP, "fir", "redwood", "cherry", "mahogany", "jacaranda", "palm", "willow", "dead",
|
||||
"magic", "umbran", "hellbark");
|
||||
helper.add(Mods.BSK, "bluebright", "starlit", "frostbright", "lunar", "dusk", "maple", "cherry");
|
||||
|
||||
TagGen.addOptional(logAppender, Mods.BYG, "stripped_bulbis_stem");
|
||||
TagGen.addOptional(woodAppender, Mods.BYG, "stripped_bulbis_wood");
|
||||
}
|
||||
|
||||
private static void genFluidTags(RegistrateTagsProvider<Fluid> prov) {
|
||||
prov.tag(AllFluidTags.BOTTOMLESS_ALLOW.tag)
|
||||
.add(Fluids.WATER, Fluids.LAVA);
|
||||
|
||||
// VALIDATE
|
||||
|
||||
for (AllFluidTags tag : AllFluidTags.values()) {
|
||||
if (tag.alwaysDatagen) {
|
||||
prov.getOrCreateRawBuilder(tag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void genEntityTags(RegistrateTagsProvider<EntityType<?>> prov) {
|
||||
|
||||
// VALIDATE
|
||||
|
||||
for (AllEntityTags tag : AllEntityTags.values()) {
|
||||
if (tag.alwaysDatagen) {
|
||||
prov.getOrCreateRawBuilder(tag.tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class StrippedWoodHelper {
|
||||
protected final TagAppender<Item> logAppender;
|
||||
protected final TagAppender<Item> woodAppender;
|
||||
|
||||
public StrippedWoodHelper(TagAppender<Item> logAppender, TagAppender<Item> woodAppender) {
|
||||
this.logAppender = logAppender;
|
||||
this.woodAppender = woodAppender;
|
||||
}
|
||||
|
||||
public void add(Mods mod, String... woodTypes) {
|
||||
for (String type : woodTypes) {
|
||||
String strippedPre = mod.strippedIsSuffix ? "" : "stripped_";
|
||||
String strippedPost = mod.strippedIsSuffix ? "_stripped" : "";
|
||||
TagGen.addOptional(logAppender, mod, strippedPre + type + "_log" + strippedPost);
|
||||
TagGen.addOptional(woodAppender, mod, strippedPre + type + (mod.omitWoodSuffix ? "" : "_wood") + strippedPost);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.simibubi.create.infrastructure.ponder;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.ponder.PonderTooltipHandler;
|
||||
import com.simibubi.create.foundation.ponder.ui.PonderTagIndexScreen;
|
||||
import com.simibubi.create.foundation.ponder.ui.PonderTagScreen;
|
||||
import com.simibubi.create.foundation.ponder.ui.PonderUI;
|
||||
|
||||
public class GeneralText {
|
||||
public static void consumeLang(BiConsumer<String, String> consumer) {
|
||||
consume(consumer, PonderTooltipHandler.HOLD_TO_PONDER, "Hold [%1$s] to Ponder");
|
||||
consume(consumer, PonderTooltipHandler.SUBJECT, "Subject of this scene");
|
||||
consume(consumer, PonderUI.PONDERING, "Pondering about...");
|
||||
consume(consumer, PonderUI.IDENTIFY_MODE, "Identify mode active.\nUnpause with [%1$s]");
|
||||
consume(consumer, PonderTagScreen.ASSOCIATED, "Associated Entries");
|
||||
|
||||
consume(consumer, PonderUI.CLOSE, "Close");
|
||||
consume(consumer, PonderUI.IDENTIFY, "Identify");
|
||||
consume(consumer, PonderUI.NEXT, "Next Scene");
|
||||
consume(consumer, PonderUI.NEXT_UP, "Up Next:");
|
||||
consume(consumer, PonderUI.PREVIOUS, "Previous Scene");
|
||||
consume(consumer, PonderUI.REPLAY, "Replay");
|
||||
consume(consumer, PonderUI.THINK_BACK, "Think Back");
|
||||
consume(consumer, PonderUI.SLOW_TEXT, "Comfy Reading");
|
||||
|
||||
consume(consumer, PonderTagIndexScreen.EXIT, "Exit");
|
||||
consume(consumer, PonderTagIndexScreen.WELCOME, "Welcome to Ponder");
|
||||
consume(consumer, PonderTagIndexScreen.CATEGORIES, "Available Categories in Create");
|
||||
consume(consumer, PonderTagIndexScreen.DESCRIPTION,
|
||||
"Click one of the icons to learn about its associated Items and Blocks");
|
||||
consume(consumer, PonderTagIndexScreen.TITLE, "Ponder Index");
|
||||
}
|
||||
|
||||
private static void consume(BiConsumer<String, String> consumer, String key, String enUS) {
|
||||
consumer.accept(Create.ID + "." + key, enUS);
|
||||
}
|
||||
}
|
|
@ -3,10 +3,7 @@ package com.simibubi.create.infrastructure.ponder;
|
|||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.ponder.PonderLocalization;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class SharedText {
|
||||
|
||||
public static void gatherText() {
|
||||
// Add entries used across several ponder scenes (Safe for hotswap)
|
||||
|
||||
|
@ -23,16 +20,7 @@ public class SharedText {
|
|||
add("storage_on_contraption", "Inventories attached to the Contraption will pick up their drops automatically");
|
||||
}
|
||||
|
||||
public static String get(ResourceLocation key) {
|
||||
return PonderLocalization.getShared(key);
|
||||
}
|
||||
|
||||
public static void add(ResourceLocation k, String v) {
|
||||
PonderLocalization.registerShared(k, v);
|
||||
}
|
||||
|
||||
private static void add(String k, String v) {
|
||||
add(Create.asResource(k), v);
|
||||
PonderLocalization.registerShared(Create.asResource(k), v);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"priority": 1100,
|
||||
"package": "com.simibubi.create.foundation.mixin",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"refmap": "create.refmap.json",
|
||||
"mixins": [
|
||||
"ClientboundMapItemDataPacketMixin",
|
||||
"ContraptionDriverInteractMixin",
|
||||
"WaterWheelFluidSpreadMixin",
|
||||
"CustomItemUseEffectsMixin",
|
||||
"EnchantmentHelperMixin",
|
||||
"EntityMixin",
|
||||
"LanguageProviderMixin",
|
||||
"LavaSwimmingMixin",
|
||||
"MainMixin",
|
||||
"MapItemSavedDataMixin",
|
||||
"TestCommandMixin",
|
||||
"WaterWheelFluidSpreadMixin",
|
||||
"accessor.AbstractProjectileDispenseBehaviorAccessor",
|
||||
"accessor.DispenserBlockAccessor",
|
||||
"accessor.FallingBlockEntityAccessor",
|
||||
|
@ -42,6 +44,5 @@
|
|||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"minVersion": "0.8"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue