diff --git a/.github/meta.json b/.github/meta.json
deleted file mode 100644
index fa64766..0000000
--- a/.github/meta.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "curseID": 569938,
- "maven": "https://maven.nanite.dev/releases/dev/latvian/mods/literal-sky-block"
-}
\ No newline at end of file
diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml
deleted file mode 100644
index acb1058..0000000
--- a/.github/workflows/build-release.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-name: Build & Release
-
-on:
- push:
- tags:
- - 'v*'
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/cache@v2
- with:
- path: |
- ~/.gradle/caches
- ~/.gradle/wrapper
- key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
- restore-keys: |
- ${{ runner.os }}-gradle-
- - uses: actions/checkout@v2
- with:
- fetch-depth: 30 # Gets the last 30 commits so the changelog might work
- - name: Set up JDK 17
- uses: actions/setup-java@v2
- with:
- distribution: 'temurin'
- java-version: '17'
- - name: Build & release to curseforge
- env:
- GIT_COMMIT: ${{ github.event.after }}
- GIT_PREVIOUS_COMMIT: ${{ github.event.before }}
- NANITE_DEPLOY: ${{ secrets.NANITE_DEPLOY }}
- CURSE_DEPLOY: ${{ secrets.CURSE_DEPLOY }}
- run: |
- chmod +x ./gradlew
- ./gradlew build publish curseforge --stacktrace --no-daemon
\ No newline at end of file
diff --git a/.github/workflows/build_main.yml b/.github/workflows/build_main.yml
new file mode 100644
index 0000000..79fd0b5
--- /dev/null
+++ b/.github/workflows/build_main.yml
@@ -0,0 +1,64 @@
+name: Java CI (Main)
+
+on:
+ push:
+ branches:
+ - 'main'
+ workflow_dispatch:
+ branches:
+ - 'main'
+ inputs:
+ release_type:
+ description: 'Release Type'
+ required: true
+ type: choice
+ default: 'release'
+ options:
+ - 'release'
+ - 'beta'
+ - 'alpha'
+ - 'none'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ if: |
+ !contains(github.event.head_commit.message, '[ci skip]')
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 30
+
+ - name: Set up JDK 21
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'temurin'
+ java-version: '21'
+ cache: gradle
+
+ - name: Grant execute permission for gradlew
+ run: chmod +x gradlew
+
+ - name: Validate Gradle Wrapper
+ uses: gradle/wrapper-validation-action@v1
+
+ - name: Build and Publish with Gradle
+ uses: gradle/gradle-build-action@v2
+ env:
+ MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
+ SAPS_TOKEN: ${{ secrets.SAPS_TOKEN }}
+ with:
+ arguments: build publish --stacktrace --no-daemon
+
+ - name: Release to CurseForge
+ uses: gradle/gradle-build-action@v2
+ if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != 'none' }}
+ env:
+ GIT_COMMIT: ${{ github.event.after }}
+ GIT_PREVIOUS_COMMIT: ${{ github.event.before }}
+ CURSEFORGE_KEY: ${{ secrets.CURSEFORGE_KEY }}
+ MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
+ RELEASE_TYPE: ${{ inputs.release_type }}
+ with:
+ arguments: curseforge modrinth --stacktrace --no-daemon
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
index 153d416..07f3f15 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,165 +1,21 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
\ No newline at end of file
+MIT License
+
+Copyright (c) 2022 Kristiāns Micītis
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index dc07152..a6f40ca 100644
--- a/README.md
+++ b/README.md
@@ -1 +1 @@
-# Literal-Sky-Block
\ No newline at end of file
+# Literal Sky Block
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index d8df5d2..0f94197 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,79 +1,112 @@
+import java.time.Instant
+
plugins {
- id "dev.architectury.loom" version "0.12.0-SNAPSHOT"
+ id 'base'
+ id 'java'
id 'maven-publish'
- id "com.matthewprenger.cursegradle" version "1.4.0"
+ id 'net.neoforged.moddev' version "1.0.14"
+ // https://maven.architectury.dev/me/shedaniel/unified-publishing/maven-metadata.xml
+ id "me.shedaniel.unified-publishing" version "0.1.13"
}
-apply from: 'https://files.saps.dev/ci/git-md-changelog.gradle'
-
-sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = 17
+ext.ENV = System.getenv()
+def isLocal = !ENV.containsKey("GITHUB_RUN_NUMBER")
-def ENV = System.getenv()
-version = "${mod_version}-build.${ENV.GITHUB_RUN_NUMBER ?: 9999}"
-archivesBaseName = project.archives_base_name
+version = "${mod_version}-${isLocal ? "local.${Instant.now().epochSecond}" : "build.${ENV.GITHUB_RUN_NUMBER}"}"
group = project.maven_group
+base.archivesBaseName = project.archives_base_name
-loom {
- silentMojangMappingsLicense()
-
- forge {
- mixinConfigs = [
- "${project.mod_id}.mixins.json"
- ]
+neoForge {
+ version = project.neoforge_version
- dataGen {
- mod project.mod_id
+ runs {
+ configureEach {
+ logLevel = org.slf4j.event.Level.INFO
}
- launches {
- data {
- arg "--existing", file("src/main/resources").absolutePath
+ client {
+ client()
+
+ if (ENV.MC_CLIENT_ARGS) {
+ programArguments.addAll(ENV.MC_CLIENT_ARGS.split(' '))
}
+
+ jvmArguments.addAll("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
+ gameDirectory = file 'run'
}
- }
-}
-repositories {
- maven {
- url "https://cursemaven.com"
+ server {
+ server()
+ programArgument("--nogui")
+ gameDirectory = file 'run_server'
+ }
}
-}
-
-dependencies {
- minecraft "com.mojang:minecraft:${project.minecraft_version}"
- forge "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
- mappings loom.layered() {
- officialMojangMappings()
+ mods {
+ literalskyblock {
+ sourceSet sourceSets.main
+ }
}
- modCompileOnly("curse.maven:oculus-581495:3929520")
-
- modLocalRuntime modImplementation("curse.maven:oculus-581495:3929520")
- modLocalRuntime modImplementation("curse.maven:rubidium-574856:4024781")
-}
-
-processResources {
- inputs.property "version", project.version
-
- filesMatching("META-INF/mods.toml") {
- expand "version": project.version
+ parchment {
+ minecraftVersion = minecraft_version
+ mappingsVersion = parchment_version
}
}
compileJava {
options.encoding = "UTF-8"
+ options.release.set(21)
}
java {
+ sourceCompatibility = targetCompatibility = '21'
withSourcesJar()
}
-jar {
- from("LICENSE") {
- rename { "${it}_${project.archivesBaseName}" }
+repositories {
+ mavenLocal()
+ mavenCentral()
+
+ maven {
+ url "https://maven.neoforged.net/releases"
+ }
+
+ maven {
+ name = 'ParchmentMC'
+ url = 'https://maven.parchmentmc.org'
+ content {
+ includeGroup "org.parchmentmc.data"
+ }
+ }
+
+ maven {
+ url "https://cursemaven.com"
+ content {
+ includeGroup "curse.maven"
+ }
}
+}
+
+dependencies {
+ // compileOnly("curse.maven:oculus-581495:5299671")
+ // compileOnly("curse.maven:rubidium-574856:4952685")
+}
+processResources {
+ def toReplace = [
+ "version": project.version,
+ ]
+
+ println("[Process Resources] Replacing properties in resources: " + toReplace)
+
+ inputs.properties toReplace
+ filesMatching("META-INF/neoforge.mods.toml") {
+ expand toReplace
+ }
+}
+
+jar {
manifest {
attributes([
"Specification-Title" : project.mod_id,
@@ -87,40 +120,66 @@ jar {
}
}
+unifiedPublishing {
+ project {
+ releaseType = "${ENV.RELEASE_TYPE ?: 'release'}"
+ gameVersions = [
+ rootProject.minecraft_version
+ ]
+ gameLoaders = ["neoforge"]
+ displayName = "$mod_name NeoForge $project.version"
+ mainPublication jar
+
+ if (ENV.CURSEFORGE_KEY) {
+ curseforge {
+ token = ENV.CURSEFORGE_KEY
+ id = project.curseforge_id
+ }
+ }
+
+ if (ENV.MODRINTH_TOKEN) {
+ modrinth {
+ token = ENV.MODRINTH_TOKEN
+ id = project.modrinth_id
+ version = "$project.version+$project.name"
+ }
+ }
+ }
+}
+
publishing {
publications {
- mavenForge(MavenPublication) {
- artifactId = rootProject.archivesBaseName
+ mavenNeoForge(MavenPublication) {
+ artifactId = archives_base_name
from components.java
}
}
repositories {
- repositories {
- if (ENV.NANITE_DEPLOY) {
- maven {
- url "https://maven.nanite.dev/releases"
- credentials {
- username = "nanite"
- password = "${ENV.NANITE_DEPLOY}"
- }
+ if (ENV.MAVEN_TOKEN) {
+ maven {
+ url "https://maven.latvian.dev/releases"
+ credentials {
+ username = "lat"
+ password = "${ENV.MAVEN_TOKEN}"
}
}
}
- }
-}
-if (ENV.CURSE_DEPLOY) {
- curseforge {
- apiKey = ENV.CURSE_DEPLOY
- project {
- id = project.curseforge_id
- releaseType = project.curseforge_type
- addGameVersion "Forge"
- addGameVersion "${minecraft_version}"
- mainArtifact(remapJar)
- changelog = getGitChangelog()
- changelogType = 'markdown'
+ if (ENV.SAPS_TOKEN) {
+ maven {
+ url "https://maven.saps.dev/releases"
+ credentials {
+ username = "latvian"
+ password = "${ENV.SAPS_TOKEN}"
+ }
+ }
}
}
}
+
+afterEvaluate {
+ tasks.withType(JavaCompile) {
+ options.compilerArgs << "-Xmaxerrs" << "1000"
+ }
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 5fd22b9..aff1f84 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,11 +1,16 @@
-org.gradle.jvmargs=-Xmx1G
-loom.platform=forge
-minecraft_version=1.18.2
-forge_version=40.1.59
-mod_version=1802.1.4
-maven_group=dev.latvian.mods
-archives_base_name=literal-sky-block
+org.gradle.jvmargs=-Xmx3G
+org.gradle.daemon=false
+
mod_id=literalskyblock
-mod_author=LatvianModder
+archives_base_name=literal-sky-block-neoforge
+mod_name=KubeJS
+maven_group=dev.latvian.mods
+mod_author=latvian.dev
curseforge_id=569938
-curseforge_type=release
+modrinth_id=hEQ4T20y
+
+minecraft_version=1.21
+mod_version=2100.1.4
+
+neoforge_version=21.0.148
+parchment_version=2024.07.07
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index df7d1aa..09523c0 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
-#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index df487c4..ffc73f0 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,10 +1,13 @@
pluginManagement {
repositories {
- maven { url "https://maven.creeperhost.net/" }
- maven { url "https://maven.shedaniel.me/" }
- maven { url "https://server.bbkr.space/artifactory/libs-release" }
gradlePluginPortal()
+ mavenCentral()
+ maven { url "https://maven.creeperhost.net/" }
}
}
+plugins {
+ id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
+}
+
rootProject.name = 'Literal-Sky-Block'
\ No newline at end of file
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/LSBBlockEntities.java b/src/main/java/dev/latvian/mods/literalskyblock/LSBBlockEntities.java
index c05324d..b93ad17 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/LSBBlockEntities.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/LSBBlockEntities.java
@@ -1,13 +1,13 @@
package dev.latvian.mods.literalskyblock;
+import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.block.entity.BlockEntityType;
-import net.minecraftforge.registries.DeferredRegister;
-import net.minecraftforge.registries.ForgeRegistries;
+import net.neoforged.neoforge.registries.DeferredRegister;
import java.util.function.Supplier;
public interface LSBBlockEntities {
- DeferredRegister> REGISTER = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, LiteralSkyBlock.MOD_ID);
+ DeferredRegister> REGISTER = DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, LiteralSkyBlock.MOD_ID);
Supplier> SKY_BLOCK = REGISTER.register("sky_block", () -> BlockEntityType.Builder.of(SkyBlockEntity::new, LSBBlocks.SKY_BLOCK.get()).build(null));
Supplier> VOID_BLOCK = REGISTER.register("void_block", () -> BlockEntityType.Builder.of(VoidBlockEntity::new, LSBBlocks.VOID_BLOCK.get()).build(null));
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/LSBBlocks.java b/src/main/java/dev/latvian/mods/literalskyblock/LSBBlocks.java
index d19151d..a626b4d 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/LSBBlocks.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/LSBBlocks.java
@@ -1,14 +1,14 @@
package dev.latvian.mods.literalskyblock;
-import net.minecraft.core.Registry;
import net.minecraft.world.level.block.Block;
-import net.minecraftforge.registries.DeferredRegister;
-
-import java.util.function.Supplier;
+import net.minecraft.world.level.block.Blocks;
+import net.minecraft.world.level.block.state.BlockBehaviour;
+import net.neoforged.neoforge.registries.DeferredBlock;
+import net.neoforged.neoforge.registries.DeferredRegister;
public interface LSBBlocks {
- DeferredRegister REGISTER = DeferredRegister.create(Registry.BLOCK_REGISTRY, LiteralSkyBlock.MOD_ID);
+ DeferredRegister.Blocks REGISTER = DeferredRegister.createBlocks(LiteralSkyBlock.MOD_ID);
- Supplier SKY_BLOCK = REGISTER.register("sky_block", SkyBlock::new);
- Supplier VOID_BLOCK = REGISTER.register("void_block", VoidBlock::new);
+ DeferredBlock SKY_BLOCK = REGISTER.registerBlock("sky_block", SkyBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.STONE));
+ DeferredBlock VOID_BLOCK = REGISTER.registerBlock("void_block", VoidBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.STONE));
}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/LSBCommon.java b/src/main/java/dev/latvian/mods/literalskyblock/LSBCommon.java
deleted file mode 100644
index fa9fc57..0000000
--- a/src/main/java/dev/latvian/mods/literalskyblock/LSBCommon.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package dev.latvian.mods.literalskyblock;
-
-/**
- * @author LatvianModder
- */
-public class LSBCommon {
- public void init() {
- }
-}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/LSBItems.java b/src/main/java/dev/latvian/mods/literalskyblock/LSBItems.java
index 3b31d62..5132adc 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/LSBItems.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/LSBItems.java
@@ -1,16 +1,12 @@
package dev.latvian.mods.literalskyblock;
-import net.minecraft.core.Registry;
import net.minecraft.world.item.BlockItem;
-import net.minecraft.world.item.CreativeModeTab;
-import net.minecraft.world.item.Item;
-import net.minecraftforge.registries.DeferredRegister;
-
-import java.util.function.Supplier;
+import net.neoforged.neoforge.registries.DeferredItem;
+import net.neoforged.neoforge.registries.DeferredRegister;
public interface LSBItems {
- DeferredRegister- REGISTER = DeferredRegister.create(Registry.ITEM_REGISTRY, LiteralSkyBlock.MOD_ID);
+ DeferredRegister.Items REGISTER = DeferredRegister.createItems(LiteralSkyBlock.MOD_ID);
- Supplier
- SKY_BLOCK = REGISTER.register("sky_block", () -> new BlockItem(LSBBlocks.SKY_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS)));
- Supplier
- VOID_BLOCK = REGISTER.register("void_block", () -> new BlockItem(LSBBlocks.VOID_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS)));
+ DeferredItem SKY_BLOCK = REGISTER.registerSimpleBlockItem("sky_block", LSBBlocks.SKY_BLOCK);
+ DeferredItem VOID_BLOCK = REGISTER.registerSimpleBlockItem("void_block", LSBBlocks.VOID_BLOCK);
}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/LSBModEventHandler.java b/src/main/java/dev/latvian/mods/literalskyblock/LSBModEventHandler.java
new file mode 100644
index 0000000..eb985f0
--- /dev/null
+++ b/src/main/java/dev/latvian/mods/literalskyblock/LSBModEventHandler.java
@@ -0,0 +1,18 @@
+package dev.latvian.mods.literalskyblock;
+
+import net.minecraft.world.item.CreativeModeTab;
+import net.minecraft.world.item.CreativeModeTabs;
+import net.neoforged.bus.api.SubscribeEvent;
+import net.neoforged.fml.common.EventBusSubscriber;
+import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
+
+@EventBusSubscriber(modid = LiteralSkyBlock.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
+public class LSBModEventHandler {
+ @SubscribeEvent
+ public static void buildCreativeModeTabContents(BuildCreativeModeTabContentsEvent event) {
+ if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS) {
+ event.accept(LSBItems.SKY_BLOCK, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
+ event.accept(LSBItems.VOID_BLOCK, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
+ }
+ }
+}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/LiteralSkyBlock.java b/src/main/java/dev/latvian/mods/literalskyblock/LiteralSkyBlock.java
index 047f356..fbd6c18 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/LiteralSkyBlock.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/LiteralSkyBlock.java
@@ -1,26 +1,18 @@
package dev.latvian.mods.literalskyblock;
-import dev.latvian.mods.literalskyblock.client.LSBClient;
-import net.minecraftforge.eventbus.api.IEventBus;
-import net.minecraftforge.fml.DistExecutor;
-import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
+import net.minecraft.resources.ResourceLocation;
+import net.neoforged.bus.api.IEventBus;
+import net.neoforged.fml.common.Mod;
-/**
- * @author LatvianModder
- */
@Mod(LiteralSkyBlock.MOD_ID)
public class LiteralSkyBlock {
public static final String MOD_ID = "literalskyblock";
- public static LSBCommon PROXY;
+ public static final ResourceLocation SKY = ResourceLocation.fromNamespaceAndPath(MOD_ID, "sky");
- public LiteralSkyBlock() {
- PROXY = DistExecutor.safeRunForDist(() -> LSBClient::new, () -> LSBCommon::new);
- IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
+ public LiteralSkyBlock(IEventBus bus) {
LSBBlocks.REGISTER.register(bus);
LSBItems.REGISTER.register(bus);
LSBBlockEntities.REGISTER.register(bus);
- PROXY.init();
}
}
\ No newline at end of file
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/SkyBlock.java b/src/main/java/dev/latvian/mods/literalskyblock/SkyBlock.java
index 36d0d9b..6e67f2d 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/SkyBlock.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/SkyBlock.java
@@ -1,19 +1,30 @@
package dev.latvian.mods.literalskyblock;
+import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.Blocks;
+import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
public class SkyBlock extends BaseEntityBlock {
- public SkyBlock() {
- super(Properties.copy(Blocks.STONE));
+ public SkyBlock(Properties properties) {
+ super(properties);
+ }
+
+ @Override
+ protected RenderShape getRenderShape(BlockState state) {
+ return RenderShape.INVISIBLE;
+ }
+
+ @Override
+ protected MapCodec extends BaseEntityBlock> codec() {
+ return Block.simpleCodec(SkyBlock::new);
}
@Nullable
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/VoidBlock.java b/src/main/java/dev/latvian/mods/literalskyblock/VoidBlock.java
index 0376cfc..58c8e42 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/VoidBlock.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/VoidBlock.java
@@ -1,11 +1,23 @@
package dev.latvian.mods.literalskyblock;
+import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
+import net.minecraft.world.level.block.BaseEntityBlock;
+import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
public class VoidBlock extends SkyBlock {
+ public VoidBlock(Properties properties) {
+ super(properties);
+ }
+
+ @Override
+ protected MapCodec extends BaseEntityBlock> codec() {
+ return Block.simpleCodec(VoidBlock::new);
+ }
+
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/client/CapturedInfo.java b/src/main/java/dev/latvian/mods/literalskyblock/client/CapturedInfo.java
new file mode 100644
index 0000000..7a7f450
--- /dev/null
+++ b/src/main/java/dev/latvian/mods/literalskyblock/client/CapturedInfo.java
@@ -0,0 +1,7 @@
+package dev.latvian.mods.literalskyblock.client;
+
+import net.minecraft.client.renderer.LightTexture;
+import org.joml.Matrix4f;
+
+public record CapturedInfo(LightTexture lightTexture, Matrix4f frustumMatrix, Matrix4f projectionMatrix) {
+}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClient.java b/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClient.java
index 6520e99..94cc2c3 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClient.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClient.java
@@ -1,53 +1,24 @@
package dev.latvian.mods.literalskyblock.client;
-import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.pipeline.TextureTarget;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
-import com.mojang.blaze3d.vertex.PoseStack;
+import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
-import com.mojang.math.Matrix4f;
-import dev.latvian.mods.literalskyblock.LSBBlockEntities;
-import dev.latvian.mods.literalskyblock.LSBCommon;
import dev.latvian.mods.literalskyblock.LiteralSkyBlock;
-import dev.latvian.mods.literalskyblock.integration.IrisCompat;
-import net.minecraft.client.Camera;
-import net.minecraft.client.CloudStatus;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.FogRenderer;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.GameRenderer;
-import net.minecraft.client.renderer.LevelRenderer;
-import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.RenderStateShard;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.ShaderInstance;
-import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
-import net.minecraft.resources.ResourceLocation;
-import net.minecraft.util.Mth;
-import net.minecraft.world.phys.Vec3;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.client.event.RegisterShadersEvent;
-import net.minecraftforge.client.event.RenderLevelLastEvent;
-import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.ModList;
-import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
-
-import java.io.IOException;
-
-/**
- * @author LatvianModder
- */
-@Mod.EventBusSubscriber(modid = LiteralSkyBlock.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
-public class LSBClient extends LSBCommon {
+import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
+
+public class LSBClient {
private static ShaderInstance skyShader;
- private static int skyWidth = -1;
- private static int skyHeight = -1;
private static TextureTarget skyRenderTarget;
- public static boolean updateSky = false;
- private static boolean isRenderingSky = false;
- private static boolean irisLoaded = false;
public static ShaderInstance getSkyShader() {
return skyShader;
@@ -57,10 +28,10 @@ public static void setSkyShader(ShaderInstance shader) {
skyShader = shader;
}
- public static final RenderType SKY_RENDER_TYPE = RenderType.create(LiteralSkyBlock.MOD_ID + "_sky", DefaultVertexFormat.POSITION, VertexFormat.Mode.QUADS, 256, false, false, RenderType.CompositeState.builder()
- .setShaderState(new RenderStateShard.ShaderStateShard(LSBClient::getSkyShader))
- .setTextureState(new RenderStateShard.EmptyTextureStateShard(LSBClient::setSkyTexture, LSBClient::noop))
- .createCompositeState(false)
+ public static final RenderType SKY_RENDER_TYPE = RenderType.create(LiteralSkyBlock.SKY.toString(), DefaultVertexFormat.POSITION, VertexFormat.Mode.QUADS, 256, false, false, RenderType.CompositeState.builder()
+ .setShaderState(new RenderStateShard.ShaderStateShard(LSBClient::getSkyShader))
+ .setTextureState(new RenderStateShard.EmptyTextureStateShard(LSBClient::setSkyTexture, LSBClient::noop))
+ .createCompositeState(false)
);
private static void setSkyTexture() {
@@ -74,8 +45,9 @@ private static void setSkyTexture() {
private static void noop() {
}
- public static void renderSky(RenderLevelLastEvent event) {
- if (isRenderingSky) {
+ public static void renderSky(RenderLevelStageEvent event) {
+ // AFTER_LEVEL ?
+ if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_LEVEL) {
return;
}
@@ -88,98 +60,37 @@ public static void renderSky(RenderLevelLastEvent event) {
return;
}
- boolean update = false;
-
- if (skyRenderTarget == null || skyWidth != ww || skyHeight != wh) {
- update = true;
- skyWidth = ww;
- skyHeight = wh;
- }
-
- if (update) {
+ if (skyRenderTarget == null || skyRenderTarget.width != ww || skyRenderTarget.height != wh) {
if (skyRenderTarget != null) {
skyRenderTarget.destroyBuffers();
}
- skyRenderTarget = new TextureTarget(skyWidth, skyHeight, true, Minecraft.ON_OSX);
+ skyRenderTarget = new TextureTarget(ww, wh, true, Minecraft.ON_OSX);
}
- if (irisLoaded) IrisCompat.preRender(mc.levelRenderer);
- mc.gameRenderer.setRenderBlockOutline(false);
- // mc.levelRenderer.graphicsChanged();
- skyRenderTarget.bindWrite(true);
-
- isRenderingSky = true;
- RenderTarget mainRenderTarget = mc.getMainRenderTarget();
- renderActualSky(mc, event);
- isRenderingSky = false;
-
- mc.gameRenderer.setRenderBlockOutline(true);
- skyRenderTarget.unbindRead();
- skyRenderTarget.unbindWrite();
- // mc.levelRenderer.graphicsChanged();
- mainRenderTarget.bindWrite(true);
- if (irisLoaded) IrisCompat.postRender(mc.levelRenderer);
- }
+ skyRenderTarget.bindWrite(false);
+ skyRenderTarget.clear(Minecraft.ON_OSX);
+ skyRenderTarget.bindWrite(false);
- public static void renderActualSky(Minecraft mc, RenderLevelLastEvent event) {
- if (mc == null || mc.level == null || mc.player == null) {
- return;
- }
+ ((LevelRendererLSB) mc.levelRenderer).lsb$renderSky(event.getPartialTick(), event.getCamera(), mc.gameRenderer, skyRenderTarget);
- PoseStack poseStack = event.getPoseStack();
- final float delta = event.getPartialTick();
- Matrix4f projectionMatrix = event.getProjectionMatrix();
- LevelRenderer levelRenderer = mc.levelRenderer;
- LevelRendererLSB levelRendererLSB = (LevelRendererLSB) levelRenderer;
- GameRenderer gameRenderer = mc.gameRenderer;
- final Camera camera = gameRenderer.getMainCamera();
- Vec3 cameraPos = camera.getPosition();
- LightTexture lightTexture = gameRenderer.lightTexture();
-
- FogRenderer.setupColor(camera, delta, mc.level, mc.options.getEffectiveRenderDistance(), gameRenderer.getDarkenWorldAmount(delta));
- FogRenderer.levelFogColor();
- RenderSystem.clear(16640, Minecraft.ON_OSX);
- final float renderDistance = gameRenderer.getRenderDistance();
- final boolean hasSpecialFog = mc.level.effects().isFoggyAt(Mth.floor(cameraPos.x), Mth.floor(cameraPos.z)) || mc.gui.getBossOverlay().shouldCreateWorldFog();
- FogRenderer.setupFog(camera, FogRenderer.FogMode.FOG_SKY, renderDistance, hasSpecialFog, delta);
- RenderSystem.setShader(GameRenderer::getPositionShader);
- levelRenderer.renderSky(poseStack, projectionMatrix, delta, camera, false, () -> FogRenderer.setupFog(camera, FogRenderer.FogMode.FOG_SKY, renderDistance, hasSpecialFog, delta));
-
- PoseStack modelViewStack = RenderSystem.getModelViewStack();
- modelViewStack.pushPose();
- modelViewStack.mulPoseMatrix(poseStack.last().pose());
- RenderSystem.applyModelViewMatrix();
-
- if (mc.options.getCloudsType() != CloudStatus.OFF) {
- RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader);
- RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
- levelRenderer.renderClouds(poseStack, projectionMatrix, delta, cameraPos.x, cameraPos.y, cameraPos.z);
- }
-
- RenderSystem.depthMask(false);
- levelRendererLSB.renderSnowAndRainLSB(lightTexture, delta, cameraPos.x, cameraPos.y, cameraPos.z);
-
- RenderSystem.depthMask(true);
- RenderSystem.disableBlend();
- modelViewStack.popPose();
- RenderSystem.applyModelViewMatrix();
- FogRenderer.setupNoFog();
+ mc.getMainRenderTarget().bindWrite(false);
}
- @Override
- public void init() {
- irisLoaded = ModList.get().isLoaded("oculus");
- }
+ public static void drawUI(GuiGraphics graphics) {
+ setSkyTexture();
- @SubscribeEvent
- public static void setup(FMLClientSetupEvent event) {
- BlockEntityRenderers.register(LSBBlockEntities.SKY_BLOCK.get(), SkyBlockEntityRenderer::new);
- BlockEntityRenderers.register(LSBBlockEntities.VOID_BLOCK.get(), SkyBlockEntityRenderer::new);
- }
+ int w = 80;
+ int h = 50;
+
+ graphics.fill(0, 0, w + 1, h + 1, 5, 0xFF000000);
- @SubscribeEvent
- public static void registerShaders(RegisterShadersEvent event) throws IOException {
- event.registerShader(new ShaderInstance(event.getResourceManager(), new ResourceLocation(LiteralSkyBlock.MOD_ID, "sky"), DefaultVertexFormat.POSITION), LSBClient::setSkyShader);
+ RenderSystem.setShader(GameRenderer::getPositionTexShader);
+ var builder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
+ builder.addVertex(0F, 0F, 10F).setUv(0F, 1F);
+ builder.addVertex(0F, h, 10F).setUv(0F, 0F);
+ builder.addVertex(w, h, 10F).setUv(1F, 0F);
+ builder.addVertex(w, 0F, 10F).setUv(1F, 1F);
+ BufferUploader.drawWithShader(builder.buildOrThrow());
}
}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClientEventHandler.java b/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClientEventHandler.java
deleted file mode 100644
index d57aa8c..0000000
--- a/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClientEventHandler.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package dev.latvian.mods.literalskyblock.client;
-
-import dev.latvian.mods.literalskyblock.LiteralSkyBlock;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.client.event.RenderLevelLastEvent;
-import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.common.Mod;
-
-@Mod.EventBusSubscriber(modid = LiteralSkyBlock.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
-public class LSBClientEventHandler {
- @SubscribeEvent
- public static void renderLast(RenderLevelLastEvent event) {
- LSBClient.renderSky(event);
- }
-}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClientGameEventHandler.java b/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClientGameEventHandler.java
new file mode 100644
index 0000000..0175747
--- /dev/null
+++ b/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClientGameEventHandler.java
@@ -0,0 +1,21 @@
+package dev.latvian.mods.literalskyblock.client;
+
+import dev.latvian.mods.literalskyblock.LiteralSkyBlock;
+import net.neoforged.api.distmarker.Dist;
+import net.neoforged.bus.api.SubscribeEvent;
+import net.neoforged.fml.common.EventBusSubscriber;
+import net.neoforged.neoforge.client.event.RenderGuiEvent;
+import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
+
+@EventBusSubscriber(modid = LiteralSkyBlock.MOD_ID, bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
+public class LSBClientGameEventHandler {
+ @SubscribeEvent
+ public static void renderLast(RenderLevelStageEvent event) {
+ LSBClient.renderSky(event);
+ }
+
+ @SubscribeEvent
+ public static void drawUI(RenderGuiEvent.Post event) {
+ LSBClient.drawUI(event.getGuiGraphics());
+ }
+}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClientModEventHandler.java b/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClientModEventHandler.java
new file mode 100644
index 0000000..8b133ca
--- /dev/null
+++ b/src/main/java/dev/latvian/mods/literalskyblock/client/LSBClientModEventHandler.java
@@ -0,0 +1,35 @@
+package dev.latvian.mods.literalskyblock.client;
+
+import com.mojang.blaze3d.vertex.DefaultVertexFormat;
+import dev.latvian.mods.literalskyblock.LSBBlockEntities;
+import dev.latvian.mods.literalskyblock.LiteralSkyBlock;
+import net.minecraft.client.renderer.ShaderInstance;
+import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
+import net.neoforged.api.distmarker.Dist;
+import net.neoforged.bus.api.SubscribeEvent;
+import net.neoforged.fml.common.EventBusSubscriber;
+import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
+import net.neoforged.neoforge.client.event.RegisterShadersEvent;
+
+import java.io.IOException;
+
+@EventBusSubscriber(modid = LiteralSkyBlock.MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
+public class LSBClientModEventHandler {
+ @SubscribeEvent
+ public static void setup(FMLClientSetupEvent event) {
+ BlockEntityRenderers.register(LSBBlockEntities.SKY_BLOCK.get(), SkyBlockEntityRenderer::new);
+ BlockEntityRenderers.register(LSBBlockEntities.VOID_BLOCK.get(), SkyBlockEntityRenderer::new);
+ }
+
+ @SubscribeEvent
+ public static void registerShaders(RegisterShadersEvent event) throws IOException {
+ event.registerShader(new ShaderInstance(event.getResourceProvider(), LiteralSkyBlock.SKY, DefaultVertexFormat.POSITION), LSBClient::setSkyShader);
+ }
+
+ /*
+ @SubscribeEvent
+ public static void registerNamedRenderTypes(RegisterNamedRenderTypesEvent event) {
+ event.register(LiteralSkyBlock.SKY, LSBClient.SKY_BLOCK_RENDER_TYPE, LSBClient.SKY_ENTITY_RENDER_TYPE);
+ }
+ */
+}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/client/LevelRendererLSB.java b/src/main/java/dev/latvian/mods/literalskyblock/client/LevelRendererLSB.java
index be3e39b..9df5ece 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/client/LevelRendererLSB.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/client/LevelRendererLSB.java
@@ -1,7 +1,10 @@
package dev.latvian.mods.literalskyblock.client;
-import net.minecraft.client.renderer.LightTexture;
+import com.mojang.blaze3d.pipeline.TextureTarget;
+import net.minecraft.client.Camera;
+import net.minecraft.client.DeltaTracker;
+import net.minecraft.client.renderer.GameRenderer;
public interface LevelRendererLSB {
- void renderSnowAndRainLSB(LightTexture arg, float g, double d, double e, double h);
+ void lsb$renderSky(DeltaTracker deltaTracker, Camera camera, GameRenderer gameRenderer, TextureTarget target);
}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/client/MinecraftLSB.java b/src/main/java/dev/latvian/mods/literalskyblock/client/MinecraftLSB.java
deleted file mode 100644
index d76c5e1..0000000
--- a/src/main/java/dev/latvian/mods/literalskyblock/client/MinecraftLSB.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package dev.latvian.mods.literalskyblock.client;
-
-import com.mojang.blaze3d.pipeline.RenderTarget;
-
-public interface MinecraftLSB {
- void setMainRenderTargetLSB(RenderTarget target);
-}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/client/SkyBlockEntityRenderer.java b/src/main/java/dev/latvian/mods/literalskyblock/client/SkyBlockEntityRenderer.java
index 5010f9c..24f4ef4 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/client/SkyBlockEntityRenderer.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/client/SkyBlockEntityRenderer.java
@@ -2,7 +2,6 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
-import com.mojang.math.Matrix4f;
import dev.latvian.mods.literalskyblock.SkyBlockEntity;
import dev.latvian.mods.literalskyblock.VoidBlockEntity;
import net.minecraft.client.renderer.MultiBufferSource;
@@ -10,6 +9,7 @@
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.core.Direction;
+import org.joml.Matrix4f;
public class SkyBlockEntityRenderer implements BlockEntityRenderer {
public SkyBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
@@ -17,26 +17,24 @@ public SkyBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
@Override
public void render(SkyBlockEntity entity, float delta, PoseStack poseStack, MultiBufferSource source, int light1, int light2) {
- Matrix4f matrix4f = poseStack.last().pose();
- renderCube(entity, matrix4f, source.getBuffer(entity instanceof VoidBlockEntity ? RenderType.endGateway() : LSBClient.SKY_RENDER_TYPE));
- LSBClient.updateSky = true;
+ renderCube(entity, poseStack.last().pose(), source.getBuffer(entity instanceof VoidBlockEntity ? RenderType.endGateway() : LSBClient.SKY_RENDER_TYPE));
}
private void renderCube(SkyBlockEntity entity, Matrix4f matrix, VertexConsumer buffer) {
- renderFace(entity, matrix, buffer, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, Direction.SOUTH);
- renderFace(entity, matrix, buffer, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, Direction.NORTH);
- renderFace(entity, matrix, buffer, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, Direction.EAST);
- renderFace(entity, matrix, buffer, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, Direction.WEST);
- renderFace(entity, matrix, buffer, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, Direction.DOWN);
- renderFace(entity, matrix, buffer, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, Direction.UP);
+ renderFace(entity, matrix, buffer, 0F, 1F, 0F, 1F, 1F, 1F, 1F, 1F, Direction.SOUTH);
+ renderFace(entity, matrix, buffer, 0F, 1F, 1F, 0F, 0F, 0F, 0F, 0F, Direction.NORTH);
+ renderFace(entity, matrix, buffer, 1F, 1F, 1F, 0F, 0F, 1F, 1F, 0F, Direction.EAST);
+ renderFace(entity, matrix, buffer, 0F, 0F, 0F, 1F, 0F, 1F, 1F, 0F, Direction.WEST);
+ renderFace(entity, matrix, buffer, 0F, 1F, 0F, 0F, 0F, 0F, 1F, 1F, Direction.DOWN);
+ renderFace(entity, matrix, buffer, 0F, 1F, 1F, 1F, 1F, 1F, 0F, 0F, Direction.UP);
}
private void renderFace(SkyBlockEntity entity, Matrix4f matrix, VertexConsumer buffer, float f, float g, float h, float i, float j, float k, float l, float m, Direction direction) {
if (entity.shouldRenderFace(direction)) {
- buffer.vertex(matrix, f, h, j).endVertex();
- buffer.vertex(matrix, g, h, k).endVertex();
- buffer.vertex(matrix, g, i, l).endVertex();
- buffer.vertex(matrix, f, i, m).endVertex();
+ buffer.addVertex(matrix, f, h, j);
+ buffer.addVertex(matrix, g, h, k);
+ buffer.addVertex(matrix, g, i, l);
+ buffer.addVertex(matrix, f, i, m);
}
}
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/integration/IrisCompat.java b/src/main/java/dev/latvian/mods/literalskyblock/integration/IrisCompat.java
index 77e5d86..b9bcd37 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/integration/IrisCompat.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/integration/IrisCompat.java
@@ -1,5 +1,6 @@
package dev.latvian.mods.literalskyblock.integration;
+/*
import com.mojang.logging.LogUtils;
import net.coderbot.iris.Iris;
import net.coderbot.iris.pipeline.WorldRenderingPhase;
@@ -54,3 +55,4 @@ public static boolean shadersEnabled() {
return IrisApi.getInstance().isShaderPackInUse();
}
}
+ */
\ No newline at end of file
diff --git a/src/main/java/dev/latvian/mods/literalskyblock/mixin/LevelRendererMixin.java b/src/main/java/dev/latvian/mods/literalskyblock/mixin/LevelRendererMixin.java
index ceab03e..e2903c5 100644
--- a/src/main/java/dev/latvian/mods/literalskyblock/mixin/LevelRendererMixin.java
+++ b/src/main/java/dev/latvian/mods/literalskyblock/mixin/LevelRendererMixin.java
@@ -1,29 +1,64 @@
package dev.latvian.mods.literalskyblock.mixin;
+import com.mojang.blaze3d.pipeline.TextureTarget;
+import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
-import com.mojang.math.Matrix4f;
+import dev.latvian.mods.literalskyblock.client.CapturedInfo;
import dev.latvian.mods.literalskyblock.client.LSBClient;
import dev.latvian.mods.literalskyblock.client.LevelRendererLSB;
import net.minecraft.client.Camera;
+import net.minecraft.client.CloudStatus;
+import net.minecraft.client.DeltaTracker;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.FogRenderer;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.RenderBuffers;
+import net.minecraft.client.renderer.culling.Frustum;
+import net.minecraft.util.Mth;
+import net.minecraft.world.phys.Vec3;
+import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import javax.annotation.Nullable;
+
@Mixin(LevelRenderer.class)
public abstract class LevelRendererMixin implements LevelRendererLSB {
+ @Shadow
+ @Nullable
+ private Frustum capturedFrustum;
+
+ @Shadow
+ private Frustum cullingFrustum;
+
+ @Shadow
+ @Final
+ private Minecraft minecraft;
+
+ @Shadow
+ private int ticks;
+
@Shadow
@Final
private RenderBuffers renderBuffers;
+ @Unique
+ private CapturedInfo lsb$capturedInfo = null;
+
+ @Inject(method = "renderLevel", at = @At(value = "HEAD"))
+ private void lsb$captureFrustum(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f frustumMatrix, Matrix4f projectionMatrix, CallbackInfo ci) {
+ lsb$capturedInfo = new CapturedInfo(lightTexture, frustumMatrix, projectionMatrix);
+ }
+
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;endBatch(Lnet/minecraft/client/renderer/RenderType;)V", ordinal = 6, shift = At.Shift.AFTER))
- private void renderLevelLSB(PoseStack poseStack, float delta, long time, boolean blockOutlines, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix, CallbackInfo ci) {
+ private void lsb$drawSkyBuffer(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f frustumMatrix, Matrix4f projectionMatrix, CallbackInfo ci) {
renderBuffers.bufferSource().endBatch(LSBClient.SKY_RENDER_TYPE);
}
@@ -31,9 +66,65 @@ private void renderLevelLSB(PoseStack poseStack, float delta, long time, boolean
private void renderSnowAndRain(LightTexture lightTexture, float delta, double cameraX, double cameraY, double cameraZ) {
}
+ @Shadow
+ public abstract void renderSky(Matrix4f frustumMatrix, Matrix4f projectionMatrix, float partialTick, Camera camera, boolean isFoggy, Runnable skyFogSetup);
+
+ @Shadow
+ protected abstract void checkPoseStack(PoseStack poseStack);
+
+ @Shadow
+ public abstract void renderClouds(PoseStack poseStack, Matrix4f frustumMatrix, Matrix4f projectionMatrix, float partialTick, double camX, double camY, double camZ);
+
+ @Unique
@Override
- public void renderSnowAndRainLSB(LightTexture lightTexture, float delta, double cameraX, double cameraY, double cameraZ) {
- renderSnowAndRain(lightTexture, delta, cameraX, cameraY, cameraZ);
- }
+ public void lsb$renderSky(DeltaTracker deltaTracker, Camera camera, GameRenderer gameRenderer, TextureTarget target) {
+ if (lsb$capturedInfo == null) {
+ return;
+ }
+
+ var modelViewStack = RenderSystem.getModelViewStack();
+ var levelRenderer = (LevelRenderer) (Object) this;
+
+ var lightTexture = lsb$capturedInfo.lightTexture();
+ var frustumMatrix = lsb$capturedInfo.frustumMatrix();
+ var projectionMatrix = lsb$capturedInfo.projectionMatrix();
+
+ float delta = deltaTracker.getGameTimeDeltaPartialTick(false);
+ Vec3 camPos = camera.getPosition();
+ double camX = camPos.x();
+ double camY = camPos.y();
+ double camZ = camPos.z();
+ Frustum frustum = this.capturedFrustum != null ? this.capturedFrustum : this.cullingFrustum;
+
+ FogRenderer.setupColor(camera, delta, this.minecraft.level, this.minecraft.options.getEffectiveRenderDistance(), gameRenderer.getDarkenWorldAmount(delta));
+ FogRenderer.levelFogColor();
+ RenderSystem.clear(16640, Minecraft.ON_OSX);
+ float f1 = gameRenderer.getRenderDistance();
+ boolean flag1 = this.minecraft.level.effects().isFoggyAt(Mth.floor(camX), Mth.floor(camY)) || this.minecraft.gui.getBossOverlay().shouldCreateWorldFog();
+ RenderSystem.setShader(GameRenderer::getPositionShader);
+ this.renderSky(frustumMatrix, projectionMatrix, delta, camera, flag1, () -> FogRenderer.setupFog(camera, FogRenderer.FogMode.FOG_SKY, f1, flag1, delta));
+ net.neoforged.neoforge.client.ClientHooks.dispatchRenderStage(net.neoforged.neoforge.client.event.RenderLevelStageEvent.Stage.AFTER_SKY, levelRenderer, null, frustumMatrix, projectionMatrix, this.ticks, camera, frustum);
+
+ FogRenderer.setupFog(camera, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f1, 32.0F), flag1, delta);
+
+ modelViewStack.pushMatrix();
+ modelViewStack.mul(frustumMatrix);
+ RenderSystem.applyModelViewMatrix();
+ PoseStack posestack = new PoseStack();
+ this.checkPoseStack(posestack);
+
+ if (this.minecraft.options.getCloudsType() != CloudStatus.OFF) {
+ this.renderClouds(posestack, frustumMatrix, projectionMatrix, delta, camX, camY, camZ);
+ }
+
+ this.renderSnowAndRain(lightTexture, delta, camX, camY, camZ);
+
+ modelViewStack.popMatrix();
+ RenderSystem.applyModelViewMatrix();
+
+ RenderSystem.depthMask(true);
+ RenderSystem.disableBlend();
+ FogRenderer.setupNoFog();
+ }
}
diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml
deleted file mode 100644
index 8021ad8..0000000
--- a/src/main/resources/META-INF/mods.toml
+++ /dev/null
@@ -1,27 +0,0 @@
-modLoader = "javafml"
-loaderVersion = "[39,)"
-issueTrackerURL = "https://github.com/nanite/Literal-Sky-Block/issues"
-license = "GNU LGPLv3"
-
-[[mods]]
-modId = "literalskyblock"
-version = "${version}"
-displayName = "Literal Sky Block"
-authors = "LatvianModder"
-description = '''
-This mod adds blocks that simulate sky
-'''
-
-[[dependencies.literalskyblock]]
-modId = "forge"
-mandatory = true
-versionRange = "[39,)"
-ordering = "NONE"
-side = "BOTH"
-
-[[dependencies.literalskyblock]]
-modId = "minecraft"
-mandatory = true
-versionRange = "[1.18,)"
-ordering = "NONE"
-side = "BOTH"
\ No newline at end of file
diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml
new file mode 100644
index 0000000..795635a
--- /dev/null
+++ b/src/main/resources/META-INF/neoforge.mods.toml
@@ -0,0 +1,30 @@
+modLoader = "javafml"
+loaderVersion = "[2,)"
+issueTrackerURL = "https://github.com/latvian-dev/literal-sky-block/issues"
+license = "MIT"
+
+[[mods]]
+modId = "literalskyblock"
+version = "${version}"
+displayName = "Literal Sky Block"
+authors = "latvian.dev"
+description = '''
+This mod adds blocks that simulate the sky
+'''
+
+[[dependencies.literalskyblock]]
+modId = "neoforge"
+mandatory = true
+versionRange = "[21.0.148,)"
+ordering = "NONE"
+side = "BOTH"
+
+[[dependencies.literalskyblock]]
+modId = "minecraft"
+mandatory = true
+versionRange = "[1.21,)"
+ordering = "NONE"
+side = "BOTH"
+
+[[mixins]]
+config = "literalskyblock.mixins.json"
\ No newline at end of file
diff --git a/src/main/resources/assets/literalskyblock/blockstates/void_block.json b/src/main/resources/assets/literalskyblock/blockstates/void_block.json
index 533868f..0538692 100644
--- a/src/main/resources/assets/literalskyblock/blockstates/void_block.json
+++ b/src/main/resources/assets/literalskyblock/blockstates/void_block.json
@@ -1,7 +1,7 @@
{
"variants": {
"": {
- "model": "literalskyblock:block/sky_block"
+ "model": "literalskyblock:block/void_block"
}
}
}
\ No newline at end of file
diff --git a/src/main/resources/assets/literalskyblock/models/block/sky_block.json b/src/main/resources/assets/literalskyblock/models/block/sky_block.json
index 4c93b7e..9ce5f99 100644
--- a/src/main/resources/assets/literalskyblock/models/block/sky_block.json
+++ b/src/main/resources/assets/literalskyblock/models/block/sky_block.json
@@ -1,5 +1,6 @@
{
+ "parent": "minecraft:block/cube_all",
"textures": {
- "particle": "minecraft:block/stone"
+ "all": "literalskyblock:block/sky_block"
}
}
\ No newline at end of file
diff --git a/src/main/resources/assets/literalskyblock/models/block/void_block.json b/src/main/resources/assets/literalskyblock/models/block/void_block.json
new file mode 100644
index 0000000..a365696
--- /dev/null
+++ b/src/main/resources/assets/literalskyblock/models/block/void_block.json
@@ -0,0 +1,6 @@
+{
+ "parent": "minecraft:block/cube_all",
+ "textures": {
+ "all": "literalskyblock:block/void_block"
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/assets/literalskyblock/models/item/sky_block.json b/src/main/resources/assets/literalskyblock/models/item/sky_block.json
index 9ce5f99..97439b5 100644
--- a/src/main/resources/assets/literalskyblock/models/item/sky_block.json
+++ b/src/main/resources/assets/literalskyblock/models/item/sky_block.json
@@ -1,6 +1,3 @@
{
- "parent": "minecraft:block/cube_all",
- "textures": {
- "all": "literalskyblock:block/sky_block"
- }
+ "parent": "literalskyblock:block/sky_block"
}
\ No newline at end of file
diff --git a/src/main/resources/assets/literalskyblock/models/item/void_block.json b/src/main/resources/assets/literalskyblock/models/item/void_block.json
index a365696..f6f6f2f 100644
--- a/src/main/resources/assets/literalskyblock/models/item/void_block.json
+++ b/src/main/resources/assets/literalskyblock/models/item/void_block.json
@@ -1,6 +1,3 @@
{
- "parent": "minecraft:block/cube_all",
- "textures": {
- "all": "literalskyblock:block/void_block"
- }
+ "parent": "literalskyblock:block/void_block"
}
\ No newline at end of file
diff --git a/src/main/resources/assets/literalskyblock/shaders/core/sky.json b/src/main/resources/assets/literalskyblock/shaders/core/sky.json
index b443f46..f957976 100644
--- a/src/main/resources/assets/literalskyblock/shaders/core/sky.json
+++ b/src/main/resources/assets/literalskyblock/shaders/core/sky.json
@@ -19,47 +19,13 @@
"name": "ModelViewMat",
"type": "matrix4x4",
"count": 16,
- "values": [
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0
- ]
+ "values": [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]
},
{
"name": "ProjMat",
"type": "matrix4x4",
"count": 16,
- "values": [
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0
- ]
+ "values": [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]
}
]
}
diff --git a/src/main/resources/data/literalskyblock/loot_tables/blocks/sky_block.json b/src/main/resources/data/literalskyblock/loot_table/blocks/sky_block.json
similarity index 100%
rename from src/main/resources/data/literalskyblock/loot_tables/blocks/sky_block.json
rename to src/main/resources/data/literalskyblock/loot_table/blocks/sky_block.json
diff --git a/src/main/resources/data/literalskyblock/loot_tables/blocks/void_block.json b/src/main/resources/data/literalskyblock/loot_table/blocks/void_block.json
similarity index 100%
rename from src/main/resources/data/literalskyblock/loot_tables/blocks/void_block.json
rename to src/main/resources/data/literalskyblock/loot_table/blocks/void_block.json
diff --git a/src/main/resources/data/literalskyblock/tags/blocks/sky_blocks.json b/src/main/resources/data/literalskyblock/tags/block/sky_blocks.json
similarity index 100%
rename from src/main/resources/data/literalskyblock/tags/blocks/sky_blocks.json
rename to src/main/resources/data/literalskyblock/tags/block/sky_blocks.json
diff --git a/src/main/resources/data/literalskyblock/tags/item/sky_blocks.json b/src/main/resources/data/literalskyblock/tags/item/sky_blocks.json
new file mode 100644
index 0000000..c2cead8
--- /dev/null
+++ b/src/main/resources/data/literalskyblock/tags/item/sky_blocks.json
@@ -0,0 +1,7 @@
+{
+ "replace": false,
+ "values": [
+ "literalskyblock:sky_block",
+ "literalskyblock:void_block"
+ ]
+}
\ No newline at end of file
diff --git a/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/main/resources/data/minecraft/tags/block/mineable/pickaxe.json
similarity index 100%
rename from src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json
rename to src/main/resources/data/minecraft/tags/block/mineable/pickaxe.json
diff --git a/src/main/resources/literalskyblock.mixins.json b/src/main/resources/literalskyblock.mixins.json
index ac85e43..7abd561 100644
--- a/src/main/resources/literalskyblock.mixins.json
+++ b/src/main/resources/literalskyblock.mixins.json
@@ -1,14 +1,15 @@
{
"required": true,
+ "minVersion": "0.8",
"package": "dev.latvian.mods.literalskyblock.mixin",
- "compatibilityLevel": "JAVA_17",
+ "compatibilityLevel": "JAVA_21",
"mixins": [
],
"client": [
"LevelRendererMixin"
],
"injectors": {
- "defaultRequire": 1
- },
- "minVersion": "0.8"
+ "defaultRequire": 1,
+ "maxShiftBy": 2
+ }
}
\ No newline at end of file
diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta
deleted file mode 100644
index a58d3d3..0000000
--- a/src/main/resources/pack.mcmeta
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "pack": {
- "description": "Literal Sky Block Mod Resources",
- "pack_format": 8
- }
-}