Skip to content

Commit

Permalink
Merge pull request #86 from flowerinsnowdh/24w45a
Browse files Browse the repository at this point in the history
feat: 24w45a supported
  • Loading branch information
flowerinsnowdh authored Nov 7, 2024
2 parents 969fb29 + 3e740aa commit 75a2a16
Show file tree
Hide file tree
Showing 45 changed files with 707 additions and 1,057 deletions.
49 changes: 28 additions & 21 deletions 24w33a-fabric/build.gradle → 24w33a-24w45a/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins() {
id('fabric-loom').version("${fabric_loom_version}")
id('maven-publish')
id('fabric-loom').version("${loom_version}")
id('maven-publish')
}

version = project.mod_version
Expand All @@ -11,14 +11,20 @@ base() {
}

repositories() {
mavenCentral()
maven() {
url = 'https://www.cursemaven.com/'
}

maven() {
url = 'https://maven.terraformersmc.com/releases/'
url = 'https://maven.pkg.github.com/flowerinsnowdh/GreatScrollableTooltips'
credentials() {
username = "${System.getenv('GITHUB_USERNAME')}"
password = "${System.getenv('GITHUB_TOKEN')}"
}
}

maven() {
url = 'https://repo.flowerinsnow.online/repository/maven-opensources/'
url = 'https://maven.terraformersmc.com/releases/'
}
}

Expand All @@ -36,14 +42,15 @@ dependencies() {

// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"

include(api("online.flowerinsnow.fnml4j:interface:${fnml4j_version}"))
include(api("online.flowerinsnow.fnml4j:core:${fnml4j_version}"))
modImplementation("com.terraformersmc:modmenu:${modmenu_version}")
modImplementation('curse.maven:legendary-tooltips-fabric-542478:5591020')
include(api("cn.flowerinsnow.greatscrollabletooltips:common:${common_module_version}"))
include(api("com.electronwill.night-config:core:${night_config_version}"))
include(api("com.electronwill.night-config:toml:${night_config_version}"))
}

processResources() {
LinkedHashMap<String, ?> props = [
'version' : project.version
]
LinkedHashMap<String, ?> props = ['version' : project.version]
props.forEach(inputs::property)

filesMatching('fabric.mod.json') {
Expand All @@ -56,28 +63,28 @@ tasks.withType(JavaCompile).configureEach() {
}

java() {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar() {
from(file('../LICENSE'))
from(file('../NOTICE'))
}

// configure the maven publication
publishing() {
publications() {
mavenJava(MavenPublication) {
artifactId = project.archives_base_name
from(components.java)
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories() {
maven() {
url = "${System.getenv('PUBLISH_REPO_URL')}"
credentials() {
username = "${System.getenv('PUBLISH_REPO_USERNAME')}"
password = "${System.getenv('PUBLISH_REPO_PASSWORD')}"
}
}
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}
21 changes: 21 additions & 0 deletions 24w33a-24w45a/gradle.properties
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
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;
}
}
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);
}
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);
}
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);
}
}
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);
}
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;
}
}
}
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;
}
}
Loading

0 comments on commit 75a2a16

Please sign in to comment.