mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-20 04:19:40 +00:00
Fewer Allocations (#243)
This commit is contained in:
1 parent
6691511e17
commit
388929cc0c
2 files changed
+50
No files matched your search
@@ -27,6 +27,7 @@ public enum Mixins {
|
||||
"angelica.MixinActiveRenderInfo"
|
||||
,"angelica.MixinEntityRenderer"
|
||||
,"angelica.MixinMinecraft"
|
||||
,"angelica.optimizations.MixinRendererLivingEntity"
|
||||
)
|
||||
),
|
||||
ANGELICA_VBO(
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.optimizations;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(RendererLivingEntity.class)
|
||||
public abstract class MixinRendererLivingEntity {
|
||||
|
||||
@Shadow protected abstract float getDeathMaxRotation(EntityLivingBase entity);
|
||||
|
||||
/**
|
||||
* @author mitchej123
|
||||
* @reason The vanilla method triggers way too many allocations for no good reason
|
||||
*/
|
||||
@Overwrite
|
||||
protected void rotateCorpse(EntityLivingBase entity, float p_77043_2_, float p_77043_3_, float partialTicks) {
|
||||
GLStateManager.glRotatef(180.0F - p_77043_3_, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
if (entity.deathTime > 0) {
|
||||
float f3 = ((float)entity.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F;
|
||||
f3 = MathHelper.sqrt_float(f3);
|
||||
|
||||
if (f3 > 1.0F) {
|
||||
f3 = 1.0F;
|
||||
}
|
||||
|
||||
GL11.glRotatef(f3 * this.getDeathMaxRotation(entity), 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
else if ((entity instanceof EntityLiving entityLiving) && entityLiving.hasCustomNameTag() || (entity instanceof EntityPlayer entityPlayer) && !entityPlayer.getHideCape()) {
|
||||
|
||||
final String s = EnumChatFormatting.getTextWithoutFormattingCodes(entity.getCommandSenderName());
|
||||
|
||||
if ((s.equals("Dinnerbone") || s.equals("Grumm"))) {
|
||||
GLStateManager.glTranslatef(0.0F, entity.height + 0.1F, 0.0F);
|
||||
GLStateManager.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user