Upload files to "src/openonyx/features/render"

This commit is contained in:
winterflyt committed 2026-11-30 05:59:06 +02:00
1 parent 6121b288e9
commit 61620a8f25
5 files changed
+349

No files matched your search

@@ -0,0 +1,153 @@
package openonyx.features.render;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.imageio.ImageIO;
import net.minecraft.client.renderer.ImageBufferDownload;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.ResourceLocation;
import openonyx.core.OnyxClient;
import openonyx.events.FileDialogUtils;
import openonyx.events.NotificationDispatcher;
import openonyx.features.Module;
import openonyx.features.ModuleCategory;
import openonyx.features.hud.group_d.NotificationLevel;
import openonyx.history.internal.ActionSetting;
import openonyx.history.internal.EnumSetting;
import openonyx.history.internal.TextSetting;
import openonyx.skins.SkinFetcher;
import openonyx.skins.SkinOverride;
import org.apache.logging.log4j.Logger;
public final class SkinChanger extends Module {
private static final ExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadExecutor(runnable -> {
Thread thread = new Thread(runnable, "onyx-skin-loader");
thread.setDaemon(true);
return thread;
});
public EnumSetting<SourceMode> source = new EnumSetting<>("Source", SourceMode.LOCAL_FILE);
public ActionSetting browse;
public ActionSetting apply;
public EnumSetting<ArmWidthMode> armWidth;
public TextSetting skinFile = new TextSetting("Skin file", "")
.describe("Full path to a 64x64 or 64x32 skin PNG")
.visibleWhen(this.source, sourceMode -> sourceMode == SourceMode.LOCAL_FILE);
private static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("onyx", "skins/local");
public TextSetting playerName;
@Override
protected void onEnable() {
this.l();
}
private static void L(String string, NotificationLevel notificationLevel) {
NotificationDispatcher.d("SkinChanger", string, notificationLevel);
}
private void L(BufferedImage bufferedImage, String string, String string1) {
if ((bufferedImage = new ImageBufferDownload().parseUserSkin(bufferedImage)) == null) {
L("Not a valid skin image", NotificationLevel.ERROR);
} else {
mc.addScheduledTask(() -> {
mc.getTextureManager().deleteTexture(RESOURCE_LOCATION);
mc.getTextureManager().loadTexture(RESOURCE_LOCATION, new DynamicTexture(bufferedImage));
if (this.isEnabled()) {
SkinOverride.L(RESOURCE_LOCATION, string);
L(string1, NotificationLevel.SUCCESS);
}
});
}
}
private void d(String string) {
EXECUTOR_SERVICE.submit(
() -> {
SkinChanger skinChanger1 = this;
try {
bufferedImage = ImageIO.read(new File(string));
} catch (IOException iOException) {
Logger logger = OnyxClient.LOGGER;
Object[] objects = new Object[2];
boolean bl = true;
objects[0] = string;
objects[1] = iOException;
logger.warn("SkinChanger: failed to read '{}'", objects);
L("Can't read that file", NotificationLevel.ERROR);
return;
}
if (bufferedImage == null) {
L("Not a readable PNG", NotificationLevel.ERROR);
} else if (bufferedImage.getWidth() == 64 && (bufferedImage.getHeight() == 64 || bufferedImage.getHeight() == 32)) {
skinChanger1.L(bufferedImage, skinChanger1.armWidth.is(ArmWidthMode.SLIM) ? "slim" : "default", "Skin applied");
} else {
L(
new StringBuilder()
.insert(0, "Skin must be 64x64 or 64x32, not ")
.append(bufferedImage.getWidth())
.append("x")
.append(bufferedImage.getHeight())
.toString(),
NotificationLevel.ERROR
);
}
}
);
}
private void L(String string) {
SkinFetcher.L(
string,
skinFetcherData -> this.L(
skinFetcherData.image(), skinFetcherData.modelType(), new StringBuilder().insert(0, "Wearing ").append(string).append("'s skin").toString()
),
string -> {
Logger logger = OnyxClient.LOGGER;
Object[] objects = new Object[1];
boolean bl = true;
objects[0] = stringx;
logger.warn("SkinChanger: {}", objects);
L(stringx, NotificationLevel.ERROR);
}
);
}
@Override
protected void onDisable() {
SkinOverride.L();
}
public SkinChanger() {
super("SkinChanger", "Overrides your own skin texture locally", ModuleCategory.RENDER);
this.browse = new ActionSetting("Browse", () -> FileDialogUtils.d("Select a skin PNG", this.skinFile.getValue(), this.skinFile::setValue))
.withButtonLabel("Browse…")
.describe("Or paste the path into the field above")
.visibleWhen(() -> this.source.is(SourceMode.LOCAL_FILE));
this.playerName = new TextSetting("Player name", "").visibleWhen(this.source, sourceMode -> sourceMode == SourceMode.PLAYER_NAME);
this.armWidth = new EnumSetting<>("Arm width", ArmWidthMode.DEFAULT)
.describe("Slim (Alex) vs default (Steve) - can't be detected from a bare local PNG")
.visibleWhen(this.source, sourceMode -> sourceMode == SourceMode.LOCAL_FILE);
this.apply = new ActionSetting("Apply", () -> {
if (this.source.is(SourceMode.LOCAL_FILE)) {
if (this.skinFile.getValue().isEmpty()) {
L("Pick a skin PNG first", NotificationLevel.WARNING);
} else {
this.d(this.skinFile.getValue());
}
} else if (this.playerName.getValue().isEmpty()) {
L("Type a player name first", NotificationLevel.WARNING);
} else {
this.L(this.playerName.getValue());
}
}).withButtonLabel("Apply skin");
this.armWidth.onChange(armWidthMode -> {
if (this.isEnabled() && this.source.is(SourceMode.LOCAL_FILE) && SkinOverride.L()) {
SkinOverride.L(SkinOverride.getResourceLocation(), armWidthMode == ArmWidthMode.SLIM ? "slim" : "default");
}
});
}
}
+99
View File
@@ -0,0 +1,99 @@
package openonyx.features.render;
import openonyx.features.Module;
import openonyx.features.ModuleCategory;
import openonyx.history.internal.ColorSetting;
import openonyx.history.internal.EnumSetting;
import openonyx.history.internal.NumberSetting;
public class Skybox extends Module {
public NumberSetting intensity;
public NumberSetting strikeInterval;
public NumberSetting strikeChance;
public ColorSetting color;
public NumberSetting scale;
public EnumSetting<PresetMode> preset = new EnumSetting<>("Preset", PresetMode.CLOUDS).describe("Sky theme to paint");
public NumberSetting strikeGlow;
private static final long i = System.nanoTime();
public NumberSetting resolution;
public NumberSetting animationSpeed;
public EnumSetting<QualityMode> quality;
public float k() {
return this.strikeInterval.getFloat();
}
public float F() {
return this.animationSpeed.getFloat();
}
public int D() {
return this.color.getOpaque();
}
public boolean F() {
return this.isEnabled();
}
public int d() {
return this.preset.getValue().L();
}
public float l() {
return 0.85F;
}
public float h() {
return (float)(System.nanoTime() - i) / 1.0E9F;
}
public float I() {
return this.intensity.getFloat() / 100.0F;
}
public float i() {
return this.strikeChance.getFloat();
}
public float D() {
return this.strikeGlow.getFloat();
}
public float d() {
return Math.clamp(this.resolution.getFloat() / 100.0F, 0.25F, 1.0F);
}
public float L() {
return this.scale.getFloat();
}
public Skybox() {
super("Skybox", "Animated sky with a fixed custom color", ModuleCategory.RENDER);
this.color = new ColorSetting("Color", -9335297).D().describe("Fixed sky color");
this.animationSpeed = new NumberSetting("Animation Speed", 1.0, 0.1, 5.0, 0.1).withSuffix("x").describe("Controls how fast the sky moves");
this.scale = new NumberSetting("Scale", 5.0, 1.0, 20.0, 0.5).describe("Size of the pattern across the sky").visibleWhen(() -> this.preset.getValue().L());
this.intensity = new NumberSetting("Intensity", 1.0, 0.1, 5.0, 0.1)
.withSuffix("%")
.describe("Brightness the pattern is pushed to")
.visibleWhen(() -> this.preset.getValue().L());
this.strikeInterval = new NumberSetting("Strike Interval", 4.0, 1.0, 10.0, 0.5)
.withSuffix("s")
.describe("Seconds between lightning rolls")
.visibleWhen(() -> this.preset.is(PresetMode.THUNDER));
this.strikeChance = new NumberSetting("Strike Chance", 0.65, 0.0, 1.0, 0.05)
.describe("Odds a roll actually produces a bolt")
.visibleWhen(() -> this.preset.is(PresetMode.THUNDER));
this.strikeGlow = new NumberSetting("Strike Glow", 1.0, 0.1, 3.0, 0.1)
.withSuffix("x")
.describe("How hard a bolt lights the storm")
.visibleWhen(() -> this.preset.is(PresetMode.THUNDER));
this.quality = new EnumSetting<>("Quality", QualityMode.BALANCED).describe("Noise detail; fewer layers cost far less GPU time");
this.resolution = new NumberSetting("Resolution", 50.0, 25.0, 100.0, 25.0)
.withSuffix("%")
.describe("Fraction of the screen resolution the sky is drawn at");
}
public int L() {
return this.quality.getValue().L();
}
}
@@ -0,0 +1,39 @@
package openonyx.features.render;
import openonyx.history.DisplayNamed;
public enum SlotsMode implements DisplayNamed {
CHEST(3, "Chestplate"),
FEET(1, "Boots"),
LEGS(2, "Leggings"),
HEAD(4, "Helmet"),
MAINHAND(0, "Main hand");
private final int d;
private final String e;
SlotsMode(int j, String string1) {
this.d = j;
this.e = string1;
}
public int L() {
return this.d;
}
private static SlotsMode[] L() {
SlotsMode[] slotsModes = new SlotsMode[5];
boolean bl = true;
slotsModes[0] = HEAD;
slotsModes[1] = CHEST;
slotsModes[2] = LEGS;
slotsModes[3] = FEET;
slotsModes[4] = MAINHAND;
return slotsModes;
}
@Override
public String getDisplayName() {
return this.e;
}
}
@@ -0,0 +1,44 @@
package openonyx.features.render;
import java.util.function.BooleanSupplier;
import openonyx.history.SettingGroup;
import openonyx.history.internal.BooleanSetting;
import openonyx.history.internal.ColorSetting;
import openonyx.history.internal.NumberSetting;
public final class SmokeEffect extends SettingGroup {
public final NumberSetting trailBlur;
public final NumberSetting handBlur;
public final NumberSetting trailFade;
public final ColorSetting color;
public final NumberSetting length;
public final NumberSetting handSoftness;
public final NumberSetting intensity;
public final NumberSetting trailSoftness;
public final NumberSetting smoke;
public final NumberSetting speed;
public final BooleanSetting itemColor = new BooleanSetting("Item color", true).describe("Takes the trail color from the hand and the held item");
public float L() {
return 0.25F;
}
public SmokeEffect visibleWhen(BooleanSupplier booleanSupplier) {
super.visibleWhen(booleanSupplier);
return this;
}
private SmokeEffect() {
super("Trail");
this.color = new ColorSetting("Color", -10079233).D().visibleWhen(() -> !this.itemColor.isEnabled());
this.intensity = new NumberSetting("Intensity", 0.85, 0.1, 1.5, 0.01);
this.speed = new NumberSetting("Speed", 1.15, 0.2, 3.0, 0.05).withSuffix("x");
this.length = new NumberSetting("Length", 0.72, 0.1, 1.0, 0.05);
this.trailFade = new NumberSetting("Trail fade", 0.91, 0.55, 0.98, 0.01);
this.trailSoftness = new NumberSetting("Trail softness", 1.35, 0.45, 2.5, 0.05);
this.trailBlur = new NumberSetting("Trail blur", 1.55, 0.2, 3.0, 0.05);
this.handSoftness = new NumberSetting("Hand softness", 1.3, 0.45, 2.5, 0.05);
this.handBlur = new NumberSetting("Hand blur", 1.45, 0.2, 3.0, 0.05);
this.smoke = new NumberSetting("Smoke", 0.55, 0.0, 0.8, 0.05);
}
}
@@ -0,0 +1,14 @@
package openonyx.features.render;
public enum SourceMode {
LOCAL_FILE,
PLAYER_NAME;
private static SourceMode[] L() {
SourceMode[] sourceModes = new SourceMode[2];
boolean bl = true;
sourceModes[0] = LOCAL_FILE;
sourceModes[1] = PLAYER_NAME;
return sourceModes;
}
}