Skip to content

Commit 661dbbe

Browse files
committed
Fix issues and adhere to template/guidelines
1 parent cb023de commit 661dbbe

File tree

7 files changed

+62
-45
lines changed

7 files changed

+62
-45
lines changed

src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import net.minecraft.client.render.entity.EntityRenderDispatcher;
99
import net.minecraft.entity.Entity;
1010
import net.minecraft.entity.LivingEntity;
11-
import org.polyfrost.polyhitbox.HitboxRendererKt;
11+
import org.polyfrost.polyhitbox.client.HitboxRendererKt;
1212
import org.spongepowered.asm.mixin.Mixin;
1313
import org.spongepowered.asm.mixin.injection.At;
1414
import org.spongepowered.asm.mixin.injection.Inject;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ object PolyHitboxConstants {
44
const val ID: String = "@MOD_ID@"
55
const val NAME: String = "@MOD_NAME@"
66
const val VERSION: String = "@MOD_VERSION@"
7-
}
7+
}

src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt renamed to src/main/kotlin/org/polyfrost/polyhitbox/PolyHitboxEntrypoint.kt

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import net.fabricmc.api.ClientModInitializer
1414
//#endif
1515
//#endif
1616

17-
import dev.deftu.omnicore.api.client.client
18-
import org.polyfrost.oneconfig.api.config.v1.ConfigManager
17+
import org.polyfrost.polyhitbox.client.PolyHitboxClient
1918

2019
//#if FORGE-LIKE
2120
//#if MC >= 1.16.5
@@ -24,29 +23,11 @@ import org.polyfrost.oneconfig.api.config.v1.ConfigManager
2423
//$$ @Mod(modid = PolyHitboxConstants.ID, version = PolyHitboxConstants.VERSION)
2524
//#endif
2625
//#endif
27-
object PolyHitbox
26+
class PolyHitboxEntrypoint
2827
//#if FABRIC
2928
: ClientModInitializer
3029
//#endif
3130
{
32-
private val hitboxInfo = HitboxInfo("hitbox.yaml")
33-
34-
private var hitboxesEnabled: Boolean
35-
get() {
36-
//#if MC < 1.14
37-
//$$ return client.renderManager.isDebugBoundingBox
38-
//#else
39-
return client.entityRenderDispatcher.shouldRenderHitboxes()
40-
//#endif
41-
}
42-
set(value) {
43-
//#if MC < 1.14
44-
//$$ client.renderManager.isDebugBoundingBox = value
45-
//#else
46-
client.entityRenderDispatcher.setRenderHitboxes(value)
47-
//#endif
48-
}
49-
5031
//#if FABRIC
5132
override
5233
//#elseif FORGE && MC <= 1.12.2
@@ -61,20 +42,13 @@ object PolyHitbox
6142
//#endif
6243
//#endif
6344
) {
64-
hitboxInfo.tree.title = "PolyHitbox"
65-
hitboxInfo.tree = ConfigManager.active().register(hitboxInfo.tree).tree
66-
var enabled = false
67-
if (hitboxInfo.showMode != 2) {
68-
enabled = true
69-
}
70-
71-
//#if FABRIC && MC > 1.14
72-
net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents.CLIENT_STARTED.register { tick ->
73-
hitboxesEnabled = enabled
74-
}
75-
//#else
76-
//hitboxesEnabled = enabled
45+
//#if FORGE && MC <= 1.12.2
46+
//$$ if (!event.side.isClient) {
47+
//$$ return
48+
//$$ }
7749
//#endif
50+
51+
PolyHitboxClient.initialize()
7852
}
7953

8054
//#if FORGE && MC >= 1.16.5
@@ -88,8 +62,4 @@ object PolyHitbox
8862
//$$ modEventBus.addListener(this::onInitializeClient)
8963
//$$ }
9064
//#endif
91-
92-
fun getHitboxInfo(): HitboxInfo {
93-
return hitboxInfo
94-
}
9565
}

