Search in sources :

Example 1 with GameSettings

use of net.minecraft.client.settings.GameSettings in project SilentGems by SilentChaos512.

the class GuiCrosshairs method renderCrosshairs.

protected void renderCrosshairs(float partialTicks, ScaledResolution resolution, int type) {
    GameSettings gamesettings = this.mc.gameSettings;
    if (gamesettings.thirdPersonView == 0) {
        if (this.mc.playerController.isSpectator() && this.mc.pointedEntity == null) {
            RayTraceResult raytraceresult = this.mc.objectMouseOver;
            if (raytraceresult == null || raytraceresult.typeOfHit != RayTraceResult.Type.BLOCK) {
                return;
            }
            BlockPos blockpos = raytraceresult.getBlockPos();
            net.minecraft.block.state.IBlockState state = this.mc.world.getBlockState(blockpos);
            if (!state.getBlock().hasTileEntity(state) || !(this.mc.world.getTileEntity(blockpos) instanceof IInventory)) {
                return;
            }
        }
        int width = resolution.getScaledWidth();
        int height = resolution.getScaledHeight();
        if (gamesettings.showDebugInfo && !gamesettings.hideGUI && !this.mc.player.hasReducedDebug() && !gamesettings.reducedDebugInfo) {
            GlStateManager.pushMatrix();
            GlStateManager.translate((float) (width / 2), (float) (height / 2), this.zLevel);
            Entity entity = this.mc.getRenderViewEntity();
            GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, -1.0F, 0.0F, 0.0F);
            GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks, 0.0F, 1.0F, 0.0F);
            GlStateManager.scale(-1.0F, -1.0F, -1.0F);
            OpenGlHelper.renderDirections(10);
            GlStateManager.popMatrix();
        } else {
            GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
            GlStateManager.enableAlpha();
            this.drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0 + 16 * type, 0, 16, 16);
            if (this.mc.gameSettings.attackIndicator == 1) {
                mc.getTextureManager().bindTexture(ICONS);
                float f = this.mc.player.getCooledAttackStrength(0.0F);
                if (f < 1.0F) {
                    int i = height / 2 - 7 + 16;
                    int j = width / 2 - 7;
                    int k = (int) (f * 17.0F);
                    this.drawTexturedModalRect(j, i, 36, 94, 16, 4);
                    this.drawTexturedModalRect(j, i, 52, 94, k, 4);
                }
            }
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) Entity(net.minecraft.entity.Entity) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) GameSettings(net.minecraft.client.settings.GameSettings)

Example 2 with GameSettings

use of net.minecraft.client.settings.GameSettings in project Almura by AlmuraDev.

the class FirstLaunchOptimization method optimizeGame.

/**
 * Called on first launch to optimize the client's GUI settings. Addresses many users lack of knowledge of
 * the various settings that can lead to better FPS. Improves overall experience with Almura.
 */
private void optimizeGame() {
    // TODO Dockter, update your optimization changes
    final GameSettings settings = Minecraft.getMinecraft().gameSettings;
    settings.autoJump = false;
    settings.ambientOcclusion = 0;
    settings.mipmapLevels = 0;
    settings.guiScale = 3;
    // settings.advancedOpengl = true;
    // settings.anisotropicFiltering = 0;
    settings.limitFramerate = 120;
    settings.enableVsync = false;
    // settings.clouds = false;
    settings.snooperEnabled = false;
    settings.renderDistanceChunks = 12;
    settings.viewBobbing = false;
    settings.resourcePacks.add("Almura Preferred Font.zip");
    settings.saveOptions();
}
Also used : GameSettings(net.minecraft.client.settings.GameSettings)

Example 3 with GameSettings

use of net.minecraft.client.settings.GameSettings in project DynamicSurroundings by OreCruncher.

the class MinecraftConfigHandler method onConfigSave.

