Skip to content

Commit

Permalink
Refactor to org.polyfrost
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jul 30, 2024
1 parent 30e0d1b commit 8e7f1a4
Show file tree
Hide file tree
Showing 48 changed files with 120 additions and 101 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Spice

Spice is an optimization mod for Minecraft 1.8.9
# Spice
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
plugins {
kotlin("jvm") version "1.9.10" apply false
kotlin("plugin.serialization") version "1.9.10"
kotlin("jvm") version libs.versions.kotlin.get() apply false
kotlin("plugin.serialization") version libs.versions.kotlin.get() apply false
alias(libs.plugins.pgt.defaults.repo) apply false
idea
}

val modVer = project.properties["version"]

version = "$modVer"
group = "wtf.zani"
group = "org.polyfrost"

subprojects {
version = rootProject.version
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[versions]
kotlin = "1.9.10"
kotlinx-serialization = "1.6.2"
lwjgl = "3.3.3"
asm = "5.0.3"
mixins = "0.8.5-SNAPSHOT" # todo i dont think this is needed?
Expand All @@ -24,6 +25,8 @@ kotlin-common = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version.
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }

kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }

annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" }

[bundles]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.util
package org.polyfrost.spice.util

import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.InvokeDynamicInsnNode
Expand Down
2 changes: 1 addition & 1 deletion modules/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
compileOnly(rootProject.libs.asmtree)
compileOnly(rootProject.libs.bundles.lwjgl)

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")
implementation(rootProject.libs.kotlinx.serialization.json)
}

