diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index a7eb43f..e2d22a4 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ # These are supported funding model platforms - +ko_fi: wurst custom: https://www.wurstclient.net/donate/ diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..ca9850e --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,43 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle +name: Java CI with Gradle + +on: + push: + paths: + - '**.java' + - 'gradle**' + - 'build.gradle' + pull_request: + paths: + - '**.java' + - 'gradle**' + - 'build.gradle' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Set up Java 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'microsoft' + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Execute Gradle build + run: ./gradlew build + - name: VirusTotal scan + if: github.event_name == 'push' + uses: crazy-max/ghaction-virustotal@v4 + with: + vt_api_key: ${{ secrets.VIRUSTOTAL_API_KEY }} + files: | + ./build/libs/*.jar + continue-on-error: true diff --git a/.github/workflows/jsonsyntax.yml b/.github/workflows/jsonsyntax.yml new file mode 100644 index 0000000..e6f9a4d --- /dev/null +++ b/.github/workflows/jsonsyntax.yml @@ -0,0 +1,20 @@ +name: JSON syntax + +on: + push: + paths: + - '**.json' + pull_request: + paths: + - '**.json' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Check JSON syntax + uses: limitusus/json-syntax-check@v2 + with: + pattern: "\\.json$" diff --git a/README.md b/README.md index 335346a..1f00973 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,15 @@ Adds glass stairs and glass slabs to Minecraft. -![https://www.curseforge.com/minecraft/mc-mods/fabric-api](https://user-images.githubusercontent.com/10100202/93722968-0aec9180-fb9b-11ea-9983-bc0fc51b47ab.png) +![Requires Fabric API](https://user-images.githubusercontent.com/10100202/93722968-0aec9180-fb9b-11ea-9983-bc0fc51b47ab.png) -## Downloads +## Downloads (for users) -https://www.curseforge.com/minecraft/mc-mods/mo-glass +[![Download Mo Glass](https://user-images.githubusercontent.com/10100202/214880552-859aa2ed-b4bc-4f8d-9ee7-bdd8c7fb33a2.png)](https://www.wurstimperium.net/mo-glass/download/?utm_source=GitHub&utm_medium=Mo+Glass&utm_campaign=README.md&utm_content=Download+Mo+Glass) -## Setup For Developers (using Windows 10 and Eclipse) +## Setup (for developers) -Requirements: [JDK 17](https://adoptium.net/?variant=openjdk17&jvmVariant=hotspot) +(This assumes that you are using Windows with [Eclipse](https://www.eclipse.org/downloads/) and [Java Development Kit 17](https://adoptium.net/?variant=openjdk17&jvmVariant=hotspot) already installed.) 1. Clone / download the repository. diff --git a/build.gradle b/build.gradle index f040408..0a59f71 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,11 @@ +buildscript { + dependencies { + classpath 'org.kohsuke:github-api:1.135' + } +} + plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' + id 'fabric-loom' version '1.4-SNAPSHOT' id 'maven-publish' id 'com.matthewprenger.cursegradle' version '1.4.0' } @@ -33,7 +39,7 @@ dependencies { processResources { inputs.property "version", project.version - + filesMatching("fabric.mod.json") { expand "version": project.version } @@ -66,7 +72,7 @@ publishing { from components.java } } - + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { // Add repositories to publish to here. @@ -86,7 +92,7 @@ curseforge { changelogType = "html" changelog = file("changelog.txt") releaseType = "release" - addGameVersion "1.19.2" + addGameVersion "1.20.2" addGameVersion "Fabric" mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) @@ -105,12 +111,38 @@ curseforge { } afterEvaluate { - tasks.curseforge353426.dependsOn remapJar - - tasks.named("curseforge353426") { - doFirst { - ant.move(file:"${project.buildDir}/devlibs/${archivesBaseName}-${version}-dev.jar", tofile:"${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar") - ant.move(file:"${project.buildDir}/devlibs/${archivesBaseName}-${version}-sources.jar", tofile:"${project.buildDir}/libs/${archivesBaseName}-${version}-sources-dev.jar") - } - } + tasks.curseforge353426.dependsOn moveDevLibs +} + +task moveDevLibs(dependsOn: [remapJar, remapSourcesJar]) { + doLast { + ant.move(file:"${project.buildDir}/devlibs/${archivesBaseName}-${version}-dev.jar", tofile:"${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar") + ant.move(file:"${project.buildDir}/devlibs/${archivesBaseName}-${version}-sources.jar", tofile:"${project.buildDir}/libs/${archivesBaseName}-${version}-sources-dev.jar") + } +} + +import org.kohsuke.github.GHReleaseBuilder +import org.kohsuke.github.GitHub + +task github(dependsOn: moveDevLibs) { + onlyIf { + ENV.GITHUB_TOKEN + } + + doLast { + def github = GitHub.connectUsingOAuth(ENV.GITHUB_TOKEN as String) + def repository = github.getRepository("Wurst-Imperium-MCX/Mo-Glass") + def ghVersion = "v" + version.substring(0, version.indexOf("-")) + + def ghRelease = repository.getReleaseByTagName(ghVersion as String); + if(ghRelease == null) { + def releaseBuilder = new GHReleaseBuilder(repository, ghVersion as String) + ghRelease = releaseBuilder.create() + } + + ghRelease.uploadAsset(remapJar.archiveFile.get().getAsFile(), "application/java-archive"); + ghRelease.uploadAsset(remapSourcesJar.archiveFile.get().getAsFile(), "application/java-archive") + ghRelease.uploadAsset(new File("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar"), "application/java-archive") + ghRelease.uploadAsset(new File("${project.buildDir}/libs/${archivesBaseName}-${version}-sources-dev.jar"), "application/java-archive") + } } diff --git a/changelog.txt b/changelog.txt index 2c8082a..ea15dbf 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,20 +1,2 @@ -

