Search in sources :

Example 1 with ClientConfiguration

use of com.almuradev.almura.core.client.ClientConfiguration in project Almura by AlmuraDev.

the class MixinRenderItemFrame method onDoRender.

@Inject(method = "doRender", at = @At(value = "HEAD"), cancellable = true)
public void onDoRender(EntityItemFrame entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
    // 0 means perform Minecraft logic only, we do not interfere
    final ClientConfiguration config = StaticAccess.config.get();
    if (config.client.itemFrameRenderDistance == 0) {
        return;
    }
    EntityLivingBase viewer = (EntityLivingBase) Minecraft.getMinecraft().getRenderViewEntity();
    if (viewer == null) {
        viewer = Minecraft.getMinecraft().player;
    }
    if (viewer != null && entity.getDistance(viewer) > config.client.itemFrameRenderDistance) {
        ci.cancel();
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) ClientConfiguration(com.almuradev.almura.core.client.ClientConfiguration) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with ClientConfiguration

use of com.almuradev.almura.core.client.ClientConfiguration in project Almura by AlmuraDev.

the class MixinTileEntityChestRenderer method onRender.

@Inject(method = "render", at = @At("HEAD"), cancellable = true)
public void onRender(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage, float val, CallbackInfo ci) {
    // 0 means perform Minecraft logic only, we do not interfere
    final ClientConfiguration config = StaticAccess.config.get();
    if (config.client.chestRenderDistance == 0) {
        return;
    }
    EntityLivingBase viewer = (EntityLivingBase) Minecraft.getMinecraft().getRenderViewEntity();
    if (viewer == null) {
        viewer = Minecraft.getMinecraft().player;
    }
    if (viewer != null && te.getDistanceSq(viewer.posX, viewer.posY, viewer.posZ) > (config.client.chestRenderDistance * 16) && te.hasWorld()) {
        ci.cancel();
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) ClientConfiguration(com.almuradev.almura.core.client.ClientConfiguration) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with ClientConfiguration

use of com.almuradev.almura.core.client.ClientConfiguration in project Almura by AlmuraDev.

the class MixinTileEntitySignRenderer method render.

/**
 * @author Grinch - Steven Downer
 * @reason Do not render signposts past a configurable length. Fairly decent client optimization.
 */
@Overwrite
public void render(TileEntitySign te, double x, double y, double z, float partialTicks, int destroyStage, float val) {
    final ClientConfiguration config = StaticAccess.config.get();
    Block block = te.getBlockType();
    GlStateManager.pushMatrix();
    float f = 0.6666667F;
    if (block == Blocks.STANDING_SIGN) {
        GlStateManager.translate((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
        float f1 = (float) (te.getBlockMetadata() * 360) / 16.0F;
        GlStateManager.rotate(-f1, 0.0F, 1.0F, 0.0F);
        this.model.signStick.showModel = true;
    } else {
        int k = te.getBlockMetadata();
        float f2 = 0.0F;
        if (k == 2) {
            f2 = 180.0F;
        }
        if (k == 4) {
            f2 = 90.0F;
        }
        if (k == 5) {
            f2 = -90.0F;
        }
        GlStateManager.translate((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
        GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.3125F, -0.4375F);
        this.model.signStick.showModel = false;
    }
    if (destroyStage >= 0) {
        this.bindTexture(DESTROY_STAGES[destroyStage]);
        GlStateManager.matrixMode(5890);
        GlStateManager.pushMatrix();
        GlStateManager.scale(4.0F, 2.0F, 1.0F);
        GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
        GlStateManager.matrixMode(5888);
    } else {
        this.bindTexture(SIGN_TEXTURE);
    }
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();
    GlStateManager.scale(0.6666667F, -0.6666667F, -0.6666667F);
    this.model.renderSign();
    GlStateManager.popMatrix();
    FontRenderer fontrenderer = this.getFontRenderer();
    float f3 = 0.010416667F;
    GlStateManager.translate(0.0F, 0.33333334F, 0.046666667F);
    GlStateManager.scale(0.010416667F, -0.010416667F, 0.010416667F);
    GlStateManager.glNormal3f(0.0F, 0.0F, -0.010416667F);
    GlStateManager.depthMask(false);
    int i = 0;
    // Almura start
    boolean renderText = te.signText.length > 0;
    if (renderText) {
        // Greater than 0 means the client has selected a non-Vanilla render distance
        if (config.client.signTextRenderDistance > 0) {
            EntityLivingBase viewer = (EntityLivingBase) Minecraft.getMinecraft().getRenderViewEntity();
            if (viewer == null) {
                viewer = Minecraft.getMinecraft().player;
            }
            if (viewer == null || !te.hasWorld() || te.getDistanceSq(viewer.posX, viewer.posY, viewer.posZ) > (config.client.signTextRenderDistance * 16)) {
                renderText = false;
            }
        }
    }
    if (renderText && destroyStage < 0) {
        // Almura End
        for (int j = 0; j < te.signText.length; ++j) {
            if (te.signText[j] != null) {
                ITextComponent itextcomponent = te.signText[j];
                List<ITextComponent> list = GuiUtilRenderComponents.splitText(itextcomponent, 90, fontrenderer, false, true);
                String s = list != null && !list.isEmpty() ? ((ITextComponent) list.get(0)).getFormattedText() : "";
                if (j == te.lineBeingEdited) {
                    s = "> " + s + " <";
                    fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, j * 10 - te.signText.length * 5, 0);
                } else {
                    fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, j * 10 - te.signText.length * 5, 0);
                }
            }
        }
    }
    GlStateManager.depthMask(true);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.popMatrix();
    if (destroyStage >= 0) {
        GlStateManager.matrixMode(5890);
        GlStateManager.popMatrix();
        GlStateManager.matrixMode(5888);
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) ITextComponent(net.minecraft.util.text.ITextComponent) Block(net.minecraft.block.Block) FontRenderer(net.minecraft.client.gui.FontRenderer) ClientConfiguration(com.almuradev.almura.core.client.ClientConfiguration) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

ClientConfiguration (com.almuradev.almura.core.client.ClientConfiguration)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 Inject (org.spongepowered.asm.mixin.injection.Inject)2 Block (net.minecraft.block.Block)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1