update to work with 1.20.2

This commit is contained in:
Rasmus Moorats 2023-11-20 16:26:03 +02:00
parent 41a998c7e6
commit 37c2050945
Signed by: xx
GPG key ID: FE14255A6AE7241C
5 changed files with 55 additions and 24 deletions
build.gradlegradle.properties
gradle/wrapper
src/main
java/ee/nns/hiddenhydration/mixin
resources

View file

@ -1,15 +1,15 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
@ -18,11 +18,31 @@ repositories {
// for more information about repositories.
}
loom {
splitEnvironmentSourceSets()
mods {
"modid" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
}
processResources {
@ -34,7 +54,6 @@ processResources {
}
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}
@ -43,11 +62,14 @@ java {
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
rename { "${it}_${project.base.archivesName.get()}"}
}
}
@ -66,4 +88,4 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}

View file

@ -1,11 +1,17 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Fabric Properties
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.1
loader_version=0.13.3
# check these on https://fabricmc.net/develop
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22
# Mod Properties
mod_version = 1.2.0
maven_group = com.xx
archives_base_name = hidden-hydration
mod_version=1.2.0
maven_group=com.xx
archives_base_name=hidden-hydration
# Dependencies
fabric_version=0.89.1+1.20.2

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -1,7 +1,7 @@
package ee.nns.hiddenhydration.mixin;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.tag.FluidTags;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldView;
import org.spongepowered.asm.mixin.Mixin;
@ -12,14 +12,17 @@ import java.util.Iterator;
@Mixin(FarmlandBlock.class)
public class HiddenHydrationMixin {
@Redirect(method = "randomTick(Lnet/minecraft/block/BlockState;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;Ljava/util/Random;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/FarmlandBlock;isWaterNearby(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;)Z"))
@Redirect(
method = "randomTick(Lnet/minecraft/block/BlockState;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/random/Random;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/FarmlandBlock;isWaterNearby(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;)Z")
)
boolean isWaterNearbyInjected(WorldView world, BlockPos pos) {
Iterator i = BlockPos.iterate(pos.add(-4, 0, -4), pos.add(4, 1, 4)).iterator();
Iterator j = BlockPos.iterate(pos.add(-2, -1, -2), pos.add(2, -1, 2)).iterator();
Iterator<BlockPos> i = BlockPos.iterate(pos.add(-4, 0, -4), pos.add(4, 1, 4)).iterator();
Iterator<BlockPos> j = BlockPos.iterate(pos.add(-2, -1, -2), pos.add(2, -1, 2)).iterator();
BlockPos blockPos;
do {
blockPos = (BlockPos) i.next();
blockPos = i.next();
if (world.getFluidState(blockPos).isIn(FluidTags.WATER)) {
return true;
@ -27,7 +30,7 @@ public class HiddenHydrationMixin {
} while (i.hasNext());
do {
blockPos = (BlockPos) j.next();
blockPos = j.next();
if (world.getFluidState(blockPos).isIn(FluidTags.WATER)) {
return true;

View file

@ -9,7 +9,7 @@
"xx"
],
"contact": {
"sources": "https://koodirepo.ee/xx/hidden-hydration"
"sources": "https://git.dog/xx/hidden-hydration"
},
"license": "Unlicense",
@ -22,8 +22,8 @@
],
"depends": {
"fabricloader": ">=0.13.3",
"minecraft": "1.18.x",
"fabricloader": ">=0.14.22",
"minecraft": "1.20.x",
"java": ">=17"
}
}