Skip to content

Commit

Permalink
forge 1.16.5
Browse files Browse the repository at this point in the history
  • Loading branch information
paulzzh committed May 14, 2024
1 parent ca68960 commit 689b145
Show file tree
Hide file tree
Showing 23 changed files with 433 additions and 124 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ jobs:
with:
name: 'urlimg Fabric 1.19.4'
path: |
urlimg-fabric/urlimg-fabric-1.19.4/build/libs/**.jar
urlimg-fabric/urlimg-fabric-1.19.4/build/libs/**.jar
# Forge 1.16.5
- name: Upload Artifact (Forge 1.16.5)
uses: actions/upload-artifact@v4
with:
name: 'urlimg Forge 1.16.5'
path: |
urlimg-forge/urlimg-forge-1.16.5/build/libs/**.jar
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
urlimg-fabric/urlimg-fabric-1.20.5/build/libs/**.jar
urlimg-fabric/urlimg-fabric-1.20.2/build/libs/**.jar
urlimg-fabric/urlimg-fabric-1.20/build/libs/**.jar
urlimg-fabric/urlimg-fabric-1.19.4/build/libs/**.jar
urlimg-fabric/urlimg-fabric-1.19.4/build/libs/**.jar
urlimg-forge/urlimg-forge-1.16.5/build/libs/**.jar
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
# 纯客户端的聊天栏图片直接显示Mod

![](./show.png)

## 特色

- 服务端无需任何更改,客户端安装即用
- 基于原版[/tellraw](https://zh.minecraft.wiki/w/%E6%96%87%E6%9C%AC%E7%BB%84%E4%BB%B6%E6%A0%BC%E5%BC%8F#%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6)`clickEvent.open_url` 不自己造轮子
-
基于原版[/tellraw](https://zh.minecraft.wiki/w/%E6%96%87%E6%9C%AC%E7%BB%84%E4%BB%B6%E6%A0%BC%E5%BC%8F#%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6)
`clickEvent.open_url` 不自己造轮子
- 自动显示在聊天栏,无需中断游戏
- 图片缓存

## 用法

- 打开一个命令方块,粘贴以下内容([不会写点我](https://www.mcmod.cn/tools/cbcreator/#/tellraw/))

````
tellraw @a [{"text": "[\u56fe\u7247]", "color": "green", "clickEvent": {"action": "open_url", "value": "https://i.mcmod.cn/class/cover/20210220/1613753764_10167_HvjN.jpg"}},{"text": "[\u56fe\u7247]", "color": "green", "clickEvent": {"action": "open_url", "value": "https://webinput.nie.netease.com/img/mc/logo.png"}}]
````

- 会显示两张图片
- 或者从服务端控制台执行(比如Velocity上可以用[这个插件](https://github.com/OskarsMC-Plugins/broadcast)`/broadcast raw {json}`来广播 一样的)
- 或者从服务端控制台执行(
比如Velocity上可以用[这个插件](https://github.com/OskarsMC-Plugins/broadcast)`/broadcast raw {json}`来广播 一样的)
- 直接从聊天栏输入会有长度限制注意

## 支持版本

| mod版本 | 加载器 | 兼容游戏版本 |
|--------|--------|---------------|
| 1.16.5 | forge | 1.16.5 |
| 1.19.4 | fabric | 1.19.4 |
| 1.20 | fabric | 1.20-1.20.1 |
| 1.20.2 | fabric | 1.20.2-1.20.4 |
| 1.20.5 | fabric | 1.20.5-1.20.6 |

## 感谢

- 项目结构 [RealHeart/ZMusic-Mod](https://github.com/RealHeart/ZMusic-Mod)
- 代码参考 [MakesYT/chatsync](https://github.com/MakesYT/chatsync_mods_fabric)
-
代码参考 [MakesYT/chatsync](https://github.com/MakesYT/chatsync_mods_fabric) [MakesYT/chatsync](https://github.com/MakesYT/chatsync_mods_forge)
- 灵感来源 [Team-Fruit/SignPicture](https://github.com/Team-Fruit/SignPicture)

## 开源协议

本项目使用 [GPL-3.0](LICENSE) 协议开放源代码
120 changes: 67 additions & 53 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,72 +1,86 @@
plugins {
id("fabric-loom") version "1.6-SNAPSHOT" apply false
id("fabric-loom") version "1.6-SNAPSHOT" apply false
}

def gitCommitHash = {
def cmd = "git rev-parse --short HEAD"
try {
def ver = cmd.execute().text.trim()
if (ver == "") return ""
return "+" + ver
} catch (Exception e) {
e.printStackTrace()
return ""
}
def cmd = "git rev-parse --short HEAD"
try {
def ver = cmd.execute().text.trim()
if (ver == "") return ""
return "+" + ver
} catch (Exception e) {
e.printStackTrace()
return ""
}
}

allprojects {
repositories {
mavenCentral()
maven {
name = 'Jitpack'
url = 'https://jitpack.io'
}
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/releases/"
}
}
repositories {
mavenCentral()
maven {
name = 'Jitpack'
url = 'https://jitpack.io'
}
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/releases/"
}
}
}

subprojects {
apply plugin: 'java-library'
apply plugin: 'java-library'

group = "com.paulzzh"
version = "1.0.0"
group = "com.paulzzh"
version = "1.0.0"

jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
//noinspection GroovyMissingReturnStatement
configurations.runtimeClasspath.collect {
if (project.name != "urlimg-common") {
if (it.name.contains("urlimg-common")) {
it.isDirectory() ? it : zipTree(it)
}
}
}
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
//noinspection GroovyMissingReturnStatement
configurations.runtimeClasspath.collect {
if (project.name != "urlimg-common") {
if (it.name.contains("urlimg-common")) {
it.isDirectory() ? it : zipTree(it)
}
}
}
}

from("${rootDir}/LICENSE")
}
from("${rootDir}/LICENSE")

processResources {
inputs.property "version", project.version
if (project.name.contains("urlimg-forge-1")) {
manifest {
attributes([
"Specification-Title" : "urlimg",
"Specification-Vendor" : "Paulzzh",
"Specification-Version" : "1",
"Implementation-Title" : "urlimg",
"Implementation-Version" : project.version,
"Implementation-Vendor" : "Paulzzh",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
}

filesMatching("fabric.mod.json") {
expand "version": project.version
}
processResources {
inputs.property "version", project.version

filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
filesMatching("fabric.mod.json") {
expand "version": project.version
}

filesMatching("mcmod.info") {
expand "version": project.version
}
}
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
filesMatching("mcmod.info") {
expand "version": project.version
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
}
8 changes: 8 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Forge'
url = 'https://maven.minecraftforge.net/'
}
mavenCentral()
gradlePluginPortal()
}
Expand All @@ -18,4 +22,8 @@ include(
"urlimg-fabric:urlimg-fabric-1.20",
"urlimg-fabric:urlimg-fabric-1.20.2",
"urlimg-fabric:urlimg-fabric-1.20.5"
)
include(
"urlimg-forge",
"urlimg-forge:urlimg-forge-1.16.5"
)
6 changes: 4 additions & 2 deletions urlimg-common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.text.ClickEvent;
Expand Down Expand Up @@ -35,10 +36,10 @@ public class Mod implements ClientModInitializer {
private static final int line_height = 10;
public static final ImageManager IM = new ImageManager() {
public void showImages(String msg) {
MinecraftClient mc = MinecraftClient.getInstance();
mc.inGameHud.getChatHud().addMessage(Text.of("urlimg=" + msg));
ChatHud hud = MinecraftClient.getInstance().inGameHud.getChatHud();
hud.addMessage(Text.of("urlimg=" + msg));
for (int i = 0; i < line; i++) {
mc.inGameHud.getChatHud().addMessage(Text.of(""));
hud.addMessage(Text.of(""));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import net.minecraft.text.OrderedText;
import net.minecraft.text.StringVisitable;
import net.minecraft.text.Style;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -16,18 +13,8 @@

@Mixin(net.minecraft.client.util.ChatMessages.class)
public class MixinChatMessages {
@Final
@Shadow
private static final OrderedText SPACES = OrderedText.styled(32, Style.EMPTY);
//private static ArrayList<OrderedText> list = Lists.newArrayList();

@Inject(method = "method_30886", at = @At("RETURN"))
private static void injected(List list, StringVisitable stringVisitable, Boolean boolean_, CallbackInfo ci) {
line_map.put((OrderedText) list.get(list.size() - 1), stringVisitable);
}

/*@Inject(method = "breakRenderedChatMessageLines", at = @At(value = "TAIL"))
private static void injected2(StringVisitable stringVisitable, int i, TextRenderer textRenderer, CallbackInfoReturnable<List<OrderedText>> cir) {
cir.setReturnValue(list);
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.text.ClickEvent;
Expand Down Expand Up @@ -35,10 +36,10 @@ public class Mod implements ClientModInitializer {
private static final int line_height = 10;
public static final ImageManager IM = new ImageManager() {
public void showImages(String msg) {
MinecraftClient mc = MinecraftClient.getInstance();
mc.inGameHud.getChatHud().addMessage(Text.of("urlimg=" + msg));
ChatHud hud = MinecraftClient.getInstance().inGameHud.getChatHud();
hud.addMessage(Text.of("urlimg=" + msg));
for (int i = 0; i < line; i++) {
mc.inGameHud.getChatHud().addMessage(Text.of(""));
hud.addMessage(Text.of(""));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import net.minecraft.text.OrderedText;
import net.minecraft.text.StringVisitable;
import net.minecraft.text.Style;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -16,18 +13,8 @@

@Mixin(net.minecraft.client.util.ChatMessages.class)
public class MixinChatMessages {
@Final
@Shadow
private static final OrderedText SPACES = OrderedText.styled(32, Style.EMPTY);
//private static ArrayList<OrderedText> list = Lists.newArrayList();

@Inject(method = "method_30886", at = @At("RETURN"))
private static void injected(List list, StringVisitable stringVisitable, Boolean boolean_, CallbackInfo ci) {
line_map.put((OrderedText) list.get(list.size() - 1), stringVisitable);
}

/*@Inject(method = "breakRenderedChatMessageLines", at = @At(value = "TAIL"))
private static void injected2(StringVisitable stringVisitable, int i, TextRenderer textRenderer, CallbackInfoReturnable<List<OrderedText>> cir) {
cir.setReturnValue(list);
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.text.ClickEvent;
Expand Down Expand Up @@ -35,10 +36,10 @@ public class Mod implements ClientModInitializer {
private static final int line_height = 10;
public static final ImageManager IM = new ImageManager() {
public void showImages(String msg) {
MinecraftClient mc = MinecraftClient.getInstance();
mc.inGameHud.getChatHud().addMessage(Text.of("urlimg=" + msg));
ChatHud hud = MinecraftClient.getInstance().inGameHud.getChatHud();
hud.addMessage(Text.of("urlimg=" + msg));
for (int i = 0; i < line; i++) {
mc.inGameHud.getChatHud().addMessage(Text.of(""));
hud.addMessage(Text.of(""));
}
}

Expand Down
Loading

0 comments on commit 689b145

Please sign in to comment.