Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Jul 20, 2021
0 parents commit c0bce80
Show file tree
Hide file tree
Showing 29 changed files with 1,023 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patreon: dodogang
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will build a package using Gradle

name: Check Builds For Errors

on: [ pull_request, push ]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
16
]
# and run on both Linux and Windows
os: [ ubuntu-20.04, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: ${{ matrix.java }}
- name: Make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew

- name: Build Fabric
run: ./gradlew :fabric:build
- name: Capture Fabric build artifacts
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: fabric/build/libs/

# - name: Build Forge
# run: ./gradlew :forge:build
# - name: Capture Forge build artifacts
# uses: actions/upload-artifact@v2
# with:
# name: Artifacts
# path: forge/build/libs/
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
build/
*.ipr
run/
*.iws
out/
*.iml
.gradle/
output/
bin/
libs/
logs/

.classpath
.project
.idea/
classes/
.metadata
.vscode
.settings
*.launch
.architectury-transformer
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020-2021 Daniel Orr

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.
6 changes: 6 additions & 0 deletions LICENSE_ASSETS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
All Rights Reserved

This license applies to any file in the following directories:
- ./common/src/main/resources/assets/
- ./fabric/src/main/resources/assets/
- ./forge/src/main/resources/assets/
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Underground Ambient Lighting
[![](https://cf.way2muchnoise.eu/full_447882_Downloads.svg)](https://www.curseforge.com/minecraft/mc-mods/undergroundambientlighting)
[![](https://cf.way2muchnoise.eu/versions/447882.svg)](https://www.curseforge.com/minecraft/mc-mods/undergroundambientlighting)

## What does this mod do?
UAL increases the ambient lighting underground very slightly, which unnoticeably increases underground visibility without impacting the usefulness of blocks such as torches!
Use **`I`** to toggle functionality! *(changeable in the controls menu)*

This mod is completely **client-side** and will work on vanilla servers.

## License

All assets found in the following directories are licensed under All Rights Reserved.
- ./common/src/main/resources/assets/
- ./fabric/src/main/resources/assets/
- ./forge/src/main/resources/assets/

Everything else is licensed under MIT.

## Other Information

- Report issues here: https://github.com/andantedevs/undergroundambientlighting/issues
- You can include this mod in your mod pack as long as you don't claim the mod as your own.

## Examples

### Disabled
![disabled](https://i.imgur.com/fnDLWLE.png)

### Enabled
![enabled](https://i.imgur.com/VZT2cCm.png)
65 changes: 65 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
plugins {
id "architectury-plugin" version "3.2-SNAPSHOT"
id "dev.architectury.loom" version "0.7.2-SNAPSHOT" apply false
}

architectury {
minecraft = rootProject.minecraft_version
}

subprojects {
apply plugin: "dev.architectury.loom"

// Silences mojang mappings, if enabled. See dependencies block just below this.
loom {
silentMojangMappingsLicense()
}

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 "net.fabricmc:yarn:${rootProject.yarn_version}:v2"
}
}

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 {
// maven {
// name = "Mod Menu Maven"
// url = "https://maven.terraformersmc.com/releases/"
// }
maven {
name = "Dodo Gang Maven Repo"
url = "http://maven.dodogang.net/releases"
allowInsecureProtocol = true
}
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"

// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
options.release = targetVersion
}
}

java {
withSourcesJar()
}
}
40 changes: 40 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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}"
}

architectury {
common(false)
}

java {
withSourcesJar()
}

publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archives_base_name
// add all the jars that should be included when publishing to maven
artifact remapJar
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}

repositories {
// if (System.getenv("DODO_GANG_MAVEN_TOKEN") != null) {
// maven {
// name = "DodoGangMavenRepo"
// url = "http://maven.dodogang.net/releases"
// allowInsecureProtocol = true
// credentials {
// username = "dodogang"
// password = System.getenv("DODO_GANG_MAVEN_TOKEN")
// }
// }
// }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package me.andante.undergroundambientlighting.client;

import me.andante.undergroundambientlighting.client.platform.AbstractPlatform;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class UAL {
public static final String MOD_ID = "undergroundambientlighting";
public static final String MOD_NAME = "Underground Ambient Lighting";

public static final Logger LOGGER = LogManager.getLogger(MOD_ID);

public static AbstractPlatform platform;

private static boolean enabled = true;
private static boolean keyWasDown = false;

private static final String TEXT_TOGGLE = "text.undergroundambientlighting.toggle";
private static final TranslatableText TEXT_TOGGLE_ENABLED = new TranslatableText(TEXT_TOGGLE, new TranslatableText(TEXT_TOGGLE + ".enabled").formatted(Formatting.GRAY));
private static final TranslatableText TEXT_TOGGLE_DISABLED = new TranslatableText(TEXT_TOGGLE, new TranslatableText(TEXT_TOGGLE + ".disabled").formatted(Formatting.GRAY));

public UAL(AbstractPlatform platform) {
log("Initializing");
UAL.platform = platform;
log("Initialized");
}

public void onClientTick(MinecraftClient client) {
ClientPlayerEntity player = client.player;
if (player == null) return;

if (platform.isUALKeyPressed() && !UAL.keyWasDown) {
keyWasDown = true;
UAL.enabled = !UAL.enabled;

player.sendMessage(UAL.enabled ? TEXT_TOGGLE_ENABLED : TEXT_TOGGLE_DISABLED, true);
player.playSound(UAL.enabled ? SoundEvents.BLOCK_TRIPWIRE_CLICK_OFF : SoundEvents.BLOCK_TRIPWIRE_CLICK_ON, 0.5f, UAL.enabled ? 1.0f : 0.75f);
} else if (!platform.isUALKeyPressed() && UAL.keyWasDown) {
UAL.keyWasDown = false;
}
}

public static boolean isEnabled() {
return UAL.enabled;
}

public static void log(String message) {
log(Level.INFO, message);
}
public static void log(Level level, String message) {
LOGGER.log(level, "[{}] {}", MOD_NAME, message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package me.andante.undergroundambientlighting.client.platform;

public interface AbstractPlatform {
boolean isUALKeyPressed();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package me.andante.undergroundambientlighting.mixin.client;

import me.andante.undergroundambientlighting.client.UAL;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.LightmapTextureManager;
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;

@Mixin(LightmapTextureManager.class)
public abstract class LightmapTextureManagerMixin {
@Shadow @Final private MinecraftClient client;

@ModifyVariable(method = "update", ordinal = 5, at = @At(value = "STORE", ordinal = 0))
private float applyUndergroundAmbientLight(float original) {
if (UAL.isEnabled()) {
assert this.client.player != null;
double playerY = this.client.player.getY();
int startY = 63;

if (playerY <= startY) {
int endY = 32;
float addedLight = 0.038f;
original += playerY >= endY
? addedLight * (float) ((Math.cos((playerY - endY) / (Math.abs(startY - endY) / Math.PI)) + 1) / 2)
: addedLight;
}
}

return original;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"undergroundambientlighting.discord": "Discord",

"key.category.undergroundambientlighting": "Underground Ambient Lighting",
"key.undergroundambientlighting.undergroundambientlighting": "Toggle Mod",
"text.undergroundambientlighting.toggle": "[UAL] %s",
"text.undergroundambientlighting.toggle.enabled": "Enabled",
"text.undergroundambientlighting.toggle.disabled": "Disabled"
}
Binary file added common/src/main/resources/pack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions common/src/main/resources/undergroundambientlighting.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"required": true,
"minVersion": "0.8",
"package": "me.andante.undergroundambientlighting.mixin",
"compatibilityLevel": "JAVA_16",
"client": [
"client.LightmapTextureManagerMixin"
],
"injectors": {
"defaultRequire": 1
}
}
Loading

0 comments on commit c0bce80

Please sign in to comment.