@SubscribeEvent
public static void onConfigSave(@Nonnull final PresetEvent.Save event) {
    final PresetData data = event.getModData(MINECRAFT);
    final GameSettings settings = Minecraft.getMinecraft().gameSettings;
    for (final Options option : GameSettings.Options.values()) {
        final String theName = option.getTranslation();
        switch(option) {
            case INVERT_MOUSE:
                data.setBoolean(theName, settings.invertMouse);
                break;
            case SENSITIVITY:
                data.setDouble(theName, settings.mouseSensitivity);
                break;
            case FOV:
                data.setDouble(theName, settings.fovSetting);
                break;
            case GAMMA:
                data.setDouble(theName, settings.gammaSetting);
                break;
            case SATURATION:
                data.setDouble(theName, settings.saturation);
                break;
            case RENDER_DISTANCE:
                data.setInt(theName, settings.renderDistanceChunks);
                break;
            case VIEW_BOBBING:
                data.setBoolean(theName, settings.viewBobbing);
                break;
            case ANAGLYPH:
                data.setBoolean(theName, settings.anaglyph);
                break;
            case FRAMERATE_LIMIT:
                data.setInt(theName, settings.limitFramerate);
                break;
            case FBO_ENABLE:
                data.setBoolean(theName, settings.fboEnable);
                break;
            case CHAT_COLOR:
                data.setBoolean(theName, settings.chatColours);
                break;
            case CHAT_LINKS:
                data.setBoolean(theName, settings.chatLinks);
                break;
            case CHAT_OPACITY:
                data.setDouble(theName, settings.chatOpacity);
                break;
            case CHAT_LINKS_PROMPT:
                data.setBoolean(theName, settings.chatLinksPrompt);
                break;
            case SNOOPER_ENABLED:
                data.setBoolean(theName, settings.snooperEnabled);
                break;
            case USE_FULLSCREEN:
                data.setBoolean(theName, settings.fullScreen);
                break;
            case ENABLE_VSYNC:
                data.setBoolean(theName, settings.enableVsync);
                break;
            case USE_VBO:
                data.setBoolean(theName, settings.useVbo);
                break;
            case TOUCHSCREEN:
                data.setBoolean(theName, settings.touchscreen);
                break;
            case CHAT_SCALE:
                data.setDouble(theName, settings.chatScale);
                break;
            case CHAT_WIDTH:
                data.setDouble(theName, settings.chatWidth);
                break;
            case CHAT_HEIGHT_FOCUSED:
                data.setDouble(theName, settings.chatHeightFocused);
                break;
            case CHAT_HEIGHT_UNFOCUSED:
                data.setDouble(theName, settings.chatHeightUnfocused);
                break;
            case MIPMAP_LEVELS:
                data.setInt(theName, settings.mipmapLevels);
                break;
            case FORCE_UNICODE_FONT:
                data.setBoolean(theName, settings.forceUnicodeFont);
                break;
            case REDUCED_DEBUG_INFO:
                data.setBoolean(theName, settings.reducedDebugInfo);
                break;
            case ENTITY_SHADOWS:
                data.setBoolean(theName, settings.entityShadows);
                break;
            case ENABLE_WEAK_ATTACKS:
                data.setBoolean(theName, settings.enableWeakAttacks);
                break;
            case SHOW_SUBTITLES:
                data.setBoolean(theName, settings.showSubtitles);
                break;
            case REALMS_NOTIFICATIONS:
                data.setBoolean(theName, settings.realmsNotifications);
                break;
            case AUTO_JUMP:
                data.setBoolean(theName, settings.autoJump);
                break;
            case RENDER_CLOUDS:
                data.setInt(theName, settings.clouds);
                break;
            case GRAPHICS:
                data.setBoolean(theName, settings.fancyGraphics);
                break;
            case AMBIENT_OCCLUSION:
                data.setInt(theName, settings.ambientOcclusion);
                break;
            case GUI_SCALE:
                data.setInt(theName, settings.guiScale);
                break;
            case PARTICLES:
                data.setInt(theName, settings.particleSetting);
                break;
            case CHAT_VISIBILITY:
                data.setInt(theName, settings.chatVisibility.ordinal());
                break;
            case MAIN_HAND:
                data.setString(theName, settings.mainHand.name());
                break;
            case ATTACK_INDICATOR:
                data.setInt(theName, settings.attackIndicator);
                break;
            default:
        }
    }
    // Not to forget sounds...
    for (final SoundCategory cat : SoundCategory.values()) data.setDouble(SOUND_PREFIX + cat.getName(), settings.getSoundLevel(cat));
    // ...and keybindings
    for (final KeyBinding keybinding : settings.keyBindings) {
        final String id = KEYBIND_PREFIX + keybinding.getKeyDescription();
        String val = Integer.toString(keybinding.getKeyCode());
        if (keybinding.getKeyModifier() != KeyModifier.NONE)
            val += ":" + keybinding.getKeyModifier();
        data.setString(id, val);
    }
}
Also used : Options(net.minecraft.client.settings.GameSettings.Options) KeyBinding(net.minecraft.client.settings.KeyBinding) SoundCategory(net.minecraft.util.SoundCategory) PresetData(org.blockartistry.Presets.api.PresetData) GameSettings(net.minecraft.client.settings.GameSettings) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with GameSettings

