Skip to content

Commit

Permalink
Update to v2.2.0
Browse files Browse the repository at this point in the history
See #11
  • Loading branch information
Hugman76 authored Aug 11, 2023
2 parents f177e39 + 12a5f84 commit f58663a
Show file tree
Hide file tree
Showing 25 changed files with 332 additions and 219 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/cache@v2
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.gradle/loom-cache
Expand All @@ -17,7 +18,8 @@ jobs:
restore-keys: |
gradle-
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
Expand Down
57 changes: 34 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@
# Automatically builds and publishes the mod when a new release is created on GitHub.
# It uploads the mod to GitHub, CurseForge and Modrinth.

name: Release

on:
release:
types:
- published
types: [published]

jobs:
build:
publish:
name: Build & Publish
runs-on: ubuntu-latest

steps:
- uses: actions/cache@v2
with:
path: |
~/.gradle/loom-cache
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- uses: actions/checkout@v2
- name: Set up JDK

- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
java-version: '17'

- name: Grant execute permission for gradlew
run: chmod +x gradlew
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew build
run: ./gradlew clean build -Pversion=${{ github.event.release.tag_name }}

- name: Upload GitHub release
uses: AButler/[email protected]
- name: Publish mod to GitHub, CurseForge and Modrinth
id: publish
uses: Kir-Antipov/[email protected]
with:
files: 'build/libs/*.jar;!build/libs/*-sources.jar;!build/libs/*-dev.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}

changelog: ${{ github.event.release.body }}
java: 17

modrinth-featured: false

