Skip to content

Commit

Permalink
Add 1.20.3
Browse files Browse the repository at this point in the history
  • Loading branch information
R0bbyYT committed Dec 6, 2023
1 parent 7dc6758 commit 25bc460
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ bin/
### Mac OS ###
.DS_Store
build-data.txt
run/
run/
.assetsroot
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ labyMod {
"1.19.3",
"1.19.4",
"1.20.1",
"1.20.2"
"1.20.2",
"1.20.3"
) { version, provider ->
configureRun(provider, version)
}
Expand Down
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_20_3.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);
}
}
}

}

0 comments on commit 25bc460

Please sign in to comment.