forked from c0508383/Backhand
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract offhand rendering to a hook class for Angelica (#63)
- Loading branch information
Showing
2 changed files
with
56 additions
and
33 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/main/java/xonin/backhand/client/hooks/ItemRendererHooks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package xonin.backhand.client.hooks; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.EntityClientPlayerMP; | ||
import net.minecraft.item.ItemMap; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import org.lwjgl.opengl.GL11; | ||
|
||
import xonin.backhand.api.core.BackhandUtils; | ||
import xonin.backhand.api.core.IBackhandPlayer; | ||
import xonin.backhand.client.utils.BackhandRenderHelper; | ||
import xonin.backhand.utils.BackhandConfig; | ||
import xonin.backhand.utils.BackhandConfigClient; | ||
|
||
public class ItemRendererHooks { | ||
|
||
/** | ||
* Extracted outside the mixin to be used in Angelica for Backhand compat | ||
* | ||
* @param frame | ||
*/ | ||
public static void renderOffhandReturn(float frame) { | ||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; | ||
if (BackhandUtils.isUsingOffhand(player)) return; | ||
|
||
ItemStack mainhandItem = player.getCurrentEquippedItem(); | ||
ItemStack offhandItem = BackhandUtils.getOffhandItem(player); | ||
if (!BackhandConfig.EmptyOffhand && !BackhandConfigClient.RenderEmptyOffhandAtRest && offhandItem == null) { | ||
return; | ||
} | ||
if (offhandItem == null && !BackhandConfigClient.RenderEmptyOffhandAtRest | ||
&& ((IBackhandPlayer) player).getOffSwingProgress(frame) == 0) { | ||
return; | ||
} | ||
if (mainhandItem != null && mainhandItem.getItem() instanceof ItemMap) { | ||
return; | ||
} | ||
|
||
BackhandRenderHelper.firstPersonFrame = frame; | ||
GL11.glEnable(GL11.GL_CULL_FACE); | ||
GL11.glCullFace(GL11.GL_FRONT); | ||
GL11.glPushMatrix(); | ||
GL11.glScalef(-1, 1, 1); | ||
float f3 = player.prevRenderArmPitch + (player.renderArmPitch - player.prevRenderArmPitch) * frame; | ||
float f4 = player.prevRenderArmYaw + (player.renderArmYaw - player.prevRenderArmYaw) * frame; | ||
GL11.glRotatef((player.rotationPitch - f3) * -0.1F, 1.0F, 0.0F, 0.0F); | ||
GL11.glRotatef((player.rotationYaw - f4) * -0.1F, 0.0F, 1.0F, 0.0F); | ||
BackhandUtils | ||
.useOffhandItem(player, false, () -> BackhandRenderHelper.itemRenderer.renderItemInFirstPerson(frame)); | ||
GL11.glPopMatrix(); | ||
GL11.glCullFace(GL11.GL_BACK); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters