Skip to content

Commit

Permalink
feat: Add v1.21.1 support (#4)
Browse files Browse the repository at this point in the history
* Update build scripts and dependencies

* Add v1.21.1 support
  • Loading branch information
RappyTV authored Oct 9, 2024
1 parent c93dc9f commit e86426a
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 93 deletions.
13 changes: 5 additions & 8 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType

dependencies {
labyProcessor()
labyApi("api")
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

tasks.compileJava {
sourceCompatibility = JavaVersion.VERSION_21.toString()
targetCompatibility = JavaVersion.VERSION_21.toString()
labyModAnnotationProcessor {
referenceType = ReferenceType.INTERFACE
}
88 changes: 19 additions & 69 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,45 @@ plugins {
id("basic-project-convention")
id("org.cadixdev.licenser") version ("0.6.1")

id("net.labymod.gradle")
id("net.labymod.gradle.addon")
id("net.labymod.labygradle")
id("net.labymod.labygradle.addon")
}

val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";")

version = providers.environmentVariable("VERSION").getOrElse("0.0.1")

labyMod {
defaultPackageName = "org.burgerbude.labymod.addons.${rootProject.name}" //change this to your main package name (used by all modules)
addonInfo {
namespace = "fullbright"
displayName = "Full Bright"
author = "BurgerbudeORG"
version = System.getenv().getOrDefault("VERSION", "0.0.1")
version = rootProject.version.toString()
}

minecraft {
registerVersions(
"1.8.9",
"1.12.2",
"1.16.5",
"1.17.1",
"1.18.2",
"1.19.2",
"1.19.3",
"1.19.4",
"1.20.1",
"1.20.2",
"1.20.4",
"1.20.5",
"1.20.6",
"1.21"
) { version, provider ->
configureRun(provider, version)
}

subprojects.forEach {
if (it.name != "game-runner") {
filter(it.name)
}
}
}

addonDev {
//localRelease()
productionRelease()
}
}

fun configureRun(provider: net.labymod.gradle.core.minecraft.provider.VersionProvider, gameVersion: String) {
provider.runConfiguration {
mainClass = "net.minecraft.launchwrapper.Launch"
jvmArgs("-Dnet.labymod.running-version=${gameVersion}")
jvmArgs("-Dmixin.debug=true")
jvmArgs("-Dnet.labymod.debugging.all=true")
jvmArgs("-Dmixin.env.disableRefMap=true")

args("--tweakClass", "net.labymod.core.loader.vanilla.launchwrapper.LabyModLaunchWrapperTweaker")
args("--labymod-dev-environment", "true")
args("--addon-dev-environment", "true")
}

provider.javaVersion = when (gameVersion) {
else -> {
JavaVersion.VERSION_21
}
}

provider.mixin {
val mixinMinVersion = when (gameVersion) {
"1.8.9", "1.12.2", "1.16.5" -> {
"0.6.6"
}

else -> {
"0.8.2"
registerVersion(versions.toTypedArray()) {
runs {
getByName("client") {
// When the property is set to true, you can log in with a Minecraft account
// devLogin = true
}
}
}

minVersion = mixinMinVersion
}
}


subprojects {
apply(plugin = "basic-project-convention")
apply(plugin = "net.labymod.gradle")
apply(plugin = "net.labymod.gradle.addon")
apply(plugin = "org.cadixdev.licenser")
plugins.apply("basic-project-convention")
plugins.apply("net.labymod.labygradle")
plugins.apply("net.labymod.labygradle.addon")
plugins.apply("org.cadixdev.licenser")

license {
header(rootProject.file("LICENSE-HEADER.txt"))
newLine.set(true)
}

version = rootProject.version
}
14 changes: 7 additions & 7 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType

dependencies {
labyProcessor()
api(project(":api"))
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
// An example of how to add an external dependency that is used by the addon.
// addonMavenDependency("org.jeasy:easy-random:5.0.0")
}

tasks.compileJava {
sourceCompatibility = JavaVersion.VERSION_21.toString()
targetCompatibility = JavaVersion.VERSION_21.toString()
labyModAnnotationProcessor {
referenceType = ReferenceType.DEFAULT
}
1 change: 1 addition & 0 deletions game-runner/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lg_versioned_module=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (C) 2022 BurgerbudeORG & Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.burgerbude.labymod.addons.fullbright.v1_21_1.mixins;

import com.mojang.blaze3d.platform.NativeImage;
import net.labymod.api.Laby;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.texture.DynamicTexture;
import org.burgerbude.labymod.addons.fullbright.core.event.UpdateLightmapTextureEvent;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(LightTexture.class)
public class MixinLightTexture {

@Shadow
@Final
private NativeImage lightPixels;

@Shadow
@Final
private DynamicTexture lightTexture;
@Shadow
private boolean updateLightTexture;
private boolean fullbright$updated = false;

@Inject(method = "updateLightTexture", at = @At("HEAD"), cancellable = true)
private void fullbright$updateLightTexture(float v, CallbackInfo ci) {
final var event = Laby.fireEvent(new UpdateLightmapTextureEvent());
if (event.isCancelled()) {
if (!this.fullbright$updated) {
this.fullbright$writeWhiteTexture();
}
this.fullbright$updated = true;
this.lightTexture.upload();
ci.cancel();
return;
}

// Is need for the singleplayer, if the user is in a screen,
// the tick method is not called and therefore the light level is not updated
if (this.fullbright$updated) {
this.updateLightTexture = true;
}

this.fullbright$updated = false;
}

private void fullbright$writeWhiteTexture() {
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
this.lightPixels.setPixelRGBA(x, y, 0xFFFFFFFF);
}
}
}

}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx4096m
org.gradle.jvmargs=-Xmx4096m
net.labymod.minecraft-versions=1.8.9;1.12.2;1.16.5;1.17.1;1.18.2;1.19.2;1.19.3;1.19.4;1.20.1;1.20.2;1.20.4;1.20.5;1.20.6;1.21;1.21.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
13 changes: 6 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ rootProject.name = "fullbright"
includeBuild("laby-build-logic")

pluginManagement {
val labyGradlePluginVersion = "0.4.1"
plugins {
id("net.labymod.gradle") version (labyGradlePluginVersion)
}
val labyGradlePluginVersion = "0.5.3"

buildscript {
repositories {
maven("https://dist.labymod.net/api/v1/maven/release/")
maven("https://repo.spongepowered.org/repository/maven-public")
maven("https://maven.neoforged.net/releases/")
maven("https://maven.fabricmc.net/")
gradlePluginPortal()
mavenCentral()
mavenLocal()
}

dependencies {
classpath("net.labymod.gradle", "addon", labyGradlePluginVersion)
classpath("net.labymod.gradle", "common", labyGradlePluginVersion)
}
}
}

plugins.apply("net.labymod.gradle")
plugins.apply("net.labymod.labygradle.settings")

sequenceOf("api", "core").forEach {
include(":$it")
Expand Down

0 comments on commit e86426a

Please sign in to comment.