Note: Requires Fabric API for Minecraft 1.19.2.

-

 

-

Changes:

-

- Fixed a crash when running Mo Glass on a server.

-

 

-

v1.6 changes:

-

- Added tinted glass slabs and stairs.

-

- Slightly modified the lighting engine to make tinted glass slabs and stairs possible.

-

- Added Italian (Italy) translations. (Thanks to XfedeX!)

-

- Added French (France) translations. (Thanks to HanatakeYurii!)

-

- Added various common item tags that other mods can use in their crafting recipes to specify what kind of glass they want.

-

- Added a "mo_glass:glass_slabs" block tag containing all glass slabs and a "mo_glass:glass_stairs" block tag containing all glass stairs. This should be useful for vertical slabs mods.

-

- Added a "mo_glass:opaque_for_lighting" block tag for blocks that need my lighting engine modification to render properly. This should be useful for mods that change how lighting works.

-

- Reduced the file size of Mo Glass. (Thanks to RDKRACZ!)

-

- Fixed glass stairs facing each other's front sides not being seamless. (before/after)

-

- Fixed glass stairs and glass slabs dripping when placed under a liquid (unlike vanilla glass blocks).

-

- Fixed glass stairs and glass slabs blocking the camera in 3rd person view (unlike vanilla glass blocks).

-

- Fixed glass slabs not being included in the "minecraft:slabs" tags.

-

- Fixed glass stairs not being included in the "minecraft:stairs" tags.

-

- Removed support for old Fabric Loader versions without the Log4Shell patch (older than v0.12.10).

+

A changelog can be found at: https://www.wimods.net/mo-glass/mo-glass-1-6-1/

+

Note: This mod requires Fabric API for Minecraft 1.20.2.

