Skip to content

Commit 41ca9fc

Browse files
committed
Merge remote-tracking branch 'origin/1.18' into 1.19.2
2 parents c3eb136 + 1a25984 commit 41ca9fc

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

fabric/src/main/java/org/embeddedt/modernfix/fabric/mixin/perf/dynamic_resources/ModelBakeryMixin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ private boolean trustedResourcePack(PackResources pack) {
233233
pack instanceof FilePackResources;
234234
}
235235

236+
/**
237+
* Make a copy of the top-level model list and stream that to avoid CMEs if the getMaterials call triggers a model
238+
* load.
239+
*/
240+
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/Collection;stream()Ljava/util/stream/Stream;", ordinal = 0))
241+
private Stream<?> getModelStream(Collection<?> modelCollection) {
242+
return new ArrayList<>(modelCollection).stream();
243+
}
244+
236245
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/stream/Stream;collect(Ljava/util/stream/Collector;)Ljava/lang/Object;", ordinal = 0))
237246
private Object collectExtraTextures(Stream<Material> instance, Collector<?, ?, ?> arCollector) {
238247
Set<Material> materialsSet = new ObjectOpenHashSet<>(instance.collect(Collectors.toSet()));

forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/dynamic_resources/ModelBakeryMixin.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import java.util.concurrent.TimeUnit;
5959
import java.util.function.BiConsumer;
6060
import java.util.function.Function;
61+
import java.util.stream.Stream;
6162

6263
/* high priority so that our injectors are added before other mods' */
6364
@Mixin(value = ModelBakery.class, priority = 600)
@@ -169,6 +170,15 @@ private void addTopLevelFile(ModelResourceLocation location, CallbackInfo ci) {
169170
}
170171
}
171172

173+
/**
174+
* Make a copy of the top-level model list and stream that to avoid CMEs if the getMaterials call triggers a model
175+
* load.
176+
*/
177+
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/Collection;stream()Ljava/util/stream/Stream;", ordinal = 0))
178+
private Stream<?> getModelStream(Collection<?> modelCollection) {
179+
return new ArrayList<>(modelCollection).stream();
180+
}
181+
172182
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;gatherFluidTextures(Ljava/util/Set;)V", remap = false), remap = false)
173183
private void gatherModelTextures(Set<Material> materialSet) {
174184
ForgeHooksClient.gatherFluidTextures(materialSet);

0 commit comments

Comments
 (0)