Skip to content

Commit

Permalink
Other way to fix elytra rendering in first person and add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
iocmet committed Oct 26, 2023
1 parent 94c852e commit 7bc1625
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public List<String> getMixins() {
mixins.add("backlytra.client.MixinRenderPlayer");
mixins.add("backlytra.client.MixinModelBiped");
mixins.add("backlytra.client.MixinEntityRenderer");
mixins.add("backlytra.client.MixinGuiInventory");
}
}

Expand Down
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 @@ -2,10 +2,8 @@

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ganymedes01.etfuturum.core.proxy.ClientProxy;
import ganymedes01.etfuturum.elytra.IClientElytraPlayer;
import ganymedes01.etfuturum.elytra.IElytraPlayer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -34,15 +32,8 @@ public void render(Entity entityIn, float p_78088_2_, float limbSwing, float age
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(GL11.GL_CULL_FACE);

if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 0 && entityIn == Minecraft.getMinecraft().thePlayer) {
if (ClientProxy.isRenderingInventoryPlayer) {
this.leftWing.render(scale);
this.rightWing.render(scale);
}
} else {
this.leftWing.render(scale);
this.rightWing.render(scale);
}
this.leftWing.render(scale);
this.rightWing.render(scale);
}

/**
Expand All @@ -54,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 @@ -67,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 @@ -18,6 +18,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 @@ -51,6 +52,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 @@ -346,6 +348,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

This file was deleted.

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 || Minecraft.getMinecraft().currentScreen instanceof GuiInventory || entityIn != Minecraft.getMinecraft().thePlayer)*/) {
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;
}
}

0 comments on commit 7bc1625

Please sign in to comment.