-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from flowerinsnowdh/24w45a
feat: 24w45a supported
- Loading branch information
Showing
45 changed files
with
707 additions
and
1,057 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Done to increase the memory available to gradle. | ||
org.gradle.jvmargs=-Xmx1G -Dfile.encoding=UTF-8 | ||
org.gradle.parallel=true | ||
|
||
# Fabric Properties | ||
# check these on https://fabricmc.net/develop | ||
minecraft_version=24w45a | ||
yarn_mappings=24w45a+build.1 | ||
loader_version=0.16.9 | ||
|
||
# Mod Properties | ||
mod_version=16.1.0+fabric | ||
maven_group=cn.flowerinsnow.greatscrollabletooltips | ||
archives_base_name=great-scrollable-tooltips | ||
|
||
# Dependencies | ||
loom_version=1.8.12 | ||
fabric_version=0.107.2+1.21.4 | ||
modmenu_version=12.0.0-beta.1 | ||
night_config_version=3.8.1 | ||
common_module_version=1.1.0 |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../gradle/wrapper/gradle-wrapper.properties → .../gradle/wrapper/gradle-wrapper.properties
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
0
24w33a-fabric/gradlew → 24w33a-24w45a/gradlew
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
93 changes: 93 additions & 0 deletions
93
...24w45a/src/main/java/cn/flowerinsnow/greatscrollabletooltips/GreatScrollableTooltips.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,93 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips; | ||
|
||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.crash.CrashReport; | ||
import cn.flowerinsnow.greatscrollabletooltips.common.config.GreatScrollableTooltipsConfig; | ||
import cn.flowerinsnow.greatscrollabletooltips.common.object.ScrollSession; | ||
import cn.flowerinsnow.greatscrollabletooltips.common.provider.ModEnvironmentProvider; | ||
import cn.flowerinsnow.greatscrollabletooltips.event.PreScreenKeyPressedEvent; | ||
import cn.flowerinsnow.greatscrollabletooltips.event.PreScreenMouseScrollEvent; | ||
import cn.flowerinsnow.greatscrollabletooltips.event.RenderTooltipEvent; | ||
import cn.flowerinsnow.greatscrollabletooltips.event.ScreenCloseEvent; | ||
import cn.flowerinsnow.greatscrollabletooltips.listener.EventTriggerListener; | ||
import cn.flowerinsnow.greatscrollabletooltips.listener.KeyScrollListener; | ||
import cn.flowerinsnow.greatscrollabletooltips.listener.MouseScrollListener; | ||
import cn.flowerinsnow.greatscrollabletooltips.listener.ScrollingStatusListener; | ||
import cn.flowerinsnow.greatscrollabletooltips.manager.KeyBindingManager; | ||
|
||
import java.io.InputStream; | ||
import java.nio.file.Path; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public class GreatScrollableTooltips implements ClientModInitializer { | ||
public static final String MODID = "great-scrollable-tooltips"; | ||
|
||
private static GreatScrollableTooltips instance; | ||
|
||
private GreatScrollableTooltipsConfig config; | ||
|
||
private ScrollSession<ItemStack> scrollSession; | ||
|
||
@Override | ||
public void onInitializeClient() { | ||
GreatScrollableTooltips.instance = this; | ||
this.scrollSession = new ScrollSession<>(); | ||
|
||
this.initConfig(); | ||
this.initListeners(); | ||
this.initKeyBindings(); | ||
} | ||
|
||
private void initConfig() { | ||
this.config = new GreatScrollableTooltipsConfig(new ModEnvironmentProvider() { | ||
@Override | ||
public InputStream getDefaultConfigAsStream() { | ||
return GreatScrollableTooltips.class.getResourceAsStream("/config.toml"); | ||
} | ||
|
||
@Override | ||
public Path getConfigFile() { | ||
return FabricLoader.getInstance().getConfigDir().resolve(GreatScrollableTooltips.MODID + ".toml"); | ||
} | ||
|
||
@Override | ||
public void crash(Throwable throwable, String msg) { | ||
MinecraftClient.getInstance().printCrashReport(CrashReport.create(throwable, msg)); | ||
} | ||
}); | ||
this.config.saveDefaultConfig(); | ||
this.config.load(); | ||
} | ||
|
||
private void initListeners() { | ||
ClientTickEvents.END_CLIENT_TICK.register(new EventTriggerListener()); | ||
PreScreenKeyPressedEvent.EVENT.register(new KeyScrollListener(this)); | ||
PreScreenMouseScrollEvent.EVENT.register(new MouseScrollListener(this)); | ||
ScrollingStatusListener scrollingStatusListener = new ScrollingStatusListener(this); | ||
RenderTooltipEvent.Pre.EVENT.register(scrollingStatusListener); | ||
RenderTooltipEvent.Miss.EVENT.register(scrollingStatusListener); | ||
ScreenCloseEvent.EVENT.register(scrollingStatusListener); | ||
} | ||
|
||
private void initKeyBindings() { | ||
KeyBindingManager.registerAll(); | ||
} | ||
|
||
public static GreatScrollableTooltips getInstance() { | ||
return GreatScrollableTooltips.instance; | ||
} | ||
|
||
public GreatScrollableTooltipsConfig getConfig() { | ||
return this.config; | ||
} | ||
|
||
public ScrollSession<ItemStack> getScrollSession() { | ||
return this.scrollSession; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...src/main/java/cn/flowerinsnow/greatscrollabletooltips/event/PreScreenKeyPressedEvent.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,23 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips.event; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||
import net.minecraft.util.ActionResult; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public interface PreScreenKeyPressedEvent { | ||
Event<PreScreenKeyPressedEvent> EVENT = EventFactory.createArrayBacked(PreScreenKeyPressedEvent.class, listeners -> (screen, keyCode, scanCode, modifiers) -> { | ||
for (PreScreenKeyPressedEvent listener : listeners) { | ||
ActionResult actionResult = listener.preScreenKeyPressed(screen, keyCode, scanCode, modifiers); | ||
if (actionResult != ActionResult.PASS) { | ||
return actionResult; | ||
} | ||
} | ||
return ActionResult.PASS; | ||
}); | ||
|
||
ActionResult preScreenKeyPressed(HandledScreen<?> screen, int keyCode, int scanCode, int modifiers); | ||
} |
23 changes: 23 additions & 0 deletions
23
...rc/main/java/cn/flowerinsnow/greatscrollabletooltips/event/PreScreenMouseScrollEvent.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,23 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips.event; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||
import net.minecraft.util.ActionResult; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public interface PreScreenMouseScrollEvent { | ||
Event<PreScreenMouseScrollEvent> EVENT = EventFactory.createArrayBacked(PreScreenMouseScrollEvent.class, listeners -> (screen, mouseX, mouseY, horizontalAmount, verticalAmount) -> { | ||
for (PreScreenMouseScrollEvent listener : listeners) { | ||
ActionResult actionResult = listener.preScreenMouseScrolled(screen, mouseX, mouseY, horizontalAmount, verticalAmount); | ||
if (actionResult != ActionResult.PASS) { | ||
return actionResult; | ||
} | ||
} | ||
return ActionResult.PASS; | ||
}); | ||
|
||
ActionResult preScreenMouseScrolled(HandledScreen<?> screen, double mouseX, double mouseY, double horizontalAmount, double verticalAmount); | ||
} |
41 changes: 41 additions & 0 deletions
41
...4w45a/src/main/java/cn/flowerinsnow/greatscrollabletooltips/event/RenderTooltipEvent.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,41 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips.event; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||
import net.minecraft.screen.slot.Slot; | ||
import net.minecraft.util.ActionResult; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public interface RenderTooltipEvent { | ||
interface Pre { | ||
Event<Pre> EVENT = EventFactory.createArrayBacked(Pre.class, listeners -> (screen, context, x, y, focusedSlot) -> { | ||
for (Pre listener : listeners) { | ||
ActionResult actionResult = listener.preRenderTooltip(screen, context, x, y, focusedSlot); | ||
if (actionResult != ActionResult.PASS) { | ||
return actionResult; | ||
} | ||
} | ||
return ActionResult.PASS; | ||
}); | ||
|
||
ActionResult preRenderTooltip(HandledScreen<?> screen, DrawContext context, int x, int y, Slot focusedSlot); | ||
} | ||
|
||
interface Miss { | ||
Event<Miss> EVENT = EventFactory.createArrayBacked(Miss.class, listeners -> screen -> { | ||
for (Miss listener : listeners) { | ||
ActionResult actionResult = listener.missRenderTooltip(screen); | ||
if (actionResult != ActionResult.PASS) { | ||
return actionResult; | ||
} | ||
} | ||
return ActionResult.PASS; | ||
}); | ||
|
||
ActionResult missRenderTooltip(HandledScreen<?> screen); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...-24w45a/src/main/java/cn/flowerinsnow/greatscrollabletooltips/event/ScreenCloseEvent.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,23 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips.event; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.util.ActionResult; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public interface ScreenCloseEvent { | ||
Event<ScreenCloseEvent> EVENT = EventFactory.createArrayBacked(ScreenCloseEvent.class, listeners -> (screen) -> { | ||
for (ScreenCloseEvent event : listeners) { | ||
ActionResult actionResult = event.onScreenClose(screen); | ||
if (actionResult != ActionResult.PASS) { | ||
return actionResult; | ||
} | ||
} | ||
return ActionResult.PASS; | ||
}); | ||
|
||
ActionResult onScreenClose(Screen oldScreen); | ||
} |
21 changes: 21 additions & 0 deletions
21
.../src/main/java/cn/flowerinsnow/greatscrollabletooltips/listener/EventTriggerListener.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,21 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips.listener; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import cn.flowerinsnow.greatscrollabletooltips.event.ScreenCloseEvent; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public class EventTriggerListener implements ClientTickEvents.EndTick { | ||
private Screen oldScreen; | ||
|
||
@Override | ||
public void onEndTick(MinecraftClient client) { | ||
if (this.oldScreen != client.currentScreen) { | ||
ScreenCloseEvent.EVENT.invoker().onScreenClose(this.oldScreen); | ||
this.oldScreen = client.currentScreen; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...45a/src/main/java/cn/flowerinsnow/greatscrollabletooltips/listener/KeyScrollListener.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,34 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips.listener; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ActionResult; | ||
import cn.flowerinsnow.greatscrollabletooltips.GreatScrollableTooltips; | ||
import cn.flowerinsnow.greatscrollabletooltips.common.object.ScrollSession; | ||
import cn.flowerinsnow.greatscrollabletooltips.event.PreScreenKeyPressedEvent; | ||
import cn.flowerinsnow.greatscrollabletooltips.manager.KeyBindingManager; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public record KeyScrollListener(GreatScrollableTooltips main) implements PreScreenKeyPressedEvent { | ||
@Override | ||
public ActionResult preScreenKeyPressed(HandledScreen<?> screen, int keyCode, int scanCode, int modifiers) { | ||
ScrollSession<ItemStack> session = this.main.getScrollSession(); | ||
if (session.isRendering()) { | ||
if (KeyBindingManager.KEY_BINDING_SCROLL_UP.get().matchesKey(keyCode, scanCode)) { | ||
session.addVertical(1); | ||
} | ||
if (KeyBindingManager.KEY_BINDING_SCROLL_LEFT.get().matchesKey(keyCode, scanCode)) { | ||
session.addHorizontal(1); | ||
} | ||
if (KeyBindingManager.KEY_BINDING_SCROLL_DOWN.get().matchesKey(keyCode, scanCode)) { | ||
session.addVertical(-1); | ||
} | ||
if (KeyBindingManager.KEY_BINDING_SCROLL_RIGHT.get().matchesKey(keyCode, scanCode)) { | ||
session.addHorizontal(-1); | ||
} | ||
} | ||
return ActionResult.PASS; | ||
} | ||
} |
Oops, something went wrong.