Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/Multiloader-1.19' into M…
Browse files Browse the repository at this point in the history
…ultiloader-1.18
  • Loading branch information
fayer3 committed Oct 9, 2023
2 parents a3f581b + 41da9b0 commit e301ed5
Show file tree
Hide file tree
Showing 19 changed files with 386 additions and 141 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ ij_smart_tabs = false
ij_visual_guides = none
ij_wrap_on_typing = false

[{*.yml,*.yaml}]
indent_size = 2
ij_yaml_align_values_properties = do_not_align
ij_yaml_autoinsert_sequence_marker = true
ij_yaml_block_mapping_on_new_line = false
ij_yaml_indent_sequence_value = true
ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true
ij_yaml_sequence_on_new_line = false
ij_yaml_space_before_colon = false
ij_yaml_spaces_within_braces = true
ij_yaml_spaces_within_brackets = true

[{*.vrmanifest,*.har,*.jsb2,*.jsb3,*.json,*.png.mcmeta,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config,mcmod.info,pack.mcmeta}]
indent_size = 2
ij_json_array_wrapping = on_every_item
Expand Down
157 changes: 127 additions & 30 deletions .github/workflows/publish-on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ run-name: Posting jars on Curseforge and Modrinth

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

jobs:
publish:
Expand All @@ -25,7 +25,7 @@ jobs:
if [ -n "${filePaths[i]}" ]; then
curl -L -o "./${fileNames[i]}" "${filePaths[i]}"
fi
if [[ "${fileNames[i]}" == *"fabric"* ]]; then
echo "FABRIC_FILE_NAME=${fileNames[i]}" >> $GITHUB_OUTPUT
echo "FABRIC_FILE_PATH=./${fileNames[i]}" >> $GITHUB_OUTPUT
Expand All @@ -48,6 +48,33 @@ jobs:
id: version
shell: bash
run: |
parse_fabric () {
unzip -j "$1" "$2" -d ./fabric
deps=false
bracket=false
parsedVersion=""
depReg='\s+"depends"'
minecraftVersionReg='\s*?"minecraft":\s*?(.+?)*'
wordReg="(.*?),*"
bracketReg="(.*])"
while read -r; do
if [[ $REPLY =~ $depReg ]]; then
deps=true
elif [[ $REPLY =~ $minecraftVersionReg && $deps == "true" ]]; then
if [[ ${BASH_REMATCH[1]} =~ $wordReg ]]; then
parsedVersion=${BASH_REMATCH[1]}
if [[ ${BASH_REMATCH[1]} == "[" ]]; then
bracket=true
fi
fi
elif [[ $bracket == "true" && $REPLY != *"]"* ]]; then
parsedVersion=${parsedVersion}$REPLY
elif [[ $bracket == "true" && $REPLY =~ $bracketReg ]]; then
parsedVersion=${parsedVersion}${BASH_REMATCH[1]}
bracket=false
fi
done < ./fabric/$2
}
file=""
if [ -n "${{ steps.assets.outputs.FABRIC_FILE_NAME }}" ]; then
file="${{ steps.assets.outputs.FABRIC_FILE_NAME }}"
Expand All @@ -57,7 +84,7 @@ jobs:
file="${{ steps.assets.outputs.QUILT_FILE_NAME }}"
fi
echo $file
# save the current IFS value
OLDIFS=$IFS
# set the IFS to the delimiter ("-")
Expand All @@ -66,24 +93,24 @@ jobs:
array=($file)
# restore the IFS value
IFS=$OLDIFS
# alphas or beats should be included in the version
if [ ${array[3]:0:1} = "a" ] || [ ${array[3]:0:1} = "b" ]; then
array[2]=${array[2]}-${array[3]}
fi
release_type="release"
if [ ${array[3]:0:1} = "a" ]; then
release_type="alpha"
elif [ ${array[3]:0:1} = "b" ]; then
release_type="beta"
fi
echo release type: ${release_type}
echo "RELEASE_TYPE=${release_type}" >> $GITHUB_OUTPUT
mc_version=${array[1]}
# mod loaders
loaders_fabric=fabric
# check if there is a quilt specific jar
Expand All @@ -93,39 +120,67 @@ jobs:
loaders_quilt="quilt"
fi
loaders_forge="forge"
echo mc version: $mc_version
echo "MC_VERSION=$mc_version" >> $GITHUB_OUTPUT
if [ -n "${{ steps.assets.outputs.FABRIC_FILE_NAME }}" ]; then
parse_fabric ${{ steps.assets.outputs.FABRIC_FILE_NAME }} "fabric.mod.json"
echo "FABRIC_MC_VERSIONS="${parsedVersion}"" >> $GITHUB_OUTPUT
fi
if [ -n "${{ steps.assets.outputs.FORGE_FILE_NAME }}" ]; then
unzip -j "${{ steps.assets.outputs.FORGE_FILE_NAME }}" "META-INF/mods.toml" -d ./forge
minecraftDep=false
minecraftIdReg='modId\s+=\s+"minecraft"'
versionRangeReg='versionRange\s+=\s+"(.+?)"'
while read -r; do
if [[ $REPLY =~ $minecraftIdReg ]]; then
minecraftDep=true
echo $REPLY
elif [[ $REPLY =~ $versionRangeReg && $minecraftDep == "true" ]]; then
echo "FORGE_MC_VERSIONS="${BASH_REMATCH[1]}"" >> $GITHUB_OUTPUT
echo ${BASH_REMATCH[0]}
echo ${BASH_REMATCH[1]}
fi
done < ./forge/mods.toml
fi
if [ -n "${{ steps.assets.outputs.QUILT_FILE_NAME }}" ]; then
parse_fabric ${{ steps.assets.outputs.QUILT_FILE_NAME }} "quilt.mod.json"
echo "QUILT_MC_VERSIONS="${parsedVersion}"" >> $GITHUB_OUTPUT
fi
echo loaders fabric: ${loaders_fabric}
echo "LOADERS_FABRIC=${loaders_fabric}" >> $GITHUB_OUTPUT
echo loaders forge: ${loaders_forge}
echo "LOADERS_FORGE=${loaders_forge}" >> $GITHUB_OUTPUT
echo loaders quilt: ${loaders_quilt}
echo "LOADERS_QUILT=${loaders_quilt}" >> $GITHUB_OUTPUT
mod_name="${array[0]^} $mc_version-${array[2]}"
echo file name fabric: "${mod_name}-fabric"
echo "VERSION_NAME_FABRIC=${mod_name}-fabric" >> $GITHUB_OUTPUT
echo file name forge: "${mod_name}-forge"
echo "VERSION_NAME_FORGE=${mod_name}-forge" >> $GITHUB_OUTPUT
echo file name quilt: "${mod_name}-quilt"
echo "VERSION_NAME_QUILT=${mod_name}-quilt" >> $GITHUB_OUTPUT
# modrinth mod versions
base_version="$mc_version-${array[2]}"
echo md version fabric: "${base_version}-fabric"
echo "MD_VERSION_FABRIC=${base_version}-fabric" >> $GITHUB_OUTPUT
echo md version forge: "${base_version}-forge"
echo "MD_VERSION_FORGE=${base_version}-forge" >> $GITHUB_OUTPUT
echo md version fquilt: "${base_version}-quilt"
echo "MD_VERSION_QUILT=${base_version}-quilt" >> $GITHUB_OUTPUT
- run: echo Minecraft target version is ${{ steps.version.outputs.MC_VERSION }}
echo "MOD_VERSION_FABRIC=${base_version}-fabric" >> $GITHUB_OUTPUT
echo "MOD_VERSION_FORGE=${base_version}-forge" >> $GITHUB_OUTPUT
echo "MOD_VERSION_QUILT=${base_version}-quilt" >> $GITHUB_OUTPUT
echo "MOD_VERSION=${base_version}" >> $GITHUB_OUTPUT
- run: echo release type is ${{ steps.version.outputs.RELEASE_TYPE }}

