Make a copy of the top-level model list when collecting materials
This should prevent CMEs if material collection triggers a model load
This commit is contained in:
parent
e04b05dcc8
commit
c1277a2bf5
|
|
@ -230,6 +230,15 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
pack instanceof FilePackResources;
|
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))
|
@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) {
|
private Object collectExtraTextures(Stream<Material> instance, Collector<?, ?, ?> arCollector) {
|
||||||
Set<Material> materialsSet = new ObjectOpenHashSet<>(instance.collect(Collectors.toSet()));
|
Set<Material> materialsSet = new ObjectOpenHashSet<>(instance.collect(Collectors.toSet()));
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/* high priority so that our injectors are added before other mods' */
|
/* high priority so that our injectors are added before other mods' */
|
||||||
@Mixin(value = ModelBakery.class, priority = 600)
|
@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))
|
||||||
|
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))
|
@Redirect(method = "processLoading", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;gatherFluidTextures(Ljava/util/Set;)V", remap = false))
|
||||||
private void gatherModelTextures(Set<Material> materialSet) {
|
private void gatherModelTextures(Set<Material> materialSet) {
|
||||||
ForgeHooksClient.gatherFluidTextures(materialSet);
|
ForgeHooksClient.gatherFluidTextures(materialSet);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user