Search in sources :

Example 1 with FloatConsumer

use of it.unimi.dsi.fastutil.floats.FloatConsumer in project WildfireFemaleGenderMod by WildfireRomeo.

the class WildfireBreastCustomizationScreen method init.

@Override
public void init() {
    int j = this.height / 2;
    GenderPlayer plr = getPlayer();
    Breasts breasts = plr.getBreasts();
    FloatConsumer onSave = value -> {
        // Just save as we updated the actual value in value change
        GenderPlayer.saveGenderInfo(plr);
    };
    this.addDrawableChild(new WildfireButton(this.width / 2 + 178, j - 61, 9, 9, new TranslatableText("wildfire_gender.label.exit"), button -> MinecraftClient.getInstance().setScreen(parent)));
    this.addDrawableChild(this.breastSlider = new WildfireSlider(this.width / 2 + 30, j - 48, 158, 20, Configuration.BUST_SIZE, plr.getBustSize(), plr::updateBustSize, value -> new TranslatableText("wildfire_gender.wardrobe.slider.breast_size", Math.round(value * 100)), onSave));
    // Customization
    this.addDrawableChild(this.xOffsetBoobSlider = new WildfireSlider(this.width / 2 + 30, j - 27, 158, 20, Configuration.BREASTS_OFFSET_X, breasts.getXOffset(), breasts::updateXOffset, value -> new TranslatableText("wildfire_gender.wardrobe.slider.separation", Math.round((Math.round(value * 100f) / 100f) * 10)), onSave));
    this.addDrawableChild(this.yOffsetBoobSlider = new WildfireSlider(this.width / 2 + 30, j - 6, 158, 20, Configuration.BREASTS_OFFSET_Y, breasts.getYOffset(), breasts::updateYOffset, value -> new TranslatableText("wildfire_gender.wardrobe.slider.height", Math.round((Math.round(value * 100f) / 100f) * 10)), onSave));
    this.addDrawableChild(this.zOffsetBoobSlider = new WildfireSlider(this.width / 2 + 30, j + 15, 158, 20, Configuration.BREASTS_OFFSET_Z, breasts.getZOffset(), breasts::updateZOffset, value -> new TranslatableText("wildfire_gender.wardrobe.slider.depth", Math.round((Math.round(value * 100f) / 100f) * 10)), onSave));
    this.addDrawableChild(this.cleavageSlider = new WildfireSlider(this.width / 2 + 30, j + 36, 158, 20, Configuration.BREASTS_CLEAVAGE, breasts.getCleavage(), breasts::updateCleavage, value -> new TranslatableText("wildfire_gender.wardrobe.slider.rotation", Math.round((Math.round(value * 100f) / 100f) * 100)), onSave));
    this.addDrawableChild(new WildfireButton(this.width / 2 + 30, j + 57, 158, 20, new TranslatableText("wildfire_gender.breast_customization.dual_physics", new TranslatableText(breasts.isUniboob() ? "wildfire_gender.label.no" : "wildfire_gender.label.yes")), button -> {
        boolean isUniboob = !breasts.isUniboob();
        if (breasts.updateUniboob(isUniboob)) {
            button.setMessage(new TranslatableText("wildfire_gender.breast_customization.dual_physics", new TranslatableText(isUniboob ? "wildfire_gender.label.no" : "wildfire_gender.label.yes")));
            GenderPlayer.saveGenderInfo(plr);
        }
    }));
    super.init();
}
Also used : GenderPlayer(com.wildfire.main.GenderPlayer) FloatConsumer(it.unimi.dsi.fastutil.floats.FloatConsumer) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Configuration(com.wildfire.main.config.Configuration) MatrixStack(net.minecraft.client.util.math.MatrixStack) TranslatableText(net.minecraft.text.TranslatableText) UUID(java.util.UUID) WildfireButton(com.wildfire.gui.WildfireButton) WildfireSlider(com.wildfire.gui.WildfireSlider) Screen(net.minecraft.client.gui.screen.Screen) Breasts(com.wildfire.main.Breasts) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) MinecraftClient(net.minecraft.client.MinecraftClient) TranslatableText(net.minecraft.text.TranslatableText) Breasts(com.wildfire.main.Breasts) WildfireButton(com.wildfire.gui.WildfireButton) FloatConsumer(it.unimi.dsi.fastutil.floats.FloatConsumer) GenderPlayer(com.wildfire.main.GenderPlayer) WildfireSlider(com.wildfire.gui.WildfireSlider)

Example 2 with FloatConsumer

use of it.unimi.dsi.fastutil.floats.FloatConsumer in project Iris by IrisShaders.

the class DispatchingDirectiveHolder method processDirective.

