Merge remote-tracking branch 'origin/1.16' into 1.18

This commit is contained in:
embeddedt 2023-08-05 11:46:24 -04:00
commit 1a25984e88
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 19 additions and 0 deletions

View File

@ -237,6 +237,15 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
pack instanceof FilePackResources;
}
/**
* Make a copy of the top-level model list and stream that to avoid CMEs if the getMaterials call triggers a model
* load.
*/
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/Collection;stream()Ljava/util/stream/Stream;", ordinal = 0))
private Stream<?> getModelStream(Collection<?> modelCollection) {
return new ArrayList<>(modelCollection).stream();
}
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/stream/Stream;collect(Ljava/util/stream/Collector;)Ljava/lang/Object;", ordinal = 0))
private Object collectExtraTextures(Stream<Material> instance, Collector<?, ?, ?> arCollector) {
Set<Material> materialsSet = new ObjectOpenHashSet<>(instance.collect(Collectors.toSet()));

View File

@ -54,6 +54,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.stream.Stream;
/* high priority so that our injectors are added before other mods' */
@Mixin(value = ModelBakery.class, priority = 600)
@ -162,6 +163,15 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
}
}
/**
* Make a copy of the top-level model list and stream that to avoid CMEs if the getMaterials call triggers a model
* load.
*/
@Redirect(method = "processLoading", at = @At(value = "INVOKE", target = "Ljava/util/Collection;stream()Ljava/util/stream/Stream;", ordinal = 0), remap = false)
private Stream<?> getModelStream(Collection<?> modelCollection) {
return new ArrayList<>(modelCollection).stream();
}
@Redirect(method = "processLoading", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;gatherFluidTextures(Ljava/util/Set;)V", remap = false), remap = false)
private void gatherModelTextures(Set<Material> materialSet) {
ForgeHooksClient.gatherFluidTextures(materialSet);