forked from me/e4mc_minecraft
Merge branch 'main' into main
This commit is contained in:
commit
20b7139acf
9 changed files with 67 additions and 8 deletions
23
README.md
Normal file
23
README.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# [e4mc_minecraft](https://e4mc.link)
|
||||
|
||||
[![Modrinth Downloads](https://img.shields.io/modrinth/dt/qANg5Jrr?color=%2300af5c&logo=modrinth&style=for-the-badge)](https://modrinth.com/project/qANg5Jrr)
|
||||
[![Modrinth Followers](https://img.shields.io/modrinth/followers/qANg5Jrr?color=00af5c&logo=modrinth&style=for-the-badge)](https://modrinth.com/project/qANg5Jrr)
|
||||
[![CurseForge Sucks](https://img.shields.io/badge/cuseforge-sucks-f16436?style=for-the-badge)](https://curseforge.com/minecraft/mc-mods/e4mc)
|
||||
|
||||
Open a LAN server to anyone, anywhere, anytime.
|
||||
|
||||
## Install
|
||||
|
||||
[Modrinth](https://modrinth.com/project/qANg5Jrr)
|
||||
|
||||
## Usage
|
||||
|
||||
Open to LAN as normal
|
||||
|
||||
## Contributing
|
||||
|
||||
Please contribute
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
|
@ -3,5 +3,5 @@ org.gradle.jvmargs=-Xmx2G
|
|||
|
||||
mod.name=e4mc
|
||||
mod.id=e4mc_minecraft
|
||||
mod.version=3.0.0
|
||||
mod.version=3.1.0
|
||||
mod.group=vg.skye
|
0
gradlew
vendored
Normal file → Executable file
0
gradlew
vendored
Normal file → Executable file
|
@ -11,6 +11,7 @@ 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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import vg.skye.e4mc_minecraft.E4mcClient;
|
||||
|
@ -45,9 +46,9 @@ public abstract class ServerNetworkIoMixin {
|
|||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "bind", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/ServerBootstrap;channel(Ljava/lang/Class;)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
private AbstractBootstrap<ServerBootstrap, ServerChannel> redirectChannel(ServerBootstrap instance, Class<? extends ServerSocketChannel> aClass) {
|
||||
return initializingE4mc.get() ? instance.channel(LocalServerChannel.class) : instance.channel(aClass);
|
||||
@ModifyArg(method = "bind", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/ServerBootstrap;channel(Ljava/lang/Class;)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
private Class<? extends ServerChannel> redirectChannel(Class<? extends ServerChannel> aClass) {
|
||||
return initializingE4mc.get() ? LocalServerChannel.class : aClass;
|
||||
}
|
||||
|
||||
@Redirect(method = "bind", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/ServerBootstrap;localAddress(Ljava/net/InetAddress;I)Lio/netty/bootstrap/AbstractBootstrap;", remap = false))
|
||||
|
|
|
@ -33,7 +33,7 @@ object E4mcClient : ModInitializer {
|
|||
//#endif
|
||||
const val NAME = "e4mc"
|
||||
const val ID = "e4mc_minecraft"
|
||||
const val VERSION = "3.0.0"
|
||||
const val VERSION = "3.1.0"
|
||||
@JvmField
|
||||
val LOGGER: Logger = LoggerFactory.getLogger("e4mc")
|
||||
@JvmField
|
||||
|
@ -49,6 +49,13 @@ object E4mcClient : ModInitializer {
|
|||
dispatcher.register(literal("e4mc")
|
||||
.then(
|
||||
literal("stop")
|
||||
.requires { src ->
|
||||
if (src.server.isDedicated) {
|
||||
src.hasPermissionLevel(4)
|
||||
} else {
|
||||
src.server.isHost((src.player ?: return@requires false).gameProfile)
|
||||
}
|
||||
}
|
||||
.executes { context ->
|
||||
if (HANDLER != null) {
|
||||
HANDLER!!.close()
|
||||
|
|
|
@ -42,7 +42,7 @@ data class DomainAssignedMessage(val DomainAssigned: String)
|
|||
data class ChannelOpenMessage(val ChannelOpen: List<Any>)
|
||||
data class ChannelClosedMessage(val ChannelClosed: Number)
|
||||
|
||||
class E4mcRelayHandler: WebSocketClient(URI("wss://ingress.e4mc.link")) {
|
||||
class E4mcRelayHandler: WebSocketClient(URI(System.getProperty("vg.skye.e4mc_minecraft.ingress_uri", "wss://ingress.e4mc.link"))) {
|
||||
private val gson = Gson()
|
||||
private val childChannels = mutableMapOf<Int, LocalChannel>()
|
||||
private val messageQueue = mutableMapOf<Int, ArrayBlockingQueue<ByteBuffer>>()
|
||||
|
@ -86,6 +86,26 @@ class E4mcRelayHandler: WebSocketClient(URI("wss://ingress.e4mc.link")) {
|
|||
|
||||
override fun onError(ex: java.lang.Exception) {
|
||||
ex.printStackTrace()
|
||||
//#if FABRIC==1
|
||||
val isClient = FabricLoader.getInstance().environmentType.equals(EnvType.CLIENT)
|
||||
//#else
|
||||
//$$ val isClient = FMLLoader.getDist().isClient
|
||||
//#endif
|
||||
if (isClient) {
|
||||
try {
|
||||
MinecraftClient.getInstance().inGameHud.chatHud.addMessage(
|
||||
//#if MC>=11900
|
||||
Text.translatable("text.e4mc_minecraft.error")
|
||||
//#elseif FABRIC==1
|
||||
//$$ TranslatableText("text.e4mc_minecraft.error")
|
||||
//#else
|
||||
//$$ TranslatableComponent("text.e4mc_minecraft.error")
|
||||
//#endif
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleDomainAssigned(json: JsonObject) {
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
"text.e4mc_minecraft.domainAssigned": "Local game hosted on domain [%s]",
|
||||
"text.e4mc_minecraft.closeServer": "Local game no longer publicly hosted",
|
||||
"text.e4mc_minecraft.serverAlreadyClosed": "Local game not publicly hosted",
|
||||
"text.e4mc_minecraft.clickToStop": " (Click here to stop)"
|
||||
"text.e4mc_minecraft.clickToStop": " (Click here to stop)",
|
||||
"text.e4mc_minecraft.error": "An error occurred in e4mc"
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
"text.e4mc_minecraft.domainAssigned": "로컬 게임을 도메인 [%s]에서 호스트합니다",
|
||||
"text.e4mc_minecraft.closeServer": "로컬 게임이 더이상 공개되지 않습니다",
|
||||
"text.e4mc_minecraft.serverAlreadyClosed": "로컬 게임이 이미 공개중이 아닙니다",
|
||||
"text.e4mc_minecraft.clickToStop": " (멉추려면 여기를 클릭하세요)"
|
||||
"text.e4mc_minecraft.clickToStop": " (멉추려면 여기를 클릭하세요)",
|
||||
"text.e4mc_minecraft.error": "e4mc에서 오류가 발생했습니다."
|
||||
}
|
6
src/main/resources/assets/e4mc_quilt/lang/zh_cn.json
Normal file
6
src/main/resources/assets/e4mc_quilt/lang/zh_cn.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"text.e4mc_minecraft.domainAssigned": "将本地游戏托管在域名[%s]上",
|
||||
"text.e4mc_minecraft.closeServer": "不再公开托管本地游戏",
|
||||
"text.e4mc_minecraft.serverAlreadyClosed": "本地游戏没有被公开托管",
|
||||
"text.e4mc_minecraft.clickToStop": "(点击这里以停止)"
|
||||
}
|
Loading…
Reference in a new issue