mirror of
https://github.com/TeamMidnightDust/CullLeaves.git
synced 2025-12-16 14:15:10 +01:00
stonecutter: setup multiversion build
This commit is contained in:
0
CHANGELOG.md
Normal file
0
CHANGELOG.md
Normal file
76
build.gradle
76
build.gradle
@@ -1,76 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
|
||||||
id "dev.architectury.loom" version "1.11-SNAPSHOT" apply false
|
|
||||||
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
|
|
||||||
}
|
|
||||||
|
|
||||||
architectury {
|
|
||||||
injectInjectables = false
|
|
||||||
minecraft = rootProject.minecraft_version
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
url = "https://api.modrinth.com/maven"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
subprojects {
|
|
||||||
apply plugin: "dev.architectury.loom"
|
|
||||||
|
|
||||||
loom {
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
|
||||||
// The following line declares the mojmap mappings, you may use other mappings as well
|
|
||||||
//mappings loom.officialMojangMappings()
|
|
||||||
// The following line declares the yarn mappings you may select this one as well.
|
|
||||||
mappings loom.layered {
|
|
||||||
it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2")
|
|
||||||
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
apply plugin: "java"
|
|
||||||
apply plugin: "architectury-plugin"
|
|
||||||
apply plugin: "maven-publish"
|
|
||||||
|
|
||||||
archivesBaseName = rootProject.archives_base_name
|
|
||||||
version = rootProject.mod_version
|
|
||||||
group = rootProject.maven_group
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
// Add repositories to retrieve artifacts from in here.
|
|
||||||
// You should only use this when depending on other mods because
|
|
||||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
|
||||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
|
||||||
// for more information about repositories.
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
options.release = 21
|
|
||||||
}
|
|
||||||
ext {
|
|
||||||
releaseChangelog = {
|
|
||||||
def changes = new StringBuilder()
|
|
||||||
changes << "## CullLeaves v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/CullLeaves/commits/)"
|
|
||||||
def proc = "git log --max-count=200 --pretty=format:%s".execute()
|
|
||||||
proc.in.eachLine { line ->
|
|
||||||
def processedLine = line.toString()
|
|
||||||
if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
|
|
||||||
changes << "\n- ${processedLine.capitalize()}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
proc.waitFor()
|
|
||||||
return changes.toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
withSourcesJar()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
227
build.gradle.kts
Normal file
227
build.gradle.kts
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
plugins {
|
||||||
|
id("dev.architectury.loom")
|
||||||
|
id("architectury-plugin")
|
||||||
|
id("me.modmuss50.mod-publish-plugin")
|
||||||
|
id("com.github.johnrengelman.shadow")
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
val minecraft = stonecutter.current.version
|
||||||
|
val loader = loom.platform.get().name.lowercase()
|
||||||
|
|
||||||
|
version = "${mod.version}+$minecraft"
|
||||||
|
group = mod.group
|
||||||
|
base {
|
||||||
|
archivesName.set("${mod.id}-$loader")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("https://maven.neoforged.net/releases/")
|
||||||
|
maven("https://api.modrinth.com/maven")
|
||||||
|
|
||||||
|
// modmenu
|
||||||
|
maven("https://maven.terraformersmc.com/")
|
||||||
|
maven("https://maven.nucleoid.xyz/")
|
||||||
|
|
||||||
|
// MidnightLib
|
||||||
|
maven("https://maven.midnightdust.eu/snapshots/")
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
minecraft("com.mojang:minecraft:$minecraft")
|
||||||
|
|
||||||
|
// MidnightLib
|
||||||
|
modImplementation ("eu.midnightdust:midnightlib:${mod.dep("midnightlib_version")}+${minecraft}-${loader}")
|
||||||
|
|
||||||
|
if (loader == "fabric") {
|
||||||
|
modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}")
|
||||||
|
modImplementation("net.fabricmc.fabric-api:fabric-api:${mod.dep("fabric_version")}")
|
||||||
|
|
||||||
|
modCompileOnly("maven.modrinth:sodium:${mod.dep("sodium_version")}-fabric")
|
||||||
|
}
|
||||||
|
if (loader == "forge") {
|
||||||
|
"forge"("net.minecraftforge:forge:${minecraft}-${mod.dep("forge_loader")}")
|
||||||
|
}
|
||||||
|
if (loader == "neoforge") {
|
||||||
|
"neoForge"("net.neoforged:neoforge:${mod.dep("neoforge_loader")}")
|
||||||
|
modCompileOnly("maven.modrinth:sodium:${mod.dep("sodium_version")}-neoforge")
|
||||||
|
}
|
||||||
|
mappings (loom.officialMojangMappings())
|
||||||
|
}
|
||||||
|
|
||||||
|
loom {
|
||||||
|
//accessWidenerPath = rootProject.file("src/main/resources/template.accesswidener")
|
||||||
|
|
||||||
|
decompilers {
|
||||||
|
get("vineflower").apply { // Adds names to lambdas - useful for mixins
|
||||||
|
options.put("mark-corresponding-synthetics", "1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (loader == "forge") {
|
||||||
|
forge.mixinConfigs("midnightlib.mixins.json")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishMods {
|
||||||
|
val modrinthToken = System.getenv("MODRINTH_TOKEN")
|
||||||
|
val curseforgeToken = System.getenv("CURSEFORGE_TOKEN")
|
||||||
|
val githubToken = System.getenv("GITHUB_TOKEN").orEmpty()
|
||||||
|
|
||||||
|
file = project.tasks.remapJar.get().archiveFile
|
||||||
|
dryRun = modrinthToken == null || curseforgeToken == null
|
||||||
|
|
||||||
|
displayName = "${mod.name} ${loader.replaceFirstChar { it.uppercase() }} ${property("mod.mc_title")}-${mod.version}"
|
||||||
|
version = mod.version
|
||||||
|
changelog = rootProject.file("CHANGELOG.md").readText()
|
||||||
|
type = BETA
|
||||||
|
|
||||||
|
modLoaders.add(loader)
|
||||||
|
|
||||||
|
val targets = property("mod.mc_targets").toString().split(' ')
|
||||||
|
modrinth {
|
||||||
|
projectId = property("publish.modrinth").toString()
|
||||||
|
accessToken = modrinthToken
|
||||||
|
targets.forEach(minecraftVersions::add)
|
||||||
|
if (loader == "fabric") {
|
||||||
|
requires("fabric-api")
|
||||||
|
optional("modmenu")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
curseforge {
|
||||||
|
projectId = property("publish.curseforge").toString()
|
||||||
|
accessToken = curseforgeToken.toString()
|
||||||
|
targets.forEach(minecraftVersions::add)
|
||||||
|
if (loader == "fabric") {
|
||||||
|
requires("fabric-api")
|
||||||
|
optional("modmenu")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
github {
|
||||||
|
accessToken = githubToken
|
||||||
|
repository = "TeamMidnightDust/CullLeaves"
|
||||||
|
commitish = "multiversion" // This is the branch the release tag will be created from
|
||||||
|
|
||||||
|
tagName = "v" + properties["mod.version"]
|
||||||
|
|
||||||
|
// Allow the release to be initially created without any files.
|
||||||
|
allowEmptyFiles = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//publishing {
|
||||||
|
// publications {
|
||||||
|
// create<MavenPublication>("mavenJava") {
|
||||||
|
// pom {
|
||||||
|
// groupId = "eu.midnightdust"
|
||||||
|
// artifactId = "midnightlib"
|
||||||
|
// version = project.version
|
||||||
|
//
|
||||||
|
// from(components["java"])
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "MidnightDust"
|
||||||
|
url = uri("https://maven.midnightdust.eu/snapshots")
|
||||||
|
credentials(PasswordCredentials::class)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("mavenJava") {
|
||||||
|
pom {
|
||||||
|
groupId = "eu.midnightdust"
|
||||||
|
artifactId = project.mod.id
|
||||||
|
version = "${project.version}-${loader}"
|
||||||
|
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
java {
|
||||||
|
withSourcesJar()
|
||||||
|
val java = if (stonecutter.eval(minecraft, ">=1.20.5")) JavaVersion.VERSION_21 else JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = java
|
||||||
|
sourceCompatibility = java
|
||||||
|
}
|
||||||
|
|
||||||
|
val shadowBundle: Configuration by configurations.creating {
|
||||||
|
isCanBeConsumed = false
|
||||||
|
isCanBeResolved = true
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.shadowJar {
|
||||||
|
configurations = listOf(shadowBundle)
|
||||||
|
archiveClassifier = "dev-shadow"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.remapJar {
|
||||||
|
injectAccessWidener = true
|
||||||
|
input = tasks.shadowJar.get().archiveFile
|
||||||
|
archiveClassifier = null
|
||||||
|
dependsOn(tasks.shadowJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.jar {
|
||||||
|
archiveClassifier = "dev"
|
||||||
|
}
|
||||||
|
|
||||||
|
val buildAndCollect = tasks.register<Copy>("buildAndCollect") {
|
||||||
|
group = "build"
|
||||||
|
from(tasks.remapJar.get().archiveFile, tasks.remapSourcesJar.get().archiveFile)
|
||||||
|
into(rootProject.layout.buildDirectory.file("libs/${mod.version}/$loader"))
|
||||||
|
dependsOn("build")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stonecutter.current.isActive) {
|
||||||
|
rootProject.tasks.register("buildActive") {
|
||||||
|
group = "project"
|
||||||
|
dependsOn(buildAndCollect)
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.tasks.register("runActive") {
|
||||||
|
group = "project"
|
||||||
|
dependsOn(tasks.named("runClient"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.processResources {
|
||||||
|
properties(
|
||||||
|
listOf("fabric.mod.json"),
|
||||||
|
"id" to mod.id,
|
||||||
|
"name" to mod.name,
|
||||||
|
"version" to mod.version,
|
||||||
|
"minecraft" to mod.prop("mc_dep_fabric")
|
||||||
|
)
|
||||||
|
properties(
|
||||||
|
listOf("META-INF/mods.toml", "pack.mcmeta"),
|
||||||
|
"id" to mod.id,
|
||||||
|
"name" to mod.name,
|
||||||
|
"version" to mod.version,
|
||||||
|
"minecraft" to mod.prop("mc_dep_forgelike")
|
||||||
|
)
|
||||||
|
properties(
|
||||||
|
listOf("META-INF/neoforge.mods.toml", "pack.mcmeta"),
|
||||||
|
"id" to mod.id,
|
||||||
|
"name" to mod.name,
|
||||||
|
"version" to mod.version,
|
||||||
|
"minecraft" to mod.prop("mc_dep_forgelike")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.build {
|
||||||
|
group = "versioned"
|
||||||
|
description = "Must run through 'chiseledBuild'"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
stonecutter {
|
||||||
|
constants {
|
||||||
|
arrayOf("fabric", "neoforge", "forge").forEach { it -> put(it, loader == it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
8
buildSrc/build.gradle.kts
Normal file
8
buildSrc/build.gradle.kts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
plugins {
|
||||||
|
`kotlin-dsl`
|
||||||
|
kotlin("jvm") version "2.0.20"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
33
buildSrc/src/main/kotlin/build-extensions.kt
Normal file
33
buildSrc/src/main/kotlin/build-extensions.kt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||||
|
import org.gradle.kotlin.dsl.expand
|
||||||
|
import org.gradle.kotlin.dsl.maven
|
||||||
|
import org.gradle.language.jvm.tasks.ProcessResources
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
val Project.mod: ModData get() = ModData(this)
|
||||||
|
fun Project.prop(key: String): String? = findProperty(key)?.toString()
|
||||||
|
fun String.upperCaseFirst() = replaceFirstChar { if (it.isLowerCase()) it.uppercaseChar() else it }
|
||||||
|
|
||||||
|
fun RepositoryHandler.strictMaven(url: String, alias: String, vararg groups: String) = exclusiveContent {
|
||||||
|
forRepository { maven(url) { name = alias } }
|
||||||
|
filter { groups.forEach(::includeGroup) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun ProcessResources.properties(files: Iterable<String>, vararg properties: Pair<String, Any>) {
|
||||||
|
for ((name, value) in properties) inputs.property(name, value)
|
||||||
|
filesMatching(files) {
|
||||||
|
expand(properties.toMap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmInline
|
||||||
|
value class ModData(private val project: Project) {
|
||||||
|
val id: String get() = requireNotNull(project.prop("mod.id")) { "Missing 'mod.id'" }
|
||||||
|
val name: String get() = requireNotNull(project.prop("mod.name")) { "Missing 'mod.name'" }
|
||||||
|
val version: String get() = requireNotNull(project.prop("mod.version")) { "Missing 'mod.version'" }
|
||||||
|
val group: String get() = requireNotNull(project.prop("mod.group")) { "Missing 'mod.group'" }
|
||||||
|
|
||||||
|
fun prop(key: String) = requireNotNull(project.prop("mod.$key")) { "Missing 'mod.$key'" }
|
||||||
|
fun dep(key: String) = requireNotNull(project.prop("deps.$key")) { "Missing 'deps.$key'" }
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
architectury {
|
|
||||||
injectInjectables = false
|
|
||||||
common(rootProject.enabled_platforms.split(","))
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven { url "https://api.modrinth.com/maven" }
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
|
||||||
// Do NOT use other classes from fabric loader
|
|
||||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
|
||||||
modCompileOnlyApi "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric"
|
|
||||||
// Remove the next line if you don't want to depend on the API
|
|
||||||
//modApi "dev.architectury:architectury:${rootProject.architectury_version}"
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.LeavesBlock;
|
|
||||||
import net.minecraft.block.MangroveRootsBlock;
|
|
||||||
import net.minecraft.resource.ResourceManager;
|
|
||||||
import net.minecraft.resource.SynchronousResourceReloader;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import net.minecraft.world.BlockView;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class CullLeavesClient {
|
|
||||||
public static final String MOD_ID = "cullleaves";
|
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
|
||||||
|
|
||||||
public static boolean forceLeafCulling = false;
|
|
||||||
public static boolean forceHideInnerLeaves = false;
|
|
||||||
|
|
||||||
public static boolean shouldHideBlock(BlockView world, BlockPos pos) {
|
|
||||||
if (CullLeavesClient.forceHideInnerLeaves) {
|
|
||||||
boolean shouldForceCull = true;
|
|
||||||
for (Direction dir : Direction.values()) {
|
|
||||||
BlockState otherState = world.getBlockState(pos.offset(dir));
|
|
||||||
if (!(otherState.getBlock() instanceof LeavesBlock) &&
|
|
||||||
!otherState.isSideSolidFullSquare(world, pos, dir.getOpposite())) {
|
|
||||||
shouldForceCull = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return shouldForceCull;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public static boolean isLeafSideInvisible(BlockState neighborState) {
|
|
||||||
if (CullLeavesConfig.enabled || CullLeavesClient.forceLeafCulling) {
|
|
||||||
return neighborState.getBlock() instanceof LeavesBlock;
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
public static boolean isRootSideInvisible(BlockState neighborState) {
|
|
||||||
if (CullLeavesConfig.cullRoots) {
|
|
||||||
return neighborState.getBlock() instanceof MangroveRootsBlock;
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ReloadListener implements SynchronousResourceReloader {
|
|
||||||
public static final ReloadListener INSTANCE = new ReloadListener();
|
|
||||||
|
|
||||||
private ReloadListener() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reload(ResourceManager manager) {
|
|
||||||
CullLeavesClient.forceLeafCulling = false;
|
|
||||||
CullLeavesClient.forceHideInnerLeaves = false;
|
|
||||||
manager.findResources("options", path -> path.toString().startsWith("cullleaves") && path.toString().endsWith("options.json")).forEach((id, resource) -> {
|
|
||||||
try {
|
|
||||||
JsonObject json = JsonParser.parseReader(resource.getReader()).getAsJsonObject();
|
|
||||||
if (json.has("forceLeafCulling")) {
|
|
||||||
CullLeavesClient.forceLeafCulling = json.get("forceLeafCulling").getAsBoolean();
|
|
||||||
LOGGER.info("Forcing leaf culling as requested by resourcepack");
|
|
||||||
}
|
|
||||||
if (json.has("forceHideInnerLeaves")) {
|
|
||||||
CullLeavesClient.forceHideInnerLeaves = json.get("forceHideInnerLeaves").getAsBoolean();
|
|
||||||
LOGGER.info("Not rendering inner leaves as requested by resourcepack");
|
|
||||||
}
|
|
||||||
} catch (IOException e) { throw new RuntimeException(e); }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.mixin;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.CullLeavesClient;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.LeavesBlock;
|
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
|
||||||
import net.minecraft.client.render.block.BlockModelRenderer;
|
|
||||||
import net.minecraft.client.render.model.BlockModelPart;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.BlockRenderView;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mixin(BlockModelRenderer.class)
|
|
||||||
public class MixinBlockModelRenderer {
|
|
||||||
@Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/world/BlockRenderView;Ljava/util/List;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZI)V", cancellable = true)
|
|
||||||
private void cullleaves$cancelRendering(BlockRenderView world, List<BlockModelPart> parts, BlockState state, BlockPos pos, MatrixStack matrices, VertexConsumer vertexConsumer, boolean cull, int overlay, CallbackInfo ci) {
|
|
||||||
if (state.getBlock() instanceof LeavesBlock &&
|
|
||||||
CullLeavesClient.shouldHideBlock(world, pos)) ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.mixin;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.CullLeavesClient;
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.LeavesBlock;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
|
|
||||||
@Mixin(value = LeavesBlock.class, priority = 1900)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public abstract class MixinLeavesBlock extends Block {
|
|
||||||
|
|
||||||
public MixinLeavesBlock(Settings settings) {
|
|
||||||
super(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSideInvisible(BlockState state, BlockState neighborState, Direction offset) {
|
|
||||||
return CullLeavesClient.isLeafSideInvisible(neighborState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.mixin;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.CullLeavesClient;
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.minecraft.block.*;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
|
|
||||||
@Mixin(value = MangroveRootsBlock.class, priority = 1900)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public abstract class MixinMangroveRootsBlock extends Block {
|
|
||||||
|
|
||||||
public MixinMangroveRootsBlock(Settings settings) {
|
|
||||||
super(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSideInvisible(BlockState state, BlockState neighborState, Direction offset) {
|
|
||||||
return CullLeavesClient.isRootSideInvisible(neighborState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
architectury {
|
|
||||||
injectInjectables = false
|
|
||||||
common(rootProject.enabled_platforms.split(","))
|
|
||||||
}
|
|
||||||
|
|
||||||
loom {
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
|
||||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
|
||||||
// Remove the next line if you don't want to depend on the API
|
|
||||||
//modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
|
||||||
|
|
||||||
compileOnly(project(path: ":common", configuration: "namedElements")) { transitive false }
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
|
||||||
id "me.shedaniel.unified-publishing"
|
|
||||||
}
|
|
||||||
|
|
||||||
architectury {
|
|
||||||
injectInjectables = false
|
|
||||||
platformSetupLoomIde()
|
|
||||||
fabric()
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven { url "https://api.modrinth.com/maven" }
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
common
|
|
||||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
|
||||||
compileClasspath.extendsFrom common
|
|
||||||
runtimeClasspath.extendsFrom common
|
|
||||||
developmentFabric.extendsFrom common
|
|
||||||
archivesBaseName = rootProject.archives_base_name + "-fabric"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
|
||||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
|
||||||
// Remove the next line if you don't want to depend on the API
|
|
||||||
//modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
|
||||||
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric")
|
|
||||||
modCompileOnlyApi "maven.modrinth:sodium:${rootProject.sodium_version}-fabric"
|
|
||||||
|
|
||||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
|
||||||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
|
||||||
common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false }
|
|
||||||
shadowCommon(project(path: ":fabric-like", configuration: "transformProductionFabric")) { transitive false }
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
inputs.property "version", project.version
|
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
|
||||||
expand "version": project.version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
exclude "architectury.common.json"
|
|
||||||
|
|
||||||
configurations = [project.configurations.shadowCommon]
|
|
||||||
archiveClassifier = "dev-shadow"
|
|
||||||
}
|
|
||||||
|
|
||||||
remapJar {
|
|
||||||
injectAccessWidener = true
|
|
||||||
input.set shadowJar.archiveFile
|
|
||||||
dependsOn shadowJar
|
|
||||||
}
|
|
||||||
|
|
||||||
sourcesJar {
|
|
||||||
def commonSources = project(":common").sourcesJar
|
|
||||||
dependsOn commonSources
|
|
||||||
from commonSources.archiveFile.map { zipTree(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
components.java {
|
|
||||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
|
||||||
skip()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unifiedPublishing {
|
|
||||||
project {
|
|
||||||
displayName = "CullLeaves v$project.version - Fabric $project.minecraft_version"
|
|
||||||
releaseType = "$project.release_type"
|
|
||||||
changelog = releaseChangelog()
|
|
||||||
gameVersions = []
|
|
||||||
gameLoaders = ["fabric","quilt"]
|
|
||||||
mainPublication remapJar
|
|
||||||
relations {
|
|
||||||
depends {
|
|
||||||
curseforge = "fabric-api"
|
|
||||||
modrinth = "fabric-api"
|
|
||||||
}
|
|
||||||
includes {
|
|
||||||
curseforge = "midnightlib"
|
|
||||||
modrinth = "midnightlib"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
|
||||||
if (CURSEFORGE_TOKEN != null) {
|
|
||||||
curseforge {
|
|
||||||
token = CURSEFORGE_TOKEN
|
|
||||||
id = rootProject.curseforge_id
|
|
||||||
gameVersions.addAll "Java 17", project.minecraft_version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
|
||||||
if (MODRINTH_TOKEN != null) {
|
|
||||||
modrinth {
|
|
||||||
token = MODRINTH_TOKEN
|
|
||||||
id = rootProject.modrinth_id
|
|
||||||
version = "$project.version-$project.name"
|
|
||||||
gameVersions.addAll project.minecraft_version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.fabric;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.CullLeavesClient;
|
|
||||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
|
||||||
import eu.midnightdust.lib.config.MidnightConfig;
|
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
|
||||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
|
||||||
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
|
|
||||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
|
||||||
import net.fabricmc.fabric.api.resource.v1.ResourceLoader;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
import net.minecraft.resource.ResourceManager;
|
|
||||||
import net.minecraft.resource.ResourceType;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
public class CullLeavesClientFabric implements ClientModInitializer {
|
|
||||||
@Override
|
|
||||||
public void onInitializeClient() {
|
|
||||||
MidnightConfig.init(CullLeavesClient.MOD_ID, CullLeavesConfig.class);
|
|
||||||
FabricLoader.getInstance().getModContainer("cullleaves").ifPresent(modContainer -> {
|
|
||||||
ResourceManagerHelper.registerBuiltinResourcePack(Identifier.of(CullLeavesClient.MOD_ID,"smartleaves"), modContainer, ResourcePackActivationType.NORMAL);
|
|
||||||
});
|
|
||||||
ResourceLoader.get(ResourceType.CLIENT_RESOURCES).registerReloader(Identifier.of(CullLeavesClient.MOD_ID, "resourcepack_options"), CullLeavesClient.ReloadListener.INSTANCE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +1,37 @@
|
|||||||
org.gradle.jvmargs=-Xmx4096M
|
# Done to increase the memory available to gradle.
|
||||||
|
org.gradle.jvmargs=-Xmx3G
|
||||||
|
#org.gradle.parallel=true
|
||||||
|
org.gradle.caching=false
|
||||||
|
org.gradle.caching.debug=false
|
||||||
|
org.gradle.parallel=false
|
||||||
|
#org.gradle.configureondemand=true
|
||||||
|
|
||||||
minecraft_version=1.21.9
|
# Mod properties
|
||||||
yarn_mappings=1.21.9+build.1
|
mod.version=4.1.0
|
||||||
enabled_platforms=fabric,neoforge
|
mod.group=eu.midnightdust
|
||||||
|
mod.id=cullleaves
|
||||||
|
mod.name=CullLeaves
|
||||||
|
|
||||||
archives_base_name=cullleaves
|
# Used for the mod metadata
|
||||||
mod_version=4.0.6
|
mod.mc_dep_fabric=[VERSIONED]
|
||||||
maven_group=eu.midnightdust
|
mod.mc_dep_forgelike=[VERSIONED]
|
||||||
release_type=release
|
# Used for the release title. I.e. '1.20.x'
|
||||||
curseforge_id=423254
|
mod.mc_title=[VERSIONED]
|
||||||
modrinth_id=GNxdLCoP
|
# Space separated versions for publishing. I.e. '1.20, 1.20.1'
|
||||||
|
mod.mc_targets=[VERSIONED]
|
||||||
|
|
||||||
midnightlib_version=1.8.3+1.21.9
|
# Mod setup
|
||||||
sodium_version=mc1.21.8-0.7.0
|
deps.fabric_loader=0.17.3
|
||||||
|
deps.fabric_version=[VERSIONED]
|
||||||
|
|
||||||
fabric_loader_version=0.17.2
|
deps.forge_loader=[VERSIONED]
|
||||||
fabric_api_version=0.134.0+1.21.9
|
deps.neoforge_loader=[VERSIONED]
|
||||||
|
deps.neoforge_patch=[VERSIONED]
|
||||||
|
|
||||||
neoforge_version=21.9.11-beta
|
# Mod dependencies
|
||||||
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
deps.midnightlib_version=1.9.0-alpha.1
|
||||||
|
deps.sodium_version=mc1.21.8-0.7.0
|
||||||
|
|
||||||
quilt_loader_version=0.18.9
|
# Publishing
|
||||||
quilt_fabric_api_version=7.0.6+0.85.0-1.20.1
|
publish.modrinth=GNxdLCoP
|
||||||
|
publish.curseforge=423254
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
|
||||||
id "me.shedaniel.unified-publishing"
|
|
||||||
}
|
|
||||||
|
|
||||||
architectury {
|
|
||||||
injectInjectables = false
|
|
||||||
platformSetupLoomIde()
|
|
||||||
neoForge()
|
|
||||||
}
|
|
||||||
|
|
||||||
loom {}
|
|
||||||
repositories {
|
|
||||||
maven { url "https://api.modrinth.com/maven" }
|
|
||||||
maven { url "https://maven.neoforged.net/releases" }
|
|
||||||
maven { url "https://maven.pkg.github.com/ims212/ForgifiedFabricAPI"
|
|
||||||
credentials {
|
|
||||||
username = "IMS212"
|
|
||||||
// Read only token
|
|
||||||
password = "ghp_" + "DEuGv0Z56vnSOYKLCXdsS9svK4nb9K39C1Hn"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maven{ url "https://maven.su5ed.dev/releases" }
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
common
|
|
||||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
|
||||||
compileClasspath.extendsFrom common
|
|
||||||
runtimeClasspath.extendsFrom common
|
|
||||||
developmentForge.extendsFrom common
|
|
||||||
archivesBaseName = rootProject.archives_base_name + "-neoforge"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
|
|
||||||
// Remove the next line if you don't want to depend on the API
|
|
||||||
//modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
|
|
||||||
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-neoforge"
|
|
||||||
modCompileOnlyApi "maven.modrinth:sodium:${rootProject.sodium_version}-neoforge"
|
|
||||||
//include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
|
|
||||||
|
|
||||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
|
||||||
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
inputs.property "version", project.version
|
|
||||||
|
|
||||||
filesMatching("META-INF/neoforge.mods.toml") {
|
|
||||||
expand "version": project.version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
exclude "fabric.mod.json"
|
|
||||||
exclude "architectury.common.json"
|
|
||||||
|
|
||||||
configurations = [project.configurations.shadowCommon]
|
|
||||||
archiveClassifier = "dev-shadow"
|
|
||||||
}
|
|
||||||
|
|
||||||
remapJar {
|
|
||||||
input.set shadowJar.archiveFile
|
|
||||||
dependsOn shadowJar
|
|
||||||
}
|
|
||||||
|
|
||||||
sourcesJar {
|
|
||||||
def commonSources = project(":common").sourcesJar
|
|
||||||
dependsOn commonSources
|
|
||||||
from commonSources.archiveFile.map { zipTree(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
components.java {
|
|
||||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
|
||||||
skip()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unifiedPublishing {
|
|
||||||
project {
|
|
||||||
displayName = "CullLeaves v$project.version - NeoForge $project.minecraft_version"
|
|
||||||
releaseType = "$project.release_type"
|
|
||||||
changelog = releaseChangelog()
|
|
||||||
gameVersions = []
|
|
||||||
gameLoaders = ["neoforge"]
|
|
||||||
|
|
||||||
mainPublication remapJar
|
|
||||||
|
|
||||||
relations {
|
|
||||||
depends {
|
|
||||||
curseforge = "midnightlib"
|
|
||||||
modrinth = "midnightlib"
|
|
||||||
}
|
|
||||||
includes {}
|
|
||||||
}
|
|
||||||
|
|
||||||
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
|
||||||
if (CURSEFORGE_TOKEN != null) {
|
|
||||||
curseforge {
|
|
||||||
token = CURSEFORGE_TOKEN
|
|
||||||
id = rootProject.curseforge_id
|
|
||||||
gameVersions.addAll "Java 17", project.minecraft_version
|
|
||||||
releaseType = "alpha"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
|
||||||
if (MODRINTH_TOKEN != null) {
|
|
||||||
modrinth {
|
|
||||||
token = MODRINTH_TOKEN
|
|
||||||
id = rootProject.modrinth_id
|
|
||||||
version = "$project.version-$project.name"
|
|
||||||
gameVersions.addAll project.minecraft_version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
loom.platform=neoforge
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.neoforge;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.CullLeavesClient;
|
|
||||||
import net.minecraft.network.packet.PacketType;
|
|
||||||
import net.minecraft.resource.*;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.neoforged.api.distmarker.Dist;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.fml.ModList;
|
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
|
||||||
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent;
|
|
||||||
import net.neoforged.neoforge.event.AddPackFindersEvent;
|
|
||||||
import net.neoforged.neoforge.resource.ResourcePackLoader;
|
|
||||||
import net.neoforged.neoforgespi.locating.IModFile;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@EventBusSubscriber(modid = CullLeavesClient.MOD_ID, value = Dist.CLIENT)
|
|
||||||
public class CullLeavesClientEvents {
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void addPackFinders(AddPackFindersEvent event) {
|
|
||||||
if (event.getPackType() == ResourceType.CLIENT_RESOURCES) {
|
|
||||||
event.addPackFinders(Identifier.of(CullLeavesClient.MOD_ID, "resourcepacks/smartleaves"), ResourceType.CLIENT_RESOURCES, Text.of("cullleaves/smartleaves"), ResourcePackSource.BUILTIN, false, ResourcePackProfile.InsertionPosition.TOP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onResourceReload(AddClientReloadListenersEvent event) {
|
|
||||||
event.addListener(Identifier.of(CullLeavesClient.MOD_ID, "resourcepack_options"), CullLeavesClient.ReloadListener.INSTANCE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.neoforge;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.CullLeavesClient;
|
|
||||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
|
||||||
import eu.midnightdust.lib.config.MidnightConfig;
|
|
||||||
import net.neoforged.fml.common.Mod;
|
|
||||||
|
|
||||||
@Mod(CullLeavesClient.MOD_ID)
|
|
||||||
public class CullLeavesClientForge {
|
|
||||||
public CullLeavesClientForge() {
|
|
||||||
MidnightConfig.init(CullLeavesClient.MOD_ID, CullLeavesConfig.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.neoforge.mixin.sodium;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.CullLeavesClient;
|
|
||||||
import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.LeavesBlock;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.client.render.model.BlockStateModel;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
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;
|
|
||||||
|
|
||||||
@Mixin(BlockRenderer.class)
|
|
||||||
public abstract class MixinBlockRenderer {
|
|
||||||
// Unfortunately, we cannot use the level view from AbstractBlockRenderContext on NeoForge because of method conflicts
|
|
||||||
@Unique private static final MinecraftClient cullleaves$client = MinecraftClient.getInstance();
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "renderModel", cancellable = true)
|
|
||||||
public void cullleaves$cancelRendering(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) {
|
|
||||||
if (CullLeavesClient.forceHideInnerLeaves && state.getBlock() instanceof LeavesBlock && CullLeavesClient.shouldHideBlock(cullleaves$client.world, pos))
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.neoforge.mixin.sodium;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.CullLeavesClient;
|
|
||||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
|
||||||
import net.caffeinemc.mods.sodium.client.gui.SodiumGameOptionPages;
|
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionFlag;
|
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionGroup;
|
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpact;
|
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpl;
|
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.control.TickBoxControl;
|
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.storage.SodiumOptionsStorage;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mixin(value = SodiumGameOptionPages.class, remap = false)
|
|
||||||
public class MixinSodiumGameOptionPages {
|
|
||||||
|
|
||||||
@Shadow @Final private static SodiumOptionsStorage sodiumOpts;
|
|
||||||
|
|
||||||
@ModifyVariable(method = "performance", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableList;copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;"))
|
|
||||||
private static List<OptionGroup> cullleaves$addCullLeavesOption(List<OptionGroup> groups) {
|
|
||||||
groups.add(OptionGroup.createBuilder()
|
|
||||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
|
||||||
.setName(Text.translatable("cullleaves.midnightconfig.enabled"))
|
|
||||||
.setTooltip(Text.translatable("cullleaves.midnightconfig.enabled.tooltip"))
|
|
||||||
.setControl(TickBoxControl::new)
|
|
||||||
.setBinding((opts, value) -> {
|
|
||||||
CullLeavesConfig.enabled = value;
|
|
||||||
CullLeavesConfig.write(CullLeavesClient.MOD_ID);
|
|
||||||
}, opts -> CullLeavesConfig.enabled)
|
|
||||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
|
||||||
.setImpact(OptionImpact.MEDIUM)
|
|
||||||
.build()
|
|
||||||
).add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
|
||||||
.setName(Text.translatable("cullleaves.midnightconfig.cullRoots"))
|
|
||||||
.setTooltip(Text.translatable("cullleaves.midnightconfig.cullRoots.tooltip"))
|
|
||||||
.setControl(TickBoxControl::new)
|
|
||||||
.setBinding((opts, value) -> {
|
|
||||||
CullLeavesConfig.cullRoots = value;
|
|
||||||
CullLeavesConfig.write(CullLeavesClient.MOD_ID);
|
|
||||||
}, opts -> CullLeavesConfig.cullRoots)
|
|
||||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
|
||||||
.setImpact(OptionImpact.MEDIUM)
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
return groups;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven { url "https://maven.quiltmc.org/repository/release/" }
|
|
||||||
maven { url "https://api.modrinth.com/maven" }
|
|
||||||
}
|
|
||||||
|
|
||||||
architectury {
|
|
||||||
injectInjectables = false
|
|
||||||
platformSetupLoomIde()
|
|
||||||
loader("quilt")
|
|
||||||
}
|
|
||||||
|
|
||||||
loom {
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
common
|
|
||||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
|
||||||
compileClasspath.extendsFrom common
|
|
||||||
runtimeClasspath.extendsFrom common
|
|
||||||
developmentQuilt.extendsFrom common
|
|
||||||
archivesBaseName = rootProject.archives_base_name + "-quilt"
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}"
|
|
||||||
modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}"
|
|
||||||
// Remove the next few lines if you don't want to depend on the API
|
|
||||||
//modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") {
|
|
||||||
// // We must not pull Fabric Loader from Architectury Fabric
|
|
||||||
// exclude group: "net.fabricmc"
|
|
||||||
// exclude group: "net.fabricmc.fabric-api"
|
|
||||||
//}
|
|
||||||
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-quilt"
|
|
||||||
include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-quilt"
|
|
||||||
|
|
||||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
|
||||||
shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false }
|
|
||||||
common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false }
|
|
||||||
shadowCommon(project(path: ":fabric-like", configuration: "transformProductionQuilt")) { transitive false }
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
inputs.property "group", rootProject.maven_group
|
|
||||||
inputs.property "version", project.version
|
|
||||||
|
|
||||||
filesMatching("quilt.mod.json") {
|
|
||||||
expand "group": rootProject.maven_group,
|
|
||||||
"version": project.version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
exclude "architectury.common.json"
|
|
||||||
|
|
||||||
configurations = [project.configurations.shadowCommon]
|
|
||||||
classifier "dev-shadow"
|
|
||||||
}
|
|
||||||
|
|
||||||
remapJar {
|
|
||||||
input.set shadowJar.archiveFile
|
|
||||||
dependsOn shadowJar
|
|
||||||
classifier null
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
classifier "dev"
|
|
||||||
}
|
|
||||||
|
|
||||||
sourcesJar {
|
|
||||||
def commonSources = project(":common").sourcesJar
|
|
||||||
dependsOn commonSources
|
|
||||||
from commonSources.archiveFile.map { zipTree(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
components.java {
|
|
||||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
|
||||||
skip()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
mavenQuilt(MavenPublication) {
|
|
||||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
|
||||||
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.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
loom.platform=quilt
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.quilt;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
|
||||||
import eu.midnightdust.lib.config.MidnightConfig;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import org.quiltmc.loader.api.ModContainer;
|
|
||||||
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;
|
|
||||||
import org.quiltmc.qsl.resource.loader.api.ResourceLoader;
|
|
||||||
import org.quiltmc.qsl.resource.loader.api.ResourcePackActivationType;
|
|
||||||
|
|
||||||
public class CullLeavesClientQuilt implements ClientModInitializer {
|
|
||||||
@Override
|
|
||||||
public void onInitializeClient(ModContainer mod) {
|
|
||||||
MidnightConfig.init("cullleaves", CullLeavesConfig.class);
|
|
||||||
ResourceLoader.registerBuiltinResourcePack(new Identifier("cullleaves:smartleaves"), mod, ResourcePackActivationType.NORMAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
{
|
|
||||||
"schema_version": 1,
|
|
||||||
"quilt_loader": {
|
|
||||||
"group": "${group}",
|
|
||||||
"id": "cullleaves",
|
|
||||||
"version": "${version}",
|
|
||||||
"intermediate_mappings": "net.fabricmc:intermediary",
|
|
||||||
"entrypoints": {
|
|
||||||
"client_init": [
|
|
||||||
"eu.midnightdust.cullleaves.quilt.CullLeavesClientQuilt"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"depends": [
|
|
||||||
{
|
|
||||||
"id": "quilt_loader",
|
|
||||||
"version": "*"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "quilt_base",
|
|
||||||
"version": "*"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "midnightlib",
|
|
||||||
"version": "*"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"breaks": [
|
|
||||||
{
|
|
||||||
"id": "sodium",
|
|
||||||
"versions": "<0.4.9"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"name": "Cull Leaves (Quilt)",
|
|
||||||
"description": "Adds culling to leaf blocks, providing a huge performance boost over vanilla.",
|
|
||||||
"contributors": {
|
|
||||||
"Motschen": "Author",
|
|
||||||
"TeamMidnightDust": "Mascot"
|
|
||||||
},
|
|
||||||
"environment": "client",
|
|
||||||
"contact": {
|
|
||||||
"email": "mail@midnightdust.eu",
|
|
||||||
"homepage": "https://modrinth.com/mod/cullleaves",
|
|
||||||
"issues": "https://github.com/TeamMidnightDust/CullLeaves/issues",
|
|
||||||
"sources": "https://github.com/TeamMidnightDust/CullLeaves"
|
|
||||||
},
|
|
||||||
"icon": "assets/cullleaves/icon.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mixin": [
|
|
||||||
"cullleaves.mixins.json"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
maven { url "https://maven.fabricmc.net/" }
|
|
||||||
maven { url "https://maven.architectury.dev/" }
|
|
||||||
maven { url "https://maven.neoforged.net/releases" }
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include("common")
|
|
||||||
include("fabric-like")
|
|
||||||
include("fabric")
|
|
||||||
//include("quilt")
|
|
||||||
include("neoforge")
|
|
||||||
|
|
||||||
rootProject.name = "cullleaves"
|
|
||||||
33
settings.gradle.kts
Normal file
33
settings.gradle.kts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
maven("https://maven.fabricmc.net/")
|
||||||
|
maven("https://maven.architectury.dev")
|
||||||
|
maven("https://maven.minecraftforge.net")
|
||||||
|
maven("https://maven.neoforged.net/releases/")
|
||||||
|
maven("https://maven.kikugie.dev/snapshots")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("dev.kikugie.stonecutter") version "0.7"
|
||||||
|
}
|
||||||
|
|
||||||
|
stonecutter {
|
||||||
|
centralScript = "build.gradle.kts"
|
||||||
|
kotlinController = true
|
||||||
|
shared {
|
||||||
|
fun mc(loader: String, vararg versions: String) {
|
||||||
|
for (version in versions) vers("$version-$loader", version)
|
||||||
|
}
|
||||||
|
//i would recommend to use neoforge for mc > 1.20.1, i haven't tested template for forge on versions higher than that
|
||||||
|
mc("fabric","1.20.1", "1.21.1", "1.21.5", "1.21.8", "1.21.10")
|
||||||
|
mc("forge","1.20.1")
|
||||||
|
//WARNING: neoforge uses mods.toml instead of neoforge.mods.toml for versions 1.20.4 (?) and earlier
|
||||||
|
mc("neoforge", "1.21.1", "1.21.5", "1.21.8", "1.21.10")
|
||||||
|
}
|
||||||
|
create(rootProject)
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "CullLeaves"
|
||||||
135
src/main/java/eu/midnightdust/cullleaves/CullLeavesClient.java
Normal file
135
src/main/java/eu/midnightdust/cullleaves/CullLeavesClient.java
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
package eu.midnightdust.cullleaves;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||||
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.packs.PackType;
|
||||||
|
|
||||||
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
|
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
|
||||||
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
|
import net.minecraft.world.level.block.LeavesBlock;
|
||||||
|
import net.minecraft.world.level.block.MangroveRootsBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
//? fabric {
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||||
|
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
|
||||||
|
import net.fabricmc.fabric.api.resource.v1.ResourceLoader;
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
//?} else if neoforge {
|
||||||
|
/*import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.server.packs.repository.Pack;
|
||||||
|
import net.minecraft.server.packs.repository.PackSource;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
|
import net.neoforged.fml.common.Mod;
|
||||||
|
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent;
|
||||||
|
import net.neoforged.neoforge.event.AddPackFindersEvent;
|
||||||
|
*///?}
|
||||||
|
|
||||||
|
//? neoforge
|
||||||
|
/*@Mod(CullLeavesClient.MOD_ID)*/
|
||||||
|
public class CullLeavesClient /*? fabric {*/ implements ClientModInitializer /*?}*/ {
|
||||||
|
public static final String MOD_ID = "cullleaves";
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
|
||||||
|
public static boolean forceLeafCulling = false;
|
||||||
|
public static boolean forceHideInnerLeaves = false;
|
||||||
|
|
||||||
|
public static boolean shouldHideBlock(BlockAndTintGetter world, BlockPos pos) {
|
||||||
|
if (CullLeavesClient.forceHideInnerLeaves) {
|
||||||
|
boolean shouldForceCull = true;
|
||||||
|
for (Direction dir : Direction.values()) {
|
||||||
|
BlockState otherState = world.getBlockState(pos.relative(dir));
|
||||||
|
if (!(otherState.getBlock() instanceof LeavesBlock) &&
|
||||||
|
!otherState.isFaceSturdy(world, pos, dir.getOpposite())) {
|
||||||
|
shouldForceCull = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return shouldForceCull;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLeafSideInvisible(BlockState neighborState) {
|
||||||
|
if (CullLeavesConfig.enabled || CullLeavesClient.forceLeafCulling) {
|
||||||
|
return neighborState.getBlock() instanceof LeavesBlock;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isRootSideInvisible(BlockState neighborState) {
|
||||||
|
if (CullLeavesConfig.cullRoots) {
|
||||||
|
return neighborState.getBlock() instanceof MangroveRootsBlock;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ReloadListener implements ResourceManagerReloadListener {
|
||||||
|
public static final ReloadListener INSTANCE = new ReloadListener();
|
||||||
|
|
||||||
|
private ReloadListener() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResourceManagerReload(ResourceManager manager) {
|
||||||
|
CullLeavesClient.forceLeafCulling = false;
|
||||||
|
CullLeavesClient.forceHideInnerLeaves = false;
|
||||||
|
manager.listResources("options", path -> path.toString().startsWith("cullleaves") && path.toString().endsWith("options.json")).forEach((id, resource) -> {
|
||||||
|
try {
|
||||||
|
JsonObject json = JsonParser.parseReader(resource.openAsReader()).getAsJsonObject();
|
||||||
|
if (json.has("forceLeafCulling")) {
|
||||||
|
CullLeavesClient.forceLeafCulling = json.get("forceLeafCulling").getAsBoolean();
|
||||||
|
LOGGER.info("Forcing leaf culling as requested by resourcepack");
|
||||||
|
}
|
||||||
|
if (json.has("forceHideInnerLeaves")) {
|
||||||
|
CullLeavesClient.forceHideInnerLeaves = json.get("forceHideInnerLeaves").getAsBoolean();
|
||||||
|
LOGGER.info("Not rendering inner leaves as requested by resourcepack");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//? fabric {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
MidnightConfig.init(CullLeavesClient.MOD_ID, CullLeavesConfig.class);
|
||||||
|
FabricLoader.getInstance().getModContainer("cullleaves").ifPresent(modContainer -> {
|
||||||
|
ResourceManagerHelper.registerBuiltinResourcePack(ResourceLocation.fromNamespaceAndPath(CullLeavesClient.MOD_ID, "smartleaves"), modContainer, ResourcePackActivationType.NORMAL);
|
||||||
|
});
|
||||||
|
ResourceLoader.get(PackType.CLIENT_RESOURCES).registerReloader(ResourceLocation.fromNamespaceAndPath(CullLeavesClient.MOD_ID, "resourcepack_options"), CullLeavesClient.ReloadListener.INSTANCE);
|
||||||
|
}
|
||||||
|
//?} else if neoforge {
|
||||||
|
/*public CullLeavesClient() {
|
||||||
|
MidnightConfig.init(CullLeavesClient.MOD_ID, CullLeavesConfig.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventBusSubscriber(modid = CullLeavesClient.MOD_ID, value = Dist.CLIENT)
|
||||||
|
public class CullLeavesClientEvents {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void addPackFinders(AddPackFindersEvent event) {
|
||||||
|
if (event.getPackType() == PackType.CLIENT_RESOURCES) {
|
||||||
|
event.addPackFinders(ResourceLocation.fromNamespaceAndPath(CullLeavesClient.MOD_ID, "resourcepacks/smartleaves"), PackType.CLIENT_RESOURCES, Component.literal("cullleaves/smartleaves"), PackSource.BUILT_IN, false, Pack.Position.TOP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onResourceReload(AddClientReloadListenersEvent event) {
|
||||||
|
event.addListener(ResourceLocation.fromNamespaceAndPath(CullLeavesClient.MOD_ID, "resourcepack_options"), CullLeavesClient.ReloadListener.INSTANCE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*///?}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package eu.midnightdust.cullleaves.config;
|
package eu.midnightdust.cullleaves.config;
|
||||||
|
|
||||||
import eu.midnightdust.lib.config.MidnightConfig;
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class CullLeavesConfig extends MidnightConfig {
|
public class CullLeavesConfig extends MidnightConfig {
|
||||||
@Entry // Enable/Disable the mod. Requires Chunk Reload (F3 + A).
|
@Entry // Enable/Disable the mod. Requires Chunk Reload (F3 + A).
|
||||||
@@ -11,8 +11,8 @@ public class CullLeavesConfig extends MidnightConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeChanges() {
|
public void writeChanges() {
|
||||||
var client = MinecraftClient.getInstance();
|
var client = Minecraft.getInstance();
|
||||||
if (client != null && client.world != null) client.worldRenderer.reload();
|
if (client != null && client.level != null) client.levelRenderer.needsUpdate();
|
||||||
super.writeChanges();
|
super.writeChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package eu.midnightdust.cullleaves.mixin;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import net.minecraft.client.renderer.block.ModelBlockRenderer;
|
||||||
|
import net.minecraft.client.renderer.block.model.BlockModelPart;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
|
import net.minecraft.world.level.block.LeavesBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(ModelBlockRenderer.class)
|
||||||
|
public class MixinBlockModelRenderer {
|
||||||
|
@Inject(at = @At("HEAD"), method = "tesselateBlock", cancellable = true)
|
||||||
|
private void cullleaves$cancelRendering(BlockAndTintGetter world, List<BlockModelPart> parts, BlockState state, BlockPos pos, PoseStack matrices, VertexConsumer vertexConsumer, boolean cull, int overlay, CallbackInfo ci) {
|
||||||
|
if (state.getBlock() instanceof LeavesBlock &&
|
||||||
|
CullLeavesClient.shouldHideBlock(world, pos)) ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/main/java/eu/midnightdust/cullleaves/mixin/MixinLeavesBlock.java
Executable file
20
src/main/java/eu/midnightdust/cullleaves/mixin/MixinLeavesBlock.java
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
package eu.midnightdust.cullleaves.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.LeavesBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(value = LeavesBlock.class, priority = 1900)
|
||||||
|
public abstract class MixinLeavesBlock extends Block {
|
||||||
|
public MixinLeavesBlock(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean skipRendering(BlockState state, BlockState neighborState, Direction offset) {
|
||||||
|
return CullLeavesClient.isLeafSideInvisible(neighborState);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/main/java/eu/midnightdust/cullleaves/mixin/MixinMangroveRootsBlock.java
Executable file
20
src/main/java/eu/midnightdust/cullleaves/mixin/MixinMangroveRootsBlock.java
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
package eu.midnightdust.cullleaves.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.MangroveRootsBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(value = MangroveRootsBlock.class, priority = 1900)
|
||||||
|
public abstract class MixinMangroveRootsBlock extends Block {
|
||||||
|
public MixinMangroveRootsBlock(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean skipRendering(BlockState state, BlockState neighborState, Direction offset) {
|
||||||
|
return CullLeavesClient.isRootSideInvisible(neighborState);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package eu.midnightdust.cullleaves.fabric.mixin.sodium;
|
package eu.midnightdust.cullleaves.mixin.sodium;
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.CullLeavesClient;
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer;
|
import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer;
|
||||||
import net.caffeinemc.mods.sodium.client.render.frapi.render.AbstractBlockRenderContext;
|
import net.caffeinemc.mods.sodium.client.render.frapi.render.AbstractBlockRenderContext;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.client.renderer.block.model.BlockStateModel;
|
||||||
import net.minecraft.block.LeavesBlock;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.client.render.model.BlockStateModel;
|
import net.minecraft.world.level.block.LeavesBlock;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
package eu.midnightdust.cullleaves.fabric.mixin.sodium;
|
package eu.midnightdust.cullleaves.mixin.sodium;
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.SodiumGameOptionPages;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionFlag;
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionFlag;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionGroup;
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionGroup;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpact;
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpact;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpl;
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpl;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.control.TickBoxControl;
|
import net.caffeinemc.mods.sodium.client.gui.options.control.TickBoxControl;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.storage.SodiumOptionsStorage;
|
import net.caffeinemc.mods.sodium.client.gui.options.storage.SodiumOptionsStorage;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.network.chat.Component;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -16,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mixin(value = net.caffeinemc.mods.sodium.client.gui.SodiumGameOptionPages.class, remap = false)
|
@Mixin(value = SodiumGameOptionPages.class, remap = false)
|
||||||
public class MixinSodiumGameOptionPages {
|
public class MixinSodiumGameOptionPages {
|
||||||
|
|
||||||
@Shadow @Final private static SodiumOptionsStorage sodiumOpts;
|
@Shadow @Final private static SodiumOptionsStorage sodiumOpts;
|
||||||
@@ -25,8 +26,8 @@ public class MixinSodiumGameOptionPages {
|
|||||||
private static List<OptionGroup> cullleaves$addCullLeavesOption(List<OptionGroup> groups) {
|
private static List<OptionGroup> cullleaves$addCullLeavesOption(List<OptionGroup> groups) {
|
||||||
groups.add(OptionGroup.createBuilder()
|
groups.add(OptionGroup.createBuilder()
|
||||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||||
.setName(Text.translatable("cullleaves.midnightconfig.enabled"))
|
.setName(Component.translatable("cullleaves.midnightconfig.enabled"))
|
||||||
.setTooltip(Text.translatable("cullleaves.midnightconfig.enabled.tooltip"))
|
.setTooltip(Component.translatable("cullleaves.midnightconfig.enabled.tooltip"))
|
||||||
.setControl(TickBoxControl::new)
|
.setControl(TickBoxControl::new)
|
||||||
.setBinding((opts, value) -> {
|
.setBinding((opts, value) -> {
|
||||||
CullLeavesConfig.enabled = value;
|
CullLeavesConfig.enabled = value;
|
||||||
@@ -36,8 +37,8 @@ public class MixinSodiumGameOptionPages {
|
|||||||
.setImpact(OptionImpact.MEDIUM)
|
.setImpact(OptionImpact.MEDIUM)
|
||||||
.build()
|
.build()
|
||||||
).add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
).add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||||
.setName(Text.translatable("cullleaves.midnightconfig.cullRoots"))
|
.setName(Component.translatable("cullleaves.midnightconfig.cullRoots"))
|
||||||
.setTooltip(Text.translatable("cullleaves.midnightconfig.cullRoots.tooltip"))
|
.setTooltip(Component.translatable("cullleaves.midnightconfig.cullRoots.tooltip"))
|
||||||
.setControl(TickBoxControl::new)
|
.setControl(TickBoxControl::new)
|
||||||
.setBinding((opts, value) -> {
|
.setBinding((opts, value) -> {
|
||||||
CullLeavesConfig.cullRoots = value;
|
CullLeavesConfig.cullRoots = value;
|
||||||
@@ -37,5 +37,5 @@ side = "CLIENT"
|
|||||||
modId = "midnightlib"
|
modId = "midnightlib"
|
||||||
required = true
|
required = true
|
||||||
versionRange = "[1.0.0,)"
|
versionRange = "[1.0.0,)"
|
||||||
ordering = "AFTER"
|
ordering = "BEFORE"
|
||||||
side = "CLIENT"
|
side = "CLIENT"
|
||||||
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "eu.midnightdust.cullleaves.fabric.mixin",
|
"package": "eu.midnightdust.cullleaves.mixin",
|
||||||
"plugin": "eu.midnightdust.cullleaves.CullLeavesMixinPlugin",
|
"plugin": "eu.midnightdust.cullleaves.CullLeavesMixinPlugin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "eu.midnightdust.cullleaves.neoforge.mixin",
|
"package": "eu.midnightdust.cullleaves.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"client": [
|
"client": [
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
"client": [
|
"client": [
|
||||||
"MixinBlockModelRenderer",
|
"MixinBlockModelRenderer",
|
||||||
"MixinLeavesBlock",
|
"MixinLeavesBlock",
|
||||||
"MixinMangroveRootsBlock"
|
"MixinMangroveRootsBlock",
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
"environment": "client",
|
"environment": "client",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"client": [
|
"client": [
|
||||||
"eu.midnightdust.cullleaves.fabric.CullLeavesClientFabric"
|
"eu.midnightdust.cullleaves.CullLeavesClient"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
16
stonecutter.gradle.kts
Normal file
16
stonecutter.gradle.kts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
plugins {
|
||||||
|
id("dev.kikugie.stonecutter")
|
||||||
|
id("dev.architectury.loom") version "1.13-SNAPSHOT" apply false
|
||||||
|
id("architectury-plugin") version "3.4-SNAPSHOT" apply false
|
||||||
|
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
||||||
|
id("me.modmuss50.mod-publish-plugin") version "0.8.4" apply false
|
||||||
|
}
|
||||||
|
stonecutter active "1.21.10-fabric" /* [SC] DO NOT EDIT */
|
||||||
|
|
||||||
|
// See https://stonecutter.kikugie.dev/wiki/config/params
|
||||||
|
stonecutter parameters {
|
||||||
|
swaps["mod_version"] = "\"" + property("mod.version") + "\";"
|
||||||
|
swaps["minecraft"] = "\"" + node.metadata.version + "\";"
|
||||||
|
constants["release"] = property("mod.id") != "template"
|
||||||
|
dependencies["fapi"] = node.project.property("deps.fabric_version") as String
|
||||||
|
}
|
||||||
12
versions/1.20.1-fabric/gradle.properties
Normal file
12
versions/1.20.1-fabric/gradle.properties
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
mod.mc_dep_fabric==1.20.1
|
||||||
|
mod.mc_dep_forgelike=[1.20, 1.20.1]
|
||||||
|
mod.mc_title=1.20.1
|
||||||
|
mod.mc_targets=1.20.1
|
||||||
|
|
||||||
|
deps.forge_loader=47.3.0
|
||||||
|
deps.neoforge_loader=[UNSUPPORTED]
|
||||||
|
|
||||||
|
deps.fabric_version=0.92.3+1.20.1
|
||||||
|
deps.modmenu_version=7.2.2
|
||||||
|
|
||||||
|
loom.platform=fabric
|
||||||
13
versions/1.20.1-forge/gradle.properties
Normal file
13
versions/1.20.1-forge/gradle.properties
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
mod.mc_dep_fabric==1.20.1
|
||||||
|
mod.mc_dep_forgelike=[1.20, 1.20.1]
|
||||||
|
mod.mc_title=1.20.1
|
||||||
|
mod.mc_targets=1.20.1
|
||||||
|
|
||||||
|
deps.forge_loader=47.3.0
|
||||||
|
deps.neoforge_loader=[UNSUPPORTED]
|
||||||
|
|
||||||
|
deps.fabric_version=0.92.3+1.20.1
|
||||||
|
|
||||||
|
deps.modmenu_version=[UNSUPPORTED]
|
||||||
|
|
||||||
|
loom.platform=forge
|
||||||
13
versions/1.21.1-fabric/gradle.properties
Normal file
13
versions/1.21.1-fabric/gradle.properties
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
mod.mc_dep_fabric=>=1.21 <=1.21.1
|
||||||
|
mod.mc_dep_forgelike=[1.21, 1.21.1]
|
||||||
|
mod.mc_title=1.21.1
|
||||||
|
mod.mc_targets=1.21 1.21.1
|
||||||
|
|
||||||
|
deps.forge_loader=0
|
||||||
|
deps.neoforge_loader=21.1.66
|
||||||
|
|
||||||
|
deps.fabric_version=0.114.0+1.21.1
|
||||||
|
|
||||||
|
deps.modmenu_version=11.0.3
|
||||||
|
|
||||||
|
loom.platform=fabric
|
||||||
13
versions/1.21.1-neoforge/gradle.properties
Normal file
13
versions/1.21.1-neoforge/gradle.properties
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
mod.mc_dep_fabric=>=1.21 <=1.21.1
|
||||||
|
mod.mc_dep_forgelike=[1.21, 1.21.1]
|
||||||
|
mod.mc_title=1.21.1
|
||||||
|
mod.mc_targets=1.21 1.21.1
|
||||||
|
|
||||||
|
deps.forge_loader=0
|
||||||
|
deps.neoforge_loader=21.1.66
|
||||||
|
|
||||||
|
deps.fabric_version=0.114.0+1.21.1
|
||||||
|
|
||||||
|
deps.modmenu_version=[UNSUPPORTED]
|
||||||
|
|
||||||
|
loom.platform=neoforge
|
||||||
12
versions/1.21.10-fabric/gradle.properties
Normal file
12
versions/1.21.10-fabric/gradle.properties
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
mod.mc_dep_fabric=>=1.21.9
|
||||||
|
mod.mc_dep_forgelike=[1.21.10,)
|
||||||
|
mod.mc_title=1.21.10
|
||||||
|
mod.mc_targets=1.21.9, 1.21.10
|
||||||
|
|
||||||
|
deps.forge_loader=0
|
||||||
|
deps.neoforge_loader=21.10.47-beta
|
||||||
|
|
||||||
|
deps.fabric_version=0.138.0+1.21.10
|
||||||
|
deps.modmenu_version=16.0.0-rc.1
|
||||||
|
|
||||||
|
loom.platform=fabric
|
||||||
12
versions/1.21.10-neoforge/gradle.properties
Normal file
12
versions/1.21.10-neoforge/gradle.properties
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
mod.mc_dep_fabric=>=1.21.9
|
||||||
|
mod.mc_dep_forgelike=[1.21.10,)
|
||||||
|
mod.mc_title=1.21.10
|
||||||
|
mod.mc_targets=1.21.9, 1.21.10
|
||||||
|
|
||||||
|
deps.forge_loader=0
|
||||||
|
deps.neoforge_loader=21.10.47-beta
|
||||||
|
|
||||||
|
deps.fabric_version=0.138.0+1.21.10
|
||||||
|
deps.modmenu_version=16.0.0-rc.1
|
||||||
|
|
||||||
|
loom.platform=neoforge
|
||||||
12
versions/1.21.5-fabric/gradle.properties
Normal file
12
versions/1.21.5-fabric/gradle.properties
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
mod.mc_dep_fabric==1.21.5
|
||||||
|
mod.mc_dep_forgelike=[1.21.5]
|
||||||
|
mod.mc_title=1.21.5
|
||||||
|
mod.mc_targets=1.21.5
|
||||||
|
|
||||||
|
deps.forge_loader=54.0.13
|
||||||
|
deps.neoforge_loader=21.4.47-beta
|
||||||
|
|
||||||
|
deps.fabric_version=0.121.0+1.21.5
|
||||||
|
deps.modmenu_version=14.0.0-rc.1
|
||||||
|
|
||||||
|
loom.platform=fabric
|
||||||
12
versions/1.21.5-neoforge/gradle.properties
Normal file
12
versions/1.21.5-neoforge/gradle.properties
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
mod.mc_dep_fabric==1.21.5
|
||||||
|
mod.mc_dep_forgelike=[1.21.5]
|
||||||
|
mod.mc_title=1.21.5
|
||||||
|
mod.mc_targets=1.21.5
|
||||||
|
|
||||||
|
deps.forge_loader=0
|
||||||
|
deps.neoforge_loader=21.5.54-beta
|
||||||
|
|
||||||
|
deps.fabric_version=0.121.0+1.21.5
|
||||||
|
deps.modmenu_version=[UNSUPPORTED]
|
||||||
|
|
||||||
|
loom.platform=neoforge
|
||||||
12
versions/1.21.8-fabric/gradle.properties
Normal file
12
versions/1.21.8-fabric/gradle.properties
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
mod.mc_dep_fabric==1.21.8
|
||||||
|
mod.mc_dep_forgelike=[1.21.8]
|
||||||
|
mod.mc_title=1.21.8
|
||||||
|
mod.mc_targets=1.21.8
|
||||||
|
|
||||||
|
deps.forge_loader=0
|
||||||
|
deps.neoforge_loader=21.8.50
|
||||||
|
|
||||||
|
deps.fabric_version=0.136.0+1.21.8
|
||||||
|
deps.modmenu_version=15.0.0
|
||||||
|
|
||||||
|
loom.platform=fabric
|
||||||
12
versions/1.21.8-neoforge/gradle.properties
Normal file
12
versions/1.21.8-neoforge/gradle.properties
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
mod.mc_dep_fabric==1.21.5
|
||||||
|
mod.mc_dep_forgelike=[1.21.5]
|
||||||
|
mod.mc_title=1.21.5
|
||||||
|
mod.mc_targets=1.21.5
|
||||||
|
|
||||||
|
deps.forge_loader=0
|
||||||
|
deps.neoforge_loader=21.8.50
|
||||||
|
|
||||||
|
deps.fabric_version=0.136.0+1.21.8
|
||||||
|
deps.modmenu_version=[UNSUPPORTED]
|
||||||
|
|
||||||
|
loom.platform=neoforge
|
||||||
Reference in New Issue
Block a user