Skip to content

Commit

Permalink
mmc update
Browse files Browse the repository at this point in the history
  • Loading branch information
RedthMC committed Dec 21, 2023
1 parent be09321 commit b8a6850
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 166 deletions.
59 changes: 30 additions & 29 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@file:Suppress("UnstableApiUsage", "PropertyName")

import cc.polyfrost.gradle.util.noServerRunConfigs
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.polyfrost.gradle.util.noServerRunConfigs

// Adds support for kotlin, and adds the Polyfrost Gradle Toolkit
// which we use to prepare the environment.
plugins {
kotlin("jvm")
id("cc.polyfrost.multi-version")
id("cc.polyfrost.defaults.repo")
id("cc.polyfrost.defaults.java")
id("cc.polyfrost.defaults.loom")
id("org.polyfrost.multi-version")
id("org.polyfrost.defaults.repo")
id("org.polyfrost.defaults.java")
id("org.polyfrost.defaults.loom")
id("com.github.johnrengelman.shadow")
id("net.kyori.blossom") version "1.3.0"
id("net.kyori.blossom") version "1.3.1"
id("signing")
java
}
Expand All @@ -39,7 +39,7 @@ blossom {
version = mod_version
// Sets the group, make sure to change this to your own. It can be a website you own backwards or your GitHub username.
// e.g. com.github.<your username> or com.<your domain>
group = "me.redth"
group = "org.polyfrost"

// Sets the name of the output jar (the one you put in your mods folder and send to other people)
// It outputs all versions of the mod into the `build` directory.
Expand All @@ -53,16 +53,13 @@ loom {
// If you're developing a server-side mod, you can remove this line.
noServerRunConfigs()

// Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.cc)
// Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org)
if (project.platform.isLegacyForge) {
launchConfigs.named("client") {
arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")

// This is enabled so OneConfig can read our Mixins and automatically apply them.
property(
"mixin.debug.export",
"true"
)
runConfigs {
"client" {
programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
property("mixin.debug.export", "true")
}
}
}
// Configures the mixins if we are building for forge, useful for when we are dealing with cross-platform projects.
Expand All @@ -84,20 +81,28 @@ val shade: Configuration by configurations.creating {
sourceSets {
val dummy by creating
main {
output.setResourcesDir(java.classesDirectory)
dummy.compileClasspath += compileClasspath
compileClasspath += dummy.output
output.setResourcesDir(java.classesDirectory)
}
}

// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod.
repositories {
maven("https://repo.polyfrost.cc/releases")
maven("https://repo.polyfrost.org/releases")
}

// Configures the libraries/dependencies for your mod.
dependencies {
// Adds the OneConfig library, so we can develop with it.
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.0-alpha+")
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.1-alpha+")

val loaderPlatform = when {
platform.isFabric -> "fabric"
platform.isLegacyForge -> "forge-legacy"
else -> "forge-latest"
}
modRuntimeOnly("me.djtheredstoner:DevAuth-$loaderPlatform:1.1.2")
// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier.
if (platform.isLegacyForge) {
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
Expand All @@ -111,14 +116,10 @@ tasks {
processResources {
inputs.property("id", mod_id)
inputs.property("name", mod_name)
val java = if (project.platform.mcMinor >= 18) {
17 // If we are playing on version 1.18, set the java version to 17
} else {
// Else if we are playing on version 1.17, use java 16.
if (project.platform.mcMinor == 17)
16
else
8 // For all previous versions, we **need** java 8 (for Forge support).
val java = when (project.platform.mcMinor) {
in 18..99 -> 17 // If we are playing on version 1.18, set the java version to 17
17 -> 16 // Else if we are playing on version 1.17, use java 16.
else -> 8 // For all previous versions, we **need** java 8 (for Forge support).
}
val compatLevel = "JAVA_${java}"
inputs.property("java", java)
Expand Down Expand Up @@ -174,7 +175,7 @@ tasks {
}

remapJar {
input.set(shadowJar.get().archiveFile)
inputFile.set(shadowJar.get().archiveFile)
archiveClassifier.set("")
}

Expand All @@ -185,7 +186,7 @@ tasks {
"ModSide" to "CLIENT", // We aren't developing a server-side mod, so this is fine.
"ForceLoadAsMod" to true, // We want to load this jar as a mod, so we force Forge to do so.
"TweakOrder" to "0", // Makes sure that the OneConfig launch wrapper is loaded as soon as possible.
"MixinConfigs" to "mixin.${mod_id}.json", // We want to use our mixin configuration, so we specify it here.
"MixinConfigs" to "mixins.${mod_id}.json", // We want to use our mixin configuration, so we specify it here.
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper.
)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod_name=MMCUtils
# Sets the id of your mod that mod loaders use to recognize it.
mod_id=mmcutils
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
mod_version=0.1.9
mod_version=0.2.0
# Sets the name of the jar file that you put in your 'mods' folder.
mod_archives_name=MMCUtils

Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

networkTimeout=30000
8 changes: 5 additions & 3 deletions root.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
plugins {
kotlin("jvm") version "1.6.21" apply false
id("cc.polyfrost.multi-version.root")
kotlin("jvm") version "1.8.22" apply false
id("org.polyfrost.multi-version.root")
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
}

preprocess {
// "1.12.2-forge"(11202, "srg") {
"1.8.9-forge"(10809, "srg")
}
// }
}
7 changes: 4 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
maven("https://repo.polyfrost.cc/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit
maven("https://repo.polyfrost.org/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit
}
plugins {
val pgtVersion = "0.1.28" // Sets the default versions for Polyfrost Gradle Toolkit
id("cc.polyfrost.multi-version.root") version pgtVersion
val pgtVersion = "0.2.9" // Sets the default versions for Polyfrost Gradle Toolkit
id("org.polyfrost.multi-version.root") version pgtVersion
}
}

Expand All @@ -21,6 +21,7 @@ rootProject.buildFileName = "root.gradle.kts"
// Adds all of our build target versions to the classpath if we need to add version-specific code.
listOf(
"1.8.9-forge", // Update this if you want to remove/add a version, along with `build.gradle.kts` and `root.gradle.kts`.
// "1.12.2-forge"
).forEach { version ->
include(":$version")
project(":$version").apply {
Expand Down
2 changes: 1 addition & 1 deletion src/dummy/java/net/optifine/render/RenderEnv.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.optifine.render;

public interface RenderEnv {
public class RenderEnv {
}
16 changes: 12 additions & 4 deletions src/main/java/me/redth/mmcutils/mixin/BlockModelRendererMixin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.redth.mmcutils.mixin;

import me.redth.mmcutils.Hooks;
import me.redth.mmcutils.core.Core;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.BlockModelRenderer;
import net.minecraft.client.renderer.WorldRenderer;
Expand All @@ -19,8 +19,16 @@
@Mixin(BlockModelRenderer.class)
public abstract class BlockModelRendererMixin {
@Dynamic("optifine")
@ModifyArgs(method = "renderQuadsSmooth", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;putColorMultiplier(FFFI)V"))
public void modifyArgs(Args args, IBlockAccess worldIn, IBlockState stateIn, BlockPos blockPosIn, WorldRenderer instance, List<BakedQuad> list, RenderEnv env) {
Hooks.INSTANCE.modifyArgs(args, stateIn, blockPosIn);
@ModifyArgs(
remap = false,
method = "renderQuadsSmooth",
at = @At(
value = "INVOKE",
remap = true,
target = "Lnet/minecraft/client/renderer/WorldRenderer;putColorMultiplier(FFFI)V"
)
)
private void mmcUtils$modifyShadow(Args args, IBlockAccess worldIn, IBlockState stateIn, BlockPos blockPosIn, WorldRenderer instance, List<BakedQuad> list, RenderEnv env) {
Core.INSTANCE.modifyArgs(args, stateIn, blockPosIn);
}
}
22 changes: 0 additions & 22 deletions src/main/kotlin/me/redth/mmcutils/Hooks.kt

This file was deleted.

98 changes: 3 additions & 95 deletions src/main/kotlin/me/redth/mmcutils/MMCUtils.kt
Original file line number Diff line number Diff line change
@@ -1,113 +1,21 @@
package me.redth.mmcutils

import cc.polyfrost.oneconfig.libs.universal.ChatColor
import me.redth.mmcutils.core.Core
import me.redth.mmcutils.config.ModConfig
import net.minecraft.client.Minecraft
import net.minecraft.scoreboard.ScorePlayerTeam
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent
import java.util.Timer
import kotlin.concurrent.schedule

@Mod(modid = MMCUtils.MODID, name = MMCUtils.NAME, version = MMCUtils.VERSION, modLanguageAdapter = "cc.polyfrost.oneconfig.utils.KotlinLanguageAdapter")
object MMCUtils {
const val MODID = "@ID@"
const val NAME = "@NAME@"
const val VERSION = "@VER@"
private val ALL_PROXY = arrayOf("AS Practice", "EU Practice", "NA Practice", "SA Practice")
private val BRIDGING_GAMES = arrayOf("Bed Fight", "Fireball Fight", "Bridges", "Battle Rush")
private val mc = Minecraft.getMinecraft()

var checkedScoreboard = false
var inPractice = false
var inPartyChat = false
var inBridgingGame = false

@Mod.EventHandler
fun init(e: FMLInitializationEvent) {
MinecraftForge.EVENT_BUS.register(this)
ModConfig.initialize()
}

@SubscribeEvent
fun onQuit(e: ClientDisconnectionFromServerEvent) {
inBridgingGame = false
inPartyChat = false
inPractice = false
checkedScoreboard = false
}

@SubscribeEvent
fun onChat(e: ClientChatReceivedEvent) {
val cleanText = e.message.unformattedText!!

scheduleCheckScoreboard(cleanText)

if (!inPractice) return

tryPartyChat(cleanText)
checkBridgingGame(cleanText)
checkGameEnd(cleanText)
}

@SubscribeEvent
fun preventTablist(e: RenderGameOverlayEvent.Pre) {
if (!ModConfig.disablePlayerList) return
if (e.type != RenderGameOverlayEvent.ElementType.PLAYER_LIST) return
if (!inPractice) return
e.isCanceled = true
}

private fun tryPartyChat(chat: String) {
if (inPartyChat) return
if (chat !in ALL_PROXY) return
if (!ModConfig.autoPartyChat) return

mc.thePlayer.sendChatMessage("/p chat")
inPartyChat = true
}

private fun checkBridgingGame(chat: String) {
if (inBridgingGame) return
if (chat !in BRIDGING_GAMES) return

inBridgingGame = true
}

private fun checkGameEnd(chat: String) {
if (!chat.startsWith("Match Results")) return

if (inBridgingGame) inBridgingGame = false

if (ModConfig.autoGG) mc.thePlayer.sendChatMessage(ModConfig.autoGGText)
}

private fun scheduleCheckScoreboard(chat: String) {
if (checkedScoreboard) return
if (inPractice) return
if (chat != "Minemen Club") return
if (!ModConfig.autoQueue) return

Timer().schedule(1000L) { checkScoreboard() }
MinecraftForge.EVENT_BUS.register(Core)
ModConfig
}

private fun checkScoreboard() {
checkedScoreboard = true
val scoreboard = mc.theWorld.scoreboard ?: return
val objective = scoreboard.getObjectiveInDisplaySlot(1) ?: return
for (score in scoreboard.getSortedScores(objective)) {
val team = scoreboard.getPlayersTeam(score.playerName) ?: continue
val text = ChatColor.stripColorCodes(ScorePlayerTeam.formatPlayerName(team, score.playerName))?: continue
val mmcProxy = text.split(".minemen.club").firstOrNull() ?: continue
if (mmcProxy.length != 2) continue
mc.thePlayer.sendChatMessage("/joinqueue $mmcProxy-practice")
inPractice = true
break
}
}
}
10 changes: 5 additions & 5 deletions src/main/kotlin/me/redth/mmcutils/config/HeightLimitHud.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package me.redth.mmcutils.config

import cc.polyfrost.oneconfig.hud.SingleTextHud
import me.redth.mmcutils.MMCUtils
import net.minecraft.client.Minecraft
import cc.polyfrost.oneconfig.utils.dsl.mc
import me.redth.mmcutils.core.Core

class HeightLimitHud : SingleTextHud("Height Limit Distance", false) {
override fun getText(example: Boolean) = if (MMCUtils.inBridgingGame) {
val distance = 100 - Minecraft.getMinecraft().thePlayer.posY.toInt()
override fun getText(example: Boolean) = if (Core.inBridgingGame) {
val distance = 100 - mc.thePlayer.posY.toInt()
distance.toString()
} else "3"

override fun shouldShow() = super.shouldShow() && MMCUtils.inBridgingGame
override fun shouldShow() = super.shouldShow() && Core.inBridgingGame
}
Loading

0 comments on commit b8a6850

Please sign in to comment.