public void processDirective(ConstDirectiveParser.ConstDirective directive) {
    final ConstDirectiveParser.Type type = directive.getType();
    final String key = directive.getKey();
    final String value = directive.getValue();
    if (type == ConstDirectiveParser.Type.BOOL) {
        BooleanConsumer consumer = booleanConstVariables.get(key);
        if (consumer != null) {
            if ("true".equals(value)) {
                consumer.accept(true);
            } else if ("false".equals(value)) {
                consumer.accept(false);
            } else {
                Iris.logger.error("Failed to process " + directive + ": " + value + " is not a valid boolean value");
            }
            return;
        }
        if (IrisLogging.ENABLE_SPAM) {
            // Only logspam in dev
            Iris.logger.info("Found potential unhandled directive: " + directive);
        }
        typeCheckHelper("int", intConstVariables, directive);
        typeCheckHelper("int", stringConstVariables, directive);
        typeCheckHelper("float", floatConstVariables, directive);
        typeCheckHelper("vec4", vec4ConstVariables, directive);
    } else if (type == ConstDirectiveParser.Type.INT) {
        // GLSL does not actually have a string type, so string constant directives use "const int" instead.
        Consumer<String> stringConsumer = stringConstVariables.get(key);
        if (stringConsumer != null) {
            stringConsumer.accept(value);
            return;
        }
        IntConsumer intConsumer = intConstVariables.get(key);
        if (intConsumer != null) {
            try {
                intConsumer.accept(Integer.parseInt(value));
            } catch (NumberFormatException e) {
                Iris.logger.error("Failed to process " + directive, e);
            }
            return;
        }
        if (IrisLogging.ENABLE_SPAM) {
            // Only logspam in dev
            Iris.logger.info("Found potential unhandled directive: " + directive);
        }
        typeCheckHelper("bool", booleanConstVariables, directive);
        typeCheckHelper("float", floatConstVariables, directive);
        typeCheckHelper("vec4", vec4ConstVariables, directive);
    } else if (type == ConstDirectiveParser.Type.FLOAT) {
        FloatConsumer consumer = floatConstVariables.get(key);
        if (consumer != null) {
            try {
                consumer.accept(Float.parseFloat(value));
            } catch (NumberFormatException e) {
                Iris.logger.error("Failed to process " + directive, e);
            }
            return;
        }
        if (IrisLogging.ENABLE_SPAM) {
            // Only logspam in dev
            Iris.logger.info("Found potential unhandled directive: " + directive);
        }
        typeCheckHelper("bool", booleanConstVariables, directive);
        typeCheckHelper("int", intConstVariables, directive);
        typeCheckHelper("int", stringConstVariables, directive);
        typeCheckHelper("vec4", vec4ConstVariables, directive);
    } else if (type == ConstDirectiveParser.Type.VEC4) {
        Consumer<Vector4f> consumer = vec4ConstVariables.get(key);
        if (consumer != null) {
            if (!value.startsWith("vec4")) {
                Iris.logger.error("Failed to process " + directive + ": value was not a valid vec4 constructor");
            }
            String vec4Args = value.substring("vec4".length()).trim();
            if (!vec4Args.startsWith("(") || !vec4Args.endsWith(")")) {
                Iris.logger.error("Failed to process " + directive + ": value was not a valid vec4 constructor");
            }
            vec4Args = vec4Args.substring(1, vec4Args.length() - 1);
            String[] parts = vec4Args.split(",");
            for (int i = 0; i < parts.length; i++) {
                parts[i] = parts[i].trim();
            }
            if (parts.length != 4) {
                Iris.logger.error("Failed to process " + directive + ": expected 4 arguments to a vec4 constructor, got " + parts.length);
            }
            try {
                consumer.accept(new Vector4f(Float.parseFloat(parts[0]), Float.parseFloat(parts[1]), Float.parseFloat(parts[2]), Float.parseFloat(parts[3])));
            } catch (NumberFormatException e) {
                Iris.logger.error("Failed to process " + directive, e);
            }
            return;
        }
        typeCheckHelper("bool", booleanConstVariables, directive);
        typeCheckHelper("int", intConstVariables, directive);
        typeCheckHelper("int", stringConstVariables, directive);
        typeCheckHelper("float", floatConstVariables, directive);
    }
}
Also used : Consumer(java.util.function.Consumer) FloatConsumer(it.unimi.dsi.fastutil.floats.FloatConsumer) BooleanConsumer(it.unimi.dsi.fastutil.booleans.BooleanConsumer) IntConsumer(java.util.function.IntConsumer) Vector4f(net.coderbot.iris.vendored.joml.Vector4f) BooleanConsumer(it.unimi.dsi.fastutil.booleans.BooleanConsumer) FloatConsumer(it.unimi.dsi.fastutil.floats.FloatConsumer) IntConsumer(java.util.function.IntConsumer)

Aggregations

FloatConsumer (it.unimi.dsi.fastutil.floats.FloatConsumer)2 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 WildfireButton (com.wildfire.gui.WildfireButton)1 WildfireSlider (com.wildfire.gui.WildfireSlider)1 Breasts (com.wildfire.main.Breasts)1 GenderPlayer (com.wildfire.main.GenderPlayer)1 Configuration (com.wildfire.main.config.Configuration)1 BooleanConsumer (it.unimi.dsi.fastutil.booleans.BooleanConsumer)1 UUID (java.util.UUID)1 Consumer (java.util.function.Consumer)1 IntConsumer (java.util.function.IntConsumer)1 Vector4f (net.coderbot.iris.vendored.joml.Vector4f)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 Screen (net.minecraft.client.gui.screen.Screen)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 TranslatableText (net.minecraft.text.TranslatableText)1