Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'fabric-loom' version '1.10-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -55,7 +55,7 @@ processResources {
}

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

java {
Expand All @@ -64,8 +64,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

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

jar {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.22
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.13

# Mod Properties
mod_version=1.0.1
mod_version=1.0.2
maven_group=xyz.fulmine.hungy
archives_base_name=hungy

# Dependencies
fabric_version=0.83.0+1.20
fabric_version=0.115.4+1.21.1
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.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package xyz.fulmine.hungy.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.entity.player.HungerManager;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.Difficulty;
import org.objectweb.asm.Opcodes;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(HungerManager.class)
public class PeacefulHungerManagerMixin {
@Inject(at = @At(
value = "FIELD",
target = "Lnet/minecraft/entity/player/HungerManager;saturationLevel:F",
opcode = Opcodes.GETFIELD,
ordinal = 0), method = "update(Lnet/minecraft/entity/player/PlayerEntity;)V")
private void alwaysHungry(PlayerEntity player, CallbackInfo info) {
if (((HungerManager)(Object)this).getSaturationLevel() <= 0 && player.getWorld().getDifficulty() == Difficulty.PEACEFUL) {
((HungerManager)(Object)this).setFoodLevel(Math.max(((HungerManager)(Object)this).getFoodLevel() - 1, 0));
public abstract class PeacefulHungerManagerMixin {
@WrapOperation(method = "update(Lnet/minecraft/entity/player/PlayerEntity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getDifficulty()Lnet/minecraft/world/Difficulty;"))
private Difficulty hungy$alwaysHungry(World instance, Operation<Difficulty> original) {
if (instance.getDifficulty() == Difficulty.PEACEFUL) {
return Difficulty.NORMAL;
}
return original.call(instance);
}
}
20 changes: 20 additions & 0 deletions src/main/java/xyz/fulmine/hungy/mixin/PretendNotPeacefulMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package xyz.fulmine.hungy.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.Difficulty;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(PlayerEntity.class)
public abstract class PretendNotPeacefulMixin {
@WrapOperation(method = "tickMovement()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getDifficulty()Lnet/minecraft/world/Difficulty;"))
private Difficulty hungy$pretendItsNotPeaceful(World instance, Operation<Difficulty> original) {
if (instance.getDifficulty() == Difficulty.PEACEFUL) {
return Difficulty.NORMAL;
}
return original.call(instance);
}
}

This file was deleted.

9 changes: 5 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"name": "hungy",
"description": "A simple mod that enables hunger in peaceful mode.",
"authors": [
"Jake Fulmine"
"Jake Fulmine",
"TheTrueYak"
],
"contact": {
"homepage": "https://modrinth.com/mod/hungy",
Expand All @@ -30,8 +31,8 @@
}
],
"depends": {
"fabricloader": ">=0.14.22",
"minecraft": "~1.20",
"java": ">=17"
"fabricloader": ">=0.16.0",
"minecraft": "~1.21.1",
"java": ">=21"
}
}
2 changes: 1 addition & 1 deletion src/main/resources/hungy.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"PeacefulHungerManagerMixin",
"PretendNotPeacefulRedirectMixin"
"PretendNotPeacefulMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down