- run: echo fabric mc versions are ${{ steps.version.outputs.FABRIC_MC_VERSIONS }}
- run: echo fabric mod version ${{ steps.version.outputs.MOD_VERSION_FABRIC }}

- run: echo forge mc versions are ${{ steps.version.outputs.FORGE_MC_VERSIONS }}
- run: echo forge mod version ${{ steps.version.outputs.MOD_VERSION_FORGE }}

- run: echo quilt mc versions are ${{ steps.version.outputs.QUILT_MC_VERSIONS }}
- run: echo quilt mod version ${{ steps.version.outputs.MOD_VERSION_QUILT }}

- name: publish fabric
if: steps.assets.outputs.FABRIC_FILE_PATH != ''
uses: Kir-Antipov/[email protected]
Expand All @@ -140,11 +195,11 @@ jobs:
files-primary: ${{ steps.assets.outputs.FABRIC_FILE_PATH }}

name: "${{ steps.version.outputs.VERSION_NAME_FABRIC }}"
version: "${{ steps.version.outputs.MD_VERSION_FABRIC }}"
version: "${{ steps.version.outputs.MOD_VERSION_FABRIC }}"
version-type: "${{ steps.version.outputs.RELEASE_TYPE }}"

loaders: "${{ steps.version.outputs.LOADERS_FABRIC }}"
game-versions: "${{ steps.version.outputs.MC_VERSION }}"
game-versions: "${{ steps.version.outputs.FABRIC_MC_VERSIONS }}"

