Skip to content

Commit

Permalink
Merge pull request #371 from iocmet/master
Browse files Browse the repository at this point in the history
Fix elytra not renders in first person
  • Loading branch information
Roadhog360 authored Nov 2, 2023
2 parents f9f29bb + 3119c35 commit 0edb4b4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public class LayerBetterElytra {
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
private static final ModelElytra modelElytra = new ModelElytra();
protected static final ResourceLocation ENCHANTED_ITEM_GLINT_RES = new ResourceLocation("textures/misc/enchanted_item_glint.png");
public static float netHeadYaw = 0.0F;
public static float headPitch = 0.0F;

public static void doRenderLayer(EntityLivingBase entityIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
public static void doRenderLayer(EntityLivingBase entityIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float scale) {
ItemStack itemstack = ItemArmorElytra.getElytra(entityIn);
if (entityIn instanceof AbstractClientPlayer && itemstack != null) {
AbstractClientPlayer player = (AbstractClientPlayer) entityIn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public ModelElytra() {
public void render(Entity entityIn, float p_78088_2_, float limbSwing, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(GL11.GL_CULL_FACE);

this.leftWing.render(scale);
this.rightWing.render(scale);
}
Expand All @@ -44,7 +45,8 @@ public void render(Entity entityIn, float p_78088_2_, float limbSwing, float age
@Override
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
float f = 0.2617994F;

float f = 0.2617994F; // 15 degrees in radians
float f1 = -0.2617994F;
float f2 = 0.0F;
float f3 = 0.0F;
Expand All @@ -57,7 +59,7 @@ public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageI
f4 = 1.0F - (float) Math.pow(-vec3d.yCoord, 1.5D);
}

f = f4 * 0.34906584F + (1.0F - f4) * f;
f = f4 * 0.34906584F + (1.0F - f4) * f; // 20 degrees in radians
f1 = f4 * -((float) Math.PI / 2F) + (1.0F - f4) * f1;
} else if (entityIn.isSneaking()) {
f = ((float) Math.PI * 2F / 9F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ganymedes01.etfuturum.client.gui.GuiConfigWarning;
import ganymedes01.etfuturum.client.gui.GuiGamemodeSwitcher;
import ganymedes01.etfuturum.client.particle.CustomParticles;
import ganymedes01.etfuturum.client.renderer.entity.elytra.LayerBetterElytra;
import ganymedes01.etfuturum.client.sound.AmbienceLoop;
import ganymedes01.etfuturum.client.sound.BeeFlySound;
import ganymedes01.etfuturum.client.sound.ElytraSound;
Expand Down Expand Up @@ -53,6 +54,7 @@
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.event.ClickEvent;
Expand Down Expand Up @@ -357,6 +359,10 @@ public void renderPlayerEventPre(RenderPlayerEvent.Pre event) {

@SubscribeEvent
public void renderPlayerSetArmour(SetArmorModel event) {
if (event.entityPlayer instanceof IElytraPlayer) {
LayerBetterElytra.doRenderLayer(event.entityLiving, event.entityPlayer.limbSwing, event.entityPlayer.limbSwingAmount, Minecraft.getMinecraft().timer.renderPartialTicks, event.entityPlayer.getAge(), 0.0625F);
}

if (isSpectator(event.entityPlayer)) {
event.result = 0;
} else if (ConfigFunctions.enableTransparentAmour) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

public class ClientProxy extends CommonProxy {

public static boolean isRenderingInventoryPlayer = false;

@Override
public void registerEvents() {
super.registerEvents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import ganymedes01.etfuturum.client.renderer.entity.elytra.LayerBetterElytra;
import ganymedes01.etfuturum.elytra.IElytraPlayer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.MathHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -70,9 +68,8 @@ private void setElytraAngles(float limbSwing, float limbSwingAmount, float ageIn
}

@Inject(method = "setRotationAngles", at = @At("RETURN"))
private void renderElytra(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn, CallbackInfo ci) {
if (entityIn instanceof IElytraPlayer && (Minecraft.getMinecraft().gameSettings.thirdPersonView != 0 || entityIn != Minecraft.getMinecraft().renderViewEntity)) {
LayerBetterElytra.doRenderLayer((EntityLivingBase) entityIn, limbSwing, limbSwingAmount, Minecraft.getMinecraft().timer.renderPartialTicks, ageInTicks, netHeadYaw, headPitch, 0.0625F);
}
private void hookVars(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn, CallbackInfo ci) {
LayerBetterElytra.netHeadYaw = netHeadYaw;
LayerBetterElytra.headPitch = headPitch;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public int getLightValue(IBlockAccess world, int x, int y, int z) {
return super.getLightValue(world, x, y, z);
}

@SideOnly(Side.CLIENT)
@Inject(method = "registerBlockIcons", at = @At(value = "HEAD"))
@SideOnly(Side.CLIENT)
private void addSoulFireIcon(IIconRegister reg, CallbackInfo ci) {
Expand Down

0 comments on commit 0edb4b4

Please sign in to comment.