-
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.
feat(1.8.9-1.10-forge): 添加自动回正、按键滚动的功能
refactor(1.8.9-1.10-forge): 重构代码
- Loading branch information
1 parent
a9be86d
commit 3befaad
Showing
35 changed files
with
799 additions
and
1,217 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
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,2 @@ | ||
version_night_config=3.6.7 | ||
version_common_module=1.1.0 |
110 changes: 110 additions & 0 deletions
110
...-forge/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,110 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips; | ||
|
||
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.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 net.minecraft.client.Minecraft; | ||
import net.minecraft.crash.CrashReport; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.common.Mod.EventHandler; | ||
import net.minecraftforge.fml.common.event.FMLInitializationEvent; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import net.minecraftforge.fml.common.eventhandler.EventBus; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
import java.io.File; | ||
import java.io.InputStream; | ||
import java.nio.file.Path; | ||
|
||
@Mod( | ||
modid = GreatScrollableTooltips.MODID, | ||
name = GreatScrollableTooltips.NAME, | ||
version = GreatScrollableTooltips.VERSION, | ||
clientSideOnly = true, | ||
guiFactory = "cn.flowerinsnow.greatscrollabletooltips.screen.GreatScrollableTooltipsGuiFactory" | ||
) | ||
@SideOnly(Side.CLIENT) | ||
public class GreatScrollableTooltips { | ||
public static final String MODID = "great-scrollable-tooltips"; | ||
public static final String NAME = "Great Scrollable Tooltips"; | ||
public static final String VERSION = "1.4.0"; | ||
|
||
private static GreatScrollableTooltips instance; | ||
|
||
private GreatScrollableTooltipsConfig config; | ||
|
||
private ScrollSession<ItemStack> scrollSession; | ||
|
||
@EventHandler | ||
public void preInit(FMLPreInitializationEvent event) { | ||
GreatScrollableTooltips.instance = this; | ||
this.scrollSession = new ScrollSession<>(); | ||
this.initConfig(new File(event.getModConfigurationDirectory(), GreatScrollableTooltips.MODID + ".toml").toPath()); | ||
|
||
} | ||
|
||
@EventHandler | ||
public void init(FMLInitializationEvent event) { | ||
this.initListeners(); | ||
this.initKeyBindings(); | ||
} | ||
|
||
private void initConfig(Path configFilePath) { | ||
this.config = new GreatScrollableTooltipsConfig(new ModEnvironmentProvider() { | ||
@Override | ||
public InputStream getDefaultConfigAsStream() { | ||
return GreatScrollableTooltips.class.getResourceAsStream("/config.toml"); | ||
} | ||
|
||
@Override | ||
public Path getConfigFile() { | ||
return configFilePath; | ||
} | ||
|
||
@Override | ||
public void crash(Throwable throwable, String msg) { | ||
Minecraft.getMinecraft().crashed(CrashReport.makeCrashReport(throwable, msg)); | ||
} | ||
}); | ||
this.config.saveDefaultConfig(); | ||
this.config.load(); | ||
} | ||
|
||
private void initListeners() { | ||
EventBus eventBus = MinecraftForge.EVENT_BUS; | ||
eventBus.register(new EventTriggerListener()); | ||
|
||
// 鼠标滚动时 | ||
eventBus.register(new MouseScrollListener(this)); | ||
|
||
// 渲染物品提示时 | ||
eventBus.register(new ScrollingStatusListener(this)); | ||
|
||
// 按键滚动时 | ||
eventBus.register(new KeyScrollListener(this)); | ||
} | ||
|
||
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; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...forge/src/main/java/cn/flowerinsnow/greatscrollabletooltips/event/ClientTickEndEvent.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,6 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips.event; | ||
|
||
import net.minecraftforge.fml.common.eventhandler.Event; | ||
|
||
public class ClientTickEndEvent extends Event { | ||
} |
59 changes: 59 additions & 0 deletions
59
...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,59 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips.event; | ||
|
||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraftforge.fml.common.eventhandler.Event; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
import java.util.Objects; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class PreScreenKeyPressedEvent extends Event { | ||
private final GuiScreen screen; | ||
private final char typedChar; | ||
private final int keyCode; | ||
|
||
public PreScreenKeyPressedEvent(GuiScreen screen, char typedChar, int keyCode) { | ||
this.screen = screen; | ||
this.typedChar = typedChar; | ||
this.keyCode = keyCode; | ||
} | ||
|
||
public GuiScreen getScreen() { | ||
return this.screen; | ||
} | ||
|
||
public char getTypedChar() { | ||
return this.typedChar; | ||
} | ||
|
||
public int getKeyCode() { | ||
return this.keyCode; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object object) { | ||
if (this == object) return true; | ||
if (object == null || getClass() != object.getClass()) return false; | ||
PreScreenKeyPressedEvent that = (PreScreenKeyPressedEvent) object; | ||
return this.typedChar == that.typedChar && this.keyCode == that.keyCode && Objects.equals(this.screen, that.screen); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = 17; | ||
result = 31 * result + (this.screen != null ? this.screen.hashCode() : 0); | ||
result = 31 * result + this.typedChar; | ||
result = 31 * result + this.keyCode; | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PreScreenKeyPressedEvent{" + | ||
"screen=" + this.screen + | ||
", typedChar=" + this.typedChar + | ||
", keyCode=" + this.keyCode + | ||
'}'; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...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,51 @@ | ||
package cn.flowerinsnow.greatscrollabletooltips.event; | ||
|
||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraftforge.fml.common.eventhandler.Event; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
import java.util.Objects; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class PreScreenMouseScrollEvent extends Event { | ||
private final GuiScreen screen; | ||
private final int amount; | ||
|
||
public PreScreenMouseScrollEvent(GuiScreen screen, int amount) { | ||
this.screen = screen; | ||
this.amount = amount; | ||
} | ||
|
||
public GuiScreen getScreen() { | ||
return this.screen; | ||
} | ||
|
||
public int getAmount() { | ||
return this.amount; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
PreScreenMouseScrollEvent that = (PreScreenMouseScrollEvent) o; | ||
return this.amount == that.amount && Objects.equals(this.screen, that.screen); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = 17; | ||
result = 31 * result + (this.screen != null ? this.screen.hashCode() : 0); | ||
result = 31 * result + this.amount; | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PreScreenMouseScrollEvent{" + | ||
"screen=" + this.screen + | ||
", amount=" + this.amount + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.