- name: publish forge
if: steps.assets.outputs.FORGE_FILE_PATH != ''
Expand All @@ -160,11 +215,11 @@ jobs:
files-primary: ${{ steps.assets.outputs.FORGE_FILE_PATH }}

name: "${{ steps.version.outputs.VERSION_NAME_FORGE }}"
version: "${{ steps.version.outputs.MD_VERSION_FORGE }}"
version: "${{ steps.version.outputs.MOD_VERSION_FORGE }}"
version-type: "${{ steps.version.outputs.RELEASE_TYPE }}"

loaders: "${{ steps.version.outputs.LOADERS_FORGE}}"
game-versions: "${{ steps.version.outputs.MC_VERSION }}"
game-versions: "${{ steps.version.outputs.FORGE_MC_VERSIONS }}"

- name: publish quilt
if: steps.assets.outputs.QUILT_FILE_PATH != ''
Expand All @@ -180,8 +235,50 @@ jobs:
files-primary: ${{ steps.assets.outputs.QUILT_FILE_PATH }}

name: "${{ steps.version.outputs.VERSION_NAME_QUILT }}"
version: "${{ steps.version.outputs.MD_VERSION_QUILT}}"
version: "${{ steps.version.outputs.MOD_VERSION_QUILT}}"
version-type: "${{ steps.version.outputs.RELEASE_TYPE }}"

loaders: "${{ steps.version.outputs.LOADERS_QUILT}}"
game-versions: "${{ steps.version.outputs.MC_VERSION }}"
game-versions: "${{ steps.version.outputs.QUILT_MC_VERSIONS }}"

# update forge versions json
- name: checkout repo forge-versions
if: steps.assets.outputs.FORGE_FILE_PATH != ''
uses: actions/checkout@v4
with:
ref: 'forge-versions'

