Skip to content

Commit

Permalink
Merge pull request #145 from fixrtm/warn-if-fixrtm-is-only-on-server
Browse files Browse the repository at this point in the history
Warn if fixRTM is added only on server
  • Loading branch information
anatawa12 authored Feb 25, 2021
2 parents 0fd5ad0 + 3e40022 commit bd4e84b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/anatawa12/fixRtm/FixRtm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ import jp.ngt.rtm.RTMCore
import net.minecraft.block.Block
import net.minecraft.client.Minecraft
import net.minecraft.client.resources.IReloadableResourceManager
import net.minecraft.entity.player.EntityPlayerMP
import net.minecraft.item.Item
import net.minecraft.launchwrapper.Launch
import net.minecraft.util.ResourceLocation
import net.minecraft.util.text.Style
import net.minecraft.util.text.TextComponentString
import net.minecraft.util.text.TextFormatting
import net.minecraftforge.client.event.ModelRegistryEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.event.RegistryEvent
Expand All @@ -29,6 +33,7 @@ import net.minecraftforge.fml.common.event.FMLConstructionEvent
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.PlayerEvent
import net.minecraftforge.fml.common.network.NetworkCheckHandler
import net.minecraftforge.fml.relauncher.Side
import java.awt.Color
Expand Down Expand Up @@ -178,6 +183,16 @@ object FixRtm {
}
}

@SubscribeEvent
@Suppress("UNUSED_PARAMETER")
fun onPlayerLoggedIn(e: PlayerEvent.PlayerLoggedInEvent) {
if (!(e.player as EntityPlayerMP).hasFixRTM) {
e.player.sendMessage(TextComponentString("In this server, fixRTM is enabled. " +
"It's recommended to use fixRTM even on client.")
.setStyle(Style().setColor(TextFormatting.YELLOW)))
}
}


@Mod.InstanceFactory
@JvmStatic
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/anatawa12/fixRtm/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import com.anatawa12.fixRtm.utils.ArrayPool
import com.anatawa12.fixRtm.utils.closeScope
import com.anatawa12.fixRtm.utils.sortedWalk
import com.google.common.collect.Iterators
import net.minecraft.entity.player.EntityPlayerMP
import net.minecraftforge.fml.common.Loader
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher
import java.io.*
import java.nio.charset.Charset
import java.util.concurrent.Executors
Expand Down Expand Up @@ -135,3 +137,6 @@ fun DataInput.readUTFNullable(): String? = closeScope {
}

fun File.mkParent(): File = apply { parentFile.mkdirs() }

val EntityPlayerMP.modList get() = NetworkDispatcher.get(this.connection.netManager).modList
val EntityPlayerMP.hasFixRTM get() = modList.containsKey(FixRtm.MODID)

0 comments on commit bd4e84b

Please sign in to comment.