diff --git a/gradle.properties b/gradle.properties index 761b76f..4bdfda0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,19 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true # Fabric Properties # check these at https://fabricmc.net/develop/ and # https://www.curseforge.com/minecraft/mc-mods/fabric-api -minecraft_version=1.19.2 -yarn_mappings=1.19.2+build.1 -loader_version=0.14.9 +minecraft_version=1.20.2 +yarn_mappings=1.20.2+build.4 +loader_version=0.14.22 #Fabric api -fabric_version=0.58.6+1.19.2 +fabric_version=0.89.3+1.20.2 # Mod Properties -mod_version = 1.6.1-MC1.19.2 +mod_version = 1.6.1-MC1.20.2 maven_group = net.wurstclient.glass archives_base_name = Mo-Glass diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..c1962a7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..ac72c34 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a58591e..aeb74cb 100644 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -143,12 +140,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -205,6 +210,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. @@ -231,4 +242,4 @@ eval "set -- $( tr '\n' ' ' )" '"$@"' -exec "$JAVACMD" "$@" \ No newline at end of file +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9618d8d..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,100 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/main/java/net/wurstclient/glass/GlassSlabBlock.java b/src/main/java/net/wurstclient/glass/GlassSlabBlock.java index a5af76a..b3c4de3 100644 --- a/src/main/java/net/wurstclient/glass/GlassSlabBlock.java +++ b/src/main/java/net/wurstclient/glass/GlassSlabBlock.java @@ -136,7 +136,7 @@ public float getAmbientOcclusionLightLevel(BlockState blockState_1, } @Override - public boolean isTranslucent(BlockState blockState_1, BlockView blockView_1, + public boolean isTransparent(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1) { return true; diff --git a/src/main/java/net/wurstclient/glass/GlassStairsBlock.java b/src/main/java/net/wurstclient/glass/GlassStairsBlock.java index a5833ed..a1ceec9 100644 --- a/src/main/java/net/wurstclient/glass/GlassStairsBlock.java +++ b/src/main/java/net/wurstclient/glass/GlassStairsBlock.java @@ -307,7 +307,7 @@ public float getAmbientOcclusionLightLevel(BlockState blockState_1, } @Override - public boolean isTranslucent(BlockState blockState_1, BlockView blockView_1, + public boolean isTransparent(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1) { return true; diff --git a/src/main/java/net/wurstclient/glass/MoGlassBlocks.java b/src/main/java/net/wurstclient/glass/MoGlassBlocks.java index 3ed9df1..b3e65b9 100644 --- a/src/main/java/net/wurstclient/glass/MoGlassBlocks.java +++ b/src/main/java/net/wurstclient/glass/MoGlassBlocks.java @@ -8,39 +8,41 @@ package net.wurstclient.glass; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.MapColor; -import net.minecraft.block.Material; +import net.minecraft.block.enums.Instrument; import net.minecraft.client.render.RenderLayer; import net.minecraft.entity.EntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.Item.Settings; -import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.DyeColor; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.Registry; import net.minecraft.world.BlockView; public enum MoGlassBlocks { ; - public static final Block GLASS_SLAB = - new GlassSlabBlock(AbstractBlock.Settings.of(Material.GLASS) - .strength(0.3F).sounds(BlockSoundGroup.GLASS).nonOpaque() + public static final Block GLASS_SLAB = new GlassSlabBlock( + AbstractBlock.Settings.create().instrument(Instrument.HAT).strength(0.3F) + .sounds(BlockSoundGroup.GLASS).nonOpaque() .allowsSpawning(MoGlassBlocks::never) .solidBlock(MoGlassBlocks::never).suffocates(MoGlassBlocks::never) .blockVision(MoGlassBlocks::never)); - public static final Block GLASS_STAIRS = - new GlassStairsBlock(AbstractBlock.Settings.of(Material.GLASS) - .strength(0.3F).sounds(BlockSoundGroup.GLASS).nonOpaque() + public static final Block GLASS_STAIRS = new GlassStairsBlock( + AbstractBlock.Settings.create().instrument(Instrument.HAT).strength(0.3F) + .sounds(BlockSoundGroup.GLASS).nonOpaque() .allowsSpawning(MoGlassBlocks::never) .solidBlock(MoGlassBlocks::never).suffocates(MoGlassBlocks::never) .blockVision(MoGlassBlocks::never)); @@ -145,17 +147,11 @@ public enum MoGlassBlocks public static void initialize() { - registerBlockCutoutMipped(GLASS_SLAB, "glass_slab", - ItemGroup.BUILDING_BLOCKS); + registerBlockCutoutMipped(GLASS_SLAB, "glass_slab"); + registerBlockCutoutMipped(GLASS_STAIRS, "glass_stairs"); - registerBlockCutoutMipped(GLASS_STAIRS, "glass_stairs", - ItemGroup.BUILDING_BLOCKS); - - registerBlockTranslucent(TINTED_GLASS_SLAB, "tinted_glass_slab", - ItemGroup.BUILDING_BLOCKS); - - registerBlockTranslucent(TINTED_GLASS_STAIRS, "tinted_glass_stairs", - ItemGroup.BUILDING_BLOCKS); + registerBlockTranslucent(TINTED_GLASS_SLAB, "tinted_glass_slab"); + registerBlockTranslucent(TINTED_GLASS_STAIRS, "tinted_glass_stairs"); String[] colors = {"white", "orange", "magenta", "light_blue", "yellow", "lime", "pink", "gray", "light_gray", "cyan", "purple", "blue", @@ -163,65 +159,74 @@ public static void initialize() for(int i = 0; i < 16; i++) registerBlockTranslucent(STAINED_GLASS_SLABS[i], - colors[i] + "_stained_glass_slab", ItemGroup.BUILDING_BLOCKS); + colors[i] + "_stained_glass_slab"); for(int i = 0; i < 16; i++) registerBlockTranslucent(STAINED_GLASS_STAIRS[i], - colors[i] + "_stained_glass_stairs", ItemGroup.BUILDING_BLOCKS); + colors[i] + "_stained_glass_stairs"); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.COLORED_BLOCKS) + .register(content -> { + + // stairs + content.addBefore(Blocks.GLASS_PANE, GLASS_STAIRS, + TINTED_GLASS_STAIRS); + content.addBefore(Blocks.GLASS_PANE, STAINED_GLASS_STAIRS); + + // slabs + content.addBefore(Blocks.GLASS_PANE, GLASS_SLAB, + TINTED_GLASS_SLAB); + content.addBefore(Blocks.GLASS_PANE, STAINED_GLASS_SLABS); + }); } - private static void registerBlockTranslucent(Block block, String idPath, - ItemGroup itemGroup) + private static void registerBlockTranslucent(Block block, String idPath) { - registerBlock(block, idPath, itemGroup); + registerBlock(block, idPath); if(MoGlass.INSTANCE.isClient()) BlockRenderLayerMap.INSTANCE.putBlock(block, RenderLayer.getTranslucent()); } - private static void registerBlockCutoutMipped(Block block, String idPath, - ItemGroup itemGroup) + private static void registerBlockCutoutMipped(Block block, String idPath) { - registerBlock(block, idPath, itemGroup); + registerBlock(block, idPath); if(MoGlass.INSTANCE.isClient()) BlockRenderLayerMap.INSTANCE.putBlock(block, RenderLayer.getCutoutMipped()); } - private static void registerBlock(Block block, String idPath, - ItemGroup itemGroup) + private static void registerBlock(Block block, String idPath) { Identifier identifier = new Identifier("mo_glass", idPath); - Registry.register(Registry.BLOCK, identifier, block); + Registry.register(Registries.BLOCK, identifier, block); - Settings itemSettings = new Item.Settings().group(itemGroup); + Settings itemSettings = new Item.Settings(); BlockItem blockItem = new BlockItem(block, itemSettings); - Registry.register(Registry.ITEM, identifier, blockItem); + Registry.register(Registries.ITEM, identifier, blockItem); } private static StainedGlassSlabBlock createStainedGlassSlab(DyeColor color) { - return new StainedGlassSlabBlock(color, - AbstractBlock.Settings.of(Material.GLASS, color).strength(0.3F) - .sounds(BlockSoundGroup.GLASS).nonOpaque() - .allowsSpawning(MoGlassBlocks::never) - .solidBlock(MoGlassBlocks::never) - .suffocates(MoGlassBlocks::never) - .blockVision(MoGlassBlocks::never)); + return new StainedGlassSlabBlock(color, AbstractBlock.Settings.create() + .mapColor(color).instrument(Instrument.HAT).strength(0.3F) + .sounds(BlockSoundGroup.GLASS).nonOpaque() + .allowsSpawning(MoGlassBlocks::never) + .solidBlock(MoGlassBlocks::never).suffocates(MoGlassBlocks::never) + .blockVision(MoGlassBlocks::never)); } private static StainedGlassStairsBlock createStainedGlassStairs( DyeColor color) { - return new StainedGlassStairsBlock(color, - AbstractBlock.Settings.of(Material.GLASS, color).strength(0.3F) - .sounds(BlockSoundGroup.GLASS).nonOpaque() - .allowsSpawning(MoGlassBlocks::never) - .solidBlock(MoGlassBlocks::never) - .suffocates(MoGlassBlocks::never) - .blockVision(MoGlassBlocks::never)); + return new StainedGlassStairsBlock(color, AbstractBlock.Settings.create() + .mapColor(color).instrument(Instrument.HAT).strength(0.3F) + .sounds(BlockSoundGroup.GLASS).nonOpaque() + .allowsSpawning(MoGlassBlocks::never) + .solidBlock(MoGlassBlocks::never).suffocates(MoGlassBlocks::never) + .blockVision(MoGlassBlocks::never)); } // Copies of the Blocks.never() methods because the originals are not diff --git a/src/main/java/net/wurstclient/glass/MoGlassTags.java b/src/main/java/net/wurstclient/glass/MoGlassTags.java index 32f1943..a314d6e 100644 --- a/src/main/java/net/wurstclient/glass/MoGlassTags.java +++ b/src/main/java/net/wurstclient/glass/MoGlassTags.java @@ -8,9 +8,9 @@ package net.wurstclient.glass; import net.minecraft.block.Block; -import net.minecraft.tag.TagKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import net.wurstclient.glass.mixin.ChunkLightProviderMixin; public enum MoGlassTags @@ -46,7 +46,7 @@ public enum MoGlassTags private static TagKey createTag(String idPath) { - return TagKey.of(Registry.BLOCK_KEY, + return TagKey.of(RegistryKeys.BLOCK, new Identifier("mo_glass", idPath)); } } diff --git a/src/main/java/net/wurstclient/glass/StainedGlassSlabBlock.java b/src/main/java/net/wurstclient/glass/StainedGlassSlabBlock.java index 2707310..2e69e62 100644 --- a/src/main/java/net/wurstclient/glass/StainedGlassSlabBlock.java +++ b/src/main/java/net/wurstclient/glass/StainedGlassSlabBlock.java @@ -145,7 +145,7 @@ public float getAmbientOcclusionLightLevel(BlockState blockState_1, } @Override - public boolean isTranslucent(BlockState blockState_1, BlockView blockView_1, + public boolean isTransparent(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1) { return true; diff --git a/src/main/java/net/wurstclient/glass/StainedGlassStairsBlock.java b/src/main/java/net/wurstclient/glass/StainedGlassStairsBlock.java index 0bb7b06..960ce50 100644 --- a/src/main/java/net/wurstclient/glass/StainedGlassStairsBlock.java +++ b/src/main/java/net/wurstclient/glass/StainedGlassStairsBlock.java @@ -310,7 +310,7 @@ public float getAmbientOcclusionLightLevel(BlockState blockState_1, } @Override - public boolean isTranslucent(BlockState blockState_1, BlockView blockView_1, + public boolean isTransparent(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1) { return true; diff --git a/src/main/java/net/wurstclient/glass/TintedGlassSlabBlock.java b/src/main/java/net/wurstclient/glass/TintedGlassSlabBlock.java index 39052d9..591971b 100644 --- a/src/main/java/net/wurstclient/glass/TintedGlassSlabBlock.java +++ b/src/main/java/net/wurstclient/glass/TintedGlassSlabBlock.java @@ -142,7 +142,7 @@ public boolean isSimpleFullBlock(BlockState blockState_1, } @Override - public boolean isTranslucent(BlockState blockState_1, BlockView blockView_1, + public boolean isTransparent(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1) { return false; diff --git a/src/main/java/net/wurstclient/glass/TintedGlassStairsBlock.java b/src/main/java/net/wurstclient/glass/TintedGlassStairsBlock.java index fbb4c55..697b417 100644 --- a/src/main/java/net/wurstclient/glass/TintedGlassStairsBlock.java +++ b/src/main/java/net/wurstclient/glass/TintedGlassStairsBlock.java @@ -307,7 +307,7 @@ public float getAmbientOcclusionLightLevel(BlockState blockState_1, } @Override - public boolean isTranslucent(BlockState blockState_1, BlockView blockView_1, + public boolean isTransparent(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1) { return false; diff --git a/src/main/java/net/wurstclient/glass/mixin/ChunkLightProviderMixin.java b/src/main/java/net/wurstclient/glass/mixin/ChunkLightProviderMixin.java index 971e095..d0cee12 100644 --- a/src/main/java/net/wurstclient/glass/mixin/ChunkLightProviderMixin.java +++ b/src/main/java/net/wurstclient/glass/mixin/ChunkLightProviderMixin.java @@ -25,22 +25,8 @@ public class ChunkLightProviderMixin at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isOpaque()Z", ordinal = 0), - method = "getStateForLighting(JLorg/apache/commons/lang3/mutable/MutableInt;)Lnet/minecraft/block/BlockState;") - private boolean isOpaqueForLighting(BlockState blockState) - { - return blockState.isOpaque() - || blockState.isIn(MoGlassTags.OPAQUE_FOR_LIGHTING); - } - - /** - * See {@link MoGlassTags#OPAQUE_FOR_LIGHTING} for why this exists. - */ - @Redirect( - at = @At(value = "INVOKE", - target = "Lnet/minecraft/block/BlockState;isOpaque()Z", - ordinal = 0), - method = "getOpaqueShape(Lnet/minecraft/block/BlockState;JLnet/minecraft/util/math/Direction;)Lnet/minecraft/util/shape/VoxelShape;") - private boolean isOpaqueForLightingShape(BlockState blockState) + method = "isTrivialForLighting(Lnet/minecraft/block/BlockState;)Z") + private static boolean isOpaqueForLightingShape(BlockState blockState) { return blockState.isOpaque() || blockState.isIn(MoGlassTags.OPAQUE_FOR_LIGHTING); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 6b91348..1ba6e4b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -40,9 +40,9 @@ ], "depends": { - "fabricloader": ">=0.14.8", - "fabric": ">=0.57.3", - "minecraft": "~1.19.1-beta.5", + "fabricloader": ">=0.14.19", + "fabric-api": ">=0.79.1", + "minecraft": "~1.20-alpha.23.17.a", "java": ">=17" }, "suggests": {