Skip to content

Commit

Permalink
Fix memory leak (LambdAurora#30), add entrypoint for API, add dynamic…
Browse files Browse the repository at this point in the history
… lighting mixin to minecarts.
  • Loading branch information
LambdAurora committed Nov 4, 2020
1 parent 6737919 commit 8eac1e7
Show file tree
Hide file tree
Showing 23 changed files with 429 additions and 85 deletions.
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. Linux]
- Minecraft [e.g. 1.16.4]
- Fabric Loader version [e.g. 0.10.6+build.214]
- Mods [e.g. fabric-api v0.25.1+build.416-1.16, lambdynamiclights v1.3.2, modmenu v1.14.6+build.31]
- Version [e.g. 1.3.2]
- Branch [e.g. mc1.16]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
18 changes: 17 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,28 @@ Then try the API of this mod!

## Quick note

Every time entity is referenced it means either an entity or a block entity.
Every time an entity is referenced it means either an entity or a block entity.

Block entity dynamic lighting is non-recommended if avoidable with block states.

If your entity re-implements tick without calling the super method the dynamic light handler will not work.

## LambDynamicLights entrypoint

Any API calls should be done in the custom entrypoint.

To use the entrypoint, make a new class implementing `DynamicLightsInitializer`,
add in your `fabric.mod.json` this:
```json
"entrypoints": {
"dynamiclights": [
"path.to.your.Class"
]
}
```

Once done, you can call the methods presented in the rest of this document in the method `onInitializeDynamicLights`.

## Dynamic light handlers

### `DynamicLightHandler`
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@

- Fixed entity lighting issue with [Sodium] 0.1.0. ([#23](https://github.com/LambdAurora/LambDynamicLights/issues/23))

## v1.3.2

- Added entity lighting capabilities to minecarts.
- Added `DynamicLightsInitializer` and `dynamiclights` entrypoint.
- Added Estonian translations.
- Added Turkish translations.
- Updated French translations.
- Fixed memory leak in dynamic light source tracking. ([#30](https://github.com/LambdAurora/LambDynamicLights/issues/30))

[SpruceUI]: https://github.com/LambdAurora/SpruceUI "SpruceUI page"
[Sodium]: https://www.curseforge.com/minecraft/mc-mods/sodium "Sodium CurseForge page"
[Canvas Renderer]: https://www.curseforge.com/minecraft/mc-mods/canvas-renderer "Canvas Renderer CurseForge page"
6 changes: 6 additions & 0 deletions HEADER
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>

This file is part of LambDynamicLights.

Licensed under the MIT license. For more information,
see the LICENSE file.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
id 'java-library'
id 'maven-publish'
id 'net.minecrell.licenser' version '0.4.1'
}

group = project.maven_group
Expand Down Expand Up @@ -96,6 +97,11 @@ jar {
from "../LICENSE"
}

license {
header file('HEADER')
include '**/*.java'
}

task shadowJar(type: Jar) {
archiveClassifier.set("dev")

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.3
yarn_mappings=1.16.3+build.17
loader_version=0.9.3+build.207
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.3
loader_version=0.10.6+build.214

# Mod Properties
mod_version = 1.3.1
mod_version = 1.3.2
maven_group = me.lambdaurora
archives_base_name = lambdynamiclights

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.20.2+build.402-1.16
fabric_version=0.25.1+build.416-1.16
spruceui_version=1.6.4
modmenu_version=1.14.6+build.31
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Represents a dynamic light source.
*
* @author LambdAurora
* @version 1.1.0
* @version 1.3.2
* @since 1.0.0
*/
public interface DynamicLightSource
Expand Down Expand Up @@ -98,7 +98,7 @@ default void setDynamicLightEnabled(boolean enabled)
*/
boolean shouldUpdateDynamicLight();

void lambdynlights_updateDynamicLight(@NotNull WorldRenderer renderer);
boolean lambdynlights_updateDynamicLight(@NotNull WorldRenderer renderer);

void lambdynlights_scheduleTrackedChunksRebuild(@NotNull WorldRenderer renderer);
}
40 changes: 18 additions & 22 deletions src/main/java/me/lambdaurora/lambdynlights/DynamicLightsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,35 @@
import net.minecraft.client.options.Option;
import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
* Represents the mod configuration.
*
* @author LambdAurora
* @version 1.3.0
* @version 1.3.2
* @since 1.0.0
*/
public class DynamicLightsConfig
{
private static final DynamicLightsMode DEFAULT_DYNAMIC_LIGHTS_MODE = DynamicLightsMode.OFF;
private static final boolean DEFAULT_ENTITIES_LIGHT_SOURCE = true;
private static final boolean DEFAULT_BLOCK_ENTITIES_LIGHT_SOURCE = true;
private static final boolean DEFAULT_WATER_SENSITIVE_CHECK = true;
private static final ExplosiveLightingMode DEFAULT_CREEPER_LIGHTING_MODE = ExplosiveLightingMode.SIMPLE;
private static final ExplosiveLightingMode DEFAULT_TNT_LIGHTING_MODE = ExplosiveLightingMode.OFF;

public static final Path CONFIG_FILE_PATH = Paths.get("config/lambdynlights.toml");
protected final FileConfig config;
private final LambDynLights mod;
private boolean firstTime;
private DynamicLightsMode dynamicLightsMode;
private ExplosiveLightingMode creeperLightingMode;
private ExplosiveLightingMode tntLightingMode;
private static final DynamicLightsMode DEFAULT_DYNAMIC_LIGHTS_MODE = DynamicLightsMode.OFF;
private static final boolean DEFAULT_ENTITIES_LIGHT_SOURCE = true;
private static final boolean DEFAULT_BLOCK_ENTITIES_LIGHT_SOURCE = true;
private static final boolean DEFAULT_WATER_SENSITIVE_CHECK = true;
private static final ExplosiveLightingMode DEFAULT_CREEPER_LIGHTING_MODE = ExplosiveLightingMode.SIMPLE;
private static final ExplosiveLightingMode DEFAULT_TNT_LIGHTING_MODE = ExplosiveLightingMode.OFF;

public static final Path CONFIG_FILE_PATH = Paths.get("config/lambdynlights.toml");
protected final FileConfig config;
private final LambDynLights mod;
private boolean firstTime;
private DynamicLightsMode dynamicLightsMode;
private ExplosiveLightingMode creeperLightingMode;
private ExplosiveLightingMode tntLightingMode;

public final Option dynamicLightsModeOption = new SpruceCyclingOption("lambdynlights.option.mode",
amount -> this.setDynamicLightsMode(this.dynamicLightsMode.next()),
Expand Down Expand Up @@ -136,13 +132,13 @@ public DynamicLightsMode getDynamicLightsMode()
*/
public void setDynamicLightsMode(@NotNull DynamicLightsMode mode)
{
this.dynamicLightsMode = mode;
this.config.set("mode", mode.getName());

if (!mode.isEnabled()) {
this.mod.clearLightSources();
}

this.dynamicLightsMode = mode;
this.config.set("mode", mode.getName());

this.firstTime = false;
}

Expand Down
Loading

0 comments on commit 8eac1e7

Please sign in to comment.