Skip to content

Commit 0fb94e6

Browse files
committed
Big refactor of literally everything
1 parent 6446da7 commit 0fb94e6

39 files changed

+965
-585
lines changed

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repositories {
2323

2424
toolkitLoomHelper {
2525
useOneConfig {
26-
version = "1.0.0-alpha.175"
26+
version = "1.0.0-alpha.176"
2727
loaderVersion = "1.1.0-alpha.53"
2828

2929
usePolyMixin = true
@@ -59,6 +59,8 @@ dependencies {
5959

6060
implementation(libs.bundles.ktor.client)
6161
includeOrShade(libs.bundles.ktor.client)
62+
implementation(libs.bundles.ktor.server)
63+
includeOrShade(libs.bundles.ktor.server)
6264
implementation(libs.bundles.ktor.serialization)
6365
includeOrShade(libs.bundles.ktor.serialization)
6466

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ discord-game-sdk4j = { group = "com.github.JnCrMx", name = "discord-game-sdk4j",
77
ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
88
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
99
ktor-client-content-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" }
10+
ktor-server-websockets = { group = "io.ktor", name = "ktor-server-websockets", version.ref = "ktor" }
1011
ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" }
1112

1213
[bundles]
1314
ktor-client = ["ktor-client-core", "ktor-client-cio", "ktor-client-content-negotiation"]
15+
ktor-server = ["ktor-server-websockets"]
1416
ktor-serialization = ["ktor-serialization-kotlinx-json"]

src/main/java/org/polyfrost/polyplus/client/mixin/Mixin_ReplaceCapeTexture.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
import com.mojang.authlib.GameProfile;
44
import net.minecraft.client.network.NetworkPlayerInfo;
55
import net.minecraft.util.ResourceLocation;
6-
import org.polyfrost.polyplus.PolyPlus;
6+
import org.polyfrost.polyplus.client.cosmetics.CosmeticManager;
77
import org.spongepowered.asm.mixin.Final;
88
import org.spongepowered.asm.mixin.Mixin;
99
import org.spongepowered.asm.mixin.Shadow;
10+
import org.spongepowered.asm.mixin.injection.At;
1011
import org.spongepowered.asm.mixin.injection.Inject;
1112
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1213

1314
@Mixin(NetworkPlayerInfo.class)
1415
public class Mixin_ReplaceCapeTexture {
15-
@Shadow
16-
private ResourceLocation locationCape;
16+
@Shadow @Final private GameProfile gameProfile;
1717

18-
@Shadow @Final
19-
private GameProfile gameProfile;
20-
21-
@Inject(method = "getLocationCape", at = @org.spongepowered.asm.mixin.injection.At("HEAD"))
22-
private void polyplus$onGetCape(CallbackInfoReturnable<ResourceLocation> cir) {
23-
this.locationCape = new ResourceLocation(PolyPlus.ID, "64px_poly.png");
18+
@Inject(method = "getLocationCape", at = @At("HEAD"))
19+
private void polyplus$useCustomCape(CallbackInfoReturnable<ResourceLocation> cir) {
20+
ResourceLocation capeLocation = CosmeticManager.get(this.gameProfile.getId(), "cape");
21+
if (capeLocation != null) {
22+
cir.setReturnValue(capeLocation);
23+
}
2424
}
2525
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.polyfrost.polyplus
2+
3+
enum class BackendUrl(val url: String) {
4+
PRODUCTION("https://plus.polyfrost.org"),
5+
STAGING("https://plus-staging.polyfrost.org"),
6+
LOCAL("http://localhost:8080");
7+
8+
operator fun plus(other: String): String {
9+
return this + other
10+
}
11+
12+
override fun toString(): String {
13+
return url
14+
}
15+
}

src/main/kotlin/org/polyfrost/polyplus/Example.kt

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

src/main/kotlin/org/polyfrost/polyplus/PolyPlus.kt

Lines changed: 0 additions & 134 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.polyfrost.polyplus
2+
3+
object PolyPlusConstants {
4+
// Sets the variables from `gradle.properties`. Depends on the `bloom` DGT plugin.
5+
const val ID = "@MOD_ID@"
6+
const val NAME = "@MOD_NAME@"
7+
const val VERSION = "@MOD_VERSION@"
8+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.polyfrost.polyplus
2+
3+
import org.polyfrost.polyplus.client.PolyPlusClient
4+
5+
//#if FABRIC
6+
//$$ import net.fabricmc.api.ClientModInitializer
7+
//#elseif FORGE
8+
//#if MC >= 1.16.5
9+
//$$ import net.minecraftforge.eventbus.api.IEventBus
10+
//$$ import net.minecraftforge.fml.common.Mod
11+
//$$ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
12+
//$$ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext
13+
//#else
14+
import net.minecraftforge.fml.common.Mod
15+
import net.minecraftforge.fml.common.event.FMLInitializationEvent
16+
//#endif
17+
//#elseif NEOFORGE
18+
//$$ import net.neoforged.bus.api.IEventBus
19+
//$$ import net.neoforged.fml.common.Mod
20+
//$$ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent
21+
//#endif
22+
23+
//#if FORGE-LIKE
24+
//#if MC >= 1.16.5
25+
//$$ @Mod(PolyPlusConstants.ID)
26+
//#else
27+
@Mod(modid = PolyPlusConstants.ID, version = PolyPlusConstants.VERSION)
28+
//#endif
29+
//#endif
30+
class PolyPlusEntrypoint
31+
//#if FABRIC
32+
//$$ : ClientModInitializer
33+
//#endif
34+
{
35+
//#if FORGE && MC >= 1.16.5
36+
//$$ init {
37+
//$$ setupForgeEvents(FMLJavaModLoadingContext.get().modEventBus)
38+
//$$ }
39+
//#elseif NEOFORGE
40+
//$$ constructor(modEventBus: IEventBus) {
41+
//$$ setupForgeEvents(modEventBus)
42+
//$$ }
43+
//#endif
44+
45+
//#if FABRIC
46+
//$$ override
47+
//#elseif FORGE && MC <= 1.12.2
48+
@Mod.EventHandler
49+
//#endif
50+
fun onInitializeClient(
51+
//#if FORGE-LIKE
52+
//#if MC >= 1.16.5
53+
//$$ event: FMLClientSetupEvent
54+
//#else
55+
event: FMLInitializationEvent
56+
//#endif
57+
//#endif
58+
) {
59+
//#if FORGE-LIKE && MC <= 1.12.2
60+
if (!event.side.isClient) {
61+
return
62+
}
63+
//#endif
64+
65+
PolyPlusClient.initialize()
66+
}
67+
68+
//#if FORGE-LIKE && MC >= 1.16.5
69+
//$$ fun setupForgeEvents(modEventBus: IEventBus) {
70+
//$$ modEventBus.addListener(this::onInitializeClient)
71+
//$$ }
72+
//#endif
73+
}

src/main/kotlin/org/polyfrost/polyplus/client/Config.kt

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

src/main/kotlin/org/polyfrost/polyplus/client/ExampleCommand.kt

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

0 commit comments

Comments
 (0)