Search in sources :

Example 41 with InvokeEvent

use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.

the class FovModifier method fovChange.

@InvokeEvent
public void fovChange(FovUpdateEvent event) {
    float base = 1.0F;
    if (event.getPlayer().isSprinting()) {
        base += (float) (0.15000000596046448 * Settings.SPRINTING_FOV_MODIFIER);
    }
    if (event.getPlayer().getItemInUse() != null && event.getPlayer().getItemInUse().getItem().equals(Items.bow)) {
        int duration = (int) Math.min(event.getPlayer().getItemInUseDuration(), MAX_BOW_TICKS);
        float modifier = MODIFIER_BY_TICK.get(duration);
        base -= modifier * Settings.BOW_FOV_MODIFIER;
    }
    Collection<PotionEffect> effects = event.getPlayer().getActivePotionEffects();
    for (PotionEffect effect : effects) {
        if (effect.getPotionID() == 1) {
            base += (MODIFIER_SPEED * (effect.getAmplifier() + 1) * Settings.SPEED_FOV_MODIFIER);
        }
        if (effect.getPotionID() == 2) {
            base += (MODIFIER_SLOWNESS * (effect.getAmplifier() + 1) * Settings.SLOWNESS_FOV_MODIFIER);
        }
    }
    event.setNewFov(base);
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 42 with InvokeEvent

use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.

the class YeetHandler method render.

@InvokeEvent
public void render(RenderEntitiesEvent event) {
    for (Yeet yeet : yeets) {
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        FontRenderer fontrenderer = renderManager.getFontRenderer();
        float f = 1.6F;
        float f1 = 0.016666668F * f;
        GlStateManager.pushMatrix();
        EntityPlayerSP entity = Minecraft.getMinecraft().thePlayer;
        float partialTicks = event.getPartialTicks();
        double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
        double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
        double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
        EntityPlayer sender = yeet.sender;
        if (sender == null)
            continue;
        double e0 = yeet.sender.lastTickPosX + (yeet.sender.posX - yeet.sender.lastTickPosX) * (double) partialTicks;
        double e1 = yeet.sender.lastTickPosY + (yeet.sender.posY - yeet.sender.lastTickPosY) * (double) partialTicks;
        double e2 = yeet.sender.lastTickPosZ + (yeet.sender.posZ - yeet.sender.lastTickPosZ) * (double) partialTicks;
        GlStateManager.translate(e0 - d0, e1 - d1, e2 - d2);
        GlStateManager.translate(0, 3, 0);
        GL11.glNormal3f(0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        // Nametag x rotations should flip in front-facing 3rd person
        int xMultiplier = 1;
        if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().gameSettings != null && Minecraft.getMinecraft().gameSettings.thirdPersonView == 2) {
            xMultiplier = -1;
        }
        GlStateManager.rotate(renderManager.playerViewX * xMultiplier, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(-f1, -f1, f1);
        GlStateManager.disableLighting();
        GlStateManager.depthMask(false);
        GlStateManager.disableDepth();
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        int i = 0;
        String string = "YEET";
        int j = fontrenderer.getStringWidth(string) / 2;
        GlStateManager.disableTexture2D();
        GlStateManager.scale(4, 4, 4);
        worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        tessellator.draw();
        GlStateManager.enableTexture2D();
        fontrenderer.drawString(string, -j, 0, 16777215, true);
        GlStateManager.enableLighting();
        GlStateManager.disableBlend();
        GlStateManager.depthMask(true);
        GlStateManager.enableDepth();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.popMatrix();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) FontRenderer(net.minecraft.client.gui.FontRenderer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) RenderManager(net.minecraft.client.renderer.entity.RenderManager) WorldRenderer(net.minecraft.client.renderer.WorldRenderer) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 43 with InvokeEvent

use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.

the class DragonHeadRenderer method onRenderPlayer.

@InvokeEvent
public void onRenderPlayer(RenderPlayerEvent event) {
    if (CosmeticsUtil.shouldHide(EnumPurchaseType.DRAGON_HEAD))
        return;
    EntityPlayer entity = event.getEntity();
    if (dragonCosmetic.isPurchasedBy(entity.getUniqueID()) && !entity.isInvisible()) {
        HyperiumPurchase packageIfReady = PurchaseApi.getInstance().getPackageIfReady(event.getEntity().getUniqueID());
        if (packageIfReady == null || packageIfReady.getCachedSettings().isDragonHeadDisabled())
            return;
        GlStateManager.pushMatrix();
        GlStateManager.translate(event.getX(), event.getY(), event.getZ());
        renderHead(event.getEntity(), event.getPartialTicks());
        GlStateManager.popMatrix();
    }
}
Also used : HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 44 with InvokeEvent

use of cc.hyperium.event.InvokeEvent 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)44 HyperiumPurchase (cc.hyperium.purchases.HyperiumPurchase)7 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)6 UUID (java.util.UUID)4 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)4 ScaledResolution (net.minecraft.client.gui.ScaledResolution)4 RenderManager (net.minecraft.client.renderer.entity.RenderManager)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 IMixinModelBiped (cc.hyperium.mixinsimp.client.model.IMixinModelBiped)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 EventBus (cc.hyperium.event.EventBus)2 AutoGG (cc.hyperium.mods.autogg.AutoGG)2 ChatColor (cc.hyperium.utils.ChatColor)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Map (java.util.Map)2 Matcher (java.util.regex.Matcher)2 Minecraft (net.minecraft.client.Minecraft)2