Skip to content

Commit

Permalink
fix forge crash
Browse files Browse the repository at this point in the history
  • Loading branch information
MORIMORI0317 committed Jun 9, 2022
1 parent ddbea81 commit 2b15764
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;

public class BetterTaskbar {
public static final String MODID = "bettertaskbar";
private static final Logger LOGGER = LogManager.getLogger(BetterTaskbar.class);
Expand All @@ -31,7 +29,7 @@ private static ITaskbarAccess createTaskbarAccess() {
String os = System.getProperty("os.name").toLowerCase();
String arc = System.getProperty("os.arch").toLowerCase();

if (os.contains("windows") && arc.contains("amd64"))
if (os.contains("windows") && arc.contains("amd64") && WindowsTaskbarAccess.check())
return new WindowsTaskbarAccess();

return new DummyTaskbarAccess();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,20 @@ private void taskbarList3(BiConsumer<ITaskbarList3, WinDef.HWND> consumer) {
throw new RuntimeException("ITaskbarList3 release failed");
}

public static boolean check() {
var clsid = new Guid.CLSID("56FDF344-FD6D-11d0-958A-006097C9A090");
var ref = new PointerByReference();
var hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, WTypes.CLSCTX_SERVER, TaskbarList3.IID_ITaskbarList3, ref);
if (W32Errors.FAILED(hr))
return false;

var tbl3 = new TaskbarList3(ref.getValue());
var hret = tbl3.HrInit();
if (W32Errors.FAILED(hret))
return false;

var rret = tbl3.Release();
return !W32Errors.FAILED(rret);
}

}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ enabled_platforms=fabric,forge

archives_base_name=bettertaskbar
mod_display_name=BetterTaskbar
mod_version=1.3
mod_version=1.4
maven_group=net.morimori0317

fabric_loader_version=0.14.0
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include("forge")

rootProject.name = "BetterTaskbar"

if (JavaVersion.current().ordinal() + 1 < 17) {
throw new IllegalStateException("申し訳ないがJava17+以外はNG")
if (JavaVersion.current().ordinal() + 1 != 17) {
throw new IllegalStateException("申し訳ないがJava17以外はNG")
}

0 comments on commit 2b15764

Please sign in to comment.