Skip to content

Commit

Permalink
refactor: invoke Minecraft.getInstance() directly
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Jan 26, 2023
1 parent 1576dfe commit 1b48b56
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
@OnlyIn(Dist.CLIENT)
public class KeyboardUtils {

private static final Minecraft MC = Minecraft.getInstance();

public static boolean isKeyDown(int key) {
return InputConstants.isKeyDown(MC.getWindow().getWindow(), key);
return InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), key);
}

public static boolean isShiftKeyDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
@OnlyIn(Dist.CLIENT)
public class LanguageUtils {

private static final Minecraft MC = Minecraft.getInstance();

public static final LanguageInfo DEFAULT_LANGUAGE_INFO = new LanguageInfo("en_us", "US", "English", false);

public static final String[] VANILLA_LANGUAGES = new String[] {
Expand All @@ -33,15 +31,15 @@ public class LanguageUtils {


public static SortedSet<LanguageInfo> getInfo() {
return MC.getLanguageManager().getLanguages();
return Minecraft.getInstance().getLanguageManager().getLanguages();
}

public static Optional<LanguageInfo> getInfo(String code) {
return Optional.ofNullable(MC.getLanguageManager().getLanguage(code));
return Optional.ofNullable(Minecraft.getInstance().getLanguageManager().getLanguage(code));
}

public static LanguageInfo getCurrentInfo() {
return MC.getLanguageManager().getSelected();
return Minecraft.getInstance().getLanguageManager().getSelected();
}

public static String[] getInfoCodes() {
Expand All @@ -50,7 +48,7 @@ public static String[] getInfoCodes() {


public static ClientLanguage get(LanguageInfo langInfo) {
return ClientLanguage.loadFrom(MC.getResourceManager(), List.of(langInfo));
return ClientLanguage.loadFrom(Minecraft.getInstance().getResourceManager(), List.of(langInfo));
}

public static ClientLanguage get(String langCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
@OnlyIn(Dist.CLIENT)
public class ResourceUtils {

private static final Minecraft MC = Minecraft.getInstance();

public static ResourceLocation modelIdOrElse(String modelId, ResourceLocation other) {
try {
return modelId.contains("#") ? new ModelResourceLocation(modelId) : new ResourceLocation(modelId);
Expand All @@ -26,6 +24,8 @@ public static ResourceLocation modelId(String modelId) {
return modelIdOrElse(modelId, ModelBakery.MISSING_MODEL_LOCATION);
}

// ====================================================================== //

public static boolean isValidModelId(String modelId) {
try {
if (modelId.contains("#")) {
Expand All @@ -39,13 +39,14 @@ public static boolean isValidModelId(String modelId) {
}
}

// ====================================================================== //

public static BakedModel getBakedModel(String modelId) {
return MC.getModelManager().getModel(modelId(modelId));
return Minecraft.getInstance().getModelManager().getModel(modelId(modelId));
}

public static BakedModel getBakedModel(ResourceLocation modelId) {
return MC.getModelManager().getModel(modelId);
return Minecraft.getInstance().getModelManager().getModel(modelId);
}


}

0 comments on commit 1b48b56

Please sign in to comment.