- name: setup python
if: steps.assets.outputs.FORGE_FILE_PATH != ''
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: execute py script to update json
if: steps.assets.outputs.FORGE_FILE_PATH != ''
run: |
python -c "
import sys, json
print(sys.argv)
mc_version = sys.argv[1]
mod_version = sys.argv[2]
release_type = sys.argv[3]
jsonContent = {}
with open('forge_updates.json', 'r') as infile:
jsonContent = json.load(infile)
for str in mc_version.split(','):
version = str.strip('[]\" ')
if version != '':
jsonContent['promos'][version + '-latest'] = mod_version
if release_type == 'release':
jsonContent['promos'][version + '-recommended'] = mod_version
print(json.dumps(jsonContent, indent='\t'))
with open('forge_updates.json', 'w') as outfile:
outfile.write(json.dumps(jsonContent, indent='\t'))
" "${{ steps.version.outputs.FORGE_MC_VERSIONS }}" "${{ steps.version.outputs.MOD_VERSION }}" "${{ steps.version.outputs.RELEASE_TYPE }}"
- name: push new update json
if: steps.assets.outputs.FORGE_FILE_PATH != ''
uses: EndBug/add-and-commit@v9
with:
message: 'update ${{ steps.version.outputs.FORGE_MC_VERSIONS }} to ${{ steps.version.outputs.MOD_VERSION }}'
push: true
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class GuiOtherHUDSettings extends GuiVROptionsBase {

static VRSettings.VrOptions[] messages = new VRSettings.VrOptions[]{
VRSettings.VrOptions.SHOW_UPDATES,
VRSettings.VrOptions.UPDATE_TYPE,
VRSettings.VrOptions.SHOW_PLUGIN,
VRSettings.VrOptions.SHOW_PLUGIN_MISSING,
VRSettings.VrOptions.CHAT_MESSAGE_STENCIL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Collections;
import java.util.List;
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;

public class SettingsList extends ContainerObjectSelectionList<SettingsList.BaseEntry> {
final Screen parent;
Expand Down Expand Up @@ -46,8 +47,8 @@ public int getRowWidth() {
return super.getRowWidth() + 32;
}

public static BaseEntry ConfigToEntry(ConfigBuilder.ConfigValue configValue, Component name) {
AbstractWidget widget = configValue.getWidget(ResettableEntry.valueButtonWidth, 20);
public static BaseEntry ConfigToEntry(ConfigBuilder.ConfigValue<?> configValue, Component name) {
AbstractWidget widget = configValue.getWidget(ResettableEntry.valueButtonWidth, 20).get();
return new ResettableEntry(name, widget, configValue);
}

Expand Down Expand Up @@ -91,13 +92,13 @@ public static class ResettableEntry extends WidgetEntry {

public static final int valueButtonWidth = 125;

public ResettableEntry(Component name, AbstractWidget valueWidget, ConfigBuilder.ConfigValue configValue) {
public ResettableEntry(Component name, AbstractWidget valueWidget, ConfigBuilder.ConfigValue<?> configValue) {
super(name, valueWidget);

this.canReset = () -> !configValue.isDefault();
this.resetButton = new Button(0, 0, 20, 20, new TextComponent("X"), button -> {
configValue.reset();
this.valueWidget = configValue.getWidget(valueWidget.getWidth(), valueWidget.getHeight());
this.valueWidget = configValue.getWidget(valueWidget.getWidth(), valueWidget.getHeight()).get();
}, (button, poseStack, x, y) -> Minecraft.getInstance().screen.renderTooltip(poseStack, new TranslatableComponent("controls.reset"), x, y));
}

Expand Down
29 changes: 27 additions & 2 deletions common/src/main/java/org/vivecraft/client/utils/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.mojang.logging.LogUtils;
import net.minecraft.SharedConstants;
import org.vivecraft.client.Xplat;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.server.config.ServerConfig;

import java.io.BufferedReader;
import java.io.IOException;
Expand All @@ -28,6 +30,20 @@ public class UpdateChecker {

public static boolean checkForUpdates() {
System.out.println("Checking for Vivecraft Updates");

char updateType;
if (Xplat.isDedicatedServer()) {
// server
updateType = ServerConfig.checkForUpdateType.get().charAt(0);
} else {
// client
updateType = switch (ClientDataHolderVR.getInstance().vrSettings.updateType) {
case RELEASE -> 'r';
case BETA -> 'b';
case ALPHA -> 'a';
};
}

try {
String apiURL = "https://api.modrinth.com/v2/project/vivecraft/version?loaders=[%22" + Xplat.getModloader() + "%22]&game_versions=[%22" + SharedConstants.VERSION_STRING + "%22]";
HttpURLConnection conn = (HttpURLConnection) new URL(apiURL).openConnection();
Expand Down Expand Up @@ -64,7 +80,7 @@ public static boolean checkForUpdates() {
Version current = new Version(currentVersionNumber, currentVersionNumber, "");

for (Version v : versions) {
if (current.compareTo(v) > 0) {
if (v.isVersionType(updateType) && current.compareTo(v) > 0) {
changelog += "§a" + v.fullVersion + "§r" + ": \n" + v.changelog + "\n\n";
if (newestVersion.isEmpty()) {
newestVersion = v.fullVersion;
Expand Down Expand Up @@ -109,7 +125,7 @@ public Version(String version, String version_number, String changelog) {
// prerelease
if (parts[2].matches("a\\d+")) {
alpha = Integer.parseInt(parts[2].replaceAll("\\D+", ""));
} else if (parts[2].matches("b\\d+\"")) {
} else if (parts[2].matches("b\\d+")) {
beta = Integer.parseInt(parts[2].replaceAll("\\D+", ""));
} else {
featureTest = true;
Expand All @@ -135,6 +151,15 @@ public int compareTo(UpdateChecker.Version o) {
return -1;
}

public boolean isVersionType(char versionType) {
return switch (versionType) {
case 'r' -> beta == 0 && alpha == 0 && !featureTest;
case 'b' -> beta >= 0 && alpha == 0 && !featureTest;
case 'a' -> alpha >= 0 && !featureTest;
default -> false;
};
}

// two digits per segment, should be enough right?
private long compareNumber() {
return alpha + beta * 100L + (alpha + beta == 0 || featureTest ? 1000L : 0L) + patch * 100000L + minor * 10000000L + major * 1000000000L;
Expand Down
Loading

0 comments on commit e301ed5

Please sign in to comment.