-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
fabric/origin/src/main/java/io/github/kituin/chatimage/integration/ActionLibIntegration.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,15 @@ | ||
package io.github.kituin.chatimage.integration; | ||
|
||
import io.github.kituin.actionlib.IActionRegisterApi; | ||
import net.minecraft.text.HoverEvent; | ||
|
||
import java.util.List; | ||
|
||
import static io.github.kituin.chatimage.tool.ChatImageStyle.SHOW_IMAGE; | ||
|
||
public class ActionLibIntegration implements IActionRegisterApi { | ||
@Override | ||
public List<HoverEvent.Action> registerHoverEventAction() { | ||
return List.of(SHOW_IMAGE); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...c/origin/src/main/java/io/github/kituin/chatimage/integration/ChatImageClientAdapter.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,68 @@ | ||
package io.github.kituin.chatimage.integration; | ||
|
||
import io.github.kituin.ChatImageCode.ChatImageFrame; | ||
import io.github.kituin.ChatImageCode.IClientAdapter; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.texture.NativeImage; | ||
import net.minecraft.client.texture.NativeImageBackedTexture; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.List; | ||
|
||
import static io.github.kituin.ChatImageCode.NetworkHelper.createFilePacket; | ||
import static io.github.kituin.chatimage.client.ChatImageClient.CONFIG; | ||
import static io.github.kituin.chatimage.client.ChatImageClient.MOD_ID; | ||
import static io.github.kituin.chatimage.network.ChatImagePacket.*; | ||
import static io.github.kituin.chatimage.tool.SimpleUtil.createTranslatableText; | ||
|
||
public class ChatImageClientAdapter implements IClientAdapter { | ||
@Override | ||
public int getTimeOut() { | ||
return CONFIG.timeout; | ||
} | ||
|
||
@Override | ||
public ChatImageFrame.TextureReader<Identifier> loadTexture(InputStream image) throws IOException { | ||
NativeImage nativeImage = NativeImage.read(image); | ||
return new ChatImageFrame.TextureReader<>( | ||
MinecraftClient.getInstance().getTextureManager().registerDynamicTexture(MOD_ID + "/chatimage", | ||
new NativeImageBackedTexture(nativeImage)), | ||
nativeImage.getWidth(), | ||
nativeImage.getHeight() | ||
); | ||
} | ||
|
||
@Override | ||
public void sendToServer(String url, File file, boolean isToServer) { | ||
if (isToServer) { | ||
List<String> stringList = createFilePacket(url, file); | ||
sendPacketAsync(FILE_CHANNEL, stringList); | ||
} else { | ||
loadFromServer(url); | ||
} | ||
} | ||
|
||
@Override | ||
public void checkCachePath() { | ||
File folder = new File(CONFIG.cachePath); | ||
if (!folder.exists()) { | ||
folder.mkdirs(); | ||
} | ||
} | ||
|
||
@Override | ||
public int getMaxFileSize() { | ||
return CONFIG.MaxFileSize; | ||
} | ||
|
||
@Override | ||
public Text getProcessMessage(int i) { | ||
return createTranslatableText("process.chatimage.message", i); | ||
} | ||
|
||
|
||
} |
37 changes: 37 additions & 0 deletions
37
fabric/origin/src/main/java/io/github/kituin/chatimage/integration/ChatImageLogger.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,37 @@ | ||
package io.github.kituin.chatimage.integration; | ||
|
||
import io.github.kituin.ChatImageCode.IChatImageCodeLogger; | ||
import io.github.kituin.chatimage.ChatImage; | ||
|
||
public class ChatImageLogger implements IChatImageCodeLogger { | ||
|
||
@Override | ||
public void info(String s) { | ||
ChatImage.LOGGER.info(s); | ||
} | ||
|
||
@Override | ||
public void info(String s, Object... objects) { | ||
ChatImage.LOGGER.info(s, objects); | ||
} | ||
|
||
@Override | ||
public void debug(String s) { | ||
ChatImage.LOGGER.debug(s); | ||
} | ||
|
||
@Override | ||
public void debug(String s, Object... objects) { | ||
ChatImage.LOGGER.debug(s, objects); | ||
} | ||
|
||
@Override | ||
public void error(String s) { | ||
ChatImage.LOGGER.error(s); | ||
} | ||
|
||
@Override | ||
public void error(String s, Object... objects) { | ||
ChatImage.LOGGER.error(s, objects); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
fabric/origin/src/main/java/io/github/kituin/chatimage/integration/ModmenuIntegration.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,14 @@ | ||
package io.github.kituin.chatimage.integration; | ||
|
||
|
||
import com.terraformersmc.modmenu.api.ConfigScreenFactory; | ||
import com.terraformersmc.modmenu.api.ModMenuApi; | ||
import io.github.kituin.chatimage.gui.ConfigScreen; | ||
|
||
public class ModmenuIntegration implements ModMenuApi { | ||
|
||
@Override | ||
public ConfigScreenFactory<?> getModConfigScreenFactory() { | ||
return ConfigScreen::new; | ||
} | ||
} |