Skip to content

Commit 516ae3f

Browse files
committed
v0.1.9 - kotlin
1 parent 313801c commit 516ae3f

File tree

12 files changed

+180
-185
lines changed

12 files changed

+180
-185
lines changed

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ val shade: Configuration by configurations.creating {
8282

8383
// Configures the output directory for when building from the `src/resources` directory.
8484
sourceSets {
85+
val dummy by creating
8586
main {
8687
output.setResourcesDir(java.classesDirectory)
88+
compileClasspath += dummy.output
8789
}
8890
}
8991

@@ -96,7 +98,6 @@ repositories {
9698
dependencies {
9799
// Adds the OneConfig library, so we can develop with it.
98100
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.0-alpha+")
99-
implementation(files("libs/optifine-1.8.9.jar"))
100101
// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier.
101102
if (platform.isLegacyForge) {
102103
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod_name=MMCUtils
55
# Sets the id of your mod that mod loaders use to recognize it.
66
mod_id=mmcutils
77
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
8-
mod_version=0.1.8
8+
mod_version=0.1.9
99
# Sets the name of the jar file that you put in your 'mods' folder.
1010
mod_archives_name=MMCUtils
1111

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package net.optifine.render;
2+
3+
public interface RenderEnv {
4+
}

src/main/java/me/redth/mmcutils/Configuration.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/main/java/me/redth/mmcutils/HeightLimitHud.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/main/java/me/redth/mmcutils/MMCUtils.java

Lines changed: 0 additions & 101 deletions
This file was deleted.
Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package me.redth.mmcutils.mixin;
22

3-
import me.redth.mmcutils.Configuration;
4-
import me.redth.mmcutils.MMCUtils;
5-
import net.minecraft.block.BlockColored;
3+
import me.redth.mmcutils.Hooks;
64
import net.minecraft.block.state.IBlockState;
75
import net.minecraft.client.renderer.BlockModelRenderer;
86
import net.minecraft.client.renderer.WorldRenderer;
@@ -23,18 +21,6 @@ public abstract class BlockModelRendererMixin {
2321
@Dynamic("optifine")
2422
@ModifyArgs(method = "renderQuadsSmooth", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;putColorMultiplier(FFFI)V"))
2523
public void modifyArgs(Args args, IBlockAccess worldIn, IBlockState stateIn, BlockPos blockPosIn, WorldRenderer instance, List<BakedQuad> list, RenderEnv env) {
26-
if (!MMCUtils.inBridgingGame) return;
27-
if (!Configuration.heightLimitOverlay) return;
28-
if (blockPosIn.getY() != 99) return;
29-
if (!(stateIn.getBlock() instanceof BlockColored)) return;
30-
31-
int meta = stateIn.getValue(BlockColored.COLOR).getMetadata();
32-
if (meta != 14 && meta != 11) return;
33-
34-
float brightness = 1F - Configuration.heightLimitDarkness / 10F;
35-
for (int i = 0; i < 3; i++) {
36-
args.set(i, (float) args.get(i) * brightness);
37-
}
24+
Hooks.INSTANCE.modifyArgs(args, stateIn, blockPosIn);
3825
}
39-
4026
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package me.redth.mmcutils
2+
3+
import me.redth.mmcutils.config.ModConfig
4+
import net.minecraft.block.BlockColored
5+
import net.minecraft.block.state.IBlockState
6+
import net.minecraft.util.BlockPos
7+
import org.spongepowered.asm.mixin.injection.invoke.arg.Args
8+
9+
object Hooks {
10+
fun modifyArgs(args: Args, stateIn: IBlockState, blockPosIn: BlockPos) {
11+
if (!MMCUtils.inBridgingGame) return
12+
if (!ModConfig.heightLimitOverlay) return
13+
if (blockPosIn.y != 99) return
14+
if (stateIn.block !is BlockColored) return
15+
val meta = stateIn.getValue(BlockColored.COLOR).metadata
16+
if (meta != 14 && meta != 11) return
17+
val brightness = 1f - ModConfig.heightLimitDarkness / 10f
18+
for (i in 0..2) {
19+
args.set(i, args.get<Float>(i) * brightness)
20+
}
21+
}
22+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package me.redth.mmcutils
2+
3+
import cc.polyfrost.oneconfig.libs.universal.ChatColor
4+
import me.redth.mmcutils.config.ModConfig
5+
import net.minecraft.client.Minecraft
6+
import net.minecraft.scoreboard.ScorePlayerTeam
7+
import net.minecraftforge.client.event.ClientChatReceivedEvent
8+
import net.minecraftforge.client.event.RenderGameOverlayEvent
9+
import net.minecraftforge.common.MinecraftForge
10+
import net.minecraftforge.fml.common.Mod
11+
import net.minecraftforge.fml.common.event.FMLInitializationEvent
12+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
13+
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent
14+
import java.util.Timer
15+
import kotlin.concurrent.schedule
16+
17+
@Mod(modid = MMCUtils.MODID, name = MMCUtils.NAME, version = MMCUtils.VERSION, modLanguageAdapter = "cc.polyfrost.oneconfig.utils.KotlinLanguageAdapter")
18+
object MMCUtils {
19+
const val MODID = "@ID@"
20+
const val NAME = "@NAME@"
21+
const val VERSION = "@VER@"
22+
val ALL_PROXY = arrayOf("AS Practice", "EU Practice", "NA Practice", "SA Practice")
23+
val BRIDGING_GAMES = arrayOf("Bed Fight", "Fireball Fight", "Bridges", "Battle Rush")
24+
private val mc = Minecraft.getMinecraft()
25+
26+
var checkedScoreboard = false
27+
var inPractice = false
28+
var inPartyChat = false
29+
var inBridgingGame = false
30+
31+
@Mod.EventHandler
32+
fun init(e: FMLInitializationEvent) {
33+
MinecraftForge.EVENT_BUS.register(this)
34+
ModConfig
35+
}
36+
37+
@SubscribeEvent
38+
fun onQuit(e: ClientDisconnectionFromServerEvent) {
39+
inBridgingGame = false
40+
inPartyChat = false
41+
inPractice = false
42+
checkedScoreboard = false
43+
}
44+
45+
@SubscribeEvent
46+
fun onChat(e: ClientChatReceivedEvent) {
47+
val clean = e.message.unformattedText
48+
if (!checkedScoreboard && !inPractice && "Minemen Club" == clean && ModConfig.autoQueue) {
49+
Timer().schedule(1000L) { checkScoreboard() }
50+
}
51+
if (!inPractice) return
52+
if (!inPartyChat && ALL_PROXY.contains(clean) && ModConfig.autoPartyChat) {
53+
mc.thePlayer.sendChatMessage("/p chat")
54+
inPartyChat = true
55+
}
56+
if (!inBridgingGame) {
57+
if (BRIDGING_GAMES.contains(clean)) inBridgingGame = true
58+
}
59+
if (clean.startsWith("Match Results")) {
60+
if (inBridgingGame) inBridgingGame = false
61+
if (ModConfig.autoGG) mc.thePlayer.sendChatMessage(ModConfig.autoGGText)
62+
}
63+
}
64+
65+
@SubscribeEvent
66+
fun onRenderGameOverlay(e: RenderGameOverlayEvent.Pre) {
67+
if (e.type != RenderGameOverlayEvent.ElementType.PLAYER_LIST) return
68+
if (!checkedScoreboard) return
69+
if (!ModConfig.disablePlayerList) return
70+
e.isCanceled = true
71+
}
72+
73+
fun checkScoreboard() {
74+
checkedScoreboard = true
75+
val scoreboard = mc.theWorld.scoreboard ?: return
76+
val objective = scoreboard.getObjectiveInDisplaySlot(1) ?: return
77+
for (score in scoreboard.getSortedScores(objective)) {
78+
val team = scoreboard.getPlayersTeam(score.playerName)
79+
var text = ScorePlayerTeam.formatPlayerName(team, score.playerName)
80+
text = ChatColor.stripColorCodes(text) ?: continue
81+
val split = text.split(".minemen.club")
82+
if (split[0].length != 2) continue
83+
val mmcProxy = split[0]
84+
mc.thePlayer.sendChatMessage("/joinqueue $mmcProxy-practice")
85+
inPractice = true
86+
break
87+
}
88+
}
89+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package me.redth.mmcutils.config
2+
3+
import cc.polyfrost.oneconfig.hud.SingleTextHud
4+
import me.redth.mmcutils.MMCUtils
5+
import net.minecraft.client.Minecraft
6+
7+
class HeightLimitHud : SingleTextHud("Height Limit Distance", false) {
8+
override fun getText(example: Boolean): String {
9+
if (!MMCUtils.inBridgingGame) return "3"
10+
val distance = 100 - Minecraft.getMinecraft().thePlayer.posY.toInt()
11+
return distance.toString()
12+
}
13+
14+
override fun shouldShow(): Boolean {
15+
return super.shouldShow() && MMCUtils.inBridgingGame
16+
}
17+
}

0 commit comments

Comments
 (0)