use of net.minecraft.client.settings.GameSettings in project BiomesOPlenty by Glitchfiend.

the class FogEventHandler method getFogBlendColour.

private static Vec3d getFogBlendColour(World world, EntityLivingBase playerEntity, int playerX, int playerY, int playerZ, float defR, float defG, float defB, double renderPartialTicks) {
    GameSettings settings = Minecraft.getMinecraft().gameSettings;
    int[] ranges = ForgeModContainer.blendRanges;
    int distance = 6;
    if (settings.fancyGraphics && settings.renderDistanceChunks >= 0 && settings.renderDistanceChunks < ranges.length) {
        distance = ranges[settings.renderDistanceChunks];
    }
    double rBiomeFog = 0;
    double gBiomeFog = 0;
    double bBiomeFog = 0;
    double weightBiomeFog = 0;
    BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
    for (int x = -distance; x <= distance; ++x) {
        for (int z = -distance; z <= distance; ++z) {
            pos.setPos(playerX + x, 0, playerZ + z);
            Biome biome = world.getBiome(pos);
            if (biome instanceof BOPBiome) {
                int fogColour = ((BOPBiome) biome).getFogColor(pos);
                // Ensure fog colouring is enabled for this biome
                if (fogColour >= 0) {
                    double rPart = (fogColour & 0xFF0000) >> 16;
                    double gPart = (fogColour & 0x00FF00) >> 8;
                    double bPart = fogColour & 0x0000FF;
                    float weightPart = 1;
                    if (x == -distance) {
                        double xDiff = 1 - (playerEntity.posX - playerX);
                        rPart *= xDiff;
                        gPart *= xDiff;
                        bPart *= xDiff;
                        weightPart *= xDiff;
                    } else if (x == distance) {
                        double xDiff = playerEntity.posX - playerX;
                        rPart *= xDiff;
                        gPart *= xDiff;
                        bPart *= xDiff;
                        weightPart *= xDiff;
                    }
                    if (z == -distance) {
                        double zDiff = 1 - (playerEntity.posZ - playerZ);
                        rPart *= zDiff;
                        gPart *= zDiff;
                        bPart *= zDiff;
                        weightPart *= zDiff;
                    } else if (z == distance) {
                        double zDiff = playerEntity.posZ - playerZ;
                        rPart *= zDiff;
                        gPart *= zDiff;
                        bPart *= zDiff;
                        weightPart *= zDiff;
                    }
                    rBiomeFog += rPart;
                    gBiomeFog += gPart;
                    bBiomeFog += bPart;
                    weightBiomeFog += weightPart;
                }
            }
        }
    }
    if (weightBiomeFog == 0 || distance == 0) {
        return new Vec3d(defR, defG, defB);
    }
    rBiomeFog /= 255f;
    gBiomeFog /= 255f;
    bBiomeFog /= 255f;
    // Calculate day / night / weather scale for BiomeFog component
    float celestialAngle = world.getCelestialAngle((float) renderPartialTicks);
    float baseScale = MathHelper.clamp(MathHelper.cos(celestialAngle * (float) Math.PI * 2.0F) * 2.0F + 0.5F, 0, 1);
    double rScale = baseScale * 0.94F + 0.06F;
    double gScale = baseScale * 0.94F + 0.06F;
    double bScale = baseScale * 0.91F + 0.09F;
    float rainStrength = world.getRainStrength((float) renderPartialTicks);
    if (rainStrength > 0) {
        rScale *= 1 - rainStrength * 0.5f;
        gScale *= 1 - rainStrength * 0.5f;
        bScale *= 1 - rainStrength * 0.4f;
    }
    float thunderStrength = world.getThunderStrength((float) renderPartialTicks);
    if (thunderStrength > 0) {
        rScale *= 1 - thunderStrength * 0.5f;
        gScale *= 1 - thunderStrength * 0.5f;
        bScale *= 1 - thunderStrength * 0.5f;
    }
    // Apply post-processing to BiomeFog component.  Default color was already processed by Vanilla.
    rBiomeFog *= rScale / weightBiomeFog;
    gBiomeFog *= gScale / weightBiomeFog;
    bBiomeFog *= bScale / weightBiomeFog;
    Vec3d processedColor = postProcessColor(world, playerEntity, rBiomeFog, gBiomeFog, bBiomeFog, renderPartialTicks);
    rBiomeFog = processedColor.x;
    gBiomeFog = processedColor.y;
    bBiomeFog = processedColor.z;
    // Mix default fog component with BiomeFog component
    double weightMixed = (distance * 2) * (distance * 2);
    double weightDefault = weightMixed - weightBiomeFog;
    double rFinal = (rBiomeFog * weightBiomeFog + defR * weightDefault) / weightMixed;
    double gFinal = (gBiomeFog * weightBiomeFog + defG * weightDefault) / weightMixed;
    double bFinal = (bBiomeFog * weightBiomeFog + defB * weightDefault) / weightMixed;
    return new Vec3d(rFinal, gFinal, bFinal);
}
Also used : BOPBiome(biomesoplenty.common.biome.BOPBiome) Biome(net.minecraft.world.biome.Biome) BlockPos(net.minecraft.util.math.BlockPos) GameSettings(net.minecraft.client.settings.GameSettings) BOPBiome(biomesoplenty.common.biome.BOPBiome) Vec3d(net.minecraft.util.math.Vec3d)