tasks.processResources {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice
package org.polyfrost.spice

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice
package org.polyfrost.spice

import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice
package org.polyfrost.spice

import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
Expand All @@ -10,11 +10,11 @@ import org.lwjgl.openal.AL10.AL_VERSION
import org.lwjgl.openal.AL10.alGetString
import org.lwjgl.system.Configuration.GLFW_CHECK_THREAD0
import org.lwjgl.system.MemoryStack
import wtf.zani.spice.debug.DebugHelper
import wtf.zani.spice.debug.DebugSection
import wtf.zani.spice.platform.api.Platform
import wtf.zani.spice.util.isMac
import wtf.zani.spice.util.isOptifineLoaded
import org.polyfrost.spice.debug.DebugHelper
import org.polyfrost.spice.debug.DebugSection
import org.polyfrost.spice.platform.api.Platform
import org.polyfrost.spice.util.isMac
import org.polyfrost.spice.util.isOptifineLoaded
import kotlin.io.path.*

object Spice {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.debug
package org.polyfrost.spice.debug

object DebugHelper {
internal val sections = mutableListOf<DebugSection>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.debug
package org.polyfrost.spice.debug

class DebugSection {
internal val lines = mutableListOf<() -> String>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.fixes
package org.polyfrost.spice.fixes

import org.lwjgl.opengl.GL
import java.util.concurrent.Callable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package wtf.zani.spice.patcher
package org.polyfrost.spice.patcher

import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.FieldInsnNode
import org.objectweb.asm.tree.MethodNode
import wtf.zani.spice.platform.api.IClassTransformer
import wtf.zani.spice.util.getStrings
import org.polyfrost.spice.platform.api.IClassTransformer
import org.polyfrost.spice.util.getStrings

object LunarTransformer : IClassTransformer {
override fun getClassNames(): Array<String>? {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package wtf.zani.spice.patcher
package org.polyfrost.spice.patcher

import org.objectweb.asm.Opcodes.INVOKESTATIC
import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.MethodInsnNode
import org.objectweb.asm.tree.MethodNode
import wtf.zani.spice.platform.api.IClassTransformer
import org.polyfrost.spice.platform.api.IClassTransformer

object OptifineTransformer : IClassTransformer {
override fun getClassNames(): Array<String> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package wtf.zani.spice.patcher.fixes
package org.polyfrost.spice.patcher.fixes

import org.lwjgl.LWJGLException
import wtf.zani.spice.patcher.util.AudioHelper
import org.polyfrost.spice.patcher.util.AudioHelper

@Suppress("unused")
object OpenAlFixes {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.patcher.fixes
package org.polyfrost.spice.patcher.fixes

import org.lwjgl.opengl.GL20.glShaderSource
import java.nio.ByteBuffer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package wtf.zani.spice.patcher.lwjgl
package org.polyfrost.spice.patcher.lwjgl

import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.LdcInsnNode
import org.objectweb.asm.tree.MethodNode
import wtf.zani.spice.platform.api.IClassTransformer
import org.polyfrost.spice.platform.api.IClassTransformer

object LibraryTransformer : IClassTransformer {
override fun getClassNames(): Array<String> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package wtf.zani.spice.patcher.lwjgl
package org.polyfrost.spice.patcher.lwjgl

import org.objectweb.asm.ClassReader
import org.objectweb.asm.tree.ClassNode
import wtf.zani.spice.util.UrlByteArrayConnection
import org.polyfrost.spice.util.UrlByteArrayConnection
import java.net.URL
import java.net.URLConnection
import java.net.URLStreamHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package wtf.zani.spice.patcher.lwjgl
package org.polyfrost.spice.patcher.lwjgl

import net.weavemc.loader.api.util.asm
import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.FieldNode
import org.objectweb.asm.tree.MethodNode
import wtf.zani.spice.platform.api.IClassTransformer
import org.polyfrost.spice.platform.api.IClassTransformer

object LwjglTransformer : IClassTransformer {
val provider = LwjglProvider()
Expand Down Expand Up @@ -107,13 +107,13 @@ object LwjglTransformer : IClassTransformer {
destroyMethod.access = Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC + Opcodes.ACC_SYNTHETIC

createMethod.instructions = asm {
invokestatic("wtf/zani/spice/patcher/fixes/OpenAlFixes", "create", "()V")
invokestatic("org/polyfrost/spice/patcher/fixes/OpenAlFixes", "create", "()V")

_return
}

destroyMethod.instructions = asm {
invokestatic("wtf/zani/spice/patcher/fixes/OpenAlFixes", "destroyContext", "()V")
invokestatic("org/polyfrost/spice/patcher/fixes/OpenAlFixes", "destroyContext", "()V")

_return
}
Expand Down Expand Up @@ -146,7 +146,7 @@ object LwjglTransformer : IClassTransformer {
aload(1)

invokestatic(
"wtf/zani/spice/patcher/fixes/OpenGlFixes",
"org/polyfrost/spice/patcher/fixes/OpenGlFixes",
method.name,
method.desc
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.patcher.util
package org.polyfrost.spice.patcher.util

import org.lwjgl.openal.AL
import org.lwjgl.openal.ALC
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.polyfrost.spice.platform

import org.polyfrost.spice.Spice
import org.polyfrost.spice.platform.api.Platform

fun bootstrap(platform: Platform) {
Spice.initialize(platform)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package wtf.zani.spice.platform
package org.polyfrost.spice.platform

import wtf.zani.spice.patcher.lwjgl.LibraryTransformer
import wtf.zani.spice.patcher.lwjgl.LwjglTransformer
import wtf.zani.spice.platform.api.Transformer
import org.polyfrost.spice.patcher.lwjgl.LibraryTransformer
import org.polyfrost.spice.patcher.lwjgl.LwjglTransformer
import org.polyfrost.spice.platform.api.Transformer

fun bootstrapTransformer(transformer: Transformer) {
transformer.addTransformer(LwjglTransformer)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.platform.api
package org.polyfrost.spice.platform.api

import org.objectweb.asm.tree.ClassNode

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.platform.api
package org.polyfrost.spice.platform.api

interface Platform {
val id: ID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.platform.api
package org.polyfrost.spice.platform.api

import java.net.URL

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.util
package org.polyfrost.spice.util

fun isOptifineLoaded(): Boolean =
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.util
package org.polyfrost.spice.util

import org.lwjgl.system.Platform
import org.lwjgl.system.Platform.MACOSX
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.util
package org.polyfrost.spice.util

import java.io.ByteArrayInputStream
import java.io.InputStream
Expand Down

This file was deleted.

4 changes: 1 addition & 3 deletions modules/root.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@file:Suppress("UnstableApiUsage", "DEPRECATION")

// Shared build logic between all OneConfig modules to reduce boilerplate.
@file:Suppress("UnstableApiUsage")

plugins {
idea
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.platform.impl.fabric
package org.polyfrost.spice.platform.impl.fabric

import net.fabricmc.api.ModInitializer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package wtf.zani.spice.platform.impl.fabric
package org.polyfrost.spice.platform.impl.fabric

import wtf.zani.spice.platform.api.Platform
import org.polyfrost.spice.platform.api.Platform

class FabricPlatform : Platform {
init {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.platform.impl.fabric.asm
package org.polyfrost.spice.platform.impl.fabric.asm

import org.objectweb.asm.ClassWriter
import org.objectweb.asm.Opcodes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package wtf.zani.spice.platform.impl.fabric.asm
package org.polyfrost.spice.platform.impl.fabric.asm

import org.objectweb.asm.tree.ClassNode
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin
import org.spongepowered.asm.mixin.extensibility.IMixinInfo
import org.spongepowered.asm.service.MixinService
import wtf.zani.spice.platform.api.IClassTransformer
import wtf.zani.spice.platform.api.Transformer
import wtf.zani.spice.platform.bootstrapTransformer
import wtf.zani.spice.platform.impl.fabric.util.collectResources
import wtf.zani.spice.util.UrlByteArrayConnection
import org.polyfrost.spice.platform.api.IClassTransformer
import org.polyfrost.spice.platform.api.Transformer
import org.polyfrost.spice.platform.bootstrapTransformer
import org.polyfrost.spice.platform.impl.fabric.util.collectResources
import org.polyfrost.spice.util.UrlByteArrayConnection
import java.lang.reflect.Method
import java.net.URL
import java.net.URLClassLoader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wtf.zani.spice.platform.impl.fabric.util
package org.polyfrost.spice.platform.impl.fabric.util

import java.io.File
import java.net.URL
Expand Down
5 changes: 3 additions & 2 deletions versions/1.8.9-fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"id": "spice",
"version": "${version}",
"name": "Spice",
"description": "optimization & qol mod for minecraft 1.8",
"description": "optimization & qol mod for minecraft 1.8 and 1.12",
"authors": [
"Polyfrost",
"zani"
],
"contact": {
Expand All @@ -15,7 +16,7 @@
"environment": "client",
"entrypoints": {
"main": [
"wtf.zani.spice.platform.impl.fabric.FabricInitializer"
"org.polyfrost.spice.platform.impl.fabric.FabricInitializer"
]
},
"mixins": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"required": false,
"minVersion": "0.7",
"package": "wtf.zani.spice.transformer.generated",
"package": "org.polyfrost.spice.transformer.generated",
"compatibilityLevel": "JAVA_8",
"mixins": [],
"refmap": "transformer.mixins.refmap.json",
"plugin": "wtf.zani.spice.platform.impl.fabric.asm.TransformerPlugin",
"plugin": "org.polyfrost.spice.platform.impl.fabric.asm.TransformerPlugin",
"injectors": {
"defaultRequire": 1
}
Expand Down
Loading

0 comments on commit 8e7f1a4

Please sign in to comment.