- name: Add job summary
run: |
echo "# Results" >> $GITHUB_STEP_SUMMARY
echo "- [CurseForge Link](${{ steps.publish.outputs.curseforge-url }})" >> $GITHUB_STEP_SUMMARY
echo "- [Modrinth Link](${{ steps.publish.outputs.modrinth-url }})" >> $GITHUB_STEP_SUMMARY
echo "- [GitHub Link](${{ steps.publish.outputs.github-url }})" >> $GITHUB_STEP_SUMMARY
echo "# Changelog" >> $GITHUB_STEP_SUMMARY
echo "${{ github.event.release.body }}" >> $GITHUB_STEP_SUMMARY
38 changes: 32 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
# UHC
The UHC (abbreviation for Ultra HardCore) is a popular Minecraft survival minigame that can be played alone or with a team.
This a mod that implements it for Fabric using the [Plasmid API](https://github.com/NucleoidMC/plasmid).
# 🍏 UHC

Check out the [wiki](https://github.com/NucleoidMC/UHC/wiki) for instructions on how to personalize your UHC experience!
UHC (abbreviation for Ultra HardCore) is a popular Minecraft survival minigame that can be played alone or with a team.
This mod also includes UHCRun, a variant of UHC that tweaks the game in many ways to make it 2x faster.

This is a part of an attempt to create an open source Fabric-based minigames server.
For more information, see [our website](https://nucleoid.xyz).
UHC is one of the minigames made for the [Nucleoid Project](https://nucleoid.xyz/), an effort to build an open source ecosystem for server-side Minecraft minigames.
You may even be interested in playing some of them over on our testing Minecraft server at `nucleoid.xyz`!
You can also find us on our [Discord](https://nucleoid.xyz/discord) if you have any troubles or queries, or would like to get involved.

## Installation

UHC can be installed on a client or a server. As this is a multiplayer minigame though, it is recommended to install it on a server.

⚠ UHC **needs** the following mods to be installed:
- Plasmid: [GitHub](https://github.com/NucleoidMC/plasmid) / [Modrinth](https://modrinth.com/mod/plasmid)
- Fabric API: [GitHub](https://github.com/FabricMC/fabric) / [CurseForge](https://www.curseforge.com/minecraft/mc-mods/fabric-api) / [Modrinth](https://modrinth.com/mod/fabric-api)

## Usage

To start a game of UHC, use `/game open` and browse the list of available game modes.

## Modifications

To configure UHC, or to contribute to the project, visit [the official documentation](https://docs.nucleoid.xyz/uhc/).

## Credits

- [Hugman](https://github.com/Hugman76) - Development

### 🌐 Translations
| Language | Translators |
|----------------|---------------------------------------|
| English (base) | [Hugman](https://github.com/Hugman76) |
| French | [Hugman](https://github.com/Hugman76) |
17 changes: 10 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Mod Properties
mod_version=2.2.0
maven_group=com.hugman
archives_base_name=uhc

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
yarn_mappings=1.20.1+build.10
loader_version=0.14.21
fabric_version=0.86.0+1.20.1
# Mod Properties
mod_version=2.1.0
maven_group=com.hugman
archives_base_name=uhc
fabric_version=0.86.1+1.20.1

# check this on https://nucleoid.xyz/use/
plasmid_version=0.5+1.20.1-SNAPSHOT
plasmid_version=0.5.101-SNAPSHOT+1.20.1
13 changes: 11 additions & 2 deletions src/main/java/com/hugman/uhc/UHC.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import com.hugman.uhc.game.phase.UHCWaiting;
import com.hugman.uhc.modifier.ModifierType;
import com.hugman.uhc.module.Module;
import com.hugman.uhc.module.ModuleManager;
import com.hugman.uhc.registry.UHCRegistries;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -26,9 +27,17 @@ public void onInitialize() {
Reflection.initialize(Module.class);
Reflection.initialize(ModifierType.class);

ModuleManager.register();
UHCRegistries.register();

CommandRegistrationCallback.EVENT.register((dispatcher, dedicated, environment) -> ModulesCommand.register(dispatcher));
GameType.register(UHC.id("uhc"), UHCConfig.CODEC, UHCWaiting::open);
}

public static void debug(String s) {
if(debug()) LOGGER.info(s);
}

public static boolean debug() {
return FabricLoader.getInstance().isDevelopmentEnvironment();
}
}
12 changes: 0 additions & 12 deletions src/main/java/com/hugman/uhc/UHCRegistries.java

This file was deleted.

11 changes: 6 additions & 5 deletions src/main/java/com/hugman/uhc/command/ModulesCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import eu.pb4.sgui.api.gui.SimpleGui;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntryList;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
Expand All @@ -21,7 +22,6 @@
import xyz.nucleoid.plasmid.game.manager.GameSpaceManager;
import xyz.nucleoid.plasmid.game.manager.ManagedGameSpace;

import java.util.List;
import java.util.Objects;

public class ModulesCommand {
Expand All @@ -44,13 +44,14 @@ public static boolean isSourceUHC(ServerCommandSource source) {

private static int displayModules(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerCommandSource source = context.getSource();
List<Module> modules = ((UHCConfig) Objects.requireNonNull(GameSpaceManager.get().byWorld(source.getWorld())).getMetadata().sourceConfig().config()).getModules();
if (modules.size() != 0) {
ScreenHandlerType<?> type = Registries.SCREEN_HANDLER.get(new Identifier("generic_9x" + MathHelper.clamp(1, MathHelper.ceil((float) modules.size() / 9), 6)));
RegistryEntryList<Module> moduleEntries = ((UHCConfig) Objects.requireNonNull(GameSpaceManager.get().byWorld(source.getWorld())).getMetadata().sourceConfig().config()).modules();
if (moduleEntries.size() != 0) {
ScreenHandlerType<?> type = Registries.SCREEN_HANDLER.get(new Identifier("generic_9x" + MathHelper.clamp(1, MathHelper.ceil((float) moduleEntries.size() / 9), 6)));
SimpleGui gui = new SimpleGui(type, source.getPlayer(), false);
gui.setTitle(Text.translatable("ui.uhc.modules.title"));
int i = 0;
for (Module module : modules) {
for (var moduleEntry : moduleEntries) {
var module = moduleEntry.value();
GuiElementBuilder elementBuilder = new GuiElementBuilder(module.icon())
.setName(Text.translatable(module.translation()).formatted(Formatting.BOLD).setStyle(Style.EMPTY.withColor(module.color())))
.hideFlags();
Expand Down
46 changes: 14 additions & 32 deletions src/main/java/com/hugman/uhc/config/UHCConfig.java
Original file line number Diff line number Diff line change
@@ -1,61 +1,43 @@
package com.hugman.uhc.config;

import com.hugman.uhc.UHC;
import com.hugman.uhc.UHCRegistries;
import com.hugman.uhc.modifier.Modifier;
import com.hugman.uhc.modifier.ModifierType;
import com.hugman.uhc.module.Module;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.Identifier;
import net.minecraft.registry.entry.RegistryEntryList;
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;

import java.util.ArrayList;
import java.util.List;

public record UHCConfig(PlayerConfig players, int teamSize, UHCMapConfig mapConfig, UHCChapterConfig chapterConfig,
List<Identifier> moduleIds) {
RegistryEntryList<Module> modules) {
public static final Codec<UHCConfig> CODEC = RecordCodecBuilder.create(instance -> instance.group(
PlayerConfig.CODEC.fieldOf("players").forGetter(UHCConfig::players),
Codec.INT.fieldOf("team_size").forGetter(UHCConfig::teamSize),
UHCMapConfig.CODEC.fieldOf("map").forGetter(UHCConfig::mapConfig),
UHCChapterConfig.CODEC.fieldOf("chapters").forGetter(UHCConfig::chapterConfig),
Identifier.CODEC.listOf().fieldOf("modules").orElse(List.of()).forGetter(UHCConfig::moduleIds)
// NOTE: we cannot use Module.REGISTRY_LIST_CODEC as Plasmid
// loads the game configs before all the other dynamic registries
// we need to work around this and use raw identifiers there
Module.LIST_CODEC.optionalFieldOf("modules", RegistryEntryList.of()).forGetter(UHCConfig::modules)
).apply(instance, UHCConfig::new));

public List<Module> getModules() {
List<Module> modules = new ArrayList<>();
if (!this.moduleIds.isEmpty()) {
for (Identifier moduleId : this.moduleIds) {
Module module = UHCRegistries.MODULE.get(moduleId);
if (module == null) {
UHC.LOGGER.error("Module {} not found", moduleId);
continue;
}
modules.add(module);
}
public List<Modifier> getModifiers() {
List<Modifier> modifiers = new ArrayList<>();
for (var moduleEntry : modules) {
modifiers.addAll(moduleEntry.value().modifiers());
}
return modules;
return modifiers;
}

public List<Modifier> getModulesPieces() {
List<Modifier> modifiers = new ArrayList<>();
if (!this.moduleIds.isEmpty()) {
for (Identifier moduleId : this.moduleIds) {
Module module = UHCRegistries.MODULE.get(moduleId);
if (module == null) {
continue;
public <V extends Modifier> List<V> getModifiers(ModifierType<V> type) {
List<V> modifiers = new ArrayList<>();
for (var moduleEntry : modules) {
for(Modifier modifier : moduleEntry.value().modifiers()) {
if(modifier.getType() == type) {
modifiers.add((V) modifier);
}
modifiers.addAll(module.pieces());
}
}
return modifiers;
}

public <V extends Modifier> List<V> getModulesPieces(ModifierType<V> type) {
return (List<V>) getModulesPieces().stream().filter(piece -> piece.getType().equals(type)).toList();
}
}
Loading

0 comments on commit f58663a

Please sign in to comment.