Example 5 with GameSettings

use of net.minecraft.client.settings.GameSettings in project PneumaticCraft by MineMaarten.

the class GuiKeybindCheckBox method setOrAddKeybind.

/**
 * @param keybindName
 * @param keyCode when a value of <0 is parsed, this will function as a getter, with a chance of returning null.
 * @return
 */
public static KeyBinding setOrAddKeybind(String keybindName, int keyCode) {
    GameSettings gameSettings = FMLClientHandler.instance().getClient().gameSettings;
    for (KeyBinding keyBinding : gameSettings.keyBindings) {
        if (keyBinding != null && keyBinding.getKeyDescription().equals(keybindName)) {
            if (keybindName.equals(keyBinding.getKeyDescription())) {
                if (keyCode >= 0) {
                    keyBinding.setKeyCode(keyCode);
                    KeyBinding.resetKeyBindingArrayAndHash();
                    gameSettings.saveOptions();
                }
                return keyBinding;
            }
        }
    }
    // When the keybind wasn't added yet
    if (keyCode < 0) {
        if (((ClientProxy) PneumaticCraft.proxy).keybindToKeyCodes.containsKey(keybindName)) {
            // If the keybind can be found in the options file
            keyCode = ((ClientProxy) PneumaticCraft.proxy).keybindToKeyCodes.get(keybindName);
        } else {
            return null;
        }
    }
    KeyBinding keyBinding = new KeyBinding(keybindName, keyCode, Names.PNEUMATIC_KEYBINDING_CATEGORY);
    ClientRegistry.registerKeyBinding(keyBinding);
    KeyBinding.resetKeyBindingArrayAndHash();
    gameSettings.saveOptions();
    return keyBinding;
}
Also used : KeyBinding(net.minecraft.client.settings.KeyBinding) ClientProxy(pneumaticCraft.proxy.ClientProxy) GameSettings(net.minecraft.client.settings.GameSettings)

Aggregations

GameSettings (net.minecraft.client.settings.GameSettings)13 KeyBinding (net.minecraft.client.settings.KeyBinding)5 BlockPos (net.minecraft.util.math.BlockPos)4 BufferedImage (java.awt.image.BufferedImage)2 Options (net.minecraft.client.settings.GameSettings.Options)2 SoundCategory (net.minecraft.util.SoundCategory)2 Biome (net.minecraft.world.biome.Biome)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 PresetData (org.blockartistry.Presets.api.PresetData)2 BOPBiome (biomesoplenty.common.biome.BOPBiome)1 Field (java.lang.reflect.Field)1 Nonnull (javax.annotation.Nonnull)1 ClientProxy (me.desht.pneumaticcraft.proxy.ClientProxy)1 Minecraft (net.minecraft.client.Minecraft)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IInventory (net.minecraft.inventory.IInventory)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 Vec3d (net.minecraft.util.math.Vec3d)1 World (net.minecraft.world.World)1