Load Modded Datapacks in DatapackScreen, before world creation (#6913)

This commit is contained in:
Cyborgmas 2020-07-20 18:56:21 -04:00 committed by GitHub
parent a3edfd3748
commit 24f3ef5ffe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 112 additions and 39 deletions

View file

@ -16,7 +16,7 @@
this.field_71459_aj = p_i45547_1_.field_178741_d.field_178756_a; this.field_71459_aj = p_i45547_1_.field_178741_d.field_178756_a;
this.field_238175_ae_ = !p_i45547_1_.field_178741_d.field_239099_d_; this.field_238175_ae_ = !p_i45547_1_.field_178741_d.field_239099_d_;
this.field_238176_af_ = !p_i45547_1_.field_178741_d.field_239100_e_; this.field_238176_af_ = !p_i45547_1_.field_178741_d.field_239100_e_;
@@ -416,13 +416,13 @@ @@ -416,14 +416,15 @@
this.field_195558_d.func_216526_a(this.field_71474_y.field_74350_i); this.field_195558_d.func_216526_a(this.field_71474_y.field_74350_i);
this.field_71417_B = new MouseHelper(this); this.field_71417_B = new MouseHelper(this);
@ -29,9 +29,11 @@
this.field_110451_am = new SimpleReloadableResourceManager(ResourcePackType.CLIENT_RESOURCES); this.field_110451_am = new SimpleReloadableResourceManager(ResourcePackType.CLIENT_RESOURCES);
+ net.minecraftforge.fml.client.ClientModLoader.begin(this, this.field_110448_aq, this.field_110451_am, this.field_195554_ax); + net.minecraftforge.fml.client.ClientModLoader.begin(this, this.field_110448_aq, this.field_110451_am, this.field_195554_ax);
this.field_110448_aq.func_198983_a(); this.field_110448_aq.func_198983_a();
+ DatapackCodec.field_234880_a_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks());
this.field_71474_y.func_198017_a(this.field_110448_aq); this.field_71474_y.func_198017_a(this.field_110448_aq);
this.field_135017_as = new LanguageManager(this.field_71474_y.field_74363_ab); this.field_135017_as = new LanguageManager(this.field_71474_y.field_74363_ab);
@@ -463,6 +463,7 @@ this.field_110451_am.func_219534_a(this.field_135017_as);
@@ -463,6 +464,7 @@
this.func_193986_ar(); this.func_193986_ar();
this.field_110451_am.func_219534_a(this.field_193995_ae); this.field_110451_am.func_219534_a(this.field_193995_ae);
this.field_71452_i = new ParticleManager(this.field_71441_e, this.field_71446_o); this.field_71452_i = new ParticleManager(this.field_71441_e, this.field_71446_o);
@ -39,7 +41,7 @@
this.field_110451_am.func_219534_a(this.field_71452_i); this.field_110451_am.func_219534_a(this.field_71452_i);
this.field_213272_aL = new PaintingSpriteUploader(this.field_71446_o); this.field_213272_aL = new PaintingSpriteUploader(this.field_71446_o);
this.field_110451_am.func_219534_a(this.field_213272_aL); this.field_110451_am.func_219534_a(this.field_213272_aL);
@@ -470,7 +471,8 @@ @@ -470,7 +472,8 @@
this.field_110451_am.func_219534_a(this.field_213273_aM); this.field_110451_am.func_219534_a(this.field_213273_aM);
this.field_241557_ar_ = new GPUWarning(); this.field_241557_ar_ = new GPUWarning();
this.field_110451_am.func_219534_a(this.field_241557_ar_); this.field_110451_am.func_219534_a(this.field_241557_ar_);
@ -49,7 +51,7 @@
this.field_184132_p = new DebugRenderer(this); this.field_184132_p = new DebugRenderer(this);
RenderSystem.setErrorCallback(this::func_195545_a); RenderSystem.setErrorCallback(this::func_195545_a);
if (this.field_71474_y.field_74353_u && !this.field_195558_d.func_198113_j()) { if (this.field_71474_y.field_74353_u && !this.field_195558_d.func_198113_j()) {
@@ -482,11 +484,6 @@ @@ -482,11 +485,6 @@
this.field_195558_d.func_224798_d(this.field_71474_y.field_225307_E); this.field_195558_d.func_224798_d(this.field_71474_y.field_225307_E);
this.field_195558_d.func_227801_c_(); this.field_195558_d.func_227801_c_();
this.func_213226_a(); this.func_213226_a();
@ -61,7 +63,7 @@
ResourceLoadProgressGui.func_212970_a(this); ResourceLoadProgressGui.func_212970_a(this);
List<IResourcePack> list = this.field_110448_aq.func_232623_f_(); List<IResourcePack> list = this.field_110448_aq.func_232623_f_();
@@ -495,7 +492,14 @@ @@ -495,7 +493,14 @@
if (SharedConstants.field_206244_b) { if (SharedConstants.field_206244_b) {
this.func_213256_aB(); this.func_213256_aB();
} }
@ -77,7 +79,7 @@
}); });
}, false)); }, false));
} }
@@ -534,7 +538,7 @@ @@ -534,7 +539,7 @@
} }
private void func_229988_a_(Throwable p_229988_1_) { private void func_229988_a_(Throwable p_229988_1_) {
@ -86,7 +88,7 @@
ITextComponent itextcomponent; ITextComponent itextcomponent;
if (p_229988_1_ instanceof SimpleReloadableResourceManager.FailedPackException) { if (p_229988_1_ instanceof SimpleReloadableResourceManager.FailedPackException) {
itextcomponent = new StringTextComponent(((SimpleReloadableResourceManager.FailedPackException)p_229988_1_).func_241203_a().func_195762_a()); itextcomponent = new StringTextComponent(((SimpleReloadableResourceManager.FailedPackException)p_229988_1_).func_241203_a().func_195762_a());
@@ -618,7 +622,7 @@ @@ -618,7 +623,7 @@
return Stream.of(Registry.field_212630_s.func_177774_c(p_213251_0_.func_77973_b())); return Stream.of(Registry.field_212630_s.func_177774_c(p_213251_0_.func_77973_b()));
}); });
SearchTreeReloadable<ItemStack> searchtreereloadable = new SearchTreeReloadable<>((p_213235_0_) -> { SearchTreeReloadable<ItemStack> searchtreereloadable = new SearchTreeReloadable<>((p_213235_0_) -> {
@ -95,7 +97,7 @@
}); });
NonNullList<ItemStack> nonnulllist = NonNullList.func_191196_a(); NonNullList<ItemStack> nonnulllist = NonNullList.func_191196_a();
@@ -688,13 +692,13 @@ @@ -688,13 +693,13 @@
Bootstrap.func_179870_a(p_71377_0_.func_71502_e()); Bootstrap.func_179870_a(p_71377_0_.func_71502_e());
if (p_71377_0_.func_71497_f() != null) { if (p_71377_0_.func_71497_f() != null) {
Bootstrap.func_179870_a("#@!@# Game crashed! Crash report saved to: #@!@# " + p_71377_0_.func_71497_f()); Bootstrap.func_179870_a("#@!@# Game crashed! Crash report saved to: #@!@# " + p_71377_0_.func_71497_f());
@ -112,7 +114,7 @@
} }
} }
@@ -703,6 +707,7 @@ @@ -703,6 +708,7 @@
return this.field_71474_y.field_211842_aO; return this.field_71474_y.field_211842_aO;
} }
@ -120,7 +122,7 @@
public CompletableFuture<Void> func_213237_g() { public CompletableFuture<Void> func_213237_g() {
if (this.field_213276_aV != null) { if (this.field_213276_aV != null) {
return this.field_213276_aV; return this.field_213276_aV;
@@ -791,10 +796,6 @@ @@ -791,10 +797,6 @@
} }
public void func_147108_a(@Nullable Screen p_147108_1_) { public void func_147108_a(@Nullable Screen p_147108_1_) {
@ -131,7 +133,7 @@
if (p_147108_1_ == null && this.field_71441_e == null) { if (p_147108_1_ == null && this.field_71441_e == null) {
p_147108_1_ = new MainMenuScreen(); p_147108_1_ = new MainMenuScreen();
} else if (p_147108_1_ == null && this.field_71439_g.func_233643_dh_()) { } else if (p_147108_1_ == null && this.field_71439_g.func_233643_dh_()) {
@@ -805,6 +806,14 @@ @@ -805,6 +807,14 @@
} }
} }
@ -146,7 +148,7 @@
if (p_147108_1_ instanceof MainMenuScreen || p_147108_1_ instanceof MultiplayerScreen) { if (p_147108_1_ instanceof MainMenuScreen || p_147108_1_ instanceof MultiplayerScreen) {
this.field_71474_y.field_74330_P = false; this.field_71474_y.field_74330_P = false;
this.field_71456_v.func_146158_b().func_146231_a(true); this.field_71456_v.func_146158_b().func_146231_a(true);
@@ -936,11 +945,13 @@ @@ -936,11 +946,13 @@
RenderSystem.enableCull(); RenderSystem.enableCull();
this.field_71424_I.func_76319_b(); this.field_71424_I.func_76319_b();
if (!this.field_71454_w) { if (!this.field_71454_w) {
@ -160,7 +162,7 @@
} }
if (this.field_238174_aV_ != null) { if (this.field_238174_aV_ != null) {
@@ -1039,7 +1050,7 @@ @@ -1039,7 +1051,7 @@
Framebuffer framebuffer = this.func_147110_a(); Framebuffer framebuffer = this.func_147110_a();
framebuffer.func_216491_a(this.field_195558_d.func_198109_k(), this.field_195558_d.func_198091_l(), field_142025_a); framebuffer.func_216491_a(this.field_195558_d.func_198109_k(), this.field_195558_d.func_198091_l(), field_142025_a);
@ -169,7 +171,7 @@
this.field_71417_B.func_198021_g(); this.field_71417_B.func_198021_g();
} }
@@ -1227,11 +1238,21 @@ @@ -1227,11 +1239,21 @@
if (p_147115_1_ && this.field_71476_x != null && this.field_71476_x.func_216346_c() == RayTraceResult.Type.BLOCK) { if (p_147115_1_ && this.field_71476_x != null && this.field_71476_x.func_216346_c() == RayTraceResult.Type.BLOCK) {
BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)this.field_71476_x; BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)this.field_71476_x;
BlockPos blockpos = blockraytraceresult.func_216350_a(); BlockPos blockpos = blockraytraceresult.func_216350_a();
@ -193,7 +195,7 @@
} }
} }
@@ -1250,6 +1271,8 @@ @@ -1250,6 +1272,8 @@
} }
} else if (!this.field_71439_g.func_184838_M()) { } else if (!this.field_71439_g.func_184838_M()) {
@ -202,7 +204,7 @@
switch(this.field_71476_x.func_216346_c()) { switch(this.field_71476_x.func_216346_c()) {
case ENTITY: case ENTITY:
this.field_71442_b.func_78764_a(this.field_71439_g, ((EntityRayTraceResult)this.field_71476_x).func_216348_a()); this.field_71442_b.func_78764_a(this.field_71439_g, ((EntityRayTraceResult)this.field_71476_x).func_216348_a());
@@ -1257,7 +1280,7 @@ @@ -1257,7 +1281,7 @@
case BLOCK: case BLOCK:
BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)this.field_71476_x; BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)this.field_71476_x;
BlockPos blockpos = blockraytraceresult.func_216350_a(); BlockPos blockpos = blockraytraceresult.func_216350_a();
@ -211,7 +213,7 @@
this.field_71442_b.func_180511_b(blockpos, blockraytraceresult.func_216354_b()); this.field_71442_b.func_180511_b(blockpos, blockraytraceresult.func_216354_b());
break; break;
} }
@@ -1267,8 +1290,10 @@ @@ -1267,8 +1291,10 @@
} }
this.field_71439_g.func_184821_cY(); this.field_71439_g.func_184821_cY();
@ -222,7 +224,7 @@
this.field_71439_g.func_184609_a(Hand.MAIN_HAND); this.field_71439_g.func_184609_a(Hand.MAIN_HAND);
} }
} }
@@ -1283,6 +1308,11 @@ @@ -1283,6 +1309,11 @@
} }
for(Hand hand : Hand.values()) { for(Hand hand : Hand.values()) {
@ -234,7 +236,7 @@
ItemStack itemstack = this.field_71439_g.func_184586_b(hand); ItemStack itemstack = this.field_71439_g.func_184586_b(hand);
if (this.field_71476_x != null) { if (this.field_71476_x != null) {
switch(this.field_71476_x.func_216346_c()) { switch(this.field_71476_x.func_216346_c()) {
@@ -1296,6 +1326,7 @@ @@ -1296,6 +1327,7 @@
if (actionresulttype.func_226246_a_()) { if (actionresulttype.func_226246_a_()) {
if (actionresulttype.func_226247_b_()) { if (actionresulttype.func_226247_b_()) {
@ -242,7 +244,7 @@
this.field_71439_g.func_184609_a(hand); this.field_71439_g.func_184609_a(hand);
} }
@@ -1308,6 +1339,7 @@ @@ -1308,6 +1340,7 @@
ActionResultType actionresulttype1 = this.field_71442_b.func_217292_a(this.field_71439_g, this.field_71441_e, hand, blockraytraceresult); ActionResultType actionresulttype1 = this.field_71442_b.func_217292_a(this.field_71439_g, this.field_71441_e, hand, blockraytraceresult);
if (actionresulttype1.func_226246_a_()) { if (actionresulttype1.func_226246_a_()) {
if (actionresulttype1.func_226247_b_()) { if (actionresulttype1.func_226247_b_()) {
@ -250,7 +252,7 @@
this.field_71439_g.func_184609_a(hand); this.field_71439_g.func_184609_a(hand);
if (!itemstack.func_190926_b() && (itemstack.func_190916_E() != i || this.field_71442_b.func_78758_h())) { if (!itemstack.func_190926_b() && (itemstack.func_190916_E() != i || this.field_71442_b.func_78758_h())) {
this.field_71460_t.field_78516_c.func_187460_a(hand); this.field_71460_t.field_78516_c.func_187460_a(hand);
@@ -1323,6 +1355,9 @@ @@ -1323,6 +1356,9 @@
} }
} }
@ -260,7 +262,7 @@
if (!itemstack.func_190926_b()) { if (!itemstack.func_190926_b()) {
ActionResultType actionresulttype2 = this.field_71442_b.func_187101_a(this.field_71439_g, this.field_71441_e, hand); ActionResultType actionresulttype2 = this.field_71442_b.func_187101_a(this.field_71439_g, this.field_71441_e, hand);
if (actionresulttype2.func_226246_a_()) { if (actionresulttype2.func_226246_a_()) {
@@ -1349,6 +1384,8 @@ @@ -1349,6 +1385,8 @@
--this.field_71467_ac; --this.field_71467_ac;
} }
@ -269,7 +271,7 @@
this.field_71424_I.func_76320_a("gui"); this.field_71424_I.func_76320_a("gui");
if (!this.field_71445_n) { if (!this.field_71445_n) {
this.field_71456_v.func_73831_a(); this.field_71456_v.func_73831_a();
@@ -1465,6 +1502,8 @@ @@ -1465,6 +1503,8 @@
this.field_71424_I.func_219895_b("keyboard"); this.field_71424_I.func_219895_b("keyboard");
this.field_195559_v.func_204870_b(); this.field_195559_v.func_204870_b();
this.field_71424_I.func_76319_b(); this.field_71424_I.func_76319_b();
@ -278,7 +280,7 @@
} }
private void func_184117_aA() { private void func_184117_aA() {
@@ -1676,6 +1715,10 @@ @@ -1676,6 +1716,10 @@
this.field_71424_I.func_76320_a("waitForServer"); this.field_71424_I.func_76320_a("waitForServer");
while(!this.field_71437_Z.func_71200_ad()) { while(!this.field_71437_Z.func_71200_ad()) {
@ -289,7 +291,7 @@
worldloadprogressscreen.func_231023_e_(); worldloadprogressscreen.func_231023_e_();
this.func_195542_b(false); this.func_195542_b(false);
@@ -1696,7 +1739,12 @@ @@ -1696,7 +1740,12 @@
networkmanager.func_150719_a(new ClientLoginNetHandler(networkmanager, this, (Screen)null, (p_229998_0_) -> { networkmanager.func_150719_a(new ClientLoginNetHandler(networkmanager, this, (Screen)null, (p_229998_0_) -> {
})); }));
networkmanager.func_179290_a(new CHandshakePacket(socketaddress.toString(), 0, ProtocolType.LOGIN)); networkmanager.func_179290_a(new CHandshakePacket(socketaddress.toString(), 0, ProtocolType.LOGIN));
@ -303,7 +305,7 @@
this.field_71453_ak = networkmanager; this.field_71453_ak = networkmanager;
} else { } else {
this.func_241559_a_(p_238195_6_, p_238195_1_, flag, () -> { this.func_241559_a_(p_238195_6_, p_238195_1_, flag, () -> {
@@ -1770,6 +1818,7 @@ @@ -1770,6 +1819,7 @@
} }
public void func_71403_a(ClientWorld p_71403_1_) { public void func_71403_a(ClientWorld p_71403_1_) {
@ -311,7 +313,7 @@
WorkingScreen workingscreen = new WorkingScreen(); WorkingScreen workingscreen = new WorkingScreen();
workingscreen.func_200210_a(new TranslationTextComponent("connect.joining")); workingscreen.func_200210_a(new TranslationTextComponent("connect.joining"));
this.func_213241_c(workingscreen); this.func_213241_c(workingscreen);
@@ -1801,10 +1850,12 @@ @@ -1801,10 +1851,12 @@
IntegratedServer integratedserver = this.field_71437_Z; IntegratedServer integratedserver = this.field_71437_Z;
this.field_71437_Z = null; this.field_71437_Z = null;
this.field_71460_t.func_190564_k(); this.field_71460_t.func_190564_k();
@ -324,7 +326,7 @@
if (integratedserver != null) { if (integratedserver != null) {
this.field_71424_I.func_76320_a("waitForServer"); this.field_71424_I.func_76320_a("waitForServer");
@@ -1819,6 +1870,7 @@ @@ -1819,6 +1871,7 @@
this.field_71456_v.func_181029_i(); this.field_71456_v.func_181029_i();
this.field_71422_O = null; this.field_71422_O = null;
this.field_71455_al = false; this.field_71455_al = false;
@ -332,7 +334,7 @@
this.field_213274_aO.func_216815_b(); this.field_213274_aO.func_216815_b();
} }
@@ -1849,6 +1901,7 @@ @@ -1849,6 +1902,7 @@
this.field_71452_i.func_78870_a(p_213257_1_); this.field_71452_i.func_78870_a(p_213257_1_);
TileEntityRendererDispatcher.field_147556_a.func_147543_a(p_213257_1_); TileEntityRendererDispatcher.field_147556_a.func_147543_a(p_213257_1_);
this.func_230150_b_(); this.func_230150_b_();
@ -340,7 +342,7 @@
} }
public boolean func_238216_r_() { public boolean func_238216_r_() {
@@ -1894,112 +1947,9 @@ @@ -1894,112 +1948,9 @@
private void func_147112_ai() { private void func_147112_ai() {
if (this.field_71476_x != null && this.field_71476_x.func_216346_c() != RayTraceResult.Type.MISS) { if (this.field_71476_x != null && this.field_71476_x.func_216346_c() != RayTraceResult.Type.MISS) {
@ -456,7 +458,7 @@
} }
} }
@@ -2081,6 +2031,7 @@ @@ -2081,6 +2032,7 @@
return field_71432_P; return field_71432_P;
} }
@ -464,7 +466,7 @@
public CompletableFuture<Void> func_213245_w() { public CompletableFuture<Void> func_213245_w() {
return this.func_213169_a(this::func_213237_g).thenCompose((p_229993_0_) -> { return this.func_213169_a(this::func_213237_g).thenCompose((p_229993_0_) -> {
return p_229993_0_; return p_229993_0_;
@@ -2388,7 +2339,7 @@ @@ -2388,7 +2340,7 @@
supplier = func_228022_c_(supplier); supplier = func_228022_c_(supplier);
} }
@ -473,7 +475,7 @@
} }
private static Supplier<IResourcePack> func_228021_b_(Supplier<IResourcePack> p_228021_0_) { private static Supplier<IResourcePack> func_228021_b_(Supplier<IResourcePack> p_228021_0_) {
@@ -2407,6 +2358,14 @@ @@ -2407,6 +2359,14 @@
this.field_175617_aL.func_229355_a_(p_228020_1_); this.field_175617_aL.func_229355_a_(p_228020_1_);
} }

View file

@ -0,0 +1,10 @@
--- a/net/minecraft/client/gui/screen/CreateWorldScreen.java
+++ b/net/minecraft/client/gui/screen/CreateWorldScreen.java
@@ -384,6 +384,7 @@
if (path != null) {
File file1 = path.toFile();
ResourcePackList<ResourcePackInfo> resourcepacklist = new ResourcePackList<>(ResourcePackInfo::new, new ServerPackFinder(), new FolderPackFinder(file1, IPackNameDecorator.field_232625_a_));
+ net.minecraftforge.fml.packs.ResourcePackLoader.loadResourcePacks(resourcepacklist, net.minecraftforge.fml.server.ServerLifecycleHooks::buildPackFinder);
resourcepacklist.func_198983_a();
resourcepacklist.func_198985_a(this.field_238933_b_.func_234884_a_());
this.field_230706_i_.func_147108_a(new DataPackScreen(this, resourcepacklist, this::func_241621_a_, file1));

View file

@ -152,15 +152,23 @@
}, this); }, this);
if (this.func_213162_bc()) { if (this.func_213162_bc()) {
this.func_213161_c(completablefuture::isDone); this.func_213161_c(completablefuture::isDone);
@@ -1284,6 +1305,7 @@ @@ -1284,10 +1305,13 @@
} }
public static DatapackCodec func_240772_a_(ResourcePackList<ResourcePackInfo> p_240772_0_, DatapackCodec p_240772_1_, boolean p_240772_2_) { public static DatapackCodec func_240772_a_(ResourcePackList<ResourcePackInfo> p_240772_0_, DatapackCodec p_240772_1_, boolean p_240772_2_) {
+ net.minecraftforge.fml.packs.ResourcePackLoader.loadResourcePacks(p_240772_0_, net.minecraftforge.fml.server.ServerLifecycleHooks::buildPackFinder); + net.minecraftforge.fml.packs.ResourcePackLoader.loadResourcePacks(p_240772_0_, net.minecraftforge.fml.server.ServerLifecycleHooks::buildPackFinder);
p_240772_0_.func_198983_a(); p_240772_0_.func_198983_a();
+ DatapackCodec.field_234880_a_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks());
+ p_240772_1_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks());
if (p_240772_2_) { if (p_240772_2_) {
p_240772_0_.func_198985_a(Collections.singleton("vanilla")); - p_240772_0_.func_198985_a(Collections.singleton("vanilla"));
@@ -1437,6 +1459,31 @@ - return new DatapackCodec(ImmutableList.of("vanilla"), ImmutableList.of());
+ p_240772_0_.func_198985_a(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla());
+ return new DatapackCodec(net.minecraftforge.common.ForgeHooks.getModPacksWithVanilla(), ImmutableList.of());
} else {
Set<String> set = Sets.newLinkedHashSet();
@@ -1437,6 +1461,31 @@
public abstract boolean func_213199_b(GameProfile p_213199_1_); public abstract boolean func_213199_b(GameProfile p_213199_1_);
@ -192,7 +200,7 @@
public void func_223711_a(Path p_223711_1_) throws IOException { public void func_223711_a(Path p_223711_1_) throws IOException {
Path path = p_223711_1_.resolve("levels"); Path path = p_223711_1_.resolve("levels");
@@ -1564,4 +1611,8 @@ @@ -1564,4 +1613,8 @@
public IServerConfiguration func_240793_aU_() { public IServerConfiguration func_240793_aU_() {
return this.field_240768_i_; return this.field_240768_i_;
} }

View file

@ -0,0 +1,20 @@
--- a/net/minecraft/util/datafix/codec/DatapackCodec.java
+++ b/net/minecraft/util/datafix/codec/DatapackCodec.java
@@ -18,7 +18,7 @@
private final List<String> field_234883_d_;
public DatapackCodec(List<String> p_i231607_1_, List<String> p_i231607_2_) {
- this.field_234882_c_ = ImmutableList.copyOf(p_i231607_1_);
+ this.field_234882_c_ = com.google.common.collect.Lists.newArrayList(p_i231607_1_);
this.field_234883_d_ = ImmutableList.copyOf(p_i231607_2_);
}
@@ -29,4 +29,8 @@
public List<String> func_234887_b_() {
return this.field_234883_d_;
}
+
+ public void addModPacks(List<String> modPacks) {
+ field_234882_c_.addAll(modPacks.stream().filter(p->!field_234882_c_.contains(p)).collect(java.util.stream.Collectors.toList()));
+ }
}

View file

@ -139,6 +139,7 @@ import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.NoteBlockEvent; import net.minecraftforge.event.world.NoteBlockEvent;
import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fml.packs.ResourcePackLoader;
import net.minecraftforge.registries.DataSerializerEntry; import net.minecraftforge.registries.DataSerializerEntry;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.ForgeRegistry;
@ -1231,4 +1232,19 @@ public class ForgeHooks
locations.stream().map(ResourceLocation::toString).forEach(array::add); locations.stream().map(ResourceLocation::toString).forEach(array::add);
} }
} }
public static List<String> getModPacks()
{
List<String> modpacks = ResourcePackLoader.getPackNames();
if(modpacks.isEmpty())
throw new IllegalStateException("Attempted to retrieve mod packs before they were loaded in!");
return modpacks;
}
public static List<String> getModPacksWithVanilla()
{
List<String> modpacks = getModPacks();
modpacks.add("vanilla");
return modpacks;
}
} }

View file

@ -34,8 +34,16 @@ import net.minecraftforge.registries.IForgeRegistryEntry;
public class Tags public class Tags
{ {
public static void init ()
{
Blocks.init();
Items.init();
}
public static class Blocks public static class Blocks
{ {
private static void init(){}
public static final ITag.INamedTag<Block> CHESTS = tag("chests"); public static final ITag.INamedTag<Block> CHESTS = tag("chests");
public static final ITag.INamedTag<Block> CHESTS_ENDER = tag("chests/ender"); public static final ITag.INamedTag<Block> CHESTS_ENDER = tag("chests/ender");
public static final ITag.INamedTag<Block> CHESTS_TRAPPED = tag("chests/trapped"); public static final ITag.INamedTag<Block> CHESTS_TRAPPED = tag("chests/trapped");
@ -132,6 +140,8 @@ public class Tags
public static class Items public static class Items
{ {
private static void init(){}
public static final ITag.INamedTag<Item> ARROWS = tag("arrows"); public static final ITag.INamedTag<Item> ARROWS = tag("arrows");
public static final ITag.INamedTag<Item> BONES = tag("bones"); public static final ITag.INamedTag<Item> BONES = tag("bones");
public static final ITag.INamedTag<Item> BOOKSHELVES = tag("bookshelves"); public static final ITag.INamedTag<Item> BOOKSHELVES = tag("bookshelves");

View file

@ -61,6 +61,11 @@ public class ResourcePackLoader
resourcePacks.addPackFinder(new LambdaFriendlyPackFinder(packFinder.apply(modResourcePacks, ModFileResourcePack::setPackInfo))); resourcePacks.addPackFinder(new LambdaFriendlyPackFinder(packFinder.apply(modResourcePacks, ModFileResourcePack::setPackInfo)));
} }
public static List<String> getPackNames()
{
return modResourcePacks.values().stream().map(pack -> pack.getPackInfo().getName()).collect(Collectors.toList());
}
public static <V> Comparator<Map.Entry<String,V>> getSorter() { public static <V> Comparator<Map.Entry<String,V>> getSorter() {
List<String> order = new ArrayList<>(); List<String> order = new ArrayList<>();
order.add("vanilla"); order.add("vanilla");

View file

@ -52,6 +52,7 @@ import net.minecraft.world.gen.foliageplacer.FoliagePlacerType;
import net.minecraft.world.gen.placement.Placement; import net.minecraft.world.gen.placement.Placement;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.gen.treedecorator.TreeDecoratorType; import net.minecraft.world.gen.treedecorator.TreeDecoratorType;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
@ -114,5 +115,6 @@ public class ForgeRegistries
{ {
GameData.init(); GameData.init();
Bootstrap.register(); Bootstrap.register();
Tags.init();
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"pack": { "pack": {
"pack_format": 4, "pack_format": 5,
"description": "Forge resource pack" "description": "Forge resource pack"
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"pack": { "pack": {
"pack_format": 4, "pack_format": 5,
"description": "Forge tests resource pack" "description": "Forge tests resource pack"
} }
} }