Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {

toolkitLoomHelper {
useOneConfig {
version = "1.0.0-alpha.153"
version = "1.0.0-alpha.163"
loaderVersion = "1.1.0-alpha.49"
usePolyMixin = true
polyMixinVersion = "0.8.4+build.6"
Expand Down
2 changes: 1 addition & 1 deletion root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ preprocess {
"1.16.5-forge"(1_16_05, "srg") {
"1.12.2-forge"(1_12_02, "srg") {
"1.12.2-fabric"(1_12_02, "yarn") {
"1.8.9-fabric"(1_08_09, "yarn"){
"1.8.9-fabric"(1_08_09, "yarn") {
"1.8.9-forge"(1_08_09, "srg")
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import dev.deftu.omnicore.api.math.OmniVector3f
import net.minecraft.entity.Entity
import kotlin.math.abs

val STIPPLE_PATTERN: Short = 0xAAAA.toShort()
const val STIPPLE_PATTERN: Short = 0xAAAA.toShort()

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

val BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader(
identifierOrThrow(PolyHitbox.MODID, "pipeline/box"),
identifierOrThrow(PolyHitboxConstants.ID, "pipeline/box"),
DefaultVertexFormats.POSITION_COLOR,
DrawMode.QUADS
).applySnippet(HITBOX_SNIPPET).build()

val OUTLINE_BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader(
identifierOrThrow(PolyHitbox.MODID, "pipeline/outline_box"),
identifierOrThrow(PolyHitboxConstants.ID, "pipeline/outline_box"),
DefaultVertexFormats.POSITION_COLOR_NORMAL,
DrawMode.LINES
).applySnippet(HITBOX_SNIPPET).build()
Expand All @@ -49,7 +49,7 @@ val OUTLINE_STIPPLE_BOX_PIPELINE: OmniRenderPipeline = OUTLINE_BOX_PIPELINE.newB
}.build()

val VIEW_RAY_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader(
identifierOrThrow(PolyHitbox.MODID, "pipeline/view_ray"),
identifierOrThrow(PolyHitboxConstants.ID, "pipeline/view_ray"),
DefaultVertexFormats.POSITION_COLOR_NORMAL,
DrawMode.LINES
).applySnippet(HITBOX_SNIPPET).build()
Expand Down
66 changes: 43 additions & 23 deletions src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
package org.polyfrost.polyhitbox

//#if FABRIC
import net.fabricmc.api.ClientModInitializer
//#elseif FORGE
//#if MC >= 1.16.5
//$$ import net.minecraftforge.eventbus.api.IEventBus
//$$ import net.minecraftforge.fml.common.Mod
//$$ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
//$$ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext
//#else
//$$ import net.minecraftforge.fml.common.Mod
//$$ import net.minecraftforge.fml.common.event.FMLInitializationEvent
//#endif
//#endif

import dev.deftu.omnicore.api.client.client
import org.apache.logging.log4j.LogManager
import org.polyfrost.oneconfig.api.config.v1.ConfigManager

//#if FORGE
//$$ @net.minecraftforge.fml.common.Mod(
//#if MC >=1.20.1 || MC <=1.12.2
//$$ modid = PolyHitbox.MODID,
//$$ name = PolyHitbox.NAME,
//$$ version = PolyHitbox.VERSION,
//$$ modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter"
//#if FORGE-LIKE
//#if MC >= 1.16.5
//$$ @Mod(PolyHitboxConstants.ID)
//#else
//$$ value = PolyHitbox.MODID
//$$ @Mod(modid = PolyHitboxConstants.ID, version = PolyHitboxConstants.VERSION)
//#endif
//$$ )
//#endif
object PolyHitbox
//#if FABRIC
: net.fabricmc.api.ClientModInitializer
: ClientModInitializer
//#endif
{
const val MODID = "@MOD_ID@"
const val NAME = "@MOD_NAME@"
const val VERSION = "@MOD_VERSION@"
private val LOGGER = LogManager.getLogger("PolyHitbox")
private val hitboxInfo = HitboxInfo("hitbox.yaml")

Expand All @@ -43,7 +49,20 @@ object PolyHitbox
//#endif
}

fun initialize() {
//#if FABRIC
override
//#elseif FORGE && MC <= 1.12.2
//$$ @Mod.EventHandler
//#endif
fun onInitializeClient(
//#if FORGE-LIKE
//#if MC >= 1.16.5
//$$ event: FMLClientSetupEvent
//#else
//$$ event: FMLInitializationEvent
//#endif
//#endif
) {
hitboxInfo.tree.title = "PolyHitbox"
hitboxInfo.tree = ConfigManager.active().register(hitboxInfo.tree).tree
var enabled = false
Expand All @@ -59,17 +78,18 @@ object PolyHitbox
//hitboxesEnabled = enabled
//#endif
}
//#endif

// TODO: Fix 1.16.5 Forge (idk what changed)
//#if FORGE
//$$ @net.minecraftforge.fml.common.Mod.EventHandler
//$$ fun onFMLInit(event: net.minecraftforge.fml.common.event.FMLInitializationEvent) {
//$$ initialize()
//#if FORGE && MC >= 1.16.5
//$$ init {
//$$ setupForgeEvents(FMLJavaModLoadingContext.get().modEventBus)
//$$ }
//#endif

//#if FORGE-LIKE && MC >= 1.16.5
//$$ private fun setupForgeEvents(modEventBus: IEventBus) {
//$$ modEventBus.addListener(this::onInitializeClient)
//$$ }
//#else
override fun onInitializeClient() {
initialize()
}
//#endif

fun getHitboxInfo(): HitboxInfo {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.polyfrost.polyhitbox

object PolyHitboxConstants {
const val ID: String = "@MOD_ID@"
const val NAME: String = "@MOD_NAME@"
const val VERSION: String = "@MOD_VERSION@"
}
Loading