Merge 1.20.4 into 1.20.5
This commit is contained in:
commit
e6b28de740
|
|
@ -5,18 +5,17 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Sets;
|
||||
import com.google.common.graph.GraphBuilder;
|
||||
import com.google.common.graph.MutableGraph;
|
||||
import net.minecraft.client.renderer.block.BlockModelShaper;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.neoforgespi.language.IModInfo;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.embeddedt.modernfix.dynamicresources.ModelLocationCache;
|
||||
import org.embeddedt.modernfix.util.ForwardingInclDefaultsMap;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
|
@ -41,14 +40,14 @@ public class ModelBakeEventHelper {
|
|||
public ModelBakeEventHelper(Map<ResourceLocation, BakedModel> modelRegistry) {
|
||||
this.modelRegistry = modelRegistry;
|
||||
this.topLevelModelLocations = new HashSet<>(modelRegistry.keySet());
|
||||
for(Block block : BuiltInRegistries.BLOCK) {
|
||||
for(BlockState state : block.getStateDefinition().getPossibleStates()) {
|
||||
topLevelModelLocations.add(ModelLocationCache.get(state));
|
||||
// Skip going through ModelLocationCache because most of the accesses will be misses
|
||||
BuiltInRegistries.BLOCK.entrySet().forEach(entry -> {
|
||||
var location = entry.getKey().location();
|
||||
for(BlockState state : entry.getValue().getStateDefinition().getPossibleStates()) {
|
||||
topLevelModelLocations.add(BlockModelShaper.stateToModelLocation(location, state));
|
||||
}
|
||||
}
|
||||
for(Item item : BuiltInRegistries.ITEM) {
|
||||
topLevelModelLocations.add(ModelLocationCache.get(item));
|
||||
}
|
||||
});
|
||||
BuiltInRegistries.ITEM.keySet().forEach(location -> topLevelModelLocations.add(new ModelResourceLocation(location, "inventory")));
|
||||
this.dependencyGraph = GraphBuilder.undirected().build();
|
||||
ModList.get().forEachModContainer((id, mc) -> {
|
||||
this.dependencyGraph.addNode(id);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.embeddedt.modernfix.neoforge.mixin.feature.registry_event_progress;
|
||||
|
||||
import net.neoforged.bus.api.Event;
|
||||
import net.neoforged.bus.api.EventPriority;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.ModLoader;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
|
|
@ -36,17 +37,25 @@ public class GameDataMixin {
|
|||
@Redirect(method = "postRegisterEvents", at = @At(value = "INVOKE", target = "Lnet/neoforged/fml/ModLoader;postEventWrapContainerInModOrder(Lnet/neoforged/bus/api/Event;)V"))
|
||||
private static <T extends Event & IModBusEvent> void swapThreadAndPost(ModLoader loader, T event) {
|
||||
RegisterEvent registryEvent = (RegisterEvent)event;
|
||||
var pb = StartupMessageManager.addProgressBar(registryEvent.getRegistryKey().location().toString(), ModList.get().size());
|
||||
try {
|
||||
loader.postEventWithWrapInModOrder(event, (mc, e) -> {
|
||||
ModLoadingContext.get().setActiveContainer(mc);
|
||||
pb.label(pb.name() + " - " + mc.getModInfo().getDisplayName());
|
||||
pb.increment();
|
||||
}, (mc, e) -> {
|
||||
ModLoadingContext.get().setActiveContainer(null);
|
||||
});
|
||||
} finally {
|
||||
pb.complete();
|
||||
// We control phases ourselves so we can make a separate progress bar for each phase.
|
||||
String registryName = registryEvent.getRegistryKey().location().toString();
|
||||
for(EventPriority phase : EventPriority.values()) {
|
||||
var pb = StartupMessageManager.addProgressBar(registryName, ModList.get().size());
|
||||
try {
|
||||
ModList.get().forEachModInOrder(mc -> {
|
||||
ModLoadingContext.get().setActiveContainer(mc);
|
||||
pb.label(pb.name() + " - " + mc.getModInfo().getDisplayName());
|
||||
pb.increment();
|
||||
var bus = mc.getEventBus();
|
||||
if(bus != null) {
|
||||
bus.post(phase, event);
|
||||
}
|
||||
ModLoadingContext.get().setActiveContainer(null);
|
||||
});
|
||||
} finally {
|
||||
pb.complete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user