-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop searching the same file multiple times for languages. (#495)
- Loading branch information
1 parent
cb36f8b
commit 10375fe
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinLanguageRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.mitchej123.hodgepodge.mixins.early.minecraft; | ||
|
||
import java.util.Set; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import cpw.mods.fml.common.ModContainer; | ||
import cpw.mods.fml.common.registry.LanguageRegistry; | ||
import cpw.mods.fml.relauncher.Side; | ||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; | ||
|
||
@Mixin(value = LanguageRegistry.class, remap = false) | ||
public class MixinLanguageRegistry { | ||
|
||
private Set<String> examinedFiles = new ObjectOpenHashSet<>(); | ||
|
||
@Inject(method = "loadLanguagesFor", at = @At("HEAD"), cancellable = true) | ||
private void hodgepodge$onlyAddLanguagesOnce(ModContainer container, Side side, CallbackInfo ci) { | ||
if (!examinedFiles.add(container.getSource().getName())) { | ||
ci.cancel(); | ||
} | ||
} | ||
} |