-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cosmetic preview doll not displaying at all.
- Loading branch information
Showing
3 changed files
with
70 additions
and
35 deletions.
There are no files selected for viewing
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
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
60 changes: 60 additions & 0 deletions
60
src/main/java/net/asodev/islandutils/modules/cosmetics/CosmeticUI.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,60 @@ | ||
package net.asodev.islandutils.modules.cosmetics; | ||
|
||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.screens.inventory.InventoryScreen; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import org.joml.Quaternionf; | ||
import org.joml.Vector3f; | ||
|
||
public class CosmeticUI { | ||
|
||
public static void renderPlayerInInventory(GuiGraphics guiGraphics, int x, int y, int size, LivingEntity livingEntity) { | ||
float yRot = CosmeticState.yRot; | ||
float xRot = (float)Math.atan(CosmeticState.xRot / 40.0f); | ||
|
||
// save rotations | ||
float preYBodyRot = livingEntity.yBodyRot; | ||
float preYRot = livingEntity.getYRot(); | ||
float preXrot = livingEntity.getXRot(); | ||
float preYHeadRot0 = livingEntity.yHeadRotO; | ||
float preYHeadRot = livingEntity.yHeadRot; | ||
|
||
// set rotations | ||
livingEntity.yBodyRot = yRot; | ||
livingEntity.setYRot(yRot); | ||
livingEntity.yHeadRot = livingEntity.yBodyRot; | ||
livingEntity.yHeadRotO = livingEntity.yBodyRot; | ||
livingEntity.setXRot(xRot * -20f); // magic value - InventoryScreen#renderEntityInInventoryFollowsMouse [setXRot] | ||
|
||
guiGraphics.pose().pushPose(); | ||
guiGraphics.pose().translate(0f, 0f, 105f); // translate to 105 on the z | ||
float f = 0.0625F; // magic value - InventoryScreen#renderBg [renderEntityInInventoryFollowsMouse] | ||
float livingEntityScale = livingEntity.getScale(); | ||
|
||
// here we make some quaternions and do some math with them | ||
// idfk this is just what the inventory code does :sob: | ||
// magic values - InventoryScreen#renderEntityInInventoryFollowsMouse | ||
Quaternionf quaternionf = (new Quaternionf()).rotateZ(3.1415927F); | ||
Quaternionf quaternionf2 = (new Quaternionf()).rotateX(xRot * 20.0F * 0.017453292F); | ||
quaternionf.mul(quaternionf2); | ||
Vector3f vector3f = new Vector3f(0.0F, livingEntity.getBbHeight() / 2.0F + f * livingEntityScale, 0.0F); | ||
InventoryScreen.renderEntityInInventory( | ||
guiGraphics, | ||
x, y - size, | ||
size / livingEntityScale, | ||
vector3f, | ||
quaternionf, | ||
quaternionf2, | ||
livingEntity | ||
); | ||
guiGraphics.pose().popPose(); | ||
|
||
// restore rotations | ||
livingEntity.yBodyRot = preYBodyRot; | ||
livingEntity.setYRot(preYRot); | ||
livingEntity.setXRot(preXrot); | ||
livingEntity.yHeadRotO = preYHeadRot0; | ||
livingEntity.yHeadRot = preYHeadRot; | ||
} | ||
|
||
} |