Skip to content

Commit 8e6ba87

Browse files
committed
no idea where i am, but i need it on my laptop
1 parent 91ee92d commit 8e6ba87

13 files changed

+162
-71
lines changed

Diff for: build.gradle

+27-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
plugins {
2-
id 'fabric-loom' version '1.1-SNAPSHOT'
2+
id 'fabric-loom' version '1.7-SNAPSHOT'
33
id 'maven-publish'
44
}
55

6-
sourceCompatibility = JavaVersion.VERSION_17
7-
targetCompatibility = JavaVersion.VERSION_17
8-
9-
archivesBaseName = project.archives_base_name
106
version = project.mod_version
117
group = project.maven_group
128

9+
base {
10+
archivesName = project.archives_base_name
11+
}
12+
1313
repositories {
1414
maven { url 'https://maven.wispforest.io/releases/' }
1515
}
1616

17+
loom {
18+
splitEnvironmentSourceSets()
19+
20+
mods {
21+
"modid" {
22+
sourceSet sourceSets.main
23+
sourceSet sourceSets.client
24+
}
25+
}
26+
27+
}
28+
1729
dependencies {
1830
// To change the versions see the gradle.properties file
1931
minecraft "com.mojang:minecraft:${project.minecraft_version}"
@@ -23,8 +35,8 @@ dependencies {
2335
annotationProcessor modImplementation("io.wispforest:owo-lib:${project.owo_version}")
2436
include "io.wispforest:owo-sentinel:${project.owo_version}"
2537

26-
// // Fabric API. This is technically optional, but you probably want it anyway.
27-
// modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
38+
// Fabric API. This is technically optional, but you probably want it anyway.
39+
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
2840
}
2941

3042
processResources {
@@ -36,27 +48,30 @@ processResources {
3648
}
3749

3850
tasks.withType(JavaCompile).configureEach {
39-
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
40-
it.options.release = 17
51+
it.options.release = 21
4152
}
4253

4354
java {
4455
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
4556
// if it is present.
4657
// If you remove this line, sources will not be generated.
4758
withSourcesJar()
59+
60+
sourceCompatibility = JavaVersion.VERSION_21
61+
targetCompatibility = JavaVersion.VERSION_21
4862
}
4963

5064
jar {
5165
from("LICENSE") {
52-
rename { "${it}_${project.archivesBaseName}"}
66+
rename { "${it}_${project.base.archivesName.get()}"}
5367
}
5468
}
5569

5670
// configure the maven publication
5771
publishing {
5872
publications {
59-
mavenJava(MavenPublication) {
73+
create("mavenJava", MavenPublication) {
74+
artifactId = project.archives_base_name
6075
from components.java
6176
}
6277
}
@@ -68,4 +83,4 @@ publishing {
6883
// The repositories here will be used for publishing your artifact, not for
6984
// retrieving dependencies.
7085
}
71-
}
86+
}

Diff for: gradle.properties

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ org.gradle.parallel=true
44

55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.20.1
8-
yarn_mappings=1.20.1+build.10
9-
loader_version=0.15.11
7+
minecraft_version=1.21
8+
yarn_mappings=1.21+build.9
9+
loader_version=0.16.0
1010

1111
# Mod Properties
12-
mod_version = 2.1.0
12+
mod_version = 2.1.1
1313
maven_group = me.ryleu
1414
archives_base_name = armor-nerf
1515

1616
# Dependencies
1717
# https://maven.wispforest.io/io/wispforest/owo-lib/
18-
owo_version=0.11.2+1.20
18+
owo_version=0.12.10+1.21
1919

20-
#fabric_version=0.92.2+1.20.1
20+
fabric_version=0.100.7+1.21

Diff for: gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#Sat Jul 20 23:38:31 EDT 2024
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4-
networkTimeout=10000
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

Diff for: gradlew

+18-13
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,10 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,26 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
146147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
148149
MAX_FD=$( ulimit -H -n ) ||
149150
warn "Could not query maximum file descriptor limit"
150151
esac
151152
case $MAX_FD in #(
152153
'' | soft) :;; #(
153154
*)
154155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
156157
ulimit -n "$MAX_FD" ||
157158
warn "Could not set maximum file descriptor limit to $MAX_FD"
158159
esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
197198
done
198199
fi
199200

200-
# Collect all arguments for the java command;
201-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202-
# shell script including quotes and variable substitutions, so put them in
203-
# double quotes to make sure that they get re-expanded; and
204-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
205210

206211
set -- \
207212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

Diff for: gradlew.bat

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
4343
%JAVA_EXE% -version >NUL 2>&1
4444
if %ERRORLEVEL% equ 0 goto execute
4545

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

