Search in sources :

Example 1 with IMixinRenderManager

use of cc.hyperium.mixinsimp.client.renderer.entity.IMixinRenderManager in project Hyperium by HyperiumClient.

the class DragonCompanion method renderPlayer.

@InvokeEvent
public void renderPlayer(RenderPlayerEvent event) {
    if (Minecraft.getMinecraft().theWorld == null || !isPurchasedBy(event.getEntity().getUniqueID()))
        return;
    HyperiumPurchase packageIfReady = PurchaseApi.getInstance().getPackageIfReady(event.getEntity().getUniqueID());
    if (packageIfReady == null || packageIfReady.getCachedSettings().getCurrentCompanion() != EnumPurchaseType.DRAGON_COMPANION)
        return;
    scale = .1F;
    AbstractClientPlayer player = event.getEntity();
    CustomDragon customDragon = dragonHashMap.computeIfAbsent(event.getEntity(), player1 -> {
        EntityDragon dragon = new EntityDragon(player1.getEntityWorld());
        dragon.setSilent(true);
        return new CustomDragon(dragon, new AnimationState());
    });
    Entity entity = customDragon.dragon;
    RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
    // Manage pos here
    float partialTicks = event.getPartialTicks();
    double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
    double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
    double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
    GlStateManager.pushMatrix();
    EntityDragon entityDragon = customDragon.dragon;
    AnimationState animationState = customDragon.animationState;
    AnimationPoint current = animationState.getCurrent(player);
    entityDragon.posX = current.x / scale;
    entityDragon.posY = current.y / scale;
    entityDragon.posZ = current.z / scale;
    GlStateManager.translate(-((IMixinRenderManager) renderManager).getPosX(), -((IMixinRenderManager) renderManager).getPosY(), -((IMixinRenderManager) renderManager).getPosZ());
    GlStateManager.translate(d0 * scale, d1 * scale, d2 * scale);
    GlStateManager.scale(scale, scale, scale);
    renderManager.renderEntitySimple(entity, event.getPartialTicks());
    GlStateManager.popMatrix();
// render
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) EntityDragon(net.minecraft.entity.boss.EntityDragon) Entity(net.minecraft.entity.Entity) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) IMixinRenderManager(cc.hyperium.mixinsimp.client.renderer.entity.IMixinRenderManager) RenderManager(net.minecraft.client.renderer.entity.RenderManager) IMixinRenderManager(cc.hyperium.mixinsimp.client.renderer.entity.IMixinRenderManager) InvokeEvent(cc.hyperium.event.InvokeEvent)

Aggregations

InvokeEvent (cc.hyperium.event.InvokeEvent)1 IMixinRenderManager (cc.hyperium.mixinsimp.client.renderer.entity.IMixinRenderManager)1 HyperiumPurchase (cc.hyperium.purchases.HyperiumPurchase)1 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)1 RenderManager (net.minecraft.client.renderer.entity.RenderManager)1 Entity (net.minecraft.entity.Entity)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1