mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-27 13:28:00 +01:00
Language Barrier
- Make LangMerger run after all of registrates providers to avoid race conditions
This commit is contained in:
parent
cf240e7581
commit
e94fddadf3
15 changed files with 3294 additions and 728 deletions
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2023-06-29T15:21:25.0351728 Create's Sequenced Assembly Recipes
|
||||
// 1.20.1 2023-06-29T19:16:25.7368047 Create's Sequenced Assembly Recipes
|
||||
dbaca5a5aa312f3bc7b826e51e665d32e798a5d7 data/create/recipes/sequenced_assembly/precision_mechanism.json
|
||||
0cdbd4f583aa0a2aa8f3ca2827199bede1732722 data/create/recipes/sequenced_assembly/sturdy_sheet.json
|
||||
1274315b5c570722d6f5b2ed7f5e53fe01b6288a data/create/recipes/sequenced_assembly/track.json
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2023-06-29T15:21:25.0778538 Create's Worldgen Data
|
||||
// 1.20.1 2023-06-29T19:16:25.7447829 Create's Worldgen Data
|
||||
f650826db97d0562230ae0bd965ccbad4c696eff data/create/forge/biome_modifier/striated_ores_nether.json
|
||||
d401f270f1ba0e5d6940aeb8f72ebb3a02dd055e data/create/forge/biome_modifier/striated_ores_overworld.json
|
||||
ed82e4fd3dba36cf2fd81a196cc6670ae0c6da9f data/create/forge/biome_modifier/zinc_ore.json
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2023-06-29T15:21:25.009674 Create's Damage Type Data
|
||||
// 1.20.1 2023-06-29T19:16:25.6732481 Create's Damage Type Data
|
||||
030ede1044384c4117ac1e491bf5c78bbd2842f5 data/create/damage_type/crush.json
|
||||
92b0416950ffeb3ba68811e587177c2f8811c2c5 data/create/damage_type/cuckoo_surprise.json
|
||||
d2a4fdb64f4ba817e13a7b20c73fd1ca34b825fc data/create/damage_type/fan_fire.json
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2023-06-29T16:09:09.4461585 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud), Create's lang merger]
|
||||
// 1.20.1 2023-06-29T19:28:41.4318502 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
|
||||
60bbdf92d2ac9824ea6144955c74043a6005f79d assets/create/blockstates/acacia_window.json
|
||||
6a67703c2697d81b7dc83e9d72a66f9c9ff08383 assets/create/blockstates/acacia_window_pane.json
|
||||
c3ae87b62e81d8e9476eccd793bb1548d74c66a1 assets/create/blockstates/adjustable_chain_gearshift.json
|
||||
|
@ -586,7 +586,7 @@ fe8c497aacc641c2f01cec90bba9f19e59cc2ed2 assets/create/blockstates/yellow_valve_
|
|||
e819e93fdcbe9fd9c050a052d2718ff3b3539365 assets/create/blockstates/zinc_block.json
|
||||
64121dcb216381c83b4fe28aa361ea07c24c9ad0 assets/create/blockstates/zinc_ore.json
|
||||
3a1e0c68a9f1d6a252f47b3f7311278711f2aae0 assets/create/lang/en_ud.json
|
||||
12da996b104ab0e5ce956c963fbdae7e59e72f79 assets/create/lang/en_us.json
|
||||
a0c0e4f23540bef4b1796ad9f4e4ace609d2919b assets/create/lang/en_us.json
|
||||
a97e1060e00ae701a02e39cd4ef8054cf345fac4 assets/create/models/block/acacia_window.json
|
||||
103e032c0b1a0a6a27c67da8c91179a564bd281c assets/create/models/block/acacia_window_pane_noside.json
|
||||
fb00b627abda76ad4fea867ca57dbfadd24fffa3 assets/create/models/block/acacia_window_pane_noside_alt.json
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2023-06-29T15:21:25.0106719 Create's Advancements
|
||||
// 1.20.1 2023-06-29T19:16:25.6752424 Create's Advancements
|
||||
2661a689fdcf729494f46e3c719f71c62e31582e data/create/advancements/andesite_alloy.json
|
||||
fa16c4afe0496edc3f157858a6e0ff177a1622ff data/create/advancements/andesite_casing.json
|
||||
5a694002d0a663bc869b09d15924a10c43dc522f data/create/advancements/anvil_plough.json
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2023-06-29T15:21:25.0401598 Create's Mechanical Crafting Recipes
|
||||
// 1.20.1 2023-06-29T19:16:25.7437852 Create's Mechanical Crafting Recipes
|
||||
f076d64d9f30709bed34775136c9241097b28aa9 data/create/recipes/mechanical_crafting/crushing_wheel.json
|
||||
694dca9dcff246bb7f560b3304fcc244c53217d5 data/create/recipes/mechanical_crafting/extendo_grip.json
|
||||
3b2837b08607c1ca466fa3eb418209b2e55da6ba data/create/recipes/mechanical_crafting/potato_cannon.json
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2023-06-29T15:21:25.0361701 Create's Standard Recipes
|
||||
// 1.20.1 2023-06-29T19:16:25.7378011 Create's Standard Recipes
|
||||
a8cc4af26f6c7c45a9eef12e92af1452fe042454 data/create/advancements/recipes/combat/crafting/appliances/netherite_backtank.json
|
||||
2c2639c7b307ee7c7a4e97e5efebf496788998ad data/create/advancements/recipes/combat/crafting/appliances/netherite_backtank_from_netherite.json
|
||||
81dcf0cb1aa99e39bc7d1a386e07cad4cee7d8b9 data/create/advancements/recipes/combat/crafting/appliances/netherite_diving_boots.json
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2023-06-29T16:13:59.3023933 Tags for minecraft:damage_type mod id create
|
||||
ecae5612a852b2d3f567e27167c87128e1a4dc1d data/minecraft/tags/damage_type/bypasses_armor.json
|
||||
// 1.20.1 2023-06-29T19:34:04.0054837 Tags for minecraft:damage_type mod id create
|
||||
98cc73dad40a3d36d74ba9b9134c1ad52a9390c3 data/minecraft/tags/damage_type/bypasses_armor.json
|
||||
62231dbbc4e6a21bafe1b3cdb3c86d06ff647ec7 data/minecraft/tags/damage_type/is_explosion.json
|
||||
ad45c55a9cc7883cfcd8b208f735c739f599e1d0 data/minecraft/tags/damage_type/is_fire.json
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2023-06-29T15:21:25.0116686 Create's Processing Recipes
|
||||
// 1.20.1 2023-06-29T19:16:25.6782348 Create's Processing Recipes
|
||||
3c94326fb730f68c1e44fe1e2ef09c9db6ffd92b data/create/recipes/compacting/andesite_from_flint.json
|
||||
8d3d5b31f3601b9f681ff710e0545a483a1494c6 data/create/recipes/compacting/blaze_cake.json
|
||||
8bd7f4e3a686ab520b2d55594d2018d0e9a50c91 data/create/recipes/compacting/chocolate.json
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
// 1.20.1 2023-06-29T15:21:25.0341785 Create's Custom Sounds
|
||||
// 1.20.1 2023-06-29T19:16:25.6862141 Create's Custom Sounds
|
||||
043955db25ffe58e7debb9a4f11e41a9571376e6 assets/create/sounds.json
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"values": [
|
||||
{
|
||||
"id": "create:fan_lava",
|
||||
"id": "create:fan_fire",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"id": "create:crush",
|
||||
"id": "create:fan_lava",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
|
@ -13,11 +13,11 @@
|
|||
"required": false
|
||||
},
|
||||
{
|
||||
"id": "create:fan_fire",
|
||||
"id": "create:mechanical_saw",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"id": "create:mechanical_saw",
|
||||
"id": "create:crush",
|
||||
"required": false
|
||||
}
|
||||
]
|
||||
|
|
|
@ -28,7 +28,6 @@ import com.simibubi.create.foundation.advancement.AllTriggers;
|
|||
import com.simibubi.create.foundation.block.CopperRegistries;
|
||||
import com.simibubi.create.foundation.damageTypes.DamageTypeDataProvider;
|
||||
import com.simibubi.create.foundation.damageTypes.DamageTypeTagGen;
|
||||
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.TagGen;
|
||||
|
@ -46,8 +45,6 @@ import com.simibubi.create.infrastructure.config.AllConfigs;
|
|||
import com.simibubi.create.infrastructure.worldgen.AllFeatures;
|
||||
import com.simibubi.create.infrastructure.worldgen.AllPlacementModifiers;
|
||||
import com.simibubi.create.infrastructure.worldgen.WorldgenDataProvider;
|
||||
import com.tterrag.registrate.providers.ProviderType;
|
||||
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.PackOutput;
|
||||
|
@ -145,7 +142,7 @@ public class Create {
|
|||
CopperRegistries.inject();
|
||||
|
||||
modEventBus.addListener(Create::init);
|
||||
modEventBus.addListener(EventPriority.LOWEST, Create::gatherData);
|
||||
modEventBus.addListener(EventPriority.LOW, Create::gatherData);
|
||||
modEventBus.addListener(AllSoundEvents::register);
|
||||
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> CreateClient.onCtorClient(modEventBus, forgeEventBus));
|
||||
|
@ -167,18 +164,16 @@ public class Create {
|
|||
});
|
||||
}
|
||||
|
||||
public static final ProviderType<LangMerger> LANG_MERGER =
|
||||
ProviderType.register("lang_merger", (p, e) -> new LangMerger(e.getGenerator()
|
||||
.getPackOutput(), ID, NAME, AllLangPartials.values()));
|
||||
|
||||
public static void gatherData(GatherDataEvent event) {
|
||||
TagGen.datagen();
|
||||
DataGenerator gen = event.getGenerator();
|
||||
PackOutput output = gen.getPackOutput();
|
||||
|
||||
if (event.includeClient()) {
|
||||
REGISTRATE.addDataGenerator(LANG_MERGER, NonNullConsumer.noop());
|
||||
gen.addProvider(true, AllSoundEvents.provider(gen));
|
||||
LangMerger.attachToRegistrateProvider(gen, output);
|
||||
}
|
||||
|
||||
if (event.includeServer()) {
|
||||
gen.addProvider(true, new AllAdvancements(output));
|
||||
gen.addProvider(true, new StandardRecipeGen(output));
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.simibubi.create.foundation.data;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.DataProvider;
|
||||
|
||||
public class ChainedDataProvider implements DataProvider {
|
||||
|
||||
private DataProvider mainProvider;
|
||||
private DataProvider addedProvider;
|
||||
|
||||
public ChainedDataProvider(DataProvider mainProvider, DataProvider addedProvider) {
|
||||
this.mainProvider = mainProvider;
|
||||
this.addedProvider = addedProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<?> run(CachedOutput pOutput) {
|
||||
return mainProvider.run(pOutput)
|
||||
.thenCompose(s -> addedProvider.run(pOutput));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return mainProvider.getName() + " with " + addedProvider.getName();
|
||||
}
|
||||
|
||||
}
|
|
@ -11,29 +11,32 @@ import java.nio.file.Path;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.apache.commons.lang3.mutable.MutableObject;
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.hash.HashingOutputStream;
|
||||
import com.google.common.hash.HashCode;
|
||||
import com.google.gson.Gson;
|
||||
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.providers.RegistrateProvider;
|
||||
import com.tterrag.registrate.providers.RegistrateDataProvider;
|
||||
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||
|
||||
public class LangMerger implements RegistrateProvider {
|
||||
public class LangMerger implements DataProvider {
|
||||
|
||||
static final Gson GSON = new GsonBuilder().setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
|
@ -60,6 +63,18 @@ public class LangMerger implements RegistrateProvider {
|
|||
populateLangIgnore();
|
||||
}
|
||||
|
||||
public static void attachToRegistrateProvider(DataGenerator gen, PackOutput output) {
|
||||
Map<String, DataProvider> providers =
|
||||
ObfuscationReflectionHelper.getPrivateValue(DataGenerator.class, gen, "providersToRun");
|
||||
Entry<String, DataProvider> entryToReplace = null;
|
||||
for (Entry<String, DataProvider> entry : providers.entrySet())
|
||||
if (entry.getValue() instanceof RegistrateDataProvider rdp)
|
||||
entryToReplace = entry;
|
||||
if (entryToReplace != null)
|
||||
providers.put(entryToReplace.getKey(), new ChainedDataProvider(entryToReplace.getValue(),
|
||||
new LangMerger(output, Create.ID, Create.NAME, AllLangPartials.values())));
|
||||
}
|
||||
|
||||
protected void populateLangIgnore() {
|
||||
// Key prefixes added here will NOT be transferred to lang templates
|
||||
langIgnore.add("create.ponder.debug_"); // Ponder debug scene text
|
||||
|
@ -194,17 +209,14 @@ public class LangMerger implements RegistrateProvider {
|
|||
.getAsJsonObject());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void save(CachedOutput cache, List<Object> dataIn, Path target, String message) throws IOException {
|
||||
|
||||
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
|
||||
HashingOutputStream hashingoutputstream = new HashingOutputStream(Hashing.sha1(), bytearrayoutputstream);
|
||||
|
||||
Writer writer = new OutputStreamWriter(hashingoutputstream, StandardCharsets.UTF_8);
|
||||
Writer writer = new OutputStreamWriter(bytearrayoutputstream, StandardCharsets.UTF_8);
|
||||
writer.append(createString(dataIn));
|
||||
writer.close();
|
||||
|
||||
cache.writeIfNeeded(target, bytearrayoutputstream.toByteArray(), hashingoutputstream.hash());
|
||||
CachedOutput.NO_CACHE.writeIfNeeded(target, bytearrayoutputstream.toByteArray(), HashCode.fromInt(0));
|
||||
Create.LOGGER.info(message);
|
||||
}
|
||||
|
||||
protected String createString(List<Object> data) {
|
||||
|
@ -218,9 +230,4 @@ public class LangMerger implements RegistrateProvider {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogicalSide getSide() {
|
||||
return LogicalSide.CLIENT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue