Add --flat argument to data generators to not create data in mod specific directores.
Useful For Forge's test mods mainly. Standardized data gen cache file's folder separators. Added ItemModelProvider to BlockStateProvider for cleaner datagen code. Added .gitattributes to fix datagen json's line endings correct on windows.
This commit is contained in:
parent
a39f1cbe1a
commit
f24991f3bb
16 changed files with 241 additions and 115 deletions
7
.gitattributes
vendored
7
.gitattributes
vendored
|
@ -14,3 +14,10 @@
|
|||
*.cfg text eol=lf
|
||||
*.py text eol=lf
|
||||
*.jks binary
|
||||
|
||||
# Disable autocrlf on generated files, they always generate with LF
|
||||
src/generated/**/.cache/cache text eol=lf
|
||||
src/generated/**/*.json text eol=lf
|
||||
src/generated_test/**/.cache/cache text eol=lf
|
||||
src/generated_test/**/*.json text eol=lf
|
||||
|
||||
|
|
|
@ -352,7 +352,10 @@ project(':forge') {
|
|||
tests { sources sourceSets.test }
|
||||
}
|
||||
|
||||
args '--mod', 'data_gen_test', '--all', '--output', rootProject.file('src/generated_test/resources/'), '--validate',
|
||||
args '--flat', '--all', '--validate',
|
||||
'--mod', 'data_gen_test',
|
||||
'--mod', 'piston_event_test',
|
||||
'--output', rootProject.file('src/generated_test/resources/'),
|
||||
'--existing', sourceSets.main.resources.srcDirs[0]
|
||||
}
|
||||
}
|
||||
|
@ -1074,6 +1077,7 @@ project(':forge') {
|
|||
MAPPING_VERSION: MAPPING_VERSION
|
||||
])
|
||||
rename 'gitignore\\.txt', '.gitignore'
|
||||
rename 'gitattributes\\.txt', '.gitattributes'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
5
mdk/gitattributes.txt
Normal file
5
mdk/gitattributes.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Disable autocrlf on generated files, they always generate with LF
|
||||
# Add any extra files or paths here to make git stop saying they
|
||||
# are changed when only line endings change.
|
||||
src/generated/**/.cache/cache text eol=lf
|
||||
src/generated/**/*.json text eol=lf
|
|
@ -1,6 +1,10 @@
|
|||
--- a/net/minecraft/data/DataGenerator.java
|
||||
+++ b/net/minecraft/data/DataGenerator.java
|
||||
@@ -19,7 +19,7 @@
|
||||
@@ -16,10 +16,11 @@
|
||||
private final Collection<Path> field_200394_b;
|
||||
private final Path field_200395_c;
|
||||
private final List<IDataProvider> field_200396_d = Lists.newArrayList();
|
||||
+ private final List<IDataProvider> providerView = java.util.Collections.unmodifiableList(field_200396_d);
|
||||
|
||||
public DataGenerator(Path p_i48266_1_, Collection<Path> p_i48266_2_) {
|
||||
this.field_200395_c = p_i48266_1_;
|
||||
|
@ -9,7 +13,7 @@
|
|||
}
|
||||
|
||||
public Collection<Path> func_200389_a() {
|
||||
@@ -38,6 +38,7 @@
|
||||
@@ -38,6 +39,7 @@
|
||||
|
||||
for(IDataProvider idataprovider : this.field_200396_d) {
|
||||
field_200393_a.info("Starting provider: {}", (Object)idataprovider.func_200397_b());
|
||||
|
@ -17,10 +21,14 @@
|
|||
stopwatch1.start();
|
||||
idataprovider.func_200398_a(directorycache);
|
||||
stopwatch1.stop();
|
||||
@@ -53,6 +54,10 @@
|
||||
@@ -53,6 +55,14 @@
|
||||
this.field_200396_d.add(p_200390_1_);
|
||||
}
|
||||
|
||||
+ public List<IDataProvider> getProviders() {
|
||||
+ return this.providerView;
|
||||
+ }
|
||||
+
|
||||
+ public void addInput(Path value) {
|
||||
+ this.field_200394_b.add(value);
|
||||
+ }
|
||||
|
|
|
@ -9,3 +9,12 @@
|
|||
private final Set<Path> field_218457_g = Sets.newHashSet();
|
||||
|
||||
public DirectoryCache(Path p_i49352_1_, String p_i49352_2_) throws IOException {
|
||||
@@ -55,7 +55,7 @@
|
||||
}
|
||||
|
||||
IOUtils.writeLines(this.field_208329_f.entrySet().stream().map((p_208319_1_) -> {
|
||||
- return (String)p_208319_1_.getValue() + ' ' + this.field_208325_b.relativize(p_208319_1_.getKey());
|
||||
+ return (String)p_208319_1_.getValue() + ' ' + this.field_208325_b.relativize(p_208319_1_.getKey()).toString().replace('\\', '/'); //Forge: Standardize file paths.
|
||||
}).collect(Collectors.toList()), System.lineSeparator(), writer);
|
||||
writer.close();
|
||||
field_208324_a.debug("Caching: cache hits: {}, created: {} removed: {}", this.field_208327_d, this.field_208329_f.size() - this.field_208327_d, this.field_208328_e.size());
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
--- a/net/minecraft/data/Main.java
|
||||
+++ b/net/minecraft/data/Main.java
|
||||
@@ -21,8 +21,11 @@
|
||||
@@ -21,8 +21,12 @@
|
||||
OptionSpec<Void> optionspec6 = optionparser.accepts("all", "Include all generators");
|
||||
OptionSpec<String> optionspec7 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
|
||||
OptionSpec<String> optionspec8 = optionparser.accepts("input", "Input folder").withRequiredArg();
|
||||
+ OptionSpec<String> existing = optionparser.accepts("existing", "Existing resource packs that generated resources can reference").withRequiredArg();
|
||||
+ OptionSpec<java.io.File> gameDir = optionparser.accepts("gameDir").withRequiredArg().ofType(java.io.File.class).defaultsTo(new java.io.File(".")).required(); //Need by modlauncher, so lets just eat it
|
||||
+ OptionSpec<String> mod = optionparser.accepts("mod", "A modid to dump").withRequiredArg().withValuesSeparatedBy(",");
|
||||
+ OptionSpec<Void> flat = optionparser.accepts("flat", "Do not append modid prefix to output directory when generating for multiple mods");
|
||||
OptionSet optionset = optionparser.parse(p_main_0_);
|
||||
- if (!optionset.has(optionspec) && optionset.hasOptions()) {
|
||||
+ if (!optionset.has(optionspec) && optionset.hasOptions() && !(optionset.specs().size() == 1 && optionset.has(gameDir))) {
|
||||
Path path = Paths.get(optionspec7.value(optionset));
|
||||
boolean flag = optionset.has(optionspec6);
|
||||
boolean flag1 = flag || optionset.has(optionspec2);
|
||||
@@ -30,10 +33,12 @@
|
||||
@@ -30,10 +34,13 @@
|
||||
boolean flag3 = flag || optionset.has(optionspec3);
|
||||
boolean flag4 = flag || optionset.has(optionspec4);
|
||||
boolean flag5 = flag || optionset.has(optionspec5);
|
||||
|
@ -24,9 +25,10 @@
|
|||
+ Collection<Path> inputs = optionset.valuesOf(optionspec8).stream().map(Paths::get).collect(Collectors.toList());
|
||||
+ Collection<Path> existingPacks = optionset.valuesOf(existing).stream().map(Paths::get).collect(Collectors.toList());
|
||||
+ java.util.Set<String> mods = new java.util.HashSet<>(optionset.valuesOf(mod));
|
||||
+ net.minecraftforge.fml.ModLoader.get().runDataGenerator(mods, path, inputs, existingPacks, flag2, flag1, flag3, flag4, flag5);
|
||||
+ boolean isFlat = mods.isEmpty() || optionset.has(flat);
|
||||
+ net.minecraftforge.fml.ModLoader.get().runDataGenerator(mods, path, inputs, existingPacks, flag2, flag1, flag3, flag4, flag5, isFlat);
|
||||
+ if (mods.contains("minecraft") || mods.isEmpty())
|
||||
+ func_200264_a(mods.isEmpty() ? path : path.resolve("minecraft"), inputs, flag1, flag2, flag3, flag4, flag5).func_200392_c();
|
||||
+ func_200264_a(isFlat ? path : path.resolve("minecraft"), inputs, flag1, flag2, flag3, flag4, flag5).func_200392_c();
|
||||
} else {
|
||||
optionparser.printHelpOn(System.out);
|
||||
}
|
||||
|
|
|
@ -1,66 +1,69 @@
|
|||
25f832a55d9d61fe27871ce866ef712b625032cc assets\data_gen_test\lang\en_us.json
|
||||
dc2deb0c2da07695855bbb88882455a80787ccac assets\data_gen_test\models\block\acacia_door_bottom.json
|
||||
e987df4921fc71322984556e9617915d4df2bdff assets\data_gen_test\models\block\acacia_door_bottom_hinge.json
|
||||
5103910559b21ce74f315358935a3e582b0c45cd assets\data_gen_test\models\block\acacia_door_top.json
|
||||
590e2cc0ba335ffc618441d6fcc582401ee646cc assets\data_gen_test\models\block\acacia_door_top_hinge.json
|
||||
9c4e371aace89c681b4ea367975f9b4569acaada assets\data_gen_test\models\block\acacia_fence_gate.json
|
||||
1e2e4ace5adef04a3cee3d528c33382a18f40513 assets\data_gen_test\models\block\acacia_fence_gate_open.json
|
||||
557312487766c0801958d72d13b0ac16d8d5d9fd assets\data_gen_test\models\block\acacia_fence_gate_wall.json
|
||||
dd8d2e76831b2a445737f378458db5c505a9b03d assets\data_gen_test\models\block\acacia_fence_gate_wall_open.json
|
||||
4d5b8be3e004e34e75c0f7d415595e14f8985d6c assets\data_gen_test\models\block\acacia_fence_post.json
|
||||
90491fcfa42ee4d8ec7958655866f5a3b55811ad assets\data_gen_test\models\block\acacia_fence_side.json
|
||||
9bf079dec64b632446a867744149d0fccff6fc70 assets\data_gen_test\models\block\acacia_log.json
|
||||
462367a50d9ab2306ca642a72b5fd20c217dc451 assets\data_gen_test\models\block\acacia_slab.json
|
||||
3032bec1f17684ceef914e3763b9be773d17b02f assets\data_gen_test\models\block\acacia_slab_top.json
|
||||
3611756373823dced8f5db5237a6ee0a5f3cbb7a assets\data_gen_test\models\block\acacia_stairs.json
|
||||
72a7c67a73c6217ad117d5583a329e89fd34f246 assets\data_gen_test\models\block\acacia_stairs_inner.json
|
||||
34f85d11d44a198433f530bd54c2c172d7699872 assets\data_gen_test\models\block\acacia_stairs_outer.json
|
||||
31c3b7793cb61870bd74e8e85af7597be57827c6 assets\data_gen_test\models\block\acacia_trapdoor_bottom.json
|
||||
8be9644fe5227cb2c3af52af01b02e9c2c4f9a38 assets\data_gen_test\models\block\acacia_trapdoor_open.json
|
||||
8978e4a1d2902029738eac82749ffc2c30088fe9 assets\data_gen_test\models\block\acacia_trapdoor_top.json
|
||||
88c7bca952fda50e5287ddb5c2e74ff179d08eb2 assets\data_gen_test\models\block\barrel.json
|
||||
ce5d10ee7ab7afed216f3159bdcd5b1deb114104 assets\data_gen_test\models\block\barrel_open.json
|
||||
c3ecb601615c300cafbdd9dc28f9fc42b6835dcd assets\data_gen_test\models\block\birch_fence_gate.json
|
||||
3bcea12fba8714c7ad7c00f440f3e7546a8958ce assets\data_gen_test\models\block\birch_fence_gate_open.json
|
||||
13b47687fb80334b3e51781e691f53f8073843a7 assets\data_gen_test\models\block\birch_fence_gate_wall.json
|
||||
dd0a89461e5f72c08ccf6f3d07bce9c290019022 assets\data_gen_test\models\block\birch_fence_gate_wall_open.json
|
||||
49948428acf0defe004ff07718afd9b50fc41326 assets\data_gen_test\models\block\block.json
|
||||
42fcd2c027f204708f423808f22f6e4c0d5f586b assets\data_gen_test\models\block\cobblestone_wall_post.json
|
||||
21d8ec1410152c67c4b7a06184be545ef1e1d0cf assets\data_gen_test\models\block\cobblestone_wall_side.json
|
||||
26c80ee9a99336b434c9984445bfcf01b25f2cd0 assets\data_gen_test\models\block\cube.json
|
||||
428f68585535789c809eb40d8151a5baa2b0045b assets\data_gen_test\models\block\furnace.json
|
||||
51a161348cf0c51252dbdbad035b7945e02a8763 assets\data_gen_test\models\block\furnace_on.json
|
||||
eb911d39c848d09bc5910aef1a86af63b4fbb6c6 assets\data_gen_test\models\block\glass_pane_noside.json
|
||||
e5df8cc0b7dd9f79fe930711bcf8e60385b8b7ab assets\data_gen_test\models\block\glass_pane_noside_alt.json
|
||||
b178beb42e1db7d177ceb28f0703876943c22a90 assets\data_gen_test\models\block\glass_pane_post.json
|
||||
17cd1168c6c32e1fbd870a9e61716aed6ba7c8a2 assets\data_gen_test\models\block\glass_pane_side.json
|
||||
85326250de254ad1bba0ad183c78e876afa3da51 assets\data_gen_test\models\block\glass_pane_side_alt.json
|
||||
cebd38234491e0882901230538b4205bcf816597 assets\data_gen_test\models\block\oak_trapdoor_bottom.json
|
||||
d8842f8f1a63ee4ac0bcc52e83a375de983b8bb0 assets\data_gen_test\models\block\oak_trapdoor_open.json
|
||||
091f1cf54c828d8c8315cedeb28a3f864a72456e assets\data_gen_test\models\block\oak_trapdoor_top.json
|
||||
a5ace137c931b71acf2599184832187a241acc9c assets\data_gen_test\models\block\stone.json
|
||||
78f9176f15f3a728ee20b5a734e89a32c8108395 assets\data_gen_test\models\block\torch.json
|
||||
e1820400e7b8e4011121eae3f7c873d73f301cd7 assets\data_gen_test\models\block\wall_torch.json
|
||||
d96ff395b92ed2419c8c4aa6e61a610ef78b3216 assets\data_gen_test\models\item\fishing_rod.json
|
||||
abe69efd05a6349acca7e39f3353d7c928a55a72 assets\data_gen_test\models\item\fishing_rod_cast.json
|
||||
e1a3a09af48181e868c26741053e36eafe8bead6 assets\data_gen_test\models\item\test_block_model.json
|
||||
9a27e0d9a3f3d2a834eff92661e090eeda1c59fe assets\data_gen_test\models\item\test_generated_model.json
|
||||
1767c874758bd7c3235db446b6219e6e1edd25b4 assets\minecraft\blockstates\acacia_door.json
|
||||
e41383b4c13ec922c0f5cfa2cc313d88fd294685 assets\minecraft\blockstates\acacia_fence.json
|
||||
967d268bfcf32474b61578bef16e853b6360dd73 assets\minecraft\blockstates\acacia_fence_gate.json
|
||||
e9af65f877e6d012bce27ae35eef3822dda98675 assets\minecraft\blockstates\acacia_log.json
|
||||
2fc1c2cff82aaebdb4ecf298e6de278c62cce3b3 assets\minecraft\blockstates\acacia_slab.json
|
||||
075938fd82340c895eff226d11898abae9a5e178 assets\minecraft\blockstates\acacia_stairs.json
|
||||
9384d458574395650a976b3ad1fe5905b100ddbf assets\minecraft\blockstates\acacia_trapdoor.json
|
||||
42a10a132337264c8821426e17d0c09b92ad42f9 assets\minecraft\blockstates\barrel.json
|
||||
9bc8ba4b8e4ad3cc7074838cf1bf8dad89e2b339 assets\minecraft\blockstates\birch_fence_gate.json
|
||||
acbf9f921b05785d49d8526870ba13aee1a322f7 assets\minecraft\blockstates\cobblestone_wall.json
|
||||
6a3c8e2691b6b7f39f1236a17bb6aa145a9db53f assets\minecraft\blockstates\furnace.json
|
||||
1b2a1344020237ab877e27c43934b042d259bf36 assets\minecraft\blockstates\glass_pane.json
|
||||
bf2e445b48b024354a69138b20a4a4a8aa5d15d1 assets\minecraft\blockstates\oak_trapdoor.json
|
||||
9c4cc92efb78811e8d70a383a1a89eb75b69db04 assets\minecraft\blockstates\stone.json
|
||||
570fdd86046df75a073b759ff7aaf4c4caf43115 assets\minecraft\blockstates\torch.json
|
||||
a012d6d92bab1c91913bd0f2dc0492a0fce916f2 assets\minecraft\blockstates\wall_torch.json
|
||||
4fbaf6f4a3ea05cc071076e27f44ac81f9cc50e3 data\data_gen_test\advancements\conditional.json
|
||||
ed4cbf1a3a2f5d8969f6346fdc9acdbe81d0c919 data\data_gen_test\recipes\conditional.json
|
||||
2c3e2073a1597baaa2970de5ae1649781f87aef8 data\data_gen_test\tags\blocks\test.json
|
||||
25f832a55d9d61fe27871ce866ef712b625032cc assets/data_gen_test/lang/en_us.json
|
||||
dc2deb0c2da07695855bbb88882455a80787ccac assets/data_gen_test/models/block/acacia_door_bottom.json
|
||||
e987df4921fc71322984556e9617915d4df2bdff assets/data_gen_test/models/block/acacia_door_bottom_hinge.json
|
||||
5103910559b21ce74f315358935a3e582b0c45cd assets/data_gen_test/models/block/acacia_door_top.json
|
||||
590e2cc0ba335ffc618441d6fcc582401ee646cc assets/data_gen_test/models/block/acacia_door_top_hinge.json
|
||||
9c4e371aace89c681b4ea367975f9b4569acaada assets/data_gen_test/models/block/acacia_fence_gate.json
|
||||
1e2e4ace5adef04a3cee3d528c33382a18f40513 assets/data_gen_test/models/block/acacia_fence_gate_open.json
|
||||
557312487766c0801958d72d13b0ac16d8d5d9fd assets/data_gen_test/models/block/acacia_fence_gate_wall.json
|
||||
dd8d2e76831b2a445737f378458db5c505a9b03d assets/data_gen_test/models/block/acacia_fence_gate_wall_open.json
|
||||
4d5b8be3e004e34e75c0f7d415595e14f8985d6c assets/data_gen_test/models/block/acacia_fence_post.json
|
||||
90491fcfa42ee4d8ec7958655866f5a3b55811ad assets/data_gen_test/models/block/acacia_fence_side.json
|
||||
9bf079dec64b632446a867744149d0fccff6fc70 assets/data_gen_test/models/block/acacia_log.json
|
||||
462367a50d9ab2306ca642a72b5fd20c217dc451 assets/data_gen_test/models/block/acacia_slab.json
|
||||
3032bec1f17684ceef914e3763b9be773d17b02f assets/data_gen_test/models/block/acacia_slab_top.json
|
||||
3611756373823dced8f5db5237a6ee0a5f3cbb7a assets/data_gen_test/models/block/acacia_stairs.json
|
||||
72a7c67a73c6217ad117d5583a329e89fd34f246 assets/data_gen_test/models/block/acacia_stairs_inner.json
|
||||
34f85d11d44a198433f530bd54c2c172d7699872 assets/data_gen_test/models/block/acacia_stairs_outer.json
|
||||
31c3b7793cb61870bd74e8e85af7597be57827c6 assets/data_gen_test/models/block/acacia_trapdoor_bottom.json
|
||||
8be9644fe5227cb2c3af52af01b02e9c2c4f9a38 assets/data_gen_test/models/block/acacia_trapdoor_open.json
|
||||
8978e4a1d2902029738eac82749ffc2c30088fe9 assets/data_gen_test/models/block/acacia_trapdoor_top.json
|
||||
88c7bca952fda50e5287ddb5c2e74ff179d08eb2 assets/data_gen_test/models/block/barrel.json
|
||||
ce5d10ee7ab7afed216f3159bdcd5b1deb114104 assets/data_gen_test/models/block/barrel_open.json
|
||||
c3ecb601615c300cafbdd9dc28f9fc42b6835dcd assets/data_gen_test/models/block/birch_fence_gate.json
|
||||
3bcea12fba8714c7ad7c00f440f3e7546a8958ce assets/data_gen_test/models/block/birch_fence_gate_open.json
|
||||
13b47687fb80334b3e51781e691f53f8073843a7 assets/data_gen_test/models/block/birch_fence_gate_wall.json
|
||||
dd0a89461e5f72c08ccf6f3d07bce9c290019022 assets/data_gen_test/models/block/birch_fence_gate_wall_open.json
|
||||
49948428acf0defe004ff07718afd9b50fc41326 assets/data_gen_test/models/block/block.json
|
||||
42fcd2c027f204708f423808f22f6e4c0d5f586b assets/data_gen_test/models/block/cobblestone_wall_post.json
|
||||
21d8ec1410152c67c4b7a06184be545ef1e1d0cf assets/data_gen_test/models/block/cobblestone_wall_side.json
|
||||
26c80ee9a99336b434c9984445bfcf01b25f2cd0 assets/data_gen_test/models/block/cube.json
|
||||
428f68585535789c809eb40d8151a5baa2b0045b assets/data_gen_test/models/block/furnace.json
|
||||
51a161348cf0c51252dbdbad035b7945e02a8763 assets/data_gen_test/models/block/furnace_on.json
|
||||
eb911d39c848d09bc5910aef1a86af63b4fbb6c6 assets/data_gen_test/models/block/glass_pane_noside.json
|
||||
e5df8cc0b7dd9f79fe930711bcf8e60385b8b7ab assets/data_gen_test/models/block/glass_pane_noside_alt.json
|
||||
b178beb42e1db7d177ceb28f0703876943c22a90 assets/data_gen_test/models/block/glass_pane_post.json
|
||||
17cd1168c6c32e1fbd870a9e61716aed6ba7c8a2 assets/data_gen_test/models/block/glass_pane_side.json
|
||||
85326250de254ad1bba0ad183c78e876afa3da51 assets/data_gen_test/models/block/glass_pane_side_alt.json
|
||||
cebd38234491e0882901230538b4205bcf816597 assets/data_gen_test/models/block/oak_trapdoor_bottom.json
|
||||
d8842f8f1a63ee4ac0bcc52e83a375de983b8bb0 assets/data_gen_test/models/block/oak_trapdoor_open.json
|
||||
091f1cf54c828d8c8315cedeb28a3f864a72456e assets/data_gen_test/models/block/oak_trapdoor_top.json
|
||||
a5ace137c931b71acf2599184832187a241acc9c assets/data_gen_test/models/block/stone.json
|
||||
78f9176f15f3a728ee20b5a734e89a32c8108395 assets/data_gen_test/models/block/torch.json
|
||||
e1820400e7b8e4011121eae3f7c873d73f301cd7 assets/data_gen_test/models/block/wall_torch.json
|
||||
d96ff395b92ed2419c8c4aa6e61a610ef78b3216 assets/data_gen_test/models/item/fishing_rod.json
|
||||
abe69efd05a6349acca7e39f3353d7c928a55a72 assets/data_gen_test/models/item/fishing_rod_cast.json
|
||||
e1a3a09af48181e868c26741053e36eafe8bead6 assets/data_gen_test/models/item/test_block_model.json
|
||||
9a27e0d9a3f3d2a834eff92661e090eeda1c59fe assets/data_gen_test/models/item/test_generated_model.json
|
||||
1767c874758bd7c3235db446b6219e6e1edd25b4 assets/minecraft/blockstates/acacia_door.json
|
||||
e41383b4c13ec922c0f5cfa2cc313d88fd294685 assets/minecraft/blockstates/acacia_fence.json
|
||||
967d268bfcf32474b61578bef16e853b6360dd73 assets/minecraft/blockstates/acacia_fence_gate.json
|
||||
e9af65f877e6d012bce27ae35eef3822dda98675 assets/minecraft/blockstates/acacia_log.json
|
||||
2fc1c2cff82aaebdb4ecf298e6de278c62cce3b3 assets/minecraft/blockstates/acacia_slab.json
|
||||
075938fd82340c895eff226d11898abae9a5e178 assets/minecraft/blockstates/acacia_stairs.json
|
||||
9384d458574395650a976b3ad1fe5905b100ddbf assets/minecraft/blockstates/acacia_trapdoor.json
|
||||
42a10a132337264c8821426e17d0c09b92ad42f9 assets/minecraft/blockstates/barrel.json
|
||||
9bc8ba4b8e4ad3cc7074838cf1bf8dad89e2b339 assets/minecraft/blockstates/birch_fence_gate.json
|
||||
acbf9f921b05785d49d8526870ba13aee1a322f7 assets/minecraft/blockstates/cobblestone_wall.json
|
||||
6a3c8e2691b6b7f39f1236a17bb6aa145a9db53f assets/minecraft/blockstates/furnace.json
|
||||
1b2a1344020237ab877e27c43934b042d259bf36 assets/minecraft/blockstates/glass_pane.json
|
||||
bf2e445b48b024354a69138b20a4a4a8aa5d15d1 assets/minecraft/blockstates/oak_trapdoor.json
|
||||
9c4cc92efb78811e8d70a383a1a89eb75b69db04 assets/minecraft/blockstates/stone.json
|
||||
570fdd86046df75a073b759ff7aaf4c4caf43115 assets/minecraft/blockstates/torch.json
|
||||
a012d6d92bab1c91913bd0f2dc0492a0fce916f2 assets/minecraft/blockstates/wall_torch.json
|
||||
273e0ed992d227f09f1c83bc22d066fb68d03c84 assets/piston_event_test/blockstates/shiftonmove.json
|
||||
108951e1323586dab98f296c9ead9b2084eb879a assets/piston_event_test/models/block/shiftonmove.json
|
||||
f51f026a75e27a0a53a76771d553c0e3385a2966 assets/piston_event_test/models/item/shiftonmove.json
|
||||
4fbaf6f4a3ea05cc071076e27f44ac81f9cc50e3 data/data_gen_test/advancements/conditional.json
|
||||
ed4cbf1a3a2f5d8969f6346fdc9acdbe81d0c919 data/data_gen_test/recipes/conditional.json
|
||||
2c3e2073a1597baaa2970de5ae1649781f87aef8 data/data_gen_test/tags/blocks/test.json
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "piston_event_test:block/shiftonmove"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "block/furnace_top"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "piston_event_test:block/shiftonmove"
|
||||
}
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package net.minecraftforge.client.model.generators;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
|
||||
/**
|
||||
|
@ -30,4 +32,10 @@ public abstract class BlockModelProvider extends ModelProvider<BlockModelBuilder
|
|||
public BlockModelProvider(DataGenerator generator, String modid, ExistingFileHelper existingFileHelper) {
|
||||
super(generator, modid, BLOCK_FOLDER, BlockModelBuilder::new, existingFileHelper);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Block Models: " + modid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,28 +84,27 @@ public abstract class BlockStateProvider implements IDataProvider {
|
|||
private final DataGenerator generator;
|
||||
private final String modid;
|
||||
private final BlockModelProvider blockModels;
|
||||
private final ItemModelProvider itemModels;
|
||||
|
||||
public BlockStateProvider(DataGenerator gen, String modid, ExistingFileHelper exFileHelper) {
|
||||
this.generator = gen;
|
||||
this.modid = modid;
|
||||
this.blockModels = new BlockModelProvider(gen, modid, exFileHelper) {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return BlockStateProvider.this.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerModels() {}
|
||||
@Override protected void registerModels() {}
|
||||
};
|
||||
this.itemModels = new ItemModelProvider(gen, modid, exFileHelper) {
|
||||
@Override protected void registerModels() {}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(DirectoryCache cache) throws IOException {
|
||||
models().clear();
|
||||
itemModels().clear();
|
||||
registeredBlocks.clear();
|
||||
registerStatesAndModels();
|
||||
models().generateAll(cache);
|
||||
itemModels().generateAll(cache);
|
||||
for (Map.Entry<Block, IGeneratedBlockstate> entry : registeredBlocks.entrySet()) {
|
||||
saveBlockState(cache, entry.getValue().toJson(), entry.getKey());
|
||||
}
|
||||
|
@ -141,6 +140,10 @@ public abstract class BlockStateProvider implements IDataProvider {
|
|||
return blockModels;
|
||||
}
|
||||
|
||||
public ItemModelProvider itemModels() {
|
||||
return itemModels;
|
||||
}
|
||||
|
||||
public ResourceLocation modLoc(String name) {
|
||||
return new ResourceLocation(modid, name);
|
||||
}
|
||||
|
@ -178,6 +181,10 @@ public abstract class BlockStateProvider implements IDataProvider {
|
|||
simpleBlock(block, new ConfiguredModel(model));
|
||||
}
|
||||
|
||||
public void simpleBlockItem(Block block, ModelFile model) {
|
||||
itemModels().getBuilder(block.getRegistryName().getPath()).parent(model);
|
||||
}
|
||||
|
||||
public void simpleBlock(Block block, ConfiguredModel... models) {
|
||||
getVariantBuilder(block)
|
||||
.partialState().setModels(models);
|
||||
|
@ -538,7 +545,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
|||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Block States";
|
||||
return "Block States: " + modid;
|
||||
}
|
||||
|
||||
public static class ConfiguredModelList {
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package net.minecraftforge.client.model.generators;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
|
||||
/**
|
||||
|
@ -30,4 +32,10 @@ public abstract class ItemModelProvider extends ModelProvider<ItemModelBuilder>
|
|||
public ItemModelProvider(DataGenerator generator, String modid, ExistingFileHelper existingFileHelper) {
|
||||
super(generator, modid, ITEM_FOLDER, ItemModelBuilder::new, existingFileHelper);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Item Models: " + modid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,8 +234,8 @@ public class ModLoader
|
|||
if (containers.size() != modInfoMap.size()) {
|
||||
LOGGER.fatal(LOADING,"File {} constructed {} mods: {}, but had {} mods specified: {}",
|
||||
modFile.getFilePath(),
|
||||
containers.size(), containers.stream().map(c -> c != null ? c.getModId() : "(null)").collect(Collectors.toList()),
|
||||
modInfoMap.size(), modInfoMap.values().stream().map(IModInfo::getModId).collect(Collectors.toList()));
|
||||
containers.size(), containers.stream().map(c -> c != null ? c.getModId() : "(null)").sorted().collect(Collectors.toList()),
|
||||
modInfoMap.size(), modInfoMap.values().stream().map(IModInfo::getModId).sorted().collect(Collectors.toList()));
|
||||
loadingExceptions.add(new ModLoadingException(null, ModLoadingStage.CONSTRUCT, "fml.modloading.missingclasses", null, modFile.getFilePath()));
|
||||
}
|
||||
return containers;
|
||||
|
@ -285,11 +285,16 @@ public class ModLoader
|
|||
this.loadingWarnings.add(warning);
|
||||
}
|
||||
|
||||
@Deprecated //Remove in 1.16
|
||||
public void runDataGenerator(final Set<String> mods, final Path path, final Collection<Path> inputs, Collection<Path> existingPacks, final boolean serverGenerators, final boolean clientGenerators, final boolean devToolGenerators, final boolean reportsGenerator, final boolean structureValidator) {
|
||||
runDataGenerator(mods, path, inputs, existingPacks, serverGenerators, clientGenerators, devToolGenerators, reportsGenerator, structureValidator, false);
|
||||
}
|
||||
|
||||
public void runDataGenerator(final Set<String> mods, final Path path, final Collection<Path> inputs, Collection<Path> existingPacks, final boolean serverGenerators, final boolean clientGenerators, final boolean devToolGenerators, final boolean reportsGenerator, final boolean structureValidator, final boolean flat) {
|
||||
if (mods.contains("minecraft") && mods.size() == 1) return;
|
||||
LOGGER.info("Initializing Data Gatherer for mods {}", mods);
|
||||
Bootstrap.register();
|
||||
dataGeneratorConfig = new GatherDataEvent.DataGeneratorConfig(mods, path, inputs, serverGenerators, clientGenerators, devToolGenerators, reportsGenerator, structureValidator);
|
||||
dataGeneratorConfig = new GatherDataEvent.DataGeneratorConfig(mods, path, inputs, serverGenerators, clientGenerators, devToolGenerators, reportsGenerator, structureValidator, flat);
|
||||
existingFileHelper = new ExistingFileHelper(existingPacks, structureValidator);
|
||||
gatherAndInitializeMods(() -> {});
|
||||
dispatchAndHandleError(LifecycleEventProvider.GATHERDATA, Runnable::run, () -> {});
|
||||
|
@ -297,6 +302,6 @@ public class ModLoader
|
|||
}
|
||||
|
||||
public Function<ModContainer, ModLifecycleEvent> getDataGeneratorEvent() {
|
||||
return mc -> new GatherDataEvent(mc, dataGeneratorConfig.makeGenerator(p->dataGeneratorConfig.getMods().size() == 1 ? p : p.resolve(mc.getModId()), dataGeneratorConfig.getMods().contains(mc.getModId())), dataGeneratorConfig, existingFileHelper);
|
||||
return mc -> new GatherDataEvent(mc, dataGeneratorConfig.makeGenerator(p->dataGeneratorConfig.isFlat() ? p : p.resolve(mc.getModId()), dataGeneratorConfig.getMods().contains(mc.getModId())), dataGeneratorConfig, existingFileHelper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,10 @@ import java.nio.file.Path;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GatherDataEvent extends ModLifecycleEvent
|
||||
{
|
||||
|
@ -61,9 +63,14 @@ public class GatherDataEvent extends ModLifecycleEvent
|
|||
private final boolean dev;
|
||||
private final boolean reports;
|
||||
private final boolean validate;
|
||||
private final boolean flat;
|
||||
private List<DataGenerator> generators = new ArrayList<>();
|
||||
|
||||
@Deprecated //Remove in 1.16
|
||||
public DataGeneratorConfig(final Set<String> mods, final Path path, final Collection<Path> inputs, final boolean server, final boolean client, final boolean dev, final boolean reports, final boolean validate) {
|
||||
this(mods, path, inputs, server, client, dev, reports, validate, false);
|
||||
}
|
||||
public DataGeneratorConfig(final Set<String> mods, final Path path, final Collection<Path> inputs, final boolean server, final boolean client, final boolean dev, final boolean reports, final boolean validate, final boolean flat) {
|
||||
this.mods = mods;
|
||||
this.path = path;
|
||||
this.inputs = inputs;
|
||||
|
@ -72,20 +79,34 @@ public class GatherDataEvent extends ModLifecycleEvent
|
|||
this.dev = dev;
|
||||
this.reports = reports;
|
||||
this.validate = validate;
|
||||
this.flat = flat;
|
||||
|
||||
}
|
||||
|
||||
public Set<String> getMods() {
|
||||
return mods;
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
return flat || getMods().size() == 1;
|
||||
}
|
||||
|
||||
public DataGenerator makeGenerator(final Function<Path,Path> pathEnhancer, final boolean shouldExecute) {
|
||||
final DataGenerator generator = new DataGenerator(pathEnhancer.apply(path), inputs);
|
||||
if (shouldExecute) generators.add(generator);
|
||||
if (shouldExecute)
|
||||
generators.add(generator);
|
||||
return generator;
|
||||
}
|
||||
|
||||
public void runAll() {
|
||||
generators.forEach(LamdbaExceptionUtils.rethrowConsumer(DataGenerator::run));
|
||||
Map<Path, List<DataGenerator>> paths = generators.stream().collect(Collectors.groupingBy(DataGenerator::getOutputFolder));
|
||||
|
||||
paths.values().forEach(LamdbaExceptionUtils.rethrowConsumer(lst -> {
|
||||
DataGenerator parent = lst.get(0);
|
||||
for (int x = 1; x < lst.size(); x++)
|
||||
lst.get(x).getProviders().forEach(parent::addProvider);
|
||||
parent.run();
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,22 +28,31 @@ import net.minecraft.block.PistonBlock;
|
|||
import net.minecraft.block.PistonBlockStructureHelper;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ExistingFileHelper;
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import net.minecraftforge.event.world.PistonEvent;
|
||||
import net.minecraftforge.event.world.PistonEvent.PistonMoveType;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
/**
|
||||
* This test mod blocks pistons from moving cobblestone at all except indirectly
|
||||
|
@ -55,21 +64,22 @@ import net.minecraftforge.fml.common.Mod;
|
|||
@Mod(value = PistonEventTest.MODID)
|
||||
public class PistonEventTest
|
||||
{
|
||||
|
||||
public static final String MODID = "piston_event_test";
|
||||
public static String blockName = "shiftonmove";
|
||||
private static DeferredRegister<Block> BLOCKS = new DeferredRegister<Block>(ForgeRegistries.BLOCKS, MODID);
|
||||
private static DeferredRegister<Item> ITEMS = new DeferredRegister<Item> (ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
private static Block shiftOnMove = new BlockShiftOnMove();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void regItem(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().register(new BlockItem(shiftOnMove, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(shiftOnMove.getRegistryName()));
|
||||
private static RegistryObject<Block> shiftOnMove = BLOCKS.register(blockName, () -> new Block(Block.Properties.create(Material.ROCK)));
|
||||
static {
|
||||
ITEMS.register(blockName, () -> new BlockItem(shiftOnMove.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void regBlock(RegistryEvent.Register<Block> event)
|
||||
public PistonEventTest()
|
||||
{
|
||||
event.getRegistry().register(shiftOnMove);
|
||||
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
BLOCKS.register(modBus);
|
||||
ITEMS.register(modBus);
|
||||
modBus.addListener(this::gatherData);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -79,7 +89,7 @@ public class PistonEventTest
|
|||
{
|
||||
World world = (World) event.getWorld();
|
||||
PistonBlockStructureHelper pistonHelper = event.getStructureHelper();
|
||||
PlayerEntity player = DistExecutor.callWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player);
|
||||
PlayerEntity player = DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player);
|
||||
if (world.isRemote && player != null)
|
||||
{
|
||||
if (pistonHelper.canMove())
|
||||
|
@ -108,10 +118,10 @@ public class PistonEventTest
|
|||
|
||||
// Make the block move up and out of the way so long as it won't replace the piston
|
||||
BlockPos pushedBlockPos = event.getFaceOffsetPos();
|
||||
if (world.getBlockState(pushedBlockPos).getBlock() == shiftOnMove && event.getDirection() != Direction.DOWN)
|
||||
if (world.getBlockState(pushedBlockPos).getBlock() == shiftOnMove.get() && event.getDirection() != Direction.DOWN)
|
||||
{
|
||||
world.setBlockState(pushedBlockPos, Blocks.AIR.getDefaultState());
|
||||
world.setBlockState(pushedBlockPos.up(), shiftOnMove.getDefaultState());
|
||||
world.setBlockState(pushedBlockPos.up(), shiftOnMove.get().getDefaultState());
|
||||
}
|
||||
|
||||
// Block pushing cobblestone (directly, indirectly works)
|
||||
|
@ -121,7 +131,7 @@ public class PistonEventTest
|
|||
{
|
||||
boolean isSticky = event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.STICKY_PISTON;
|
||||
|
||||
PlayerEntity player = DistExecutor.callWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player);
|
||||
PlayerEntity player = DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player);
|
||||
if (event.getWorld().isRemote() && player != null)
|
||||
{
|
||||
if (isSticky)
|
||||
|
@ -141,17 +151,30 @@ public class PistonEventTest
|
|||
}
|
||||
}
|
||||
|
||||
public static class BlockShiftOnMove extends Block
|
||||
public void gatherData(GatherDataEvent event)
|
||||
{
|
||||
public static String blockName = "shiftonmove";
|
||||
public static ResourceLocation blockId = new ResourceLocation(MODID, blockName);
|
||||
DataGenerator gen = event.getGenerator();
|
||||
|
||||
public BlockShiftOnMove()
|
||||
if (event.includeClient())
|
||||
{
|
||||
super(Block.Properties.create(Material.ROCK));
|
||||
this.setRegistryName(blockId);
|
||||
}
|
||||
|
||||
gen.addProvider(new BlockStates(gen, event.getExistingFileHelper()));
|
||||
}
|
||||
}
|
||||
|
||||
private class BlockStates extends BlockStateProvider
|
||||
{
|
||||
public BlockStates(DataGenerator gen, ExistingFileHelper exFileHelper)
|
||||
{
|
||||
super(gen, MODID, exFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerStatesAndModels()
|
||||
{
|
||||
ModelFile model = models().cubeAll(shiftOnMove.get().getRegistryName().getPath(), mcLoc("block/furnace_top"));
|
||||
simpleBlock(shiftOnMove.get(), model);
|
||||
simpleBlockItem(shiftOnMove.get(), model);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue