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
10 changes: 3 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
# against bad commits.

name: build
on: [pull_request, push]
on: [pull_request, push, workflow_dispatch]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
1.8, # Minimum supported by Minecraft
11, # Current Java LTS
15 # Latest version
]
java: [21]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.os }}
Expand All @@ -34,7 +30,7 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '11' }} # Only upload artifacts built from LTS java on one OS
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from LTS java on one OS
uses: actions/upload-artifact@v2
with:
name: Artifacts
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ bin/
# fabric

run/
/remappedSrc/
11 changes: 6 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.10
minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.15.11


# Mod Properties
mod_version = 0.2.0+1.20.5
mod_version = 0.2.0+1.21
maven_group = com.minenash
archives_base_name = action_hunger

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.97.6+1.20.5
fabric_version=0.100.7+1.21

# Optional
# bewitchment_version=4048571
Expand Down
23 changes: 9 additions & 14 deletions src/main/java/com/minenash/action_hunger/ActionHunger.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
Expand All @@ -32,15 +31,13 @@ public void onInitialize() {
Config.init("action_hunger", "ActionHunger", Config.class);
mapHealthEffects();

CommandRegistrationCallback.EVENT.register((dispatcher, access, env) -> {
dispatcher.register(CommandManager.literal("action_hunger_reload").executes( context -> {
Config.init("action_hunger", "ActionHunger", Config.class);
mapHealthEffects();
context.getSource().getServer().getPlayerManager().sendToAll(ServerPlayNetworking.createS2CPacket(new FoodLevelForSprintPacket(Config.foodLevelForSprint)));
context.getSource().sendMessage(Text.literal("§2[ActionHunger]:§a Config reload complete"));
return 1;
} ));
});
CommandRegistrationCallback.EVENT.register((dispatcher, access, env) -> dispatcher.register(CommandManager.literal("action_hunger_reload").executes(context -> {
Config.init("action_hunger", "ActionHunger", Config.class);
mapHealthEffects();
context.getSource().getServer().getPlayerManager().sendToAll(ServerPlayNetworking.createS2CPacket(new FoodLevelForSprintPacket(Config.foodLevelForSprint)));
context.getSource().sendMessage(Text.literal("§2[ActionHunger]:§a Config reload complete"));
return 1;
} )));

ServerTickEvents.END_SERVER_TICK.register(server -> {
for (HealthEffect effect : Config.effects) {
Expand All @@ -64,15 +61,13 @@ public void onInitialize() {

});

ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> {
((LivingEntityAccessor)player).setActiveItemStack(ItemStack.EMPTY);
});
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> ((LivingEntityAccessor)player).setActiveItemStack(ItemStack.EMPTY));

}

private void mapHealthEffects() {
for (HealthEffect effect : Config.effects)
effect.statusEffect = Registries.STATUS_EFFECT.get(new Identifier(effect.effect));
effect.statusEffect = Registries.STATUS_EFFECT.get(Identifier.of(effect.effect));
}

public static double getCurveModifier(float stepper, Config.Curve curve, float multiplier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.util.Identifier;

public record FoodLevelForSprintPacket(int foodLevel) implements CustomPayload {
public static final CustomPayload.Id<FoodLevelForSprintPacket> PACKET_ID = new CustomPayload.Id<>(new Identifier("action_hunger", "food_level_for_sprint"));
public static final CustomPayload.Id<FoodLevelForSprintPacket> PACKET_ID = new CustomPayload.Id<>(Identifier.of("action_hunger", "food_level_for_sprint"));
public static final PacketCodec<RegistryByteBuf, FoodLevelForSprintPacket> PACKET_CODEC = PacketCodecs.VAR_INT.xmap(FoodLevelForSprintPacket::new, FoodLevelForSprintPacket::foodLevel).cast();

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.minenash.action_hunger.config;

import net.minecraft.entity.effect.StatusEffect;
import static com.minenash.action_hunger.config.Config.*;

import com.minenash.action_hunger.config.Config.AmplifierCurveSource;
import com.minenash.action_hunger.config.Config.Curve;
import com.minenash.action_hunger.config.Config.RequiredBounds;

public class HealthEffect {

Expand Down