mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
Fix renders being incorrectly offset while sneaking
This commit is contained in:
1 parent
e1f7dfe9f1
commit
5c08d92b40
4 files changed
+33
-4
No files matched your search
@@ -40,6 +40,7 @@ import crazypants.enderio.item.darksteel.upgrade.NightVisionUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SolarUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SpeedUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.SwimUpgrade;
|
||||
import crazypants.enderio.item.darksteel.upgrade.IRenderUpgrade.Helper;
|
||||
import crazypants.enderio.machine.solar.TileEntitySolarPanel;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.util.Util;
|
||||
@@ -428,6 +429,9 @@ public class DarkSteelController {
|
||||
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
if(player.isSneaking()) {
|
||||
GL11.glTranslatef(0, 0.0625f, 0);
|
||||
}
|
||||
GL11.glRotatef(yawOffset, 0, -1, 0);
|
||||
GL11.glRotatef(yaw - 270, 0, 1, 0);
|
||||
GL11.glRotatef(pitch, 0, 0, 1);
|
||||
|
||||
@@ -83,8 +83,9 @@ public class GliderUpgrade extends AbstractUpgrade {
|
||||
RenderUtil.bindItemTexture();
|
||||
glDepthMask(true);
|
||||
item.hoverStart = 0;
|
||||
Helper.rotateIfSneaking(event.entityPlayer);
|
||||
GL11.glTranslatef(-0, 1, 0.25f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 1, 0, 0);
|
||||
GL11.glScalef(3, 3, 3);
|
||||
RenderManager.instance.renderEntityWithPosYaw(item, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,34 @@
|
||||
package crazypants.enderio.item.darksteel.upgrade;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public interface IRenderUpgrade {
|
||||
|
||||
void render(RenderPlayerEvent event, ItemStack stack, boolean head);
|
||||
|
||||
/**
|
||||
* A few helper methods for rendering. Credit to Vazkii, used from Botania.
|
||||
* {@link #translateToHeadLevel(EntityPlayer)} edited to remove sneaking
|
||||
* translation.
|
||||
*/
|
||||
public static class Helper {
|
||||
|
||||
public static void rotateIfSneaking(EntityPlayer player) {
|
||||
if (player.isSneaking())
|
||||
applySneakingRotation();
|
||||
}
|
||||
|
||||
public static void applySneakingRotation() {
|
||||
GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
public static void translateToHeadLevel(EntityPlayer player) {
|
||||
GL11.glTranslated(0, (player != Minecraft.getMinecraft().thePlayer ? 1.62F : -0.08F) - player.getDefaultEyeHeight(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.darksteel.DarkSteelItems;
|
||||
import crazypants.enderio.item.darksteel.upgrade.IRenderUpgrade.Helper;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.glDepthMask;
|
||||
|
||||
public class SolarUpgrade extends AbstractUpgrade {
|
||||
@@ -106,7 +106,7 @@ public class SolarUpgrade extends AbstractUpgrade {
|
||||
public IRenderUpgrade getRender() {
|
||||
return render;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class Render implements IRenderUpgrade {
|
||||
|
||||
@@ -120,8 +120,8 @@ public class SolarUpgrade extends AbstractUpgrade {
|
||||
RenderUtil.bindItemTexture();
|
||||
glDepthMask(true);
|
||||
item.hoverStart = 0;
|
||||
Helper.translateToHeadLevel(event.entityPlayer);
|
||||
GL11.glTranslated(0, -0.08, 0);
|
||||
GL11.glTranslated(0, (event.entityPlayer != Minecraft.getMinecraft().thePlayer ? 1.62F : 0F) - event.entityPlayer.getDefaultEyeHeight() + (event.entityPlayer.isSneaking() ? 0.0625 : 0), 0);
|
||||
GL11.glRotated(180, 1, 0, 0);
|
||||
GL11.glScalef(2.1f, 2.1f, 2.1f);
|
||||
byte level = loadFromItem(stack).level;
|
||||
|
||||
Reference in new issue
Block a user