Skip to content

Commit

Permalink
1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnVN committed Dec 25, 2024
1 parent 5cd3382 commit 3ca6cda
Show file tree
Hide file tree
Showing 41 changed files with 545 additions and 364 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'microsoft'
java-version: 21
distribution: 'temurin'

- name: Build
run: ./gradlew build
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# autumn

A client-side Minecraft Fabric mod

Requires [Fabric Loader](https://fabricmc.net/use/), [Fabric API](https://modrinth.com/mod/fabric-api) and Minecraft 1.20.4+
Requires [Fabric Loader](https://fabricmc.net/use/), [Fabric API](https://modrinth.com/mod/fabric-api) and Minecraft
1.21.4+

## Features

https://github.com/AutumnVN/autumn/blob/main/src/client/java/autumnvn/autumn/Options.java#L25-L100
https://github.com/AutumnVN/autumn/blob/main/src/client/java/autumnvn/autumn/Options.java#L20-L100
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -45,25 +45,26 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
rename { "${it}_${project.base.archivesName.get()}" }
}
}

publishing {
publications {
mavenJava(MavenPublication) {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.7
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.2
loader_version=0.16.9

# Mod Properties
mod_version=1.0.0
maven_group=autumnvn.autumn
archives_base_name=autumn

# Dependencies
fabric_version=0.96.4+1.20.4
modmenu_version=9.0.0
fabric_version=0.112.2+1.21.4
modmenu_version=12.0.0
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
17 changes: 12 additions & 5 deletions src/client/java/autumnvn/autumn/AutumnClient.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
package autumnvn.autumn;

import org.lwjgl.glfw.GLFW;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.CropBlock;
import net.minecraft.block.NetherWartBlock;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.option.SimpleOption;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult.Type;
import net.minecraft.util.math.BlockPos;
import org.lwjgl.glfw.GLFW;

public class AutumnClient implements ClientModInitializer {
public static MinecraftClient client;
Expand All @@ -40,9 +43,12 @@ public void onInitializeClient() {
settingKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("Open Autumn Settings", GLFW.GLFW_KEY_BACKSLASH, "Autumn"));
zoomKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("Zoom", GLFW.GLFW_KEY_LEFT_ALT, "Autumn"));

FabricLoader.getInstance().getModContainer("autumn").ifPresent(container -> ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("autumn", "autumn"), container, ResourcePackActivationType.DEFAULT_ENABLED));
FabricLoader.getInstance().getModContainer("autumn").ifPresent(container -> ResourceManagerHelper.registerBuiltinResourcePack(Identifier.of("autumn", "autumn"), container, ResourcePackActivationType.DEFAULT_ENABLED));
BlockRenderLayerMap.INSTANCE.putBlock(Blocks.BARRIER, RenderLayer.getTranslucent());


ClientTickEvents.START_WORLD_TICK.register(world -> {
ClientTickEvents.START_CLIENT_TICK.register(client -> {
if (client.player == null || client.interactionManager == null || client.world == null) return;
while (settingKey.wasPressed()) {
client.setScreen(new SettingsScreen(client.currentScreen));
}
Expand All @@ -59,8 +65,8 @@ public void onInitializeClient() {
if (options.rightClickHarvest.getValue() && client.options.useKey.isPressed() && client.crosshairTarget != null && client.crosshairTarget.getType() == Type.BLOCK) {
BlockHitResult hitResult = (BlockHitResult) client.crosshairTarget;
BlockPos pos = hitResult.getBlockPos();
Block block = world.getBlockState(pos).getBlock();
if (block instanceof CropBlock cropBlock && cropBlock.isMature(world.getBlockState(pos)) || block instanceof NetherWartBlock && world.getBlockState(pos).get(NetherWartBlock.AGE) == 3) {
Block block = client.world.getBlockState(pos).getBlock();
if (block instanceof CropBlock cropBlock && cropBlock.isMature(client.world.getBlockState(pos)) || block instanceof NetherWartBlock && client.world.getBlockState(pos).get(NetherWartBlock.AGE) == 3) {
client.interactionManager.attackBlock(pos, hitResult.getSide());
client.player.swingHand(client.player.getActiveHand());
}
Expand All @@ -69,6 +75,7 @@ public void onInitializeClient() {
}

private void handleToggleKey(KeyBinding key, SimpleOption<Boolean> option, String name) {
if (client.player == null) return;
while (key.wasPressed()) {
option.setValue(!option.getValue());
client.player.sendMessage(Text.of(name + " is now " + (option.getValue() ? "§aON" : "§cOFF")), true);
Expand Down
10 changes: 3 additions & 7 deletions src/client/java/autumnvn/autumn/ButtonListWidget.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package autumnvn.autumn;

import java.util.List;
import java.util.Map;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.MinecraftClient;
Expand All @@ -12,6 +10,9 @@
import net.minecraft.client.gui.widget.ElementListWidget;
import net.minecraft.client.option.SimpleOption;

import java.util.List;
import java.util.Map;

public class ButtonListWidget extends ElementListWidget<ButtonListWidget.ButtonEntry> {
public ButtonListWidget(MinecraftClient client, int width, int height, int y, int itemHeight) {
super(client, width, height, y, itemHeight);
Expand All @@ -30,11 +31,6 @@ public int getRowWidth() {
return 400;
}

@Override
protected int getScrollbarPositionX() {
return super.getScrollbarPositionX() + 32;
}

static class ButtonEntry extends ElementListWidget.Entry<ButtonEntry> {
List<ClickableWidget> buttons;

Expand Down
39 changes: 18 additions & 21 deletions src/client/java/autumnvn/autumn/Options.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package autumnvn.autumn;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import com.google.gson.JsonParser;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.JsonOps;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.option.SimpleOption;
import net.minecraft.text.Text;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class Options {
File file;
Map<String, SimpleOption<?>> options;
Expand Down Expand Up @@ -45,21 +40,21 @@ public class Options {

public Options() {
this.file = new File(AutumnClient.client.runDirectory, "config/autumn.properties");
this.options = new HashMap<String, SimpleOption<?>>();
this.options = new HashMap<>();

autoAttack = SimpleOption.ofBoolean("Auto Attack", value -> Tooltip.of(Text.of("Automatically attack living entity at crosshair within reach")), false);
options.put("autoAttack", autoAttack);
ignorePlayer = SimpleOption.ofBoolean("Ignore Player", value -> Tooltip.of(Text.of("Auto Attack will ignore player")), false);
options.put("ignorePlayer", ignorePlayer);
betterChat = SimpleOption.ofBoolean("Better Chat", value -> Tooltip.of(Text.of("Lengthen chat history to 65535 lines, keep chat/command history on switching world/server & remove chat indicator")), true);
betterChat = SimpleOption.ofBoolean("Better Chat", value -> Tooltip.of(Text.of("Lengthen chat history to 65k lines, keep chat/command history on switching world/server & remove chat indicator")), true);
options.put("betterChat", betterChat);
betterNametag = SimpleOption.ofBoolean("Better Nametag", value -> Tooltip.of(Text.of("Add health & gamemode to nametag, make nametag always visible & show targeted entity nametag")), true);
betterNametag = SimpleOption.ofBoolean("Better Nametag", value -> Tooltip.of(Text.of("Add health & gamemode to nametag, make player nametag always visible & show recently targeted entity nametag")), true);
options.put("betterNametag", betterNametag);
deathCoord = SimpleOption.ofBoolean("Death Coord", value -> Tooltip.of(Text.of("Show death coordinates in chat")), true);
options.put("deathCoord", deathCoord);
fullBright = SimpleOption.ofBoolean("Full Bright", value -> Tooltip.of(Text.of("No more darkness")), true);
options.put("fullBright", fullBright);
horseSwim = SimpleOption.ofBoolean("Horse Swim", value -> Tooltip.of(Text.of("Make riding horse swim in water")), true);
horseSwim = SimpleOption.ofBoolean("Horse Swim", value -> Tooltip.of(Text.of("Make riding horse swim in water & lava")), true);
options.put("horseSwim", horseSwim);
infoHud = SimpleOption.ofBoolean("Info Hud", value -> Tooltip.of(Text.of("Show fps, coordinates, direction, tps, targeted entity health & horse stats on screen, show armor above hotbar, show hunger & xp bar when riding")), true);
options.put("infoHud", infoHud);
Expand All @@ -85,23 +80,22 @@ public Options() {
options.put("rightClickHarvest", rightClickHarvest);
thirdPersonNoClip = SimpleOption.ofBoolean("Third Person No Clip", value -> Tooltip.of(Text.of("Let third-person camera clip through blocks")), true);
options.put("thirdPersonNoClip", thirdPersonNoClip);
visibleBarrier = SimpleOption.ofBoolean("Visible Barrier", value -> Tooltip.of(Text.of("Force render barrier block")), true);
visibleBarrier = SimpleOption.ofBoolean("Visible Barrier", value -> Tooltip.of(Text.of("Force render barrier block")), true, value -> AutumnClient.client.worldRenderer.reload());
options.put("visibleBarrier", visibleBarrier);

if (file.exists()) {
try (BufferedReader reader = new BufferedReader(new FileReader(file, StandardCharsets.UTF_8))) {
reader.lines().forEach(line -> {
String[] split = line.split("=");
if (split.length != 2) {
Autumn.LOGGER.warn("Invalid line in config file: " + line);
Autumn.LOGGER.warn("Invalid line in config file: {}", line);
return;
}
String key = split[0];
String value = split[1];
SimpleOption<?> option = options.get(key);
if (option == null || value.isEmpty()) {
Autumn.LOGGER.warn("Invalid option in config file: " + line);
return;
Autumn.LOGGER.warn("Invalid option in config file: {}", line);
} else {
parseOption(option, value);
}
Expand All @@ -110,14 +104,17 @@ public Options() {
Autumn.LOGGER.error("Failed to read config file", e);
}
} else {
file.getParentFile().mkdirs();
boolean mkdirs = file.getParentFile().mkdirs();
if (!mkdirs) {
Autumn.LOGGER.error("Failed to create config directory");
}
save();
}
}

<T> void parseOption(SimpleOption<T> option, String value) {
DataResult<T> result = option.getCodec().parse(JsonOps.INSTANCE, JsonParser.parseString(value));
result.error().ifPresent(e -> Autumn.LOGGER.warn("Failed to parse option: " + e.message()));
result.error().ifPresent(e -> Autumn.LOGGER.warn("Failed to parse option: {}", e.message()));
result.result().ifPresent(option::setValue);
}

Expand Down
Loading

0 comments on commit 3ca6cda

Please sign in to comment.