src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt renamed to src/main/kotlin/org/polyfrost/polyhitbox/client/HitboxInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.polyfrost.polyhitbox
1+
package org.polyfrost.polyhitbox.client
22

33
import dev.deftu.omnicore.api.color.OmniColor
44
import org.polyfrost.oneconfig.api.config.v1.Properties.ktProperty

src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt renamed to src/main/kotlin/org/polyfrost/polyhitbox/client/HitboxRenderer.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.polyfrost.polyhitbox
1+
package org.polyfrost.polyhitbox.client
22

33
import dev.deftu.omnicore.api.client.render.DefaultVertexFormats
44
import dev.deftu.omnicore.api.client.render.DrawMode
@@ -16,6 +16,8 @@ import dev.deftu.omnicore.api.data.shape.OmniVoxelShapes
1616
import dev.deftu.omnicore.api.data.vec.OmniVec3d
1717
import dev.deftu.omnicore.api.identifierOrThrow
1818
import dev.deftu.omnicore.api.math.OmniVector3f
19+
import org.polyfrost.polyhitbox.PolyHitboxConstants
20+
import org.polyfrost.polyhitbox.PolyHitboxEntrypoint
1921
import kotlin.math.abs
2022

2123
const val STIPPLE_PATTERN: Short = 0xAAAA.toShort()
@@ -69,7 +71,7 @@ fun renderHitbox(
6971
collisionSize: Double,
7072
boundingBox: OmniAABB,
7173
) {
72-
val info = PolyHitbox.getHitboxInfo()
74+
val info = PolyHitboxClient.getHitboxInfo()
7375
when (info.showMode) {
7476
0 -> info.isTargeted = isTargeted
7577
1 -> if (!isTargeted) return else info.isTargeted = true
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.polyfrost.polyhitbox.client
2+
3+
import dev.deftu.omnicore.api.client.client
4+
import org.polyfrost.oneconfig.api.config.v1.ConfigManager
5+
6+
object PolyHitboxClient {
7+
private val hitboxInfo = HitboxInfo("hitbox.yaml")
8+
9+
private var hitboxesEnabled: Boolean
10+
get() {
11+
//#if MC < 1.14
12+
//$$ return client.renderManager.isDebugBoundingBox
13+
//#else
14+
return client.entityRenderDispatcher.shouldRenderHitboxes()
15+
//#endif
16+
}
17+
set(value) {
18+
//#if MC < 1.14
19+
//$$ client.renderManager.isDebugBoundingBox = value
20+
//#else
21+
client.entityRenderDispatcher.setRenderHitboxes(value)
22+
//#endif
23+
}
24+
25+
fun initialize() {
26+
hitboxInfo.tree.title = "PolyHitbox"
27+
hitboxInfo.tree = ConfigManager.active().register(hitboxInfo.tree).tree
28+
var enabled = false
29+
if (hitboxInfo.showMode != 2) {
30+
enabled = true
31+
}
32+
33+
//#if FABRIC && MC > 1.14
34+
net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents.CLIENT_STARTED.register { tick ->
35+
hitboxesEnabled = enabled
36+
}
37+
//#else
38+
//hitboxesEnabled = enabled
39+
//#endif
40+
}
41+
42+
fun getHitboxInfo(): HitboxInfo {
43+
return hitboxInfo
44+
}
45+
}

src/main/resources/fabric.mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
"entrypoints": {
1313
"client": [
1414
{
15-
"value": "org.polyfrost.polyhitbox.PolyHitbox",
15+
"value": "org.polyfrost.polyhitbox.PolyHitboxEntrypoint",
1616
"adapter": "kotlin"
1717
}
1818
]
1919
},
2020
"mixins": [
2121
"mixins.${mod_id}.json"
2222
]
23-
}
23+
}

0 commit comments

Comments
 (0)