Skip to content

Commit

Permalink
LambDynamicLights v3.0.0+1.21.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdAurora committed Oct 9, 2024
1 parent 4e971c1 commit 1b63d33
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 411 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
- Updated Mexican Spanish translations ([#214](https://github.com/LambdAurora/LambDynamicLights/pull/214)).
- Updated Italian translations ([#232](https://github.com/LambdAurora/LambDynamicLights/pull/232)).
- Updated Polish translations ([#235](https://github.com/LambdAurora/LambDynamicLights/pull/235)).
- Removed block entity lighting as the use-case was extremely niche.
- This may be re-introduced if a valid use-case is found.
- Switched license to [Lambda License](https://github.com/LambdAurora/LambDynamicLights/blob/bbefb8860bca2e797f8a2ba8a59d1120b6e1c7b4/LICENSE).

[SpruceUI]: https://github.com/LambdAurora/SpruceUI "SpruceUI page"
Expand Down
3 changes: 2 additions & 1 deletion build_logic/src/main/kotlin/lambdynamiclights.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ dependencies {
@Suppress("UnstableApiUsage")
mappings(loom.layered {
addLayer(MojangMappingsSpec(false))
parchment("org.parchmentmc.data:parchment-${Constants.getMcVersionString()}:${libs.versions.mappings.parchment.get()}@zip")
// Parchment is currently broken when used with the hacked mojmap layer due to remapping shenanigans.
//parchment("org.parchmentmc.data:parchment-${Constants.getMcVersionString()}:${libs.versions.mappings.parchment.get()}@zip")
mappings("dev.lambdaurora:yalmm:${Constants.mcVersion()}+build.${libs.versions.mappings.yalmm.get()}")
})
modImplementation(libs.fabric.loader)
Expand Down
2 changes: 1 addition & 1 deletion build_logic/src/main/kotlin/lambdynamiclights/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.gradle.accessors.dm.LibrariesForLibs
object Constants {
const val GROUP = "dev.lambdaurora"
const val NAME = "lambdynamiclights"
const val VERSION = "3.0.0-alpha.1"
const val VERSION = "3.0.0"
const val JAVA_VERSION = 21

private var minecraftVersion: String? = null
Expand Down
1 change: 0 additions & 1 deletion build_logic/src/main/kotlin/lambdynamiclights/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ object Utils {

readme = lines.joinToString("\n")
readme = readme.replace(linkRegex.toRegex(), "![\$1](https://raw.githubusercontent.com/LambdAurora/LambDynamicLights/1.21/\$2)")
project.logger.lifecycle("Readme: {}", readme)
return readme
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
minecraft = "1.21.1"
fabric-loader = "0.15.11"
fabric-loader = "0.16.5"
fabric-api = "0.105.0+1.21.1"
mappings-yalmm = "2"
mappings-parchment = "2024.07.28"
Expand All @@ -17,7 +17,7 @@ nightconfig = "3.8.1"

# Gradle
gradle-licenser = "1.2.+"
gradle-loom = "1.7.+"
gradle-loom = "1.8.+"
mappingio = "0.6.1"

[libraries]
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class DynamicLightsConfig {
private DynamicLightsMode dynamicLightsMode;
private final BooleanSettingEntry entitiesLightSource;
private final BooleanSettingEntry selfLightSource;
private final BooleanSettingEntry blockEntitiesLightSource;
private final BooleanSettingEntry waterSensitiveCheck;
private ExplosiveLightingMode creeperLightingMode;
private ExplosiveLightingMode tntLightingMode;
Expand Down Expand Up @@ -82,11 +81,6 @@ public DynamicLightsConfig(@NotNull LambDynLights mod) {
source instanceof LocalPlayer && source == Minecraft.getInstance().player
);
});
this.blockEntitiesLightSource = new BooleanSettingEntry("light_sources.block_entities", DEFAULT_BLOCK_ENTITIES_LIGHT_SOURCE, this.config,
Text.translatable("lambdynlights.tooltip.block_entities"))
.withOnSet(value -> {
if (!value) this.mod.removeBlockEntitiesLightSource();
});
this.waterSensitiveCheck = new BooleanSettingEntry("light_sources.water_sensitive_check", DEFAULT_WATER_SENSITIVE_CHECK, this.config,
Text.translatable("lambdynlights.tooltip.water_sensitive"));
}
Expand All @@ -102,7 +96,6 @@ public void load() {
.orElse(DEFAULT_DYNAMIC_LIGHTS_MODE);
this.entitiesLightSource.load(this.config);
this.selfLightSource.load(this.config);
this.blockEntitiesLightSource.load(this.config);
this.waterSensitiveCheck.load(this.config);
this.creeperLightingMode = ExplosiveLightingMode.byId(this.config.getOrElse("light_sources.creeper", DEFAULT_CREEPER_LIGHTING_MODE.getName()))
.orElse(DEFAULT_CREEPER_LIGHTING_MODE);
Expand Down Expand Up @@ -135,7 +128,6 @@ public void reset() {
this.setDynamicLightsMode(DEFAULT_DYNAMIC_LIGHTS_MODE);
this.getEntitiesLightSource().set(DEFAULT_ENTITIES_LIGHT_SOURCE);
this.getSelfLightSource().set(DEFAULT_SELF_LIGHT_SOURCE);
this.getBlockEntitiesLightSource().set(DEFAULT_BLOCK_ENTITIES_LIGHT_SOURCE);
this.getWaterSensitiveCheck().set(DEFAULT_WATER_SENSITIVE_CHECK);
this.setCreeperLightingMode(DEFAULT_CREEPER_LIGHTING_MODE);
this.setTntLightingMode(DEFAULT_TNT_LIGHTING_MODE);
Expand Down Expand Up @@ -178,13 +170,6 @@ public BooleanSettingEntry getSelfLightSource() {
return this.selfLightSource;
}

/**
* {@return the block entities as light source setting holder}
*/
public BooleanSettingEntry getBlockEntitiesLightSource() {
return this.blockEntitiesLightSource;
}

/**
* {@return the water sensitive check setting holder}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand Down Expand Up @@ -367,13 +366,6 @@ public void removeTntLightSources() {
this.removeLightSources(entity -> entity instanceof PrimedTnt);
}

/**
* Removes block entities light source from tracked light sources.
*/
public void removeBlockEntitiesLightSource() {
this.removeLightSources(lightSource -> lightSource instanceof BlockEntity);
}

/**
* Logs an informational message.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public static boolean isCanvasInstalled() {
public static boolean isSodium05XInstalled() {
return FabricLoader.getInstance().getModContainer("sodium").map(mod -> {
try {
return mod.getMetadata().getVersion().compareTo(Version.parse("0.5.0")) >= 0;
var sodium050 = Version.parse("0.5.0");
var sodium060 = Version.parse("0.6.0-beta.1");
return mod.getMetadata().getVersion().compareTo(sodium050) >= 0
&& mod.getMetadata().getVersion().compareTo(sodium060) < 0;
} catch (VersionParsingException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.jetbrains.annotations.Nullable;

/**
* @author LambdAurora
* @version 2.3.0
* @version 3.0.0
* @since 1.1.0
*/
public final class DynamicLightHandlers {
Expand Down Expand Up @@ -72,18 +70,6 @@ public static <T extends Entity> void registerDynamicLightHandler(EntityType<T>
register((DynamicLightHandlerHolder<T>) type, handler);
}

/**
* Registers a block entity dynamic light handler.
*
* @param type the block entity type
* @param handler the dynamic light handler
* @param <T> the type of the block entity
*/
@SuppressWarnings("unchecked")
public static <T extends BlockEntity> void registerDynamicLightHandler(BlockEntityType<T> type, DynamicLightHandler<T> handler) {
register((DynamicLightHandlerHolder<T>) type, handler);
}

private static <T> void register(DynamicLightHandlerHolder<T> holder, DynamicLightHandler<T> handler) {
var registeredHandler = holder.lambdynlights$getDynamicLightHandler();
if (registeredHandler != null) {
Expand All @@ -105,17 +91,6 @@ private static <T> void register(DynamicLightHandlerHolder<T> holder, DynamicLig
return DynamicLightHandlerHolder.cast(type).lambdynlights$getDynamicLightHandler();
}

/**
* Returns the registered dynamic light handler of the specified block entity.
*
* @param type the block entity type
* @param <T> the type of the block entity
* @return the registered dynamic light handler
*/
public static <T extends BlockEntity> @Nullable DynamicLightHandler<T> getDynamicLightHandler(BlockEntityType<T> type) {
return DynamicLightHandlerHolder.cast(type).lambdynlights$getDynamicLightHandler();
}

/**
* Returns whether the given entity can light up.
*
Expand All @@ -131,18 +106,6 @@ public static <T extends Entity> boolean canLightUp(T entity) {
return !(setting == null || !setting.get());
}

/**
* Returns whether the given block entity can light up.
*
* @param entity the entity
* @param <T> the type of the block entity
* @return {@code true} if the block entity can light up, otherwise {@code false}
*/
public static <T extends BlockEntity> boolean canLightUp(T entity) {
var setting = DynamicLightHandlerHolder.cast(entity.getType()).lambdynlights$getSetting();
return !(setting == null || !setting.get());
}

/**
* Returns the luminance from an entity.
*
Expand All @@ -166,25 +129,4 @@ public static <T extends Entity> int getLuminanceFrom(T entity) {
return 0;
return handler.getLuminance(entity);
}

/**
* Returns the luminance from a block entity.
*
* @param entity the block entity
* @param <T> the type of the block entity
* @return the luminance
*/
@SuppressWarnings("unchecked")
public static <T extends BlockEntity> int getLuminanceFrom(T entity) {
if (!LambDynLights.get().config.getBlockEntitiesLightSource().get())
return 0;
DynamicLightHandler<T> handler = (DynamicLightHandler<T>) getDynamicLightHandler(entity.getType());
if (handler == null)
return 0;
if (!canLightUp(entity))
return 0;
if (handler.isWaterSensitive(entity) && entity.getLevel() != null && !entity.getLevel().getFluidState(entity.getPos()).isEmpty())
return 0;
return handler.getLuminance(entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* Represents the settings screen of LambDynamicLights.
*
* @author LambdAurora
* @version 2.2.0
* @version 3.0.0
* @since 1.0.0
*/
public class SettingsScreen extends SpruceScreen {
Expand All @@ -53,7 +53,6 @@ public class SettingsScreen extends SpruceScreen {
private final Screen parent;
private final SpruceOption entitiesOption;
private final SpruceOption selfOption;
private final SpruceOption blockEntitiesOption;
private final SpruceOption waterSensitiveOption;
private final SpruceOption creeperLightingOption;
private final SpruceOption tntLightingOption;
Expand All @@ -67,7 +66,6 @@ public SettingsScreen(@Nullable Screen parent) {

this.entitiesOption = this.config.getEntitiesLightSource().getOption();
this.selfOption = this.config.getSelfLightSource().getOption();
this.blockEntitiesOption = this.config.getBlockEntitiesLightSource().getOption();
this.waterSensitiveOption = this.config.getWaterSensitiveCheck().getOption();
this.creeperLightingOption = new SpruceCyclingOption("entity.minecraft.creeper",
amount -> this.config.setCreeperLightingMode(this.config.getCreeperLightingMode().next()),
Expand Down Expand Up @@ -113,8 +111,6 @@ protected void init() {
this.tabbedWidget.addSeparatorEntry(null);
this.tabbedWidget.addTabEntry(Text.empty().append(dynamicLightSources).append(": ").append(this.entitiesOption.getPrefix()),
null, this.tabContainerBuilder(this::buildEntitiesTab));
this.tabbedWidget.addTabEntry(Text.empty().append(dynamicLightSources).append(": ").append(this.blockEntitiesOption.getPrefix()),
null, this.tabContainerBuilder(this::buildBlockEntitiesTab));
this.addWidget(this.tabbedWidget);
}

Expand Down Expand Up @@ -176,8 +172,8 @@ private SpruceOptionListWidget buildGeneralTab(int width, int height) {
list.setBackground(INNER_BACKGROUND);
list.addSingleOptionEntry(this.config.dynamicLightsModeOption);
list.addSingleOptionEntry(new SpruceSeparatorOption(DYNAMIC_LIGHT_SOURCES_KEY, true, null));
list.addOptionEntry(this.entitiesOption, this.blockEntitiesOption);
list.addOptionEntry(this.selfOption, this.waterSensitiveOption);
list.addOptionEntry(this.entitiesOption, this.selfOption);
list.addOptionEntry(this.waterSensitiveOption, null);
list.addOptionEntry(this.creeperLightingOption, this.tntLightingOption);
return list;
}
Expand All @@ -186,10 +182,6 @@ private LightSourceListWidget buildEntitiesTab(int width, int height) {
return this.buildLightSourcesTab(width, height, BuiltInRegistries.ENTITY_TYPE.stream().map(DynamicLightHandlerHolder::cast).collect(Collectors.toList()));
}

private LightSourceListWidget buildBlockEntitiesTab(int width, int height) {
return this.buildLightSourcesTab(width, height, BuiltInRegistries.BLOCK_ENTITY_TYPE.stream().map(DynamicLightHandlerHolder::cast).collect(Collectors.toList()));
}

private LightSourceListWidget buildLightSourcesTab(int width, int height, List<DynamicLightHandlerHolder<?>> entries) {
var list = new LightSourceListWidget(Position.of(0, 0), width, height);
list.setBackground(INNER_BACKGROUND);
Expand Down

This file was deleted.

Loading

0 comments on commit 1b63d33

Please sign in to comment.