5252
goto fail
5353

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

5858
if exist "%JAVA_EXE%" goto execute
5959

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6565

6666
goto fail
6767

Diff for: src/main/java/me/ryleu/armornerf/ArmorFormula.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package me.ryleu.armornerf;
22

3+
import net.minecraft.entity.LivingEntity;
4+
import net.minecraft.entity.damage.DamageSource;
5+
36
public abstract class ArmorFormula {
4-
public abstract float calculate(float damage, float armor, float armorToughness);
7+
public abstract float calculate(LivingEntity armorWearer, float damageAmount, DamageSource damageSource, float armor, float armorToughness);
58
}

Diff for: src/main/java/me/ryleu/armornerf/formula/FlatToughnessFormula.java

+20-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,32 @@
22

33
import me.ryleu.armornerf.ArmorFormula;
44
import me.ryleu.armornerf.ArmorNerf;
5+
import net.minecraft.enchantment.EnchantmentHelper;
6+
import net.minecraft.entity.LivingEntity;
7+
import net.minecraft.entity.damage.DamageSource;
8+
import net.minecraft.item.ItemStack;
9+
import net.minecraft.server.world.ServerWorld;
510
import net.minecraft.util.math.MathHelper;
11+
import net.minecraft.world.World;
612

713
/**
814
* Toughness will reduce damage by a flat amount with this formula
915
*/
1016
public class FlatToughnessFormula extends ArmorFormula {
1117
@Override
12-
public float calculate(float damage, float armor, float armorToughness) {
13-
float adjustedDamage = damage - armorToughness / 4F; // divide by the number of armor pieces
14-
// divide by 20 to get a percentage of the armor bar filled
15-
float adjustedArmor = MathHelper.clamp((armor / 20F) * ArmorNerf.CONFIG.armorPercentage(), 0F, 1F);
16-
return adjustedDamage * (1F - adjustedArmor);
18+
public float calculate(LivingEntity armorWearer, float damageAmount, DamageSource damageSource, float armor, float armorToughness) {
19+
float damageReduction = armorToughness / 4F;
20+
float adjustedArmor = Math.min(Math.max(armor, armor * 0.2F) / 20F * ArmorNerf.CONFIG.armorPercentage(), 1F);
21+
ItemStack itemStack = damageSource.getWeaponStack();
22+
World world = armorWearer.getWorld();
23+
float effectivenessAdjusted;
24+
if (itemStack != null && world instanceof ServerWorld serverWorld) {
25+
effectivenessAdjusted = MathHelper.clamp(EnchantmentHelper.getArmorEffectiveness(
26+
serverWorld, itemStack, armorWearer, damageSource, adjustedArmor), 0.0F, 1.0F);
27+
} else {
28+
effectivenessAdjusted = adjustedArmor;
29+
}
30+
31+
return (damageAmount - damageReduction) * (1.0F - effectivenessAdjusted);
1732
}
1833
}

Diff for: src/main/java/me/ryleu/armornerf/formula/LargeToughnessFormula.java

+22-5
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,32 @@
22

33
import me.ryleu.armornerf.ArmorFormula;
44
import me.ryleu.armornerf.ArmorNerf;
5+
import net.minecraft.enchantment.EnchantmentHelper;
6+
import net.minecraft.entity.LivingEntity;
7+
import net.minecraft.entity.damage.DamageSource;
8+
import net.minecraft.item.ItemStack;
9+
import net.minecraft.server.world.ServerWorld;
10+
import net.minecraft.util.math.MathHelper;
11+
import net.minecraft.world.World;
512

613
/**
714
* Toughness will protect more against larger damage values with this formula
815
*/
916
public class LargeToughnessFormula extends ArmorFormula {
10-
@Override
11-
public float calculate(float damage, float armor, float armorToughness) {
12-
float armorIncrease = Math.min(damage, 20F) * armorToughness / 100F;
13-
float adjustedArmor = ((armor + armorIncrease) / 20F) * ArmorNerf.CONFIG.armorPercentage();
14-
return (1 - adjustedArmor) * damage;
17+
@Override
18+
public float calculate(LivingEntity armorWearer, float damageAmount, DamageSource damageSource, float armor, float armorToughness) {
19+
float armorIncrease = Math.min(damageAmount, 20F) * armorToughness / 100F;
20+
float adjustedArmor = Math.min((armor / 20F + armorIncrease) * ArmorNerf.CONFIG.armorPercentage(), 1F);
21+
ItemStack itemStack = damageSource.getWeaponStack();
22+
World world = armorWearer.getWorld();
23+
float effectivenessAdjusted;
24+
if (itemStack != null && world instanceof ServerWorld serverWorld) {
25+
effectivenessAdjusted = MathHelper.clamp(EnchantmentHelper.getArmorEffectiveness(
26+
serverWorld, itemStack, armorWearer, damageSource, adjustedArmor), 0.0F, 1.0F);
27+
} else {
28+
effectivenessAdjusted = adjustedArmor;
29+
}
30+
31+
return damageAmount * (1.0F - effectivenessAdjusted);
1532
}
1633
}

Diff for: src/main/java/me/ryleu/armornerf/formula/ToughnessDisabledFormula.java

+19-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,28 @@
22

33
import me.ryleu.armornerf.ArmorFormula;
44
import me.ryleu.armornerf.ArmorNerf;
5+
import net.minecraft.enchantment.EnchantmentHelper;
6+
import net.minecraft.entity.LivingEntity;
7+
import net.minecraft.entity.damage.DamageSource;
8+
import net.minecraft.item.ItemStack;
9+
import net.minecraft.server.world.ServerWorld;
510
import net.minecraft.util.math.MathHelper;
11+
import net.minecraft.world.World;
612

713
public class ToughnessDisabledFormula extends ArmorFormula {
814
@Override
9-
public float calculate(float damage, float armor, float armorToughness) {
10-
float adjustedArmor = MathHelper.clamp((armor / 20F) * ArmorNerf.CONFIG.armorPercentage(), 0F, 1F);
11-
return damage * (1F - adjustedArmor);
15+
public float calculate(LivingEntity armorWearer, float damageAmount, DamageSource damageSource, float armor, float armorToughness) {
16+
float adjustedArmor = Math.min(armor / 20F * ArmorNerf.CONFIG.armorPercentage(), 1F);
17+
ItemStack itemStack = damageSource.getWeaponStack();
18+
World world = armorWearer.getWorld();
19+
float effectivenessAdjusted;
20+
if (itemStack != null && world instanceof ServerWorld serverWorld) {
21+
effectivenessAdjusted = MathHelper.clamp(EnchantmentHelper.getArmorEffectiveness(
22+
serverWorld, itemStack, armorWearer, damageSource, adjustedArmor), 0.0F, 1.0F);
23+
} else {
24+
effectivenessAdjusted = adjustedArmor;
25+
}
26+
27+
return damageAmount * (1.0F - effectivenessAdjusted);
1228
}
1329
}

Diff for: src/main/java/me/ryleu/armornerf/formula/VanillaFormula.java

+22-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,30 @@
22

33
import me.ryleu.armornerf.ArmorFormula;
44
import me.ryleu.armornerf.ArmorNerf;
5+
import net.minecraft.enchantment.EnchantmentHelper;
6+
import net.minecraft.entity.LivingEntity;
7+
import net.minecraft.entity.damage.DamageSource;
8+
import net.minecraft.item.ItemStack;
9+
import net.minecraft.server.world.ServerWorld;
10+
import net.minecraft.util.math.MathHelper;
11+
import net.minecraft.world.World;
512

613
public class VanillaFormula extends ArmorFormula {
714
@Override
8-
public float calculate(float damage, float armor, float armorToughness) {
9-
float armorReduction = damage / (2F + armorToughness / 4F);
10-
float adjustedArmor = Math.min(Math.max(
11-
armor * 0.2F, // large damage amounts cannot lower the armor below 20% efficacy
12-
(armor - armorReduction)
13-
) * ArmorNerf.CONFIG.armorPercentage() / 20F, 1F);
14-
return damage * (1F - adjustedArmor);
15+
public float calculate(LivingEntity armorWearer, float damageAmount, DamageSource damageSource, float armor, float armorToughness) {
16+
float armorReduction = damageAmount / (2.0F + armorToughness / 4.0F);
17+
float adjustedArmor = Math.min(
18+
Math.max(armor - armorReduction, armor * 0.2F) / 20F * ArmorNerf.CONFIG.armorPercentage(), 1F);
19+
ItemStack itemStack = damageSource.getWeaponStack();
20+
World world = armorWearer.getWorld();
21+
float effectivenessAdjusted;
22+
if (itemStack != null && world instanceof ServerWorld serverWorld) {
23+
effectivenessAdjusted = MathHelper.clamp(EnchantmentHelper.getArmorEffectiveness(
24+
serverWorld, itemStack, armorWearer, damageSource, adjustedArmor), 0.0F, 1.0F);
25+
} else {
26+
effectivenessAdjusted = adjustedArmor;
27+
}
28+
29+
return damageAmount * (1.0F - effectivenessAdjusted);
1530
}
1631
}

0 commit comments

Comments
 (0)