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
27 changes: 6 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,18 @@ plugins {

toolkitLoomHelper {
useOneConfig {
version = "1.0.0-alpha.70"
loaderVersion = "1.1.0-alpha.44"

version = "1.0.0-alpha.153"
loaderVersion = "1.1.0-alpha.49"
usePolyMixin = true
polyMixinVersion = "0.8.4+build.2"

polyMixinVersion = "0.8.4+build.6"
applyLoaderTweaker = true

for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) {
+module
}
}

useDevAuth("1.2.1")
useMixinExtras("0.4.1")
useMixinExtras("0.5.0")

// Turns off the server-side run configs, as we're building a client-sided mod.
disableRunConfigs(GameSide.SERVER)
Expand All @@ -43,17 +41,4 @@ toolkitLoomHelper {
// Configures the Mixin tweaker if we are building for Forge.
useForgeMixin(modData.id)
}
}

dependencies {
// Add (Legacy) Fabric API as dependencies (these are both optional but are particularly useful).
if (mcData.isFabric) {
if (mcData.isLegacyFabric) {
// 1.8.9 - 1.13
modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}")
} else {
// 1.16.5+
modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}")
}
}
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ org.gradle.parallel=true
org.gradle.configureoncommand=true
org.gradle.parallel.threads=4
org.gradle.jvmargs=-Xmx2G
loom.ignoreDependencyLoomVersionValidation=true

mod.group=org.polyfrost
mod.id=polyhitbox
Expand Down
26 changes: 25 additions & 1 deletion root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,29 @@ plugins {
}

preprocess {
"1.8.9-forge"(10809, "srg")
"1.21.8-fabric"(1_21_08, "yarn") {
"1.21.5-fabric"(1_21_05, "yarn") {
"1.21.4-fabric"(1_21_04, "yarn") {
"1.21.1-fabric"(1_21_01, "yarn") {
"1.20.4-fabric"(1_20_04, "yarn") {
"1.20.1-fabric"(1_20_01, "yarn") {
"1.16.5-fabric"(1_16_05, "yarn") {
"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-forge"(1_08_09, "srg")
}
}
}
}
}
}
}
}
}
}
}

strictExtraMappings.set(true)
}
18 changes: 15 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,31 @@ pluginManagement {
}

plugins {
kotlin("jvm") version("2.0.0")
id("dev.deftu.gradle.multiversion-root") version("2.35.0")
kotlin("jvm") version ("2.2.10")
id("dev.deftu.gradle.multiversion-root") version ("2.51.0")
}
}

val projectName: String = extra["mod.name"]?.toString()
?: throw MissingPropertyException("mod.name has not been set.")
rootProject.name = projectName

rootProject.buildFileName = "root.gradle.kts"

// Adds all of our build target versions to the classpath if we need to add version-specific code.
listOf(
"1.8.9-forge"
"1.8.9-forge",
"1.8.9-fabric",
"1.12.2-forge",
"1.12.2-fabric",
"1.16.5-forge",
"1.16.5-fabric",
"1.20.1-fabric",
"1.20.4-fabric",
"1.21.1-fabric",
"1.21.4-fabric",
"1.21.5-fabric",
"1.21.8-fabric"
).forEach { version ->
include(":$version")
project(":$version").apply {
Expand Down
122 changes: 122 additions & 0 deletions src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package org.polyfrost.polyhitbox.mixin;

import dev.deftu.omnicore.api.client.OmniClient;
import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStack;
import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStacks;
import dev.deftu.omnicore.api.data.vec.OmniVec3d;
import dev.deftu.omnicore.api.entity.OmniEntities;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import org.polyfrost.polyhitbox.HitboxRendererKt;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

//#if MC >=1.21.5
import net.minecraft.client.render.entity.state.EntityHitbox;
//#endif

//#if MC >=1.16.5
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import org.spongepowered.asm.mixin.Unique;
//#endif

@Mixin(EntityRenderDispatcher.class)
public abstract class MixinRenderManager {
//#if MC >=1.21.5
@Unique
private static ThreadLocal<Entity> polyhitbox$entity = ThreadLocal.withInitial(() -> null);
//#endif

@Inject(
//#if MC >=1.16.5
method = "renderHitbox",
//#else
//$$ method = "renderDebugBoundingBox",
//#endif
at = @At("HEAD"),
cancellable = true
)
//#if MC >=1.16.5
private
//#if MC >=1.20.1
static
//#endif
void polyhitbox$customRendering(
MatrixStack matrixStack,
VertexConsumer vertexConsumer,
//#if MC >=1.21.5
EntityHitbox entityHitbox,
//#else
//$$ Entity entity,
//$$ float tickDelta,
//#if MC >=1.21.1
//$$ float offsetX, float offsetY, float offsetZ,
//#endif
//#endif
CallbackInfo ci
) {
//#else
//$$ private void polyhitbox$customRendering(Entity entity, double offsetX, double offsetY, double offsetZ, float yaw, float tickDelta, CallbackInfo ci) {
//#endif
ci.cancel();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overwrite

OmniMatrixStack stack = OmniMatrixStacks.vanilla(
//#if MC >=1.16.5
matrixStack
//#endif
);

//#if MC >=1.21.5
Entity entity = polyhitbox$entity.get();
OmniVec3d offset = new OmniVec3d(entityHitbox.comp_3855(), entityHitbox.comp_3856(), entityHitbox.comp_3857());
//#else
//$$ OmniVec3d offset = OmniVec3d.ZERO;
//#endif

HitboxRendererKt.renderHitbox(
stack,
offset,
OmniEntities.getCurrentPos(entity),
new OmniVec3d(entity.getRotationVector()),
entity.getStandingEyeHeight(),
entity instanceof LivingEntity,
entity == OmniClient.get().targetedEntity,
//#if MC >=1.16.5
entity.getWidth(),
//#else
//$$ entity.width,
//#endif
entity.getTargetingMargin(),
OmniEntities.getRenderBoundingBox(entity)
);
}

//#if MC >=1.21.5
@com.llamalad7.mixinextras.injector.v2.WrapWithCondition(method = "renderHitboxes(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/entity/state/EntityHitboxAndView;Lnet/minecraft/client/render/VertexConsumer;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/VertexRendering;drawVector(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lorg/joml/Vector3f;Lnet/minecraft/util/math/Vec3d;I)V"))
private static boolean polyhitbox$removeViewRay(
net.minecraft.client.util.math.MatrixStack matrixStack,
net.minecraft.client.render.VertexConsumer vertexConsumer,
org.joml.Vector3f vector3f,
net.minecraft.util.math.Vec3d vec3d,
int i
) {
return false;
}

@Inject(method = "render(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"))
private static void polyhitbox$storeEntity(
Entity entity,
double x, double y, double z, float tickDelta,
MatrixStack matrixStack,
VertexConsumerProvider vertexConsumerProvider,
int i,
CallbackInfo ci
) {
polyhitbox$entity.set(entity);
}
//#endif
}
Loading
Loading