Skip to content

Commit 030501b

Browse files
authored
Tons of fixes & Updated OneConfig (#12)
1 parent b8485a0 commit 030501b

File tree

5 files changed

+56
-29
lines changed

5 files changed

+56
-29
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins {
1616

1717
toolkitLoomHelper {
1818
useOneConfig {
19-
version = "1.0.0-alpha.153"
19+
version = "1.0.0-alpha.163"
2020
loaderVersion = "1.1.0-alpha.49"
2121
usePolyMixin = true
2222
polyMixinVersion = "0.8.4+build.6"

root.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ preprocess {
1313
"1.16.5-forge"(1_16_05, "srg") {
1414
"1.12.2-forge"(1_12_02, "srg") {
1515
"1.12.2-fabric"(1_12_02, "yarn") {
16-
"1.8.9-fabric"(1_08_09, "yarn"){
16+
"1.8.9-fabric"(1_08_09, "yarn") {
1717
"1.8.9-forge"(1_08_09, "srg")
1818
}
1919
}

src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import dev.deftu.omnicore.api.math.OmniVector3f
1919
import net.minecraft.entity.Entity
2020
import kotlin.math.abs
2121

22-
val STIPPLE_PATTERN: Short = 0xAAAA.toShort()
22+
const val STIPPLE_PATTERN: Short = 0xAAAA.toShort()
2323

2424
val HITBOX_SNIPPET: OmniRenderPipeline.Snippet = OmniRenderPipelineSnippets.builder().run {
2525
setDepthTest(OmniRenderPipeline.DepthTest.LESS_OR_EQUAL)
@@ -33,13 +33,13 @@ val HITBOX_SNIPPET: OmniRenderPipeline.Snippet = OmniRenderPipelineSnippets.buil
3333
}
3434

3535
val BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader(
36-
identifierOrThrow(PolyHitbox.MODID, "pipeline/box"),
36+
identifierOrThrow(PolyHitboxConstants.ID, "pipeline/box"),
3737
DefaultVertexFormats.POSITION_COLOR,
3838
DrawMode.QUADS
3939
).applySnippet(HITBOX_SNIPPET).build()
4040

4141
val OUTLINE_BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader(
42-
identifierOrThrow(PolyHitbox.MODID, "pipeline/outline_box"),
42+
identifierOrThrow(PolyHitboxConstants.ID, "pipeline/outline_box"),
4343
DefaultVertexFormats.POSITION_COLOR_NORMAL,
4444
DrawMode.LINES
4545
).applySnippet(HITBOX_SNIPPET).build()
@@ -49,7 +49,7 @@ val OUTLINE_STIPPLE_BOX_PIPELINE: OmniRenderPipeline = OUTLINE_BOX_PIPELINE.newB
4949
}.build()
5050

5151
val VIEW_RAY_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader(
52-
identifierOrThrow(PolyHitbox.MODID, "pipeline/view_ray"),
52+
identifierOrThrow(PolyHitboxConstants.ID, "pipeline/view_ray"),
5353
DefaultVertexFormats.POSITION_COLOR_NORMAL,
5454
DrawMode.LINES
5555
).applySnippet(HITBOX_SNIPPET).build()

src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
package org.polyfrost.polyhitbox
22

3+
//#if FABRIC
4+
import net.fabricmc.api.ClientModInitializer
5+
//#elseif FORGE
6+
//#if MC >= 1.16.5
7+
//$$ import net.minecraftforge.eventbus.api.IEventBus
8+
//$$ import net.minecraftforge.fml.common.Mod
9+
//$$ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
10+
//$$ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext
11+
//#else
12+
//$$ import net.minecraftforge.fml.common.Mod
13+
//$$ import net.minecraftforge.fml.common.event.FMLInitializationEvent
14+
//#endif
15+
//#endif
16+
317
import dev.deftu.omnicore.api.client.client
418
import org.apache.logging.log4j.LogManager
519
import org.polyfrost.oneconfig.api.config.v1.ConfigManager
620

7-
//#if FORGE
8-
//$$ @net.minecraftforge.fml.common.Mod(
9-
//#if MC >=1.20.1 || MC <=1.12.2
10-
//$$ modid = PolyHitbox.MODID,
11-
//$$ name = PolyHitbox.NAME,
12-
//$$ version = PolyHitbox.VERSION,
13-
//$$ modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter"
21+
//#if FORGE-LIKE
22+
//#if MC >= 1.16.5
23+
//$$ @Mod(PolyHitboxConstants.ID)
1424
//#else
15-
//$$ value = PolyHitbox.MODID
25+
//$$ @Mod(modid = PolyHitboxConstants.ID, version = PolyHitboxConstants.VERSION)
1626
//#endif
17-
//$$ )
1827
//#endif
1928
object PolyHitbox
2029
//#if FABRIC
21-
: net.fabricmc.api.ClientModInitializer
30+
: ClientModInitializer
2231
//#endif
2332
{
24-
const val MODID = "@MOD_ID@"
25-
const val NAME = "@MOD_NAME@"
26-
const val VERSION = "@MOD_VERSION@"
2733
private val LOGGER = LogManager.getLogger("PolyHitbox")
2834
private val hitboxInfo = HitboxInfo("hitbox.yaml")
2935

@@ -43,7 +49,20 @@ object PolyHitbox
4349
//#endif
4450
}
4551

46-
fun initialize() {
52+
//#if FABRIC
53+
override
54+
//#elseif FORGE && MC <= 1.12.2
55+
//$$ @Mod.EventHandler
56+
//#endif
57+
fun onInitializeClient(
58+
//#if FORGE-LIKE
59+
//#if MC >= 1.16.5
60+
//$$ event: FMLClientSetupEvent
61+
//#else
62+
//$$ event: FMLInitializationEvent
63+
//#endif
64+
//#endif
65+
) {
4766
hitboxInfo.tree.title = "PolyHitbox"
4867
hitboxInfo.tree = ConfigManager.active().register(hitboxInfo.tree).tree
4968
var enabled = false
@@ -59,17 +78,18 @@ object PolyHitbox
5978
//hitboxesEnabled = enabled
6079
//#endif
6180
}
81+
//#endif
6282

63-
// TODO: Fix 1.16.5 Forge (idk what changed)
64-
//#if FORGE
65-
//$$ @net.minecraftforge.fml.common.Mod.EventHandler
66-
//$$ fun onFMLInit(event: net.minecraftforge.fml.common.event.FMLInitializationEvent) {
67-
//$$ initialize()
83+
//#if FORGE && MC >= 1.16.5
84+
//$$ init {
85+
//$$ setupForgeEvents(FMLJavaModLoadingContext.get().modEventBus)
86+
//$$ }
87+
//#endif
88+
89+
//#if FORGE-LIKE && MC >= 1.16.5
90+
//$$ private fun setupForgeEvents(modEventBus: IEventBus) {
91+
//$$ modEventBus.addListener(this::onInitializeClient)
6892
//$$ }
69-
//#else
70-
override fun onInitializeClient() {
71-
initialize()
72-
}
7393
//#endif
7494

7595
fun getHitboxInfo(): HitboxInfo {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.polyfrost.polyhitbox
2+
3+
object PolyHitboxConstants {
4+
const val ID: String = "@MOD_ID@"
5+
const val NAME: String = "@MOD_NAME@"
6+
const val VERSION: String = "@MOD_VERSION@"
7+
}

0 commit comments

Comments
 (0)