Skip to content

Commit 2ec3b1c

Browse files
committed
Fix cape tab
1 parent 14f0b04 commit 2ec3b1c

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

src/main/java/org/samo_lego/fabrictailor/client/screen/SkinChangeScreen.java

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
import net.minecraft.client.player.LocalPlayer;
1919
import net.minecraft.network.chat.CommonComponents;
2020
import net.minecraft.network.chat.Component;
21+
import net.minecraft.world.entity.LivingEntity;
22+
import org.joml.Quaternionf;
23+
import org.joml.Vector3f;
2124
import org.samo_lego.fabrictailor.casts.TailoredPlayer;
2225
import org.samo_lego.fabrictailor.client.screen.tabs.CapeTab;
2326
import org.samo_lego.fabrictailor.client.screen.tabs.LocalSkinTab;
@@ -234,28 +237,10 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
234237
float f = (float) Math.atan(mousex / 40.0f);
235238
float g = (float) Math.atan(mousey / 40.0f);
236239

237-
float yBodyRot = player.yBodyRot;
238-
float yRot = player.getYRot();
239-
float xRot = player.getXRot();
240-
float yHeadRotO = player.yHeadRotO;
241-
float yHeadRot = player.yHeadRot;
242-
243-
player.yBodyRot += 180.0f;
244-
player.setYRot(yRot + 180f);
245-
player.setXRot(xRot + 180.0f);
246-
player.yHeadRot += 180.0f;
247-
player.yHeadRotO += 180.0f;
248-
249-
250240
int x = this.startX + 24;
251241
int y = this.startY - 76;
252-
InventoryScreen.renderEntityInInventoryFollowsMouse(guiGraphics, x, y, x + 75, y + 208, 48, 1.0f, -mouseX - 2, mouseY - 16, this.minecraft.player);
242+
renderEntityInInventoryFollowsMouseBackwards(guiGraphics, x, y, x + 75, y + 208, 48, 1.0f, mouseX + 2, mouseY - 16, this.minecraft.player);
253243

254-
player.yBodyRot = yBodyRot;
255-
player.setYRot(yRot);
256-
player.setXRot(xRot);
257-
player.yHeadRotO = yHeadRotO;
258-
player.yHeadRot = yHeadRot;
259244
} else {
260245
// Drawing Player
261246
// Luckily vanilla code is available
@@ -265,6 +250,41 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
265250
}
266251
}
267252

253+
public void renderEntityInInventoryFollowsMouseBackwards(GuiGraphics guiGraphics, int i, int j, int k, int l, int m, float f, float g, float h, LivingEntity livingEntity) {
254+
float mousex = -(((float) width / 2) - 75 - g);
255+
float mousey = ((float) height / 2) - h;
256+
float n = (float) (i + k) / 2.0F;
257+
float o = (float) (j + l) / 2.0F;
258+
float p = (float) Math.atan(mousex / 40.0f);
259+
float q = (float) Math.atan(mousey / 40.0f);
260+
guiGraphics.enableScissor(i, j, k, l);
261+
//float p = (float) Math.atan((double) ((n - g) / 40.0F));
262+
//float q = (float) Math.atan((double) ((o - h) / 40.0F));
263+
Quaternionf quaternionf = (new Quaternionf()).rotateZ(3.1415927F);
264+
Quaternionf quaternionf2 = (new Quaternionf()).rotateX(q * 20.0F * 0.017453292F);
265+
quaternionf.mul(quaternionf2);
266+
float r = livingEntity.yBodyRot;
267+
float s = livingEntity.getYRot();
268+
float t = livingEntity.getXRot();
269+
float u = livingEntity.yHeadRotO;
270+
float v = livingEntity.yHeadRot;
271+
livingEntity.yBodyRot = p * 40.0F;
272+
livingEntity.setYRot(p * 40.0F);
273+
livingEntity.setXRot(-q * 40.0F);
274+
livingEntity.yHeadRot = livingEntity.getYRot();
275+
livingEntity.yHeadRotO = livingEntity.getYRot();
276+
float w = livingEntity.getScale();
277+
Vector3f vector3f = new Vector3f(0.0F, livingEntity.getBbHeight() / 2.0F + f * w, 0.0F);
278+
float x = (float) m / w;
279+
InventoryScreen.renderEntityInInventory(guiGraphics, n, o, x, vector3f, quaternionf, quaternionf2, livingEntity);
280+
livingEntity.yBodyRot = r;
281+
livingEntity.setYRot(s);
282+
livingEntity.setXRot(t);
283+
livingEntity.yHeadRotO = u;
284+
livingEntity.yHeadRot = v;
285+
guiGraphics.disableScissor();
286+
}
287+
268288
/**
269289
* Draws tabs.
270290
*

0 commit comments

Comments
 (0)