Skip to content

Commit

Permalink
fixDebugBoundingBox being offset up for the player (#104)
Browse files Browse the repository at this point in the history
* fixDebugBoundingBox

* forgot Side.CLIENT
  • Loading branch information
Alexdoru authored Sep 9, 2022
1 parent 921ae36 commit 817ae42
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class LoadingConfig {
public boolean fixPotionRenderOffset;
public boolean fixPotionLimit;
public boolean fixPerspectiveCamera;
public boolean fixDebugBoundingBox;
public boolean fixHopperVoidingItems;
public boolean fixHugeChatKick;
public boolean logHugeChat;
Expand Down Expand Up @@ -170,6 +171,9 @@ public LoadingConfig(File file) {
true,
"Prevent tall grass and such to affect the perspective camera")
.getBoolean();
fixDebugBoundingBox = config.get(
"fixes", "fixDebugBoundingBox", true, "Fixes the debug hitbox of the player beeing offset")
.getBoolean();
fixGlStateBugs = config.get(
"fixes",
"fixGlStateBugs",
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
public enum Mixins {
// Vanilla Fixes
FIX_PERSPECTIVE_CAMERA(
"minecraft.MixinEntityRenderer", () -> Hodgepodge.config.fixPerspectiveCamera, TargetedMod.VANILLA),
"minecraft.MixinEntityRenderer",
Side.CLIENT,
() -> Hodgepodge.config.fixPerspectiveCamera,
TargetedMod.VANILLA),
FIX_DEBUG_BOUNDING_BOX(
"minecraft.MixinRenderManager",
Side.CLIENT,
() -> Hodgepodge.config.fixDebugBoundingBox,
TargetedMod.VANILLA),
FENCE_CONNECTIONS_FIX(
"minecraft.MixinBlockFence", () -> Hodgepodge.config.fixFenceConnections, TargetedMod.VANILLA),
FIX_INVENTORY_OFFSET_WITH_POTIONS(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.mitchej123.hodgepodge.mixins.minecraft;

import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(RenderManager.class)
public class MixinRenderManager {

@Redirect(
method = "renderDebugBoundingBox",
at =
@At(
value = "INVOKE",
target =
"Lnet/minecraft/util/AxisAlignedBB;getBoundingBox(DDDDDD)Lnet/minecraft/util/AxisAlignedBB;"))
public AxisAlignedBB hodgepodge$fixDebugBoundingBox(
double minX,
double minY,
double minZ,
double maxX,
double maxY,
double maxZ,
Entity entity,
double p_85094_2_,
double p_85094_4_,
double p_85094_6_,
float p_85094_8_,
float p_85094_9_) {
if (entity instanceof EntityPlayerSP) {
final float offset = -1.62F + (entity.isSneaking() ? 0.08F : 0);
return AxisAlignedBB.getBoundingBox(minX, minY + offset, minZ, maxX, maxY + offset, maxZ);
}
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
}

0 comments on commit 817ae42

Please sign in to comment.