Skip to content

Commit

Permalink
Version 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
EssentialGGBot committed Aug 8, 2024
1 parent d070773 commit 6ae6376
Show file tree
Hide file tree
Showing 503 changed files with 6,867 additions and 1,514 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Essential is a quality of life mod that boosts Minecraft Java Edition to the nex
The source code of the Essential Mod is accessible to everyone, demonstrating our commitment to transparency with our
users and the broader community.

For assistance with this repository or the mod, please utilize the support channels available in our [Discord](https://essential.gg/discord).
For assistance with this repository or the mod, please utilize the dedicated channels available in our [Discord](https://essential.gg/discord).

Discover more about Essential on our [Website](https://essential.gg) or visit the [Essential Wiki](https://essential.gg/wiki).

Expand Down Expand Up @@ -186,7 +186,7 @@ Essential Mod's source code.
- Utilize any code or assets, including for personal use
- Incorporate the source code in any other projects or use our code as a reference in new projects
- Modify or alter the source code provided here
- Distributing compiled versions of the source code or modified source code
- Distribute compiled versions of the source code or modified source code

This summary is not an exhaustive interpretation of the license; for a comprehensive understanding, please refer to [the
full license file](https://github.com/EssentialGG/Essential/blob/main/LICENSE).
2 changes: 1 addition & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation("org.ow2.asm:asm-commons:9.3")
implementation ("com.google.guava:guava:30.1.1-jre")

implementation("gg.essential:essential-gradle-toolkit:0.5.0")
implementation("gg.essential:essential-gradle-toolkit:0.6.2")
}

gradlePlugin {
Expand Down
4 changes: 3 additions & 1 deletion build-logic/src/main/kotlin/essential/preprocessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import java.io.File

fun Project.configurePreprocessTree(versions: File) {
configure<RootPreprocessExtension> {
strictExtraMappings.set(true)

val fabric12100 = createNode("1.21-fabric", 12100, "yarn")
val fabric12006 = createNode("1.20.6-fabric", 12006, "yarn")
val forge12004 = createNode("1.20.4-forge", 12004, "srg")
Expand Down Expand Up @@ -54,7 +56,7 @@ fun Project.configurePreprocessTree(versions: File) {
fabric12001.link(fabric12000)
fabric12000.link(fabric11904)
forge11904.link(fabric11904)
fabric11904.link(fabric11903)
fabric11904.link(fabric11903, versions.resolve("1.19.4-1.19.3.txt"))
forge11903.link(fabric11903)
fabric11903.link(fabric11902, versions.resolve("1.19.3-1.19.2.txt"))
forge11902.link(fabric11902)
Expand Down
4 changes: 2 additions & 2 deletions build-logic/src/main/kotlin/essential/universal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ fun Project.universalLibs() {
compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-json:${kotlin.serialization}")
compileOnly("org.jetbrains:annotations:23.0.0")

// Provided by MC on 1.17+, and by `:slf4j-to-log4j` on older versions
compileOnly("org.slf4j:slf4j-api:1.7.36")
// Provided by MC on modern versions, and by `:slf4j-to-log4j` on older versions
compileOnly(catalog.findLibrary("slf4j-api").orElseThrow())
// Provided by MC (should ideally migrate away from this as MC itself is migrating to slf4j)
compileOnly("org.apache.logging.log4j:log4j-api:2.0-beta9")
// Depending on LWJGL3 instead of 2 so we can choose opengl bindings only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private fun Project.createConfigurations(platform: Platform): Configurations {
val bundle by configurations.creating {
exclude(module = "fabric-loader") // specifying module only, so the yarn-mapped version in excluded as well
exclude(group = "net.minecraftforge", module = "forge")
if (platform.mcVersion >= 11700) {
if (platform.mcVersion >= 11903) {
exclude(group = "org.slf4j", module = "slf4j-api")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private fun Project.createRelocateTask(): TaskProvider<RelocateTask> {
val jarTask = tasks.getByName<Jar>("bundleJar")
from(jarTask.archiveFile)
manifest.inheritFrom(jarTask.manifest)
mergeServiceFiles()
}
project.tasks.named("assemble") { dependsOn(relocatedJar) }
return relocatedJar
Expand All @@ -130,15 +131,18 @@ private fun Project.createAbiValidationTasks(relocateTask: TaskProvider<Relocate
"gg.essential.event",
"gg.essential.gui",
"gg.essential.handlers",
"gg.essential.ice",
"gg.essential.image",
"gg.essential.key",
"gg.essential.main",
"gg.essential.mixins",
"gg.essential.mod",
"gg.essential.model",
"gg.essential.network",
"gg.essential.quic",
"gg.essential.render",
"gg.essential.serialization",
"gg.essential.slf4j",
"gg.essential.sps",
"gg.essential.util",
// Internally pre-relocated dependencies
Expand Down
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ dependencies {

// Some of our dependencies rely on slf4j but that's not included in MC prior to 1.17, so we'll manually bundle a
// log4j adapter for those versions
if (platform.mcVersion < 11700) {
// We also bundle it for version 1.17-1.19.2 because those ship slf4j 1.x and only 1.19.3+ starts shipping 2.x
if (platform.mcVersion < 11903) {
implementation(bundle(project(":slf4j-to-log4j"))!!)
}
implementation(bundle(project(":quic-connector"))!!)
Expand Down Expand Up @@ -213,7 +214,7 @@ tasks.relocatedJar {
// cosmetics
relocate("dev.folomeev.kotgl", "gg.essential.lib.kotgl")

if (mcVersion < 11700) {
if (mcVersion < 11903) {
// Slf4j
relocate("org.slf4j", "gg.essential.lib.slf4j")
}
Expand Down
19 changes: 19 additions & 0 deletions changelog/release-1.3.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Title: Emote Preview Refresh
Summary: Quality of life improvements and fixes

## New Versions
- Added support for 1.21.1 Fabric

## Improvements
- Improved Emote preview design
- Added a minimum scrollbar width and height to all Essential GUIs
- Improved various cosmetics to rotate independently from player rotation
- Added the ability to access the outfit context menu by clicking on the outfit name
- Added animated gradient backgrounds for highlighted items in the Wardrobe
- Improved Gift Received notification design to be consistent with other notifications
- Removed unnecessary "Starting Integrated Server..." modal

## Bug Fixes
- Fixed cosmetic & armor visibility for certain combination of cosmetics
- Fixed cosmetics on legs not being hidden properly when armor is equipped on legs or feet but not both
- Fixed an issue when opening the screenshot browser on Feather Client
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import gg.essential.elementa.constraints.ColorConstraint
import gg.essential.elementa.constraints.animation.Animations
import gg.essential.elementa.dsl.animate
import gg.essential.elementa.dsl.toConstraint
import gg.essential.elementa.state.BasicState
import gg.essential.elementa.state.State
import gg.essential.elementa.state.toConstraint
import gg.essential.gui.common.onSetValueAndNow
import gg.essential.gui.elementa.state.v2.color.toConstraint
import gg.essential.gui.elementa.state.v2.effect
import gg.essential.gui.elementa.state.v2.stateOf
import gg.essential.gui.elementa.state.v2.toV2
import gg.essential.gui.util.hasWindow
import java.awt.Color
Expand All @@ -33,15 +33,16 @@ fun Modifier.color(color: State<Color>) = this then BasicColorModifier { color.t

fun Modifier.color(color: StateV2<Color>) = this then BasicColorModifier { color.toConstraint() }

fun Modifier.hoverColor(color: Color, duration: Float = 0f) = hoverColor(BasicState(color), duration)
fun Modifier.hoverColor(color: Color, duration: Float = 0f) = hoverColor(stateOf(color), duration)

@Deprecated("Using StateV1 is discouraged, use StateV2 instead")
fun Modifier.hoverColor(color: State<Color>, duration: Float = 0f) = whenHovered(if (duration == 0f) Modifier.color(color) else Modifier.animateColor(color, duration))

fun Modifier.hoverColor(color: StateV2<Color>, duration: Float = 0f) = whenHovered(if (duration == 0f) Modifier.color(color) else Modifier.animateColor(color, duration))

fun Modifier.animateColor(color: Color, duration: Float = .3f) = animateColor(BasicState(color), duration)
fun Modifier.animateColor(color: Color, duration: Float = .3f) = animateColor(stateOf(color), duration)

@Deprecated("Using StateV1 is discouraged, use StateV2 instead")
fun Modifier.animateColor(color: State<Color>, duration: Float = .3f) = animateColor(color.toV2(), duration)

fun Modifier.animateColor(color: StateV2<Color>, duration: Float = .3f) = this then AnimateColorModifier(color, duration)
Expand All @@ -60,8 +61,8 @@ private class AnimateColorModifier(private val colorState: StateV2<Color>, priva
}
}

val removeListenerCallback = colorState.onSetValueAndNow(component) {
animate(it.toConstraint())
val removeListenerCallback = effect(component) {
animate(colorState().toConstraint())
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ package gg.essential.gui.layoutdsl

import gg.essential.elementa.UIComponent
import gg.essential.elementa.events.UIClickEvent
import gg.essential.gui.elementa.state.v2.toV2
import gg.essential.gui.util.Tag
import gg.essential.gui.util.hoverScope
import gg.essential.gui.util.makeHoverScope
import gg.essential.gui.util.addTag
import gg.essential.gui.util.removeTag
import gg.essential.gui.util.*

import gg.essential.elementa.state.State as StateV1
import gg.essential.gui.elementa.state.v2.State as StateV2
Expand All @@ -38,7 +33,7 @@ fun Modifier.hoverScope(state: StateV1<Boolean>? = null) =
then { makeHoverScope(state); { throw NotImplementedError() } }

/** Declare this component and its children to be in a hover scope. See [makeHoverScope]. */
fun Modifier.hoverScope(state: gg.essential.gui.elementa.state.v2.State<Boolean>) =
fun Modifier.hoverScope(state: StateV2<Boolean>) =
then { makeHoverScope(state); { throw NotImplementedError() } }

/**
Expand All @@ -59,13 +54,13 @@ fun Modifier.inheritHoverScope() =
* A [Modifier.hoverScope] is **require** on the component or one of its parents.
*/
fun Modifier.whenHovered(hoverModifier: Modifier, noHoverModifier: Modifier = Modifier): Modifier =
then { Modifier.whenTrue(hoverScope(), hoverModifier, noHoverModifier).applyToComponent(this) }
then { Modifier.whenTrue(hoverScopeV2(), hoverModifier, noHoverModifier).applyToComponent(this) }

/**
* Provides the [hoverScope] to be evaluated in a lambda which returns a modifier
*/
fun Modifier.withHoverState(func: (StateV2<Boolean>) -> Modifier) =
then { func(hoverScope().toV2()).applyToComponent(this) }
then { func(hoverScopeV2()).applyToComponent(this) }

/** Applies a Tag to this component. See [UIComponent.addTag]. */
fun Modifier.tag(tag: Tag) = then { addTag(tag); { removeTag(tag) } }
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import gg.essential.elementa.state.v2.ReferenceHolder
import gg.essential.gui.common.ListState
import gg.essential.gui.common.not
import gg.essential.gui.elementa.state.v2.*
import gg.essential.gui.elementa.state.v2.collections.MutableTrackedList
import gg.essential.gui.elementa.state.v2.collections.TrackedList
import gg.essential.gui.elementa.state.v2.collections.trackedListOf
import gg.essential.gui.elementa.state.v2.combinators.not
import gg.essential.gui.util.hoveredState
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
Expand Down Expand Up @@ -60,21 +64,21 @@ class LayoutScope(

@Suppress("FunctionName")
fun if_(state: State<Boolean>, cache: Boolean = true, block: LayoutScope.() -> Unit): IfDsl {
forEach(ListState.from(state.map { if (it) listOf(Unit) else emptyList() }), cache) { block() }
return IfDsl({ !state }, cache)
return if_(state.toV2(), cache, block)
}

fun if_(state: StateV2<Boolean>, cache: Boolean = true, block: LayoutScope.() -> Unit): IfDsl {
return if_(state.toV1(component), cache, block)
forEach({ if (state()) trackedListOf(Unit) else trackedListOf() }, cache) { block() }
return IfDsl({ !state() }, cache)
}

fun <T> ifNotNull(state: State<T?>, cache: Boolean = false, block: LayoutScope.(T) -> Unit): IfDsl {
forEach(ListState.from(state.map { listOfNotNull(it) }), cache) { block(it) }
return IfDsl({ state.map { it == null } }, true)
return ifNotNull(state.toV2(), cache, block)
}

fun <T> ifNotNull(state: StateV2<T?>, cache: Boolean = false, block: LayoutScope.(T) -> Unit): IfDsl {
return ifNotNull(state.toV1(component), cache, block)
forEach({ state()?.let { trackedListOf(it) } ?: trackedListOf() }, cache) { block(it) }
return IfDsl({ state() == null }, true)
}

fun if_(condition: StateByScope.() -> Boolean, cache: Boolean = false, block: LayoutScope.() -> Unit): IfDsl {
Expand All @@ -85,20 +89,20 @@ class LayoutScope(
return ifNotNull(stateBy(stateBlock), cache, block)
}

class IfDsl(internal val elseState: () -> State<Boolean>, internal var cache: Boolean)
class IfDsl(internal val elseState: StateV2<Boolean>, internal var cache: Boolean)

infix fun IfDsl.`else`(block: LayoutScope.() -> Unit) {
if_(elseState(), cache, block)
if_(elseState, cache, block)
}

/** Makes available to the inner scope the value of the given [state]. */
fun <T> bind(state: State<T>, cache: Boolean = false, block: LayoutScope.(T) -> Unit) {
forEach(ListState.from(state.map { listOf(it) }), cache) { block(it) }
bind(state.toV2(), cache, block)
}

/** Makes available to the inner scope the value of the given [state]. */
fun <T> bind(state: StateV2<T>, cache: Boolean = false, block: LayoutScope.(T) -> Unit) {
bind(state.toV1(component), cache, block)
forEach({ trackedListOf(state()) }, cache) { block(it) }
}

/** Makes available to the inner scope the value derived from the given [stateBlock]. */
Expand All @@ -119,6 +123,13 @@ class LayoutScope(
* This requires that [T] be usable as a key in a HashMap.
*/
fun <T> forEach(state: ListState<T>, cache: Boolean = false, block: LayoutScope.(T) -> Unit) {
forEach(state.toV2().toListState(), cache, block)
}

/**
* StateV2 support for forEach
*/
fun <T> forEach(list: ListStateV2<T>, cache: Boolean = false, block: LayoutScope.(T) -> Unit) {
val forEachScope = LayoutScope(component, this@LayoutScope, stateScope)
childrenScopes.add(forEachScope)

Expand Down Expand Up @@ -162,21 +173,30 @@ class LayoutScope(
forEachScope.childrenScopes.clear()
}

state.get().forEachIndexed(::add)
state.onAdd(::add)
state.onRemove(::remove)
state.onSet { index, element, oldElement ->
remove(index, oldElement)
add(index, element)
fun update(change: TrackedList.Change<T>) {
when (change) {
is TrackedList.Add -> {
val (index, element) = change.element
add(index, element)
}
is TrackedList.Remove -> {
val (index, element) = change.element
remove(index, element)
}
is TrackedList.Clear -> {
clear(change.oldElements)
}
}
}
state.onClear(::clear)
}

/**
* StateV2 support for forEach
*/
fun <T> forEach(list: ListStateV2<T>, cache: Boolean = false, block: LayoutScope.(T) -> Unit) =
forEach(ListState.from(list.toV1(component)), cache, block)
var trackedList: TrackedList<T> = MutableTrackedList()
effect(stateScope) {
val newList = list()
val oldList = trackedList
newList.getChangesSince(oldList).forEach { change -> update(change) }
trackedList = newList
}
}

/** Whether this scope is a virtual "forEach" scope. These share their target component with their parent scope. */
private fun isVirtual(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ package gg.essential.gui.layoutdsl

import gg.essential.elementa.components.UIContainer
import gg.essential.elementa.components.Window
import gg.essential.elementa.state.BasicState
import gg.essential.elementa.state.State
import gg.essential.gui.elementa.state.v2.MutableState
import gg.essential.gui.elementa.state.v2.mutableStateOf
import gg.essential.universal.UMatrixStack

/**
Expand All @@ -25,7 +25,7 @@ import gg.essential.universal.UMatrixStack
* "make it not lag". Properly profiling and fixing initialization performance issues should always be preferred.
*/
fun LayoutScope.lazyBox(modifier: Modifier = Modifier.fillParent(), block: LayoutScope.() -> Unit) {
val initialized = BasicState(false)
val initialized = mutableStateOf(false)
box(modifier) {
if_(initialized, cache = false /** don't need it; once initialized, we are never going back */) {
block()
Expand All @@ -35,7 +35,7 @@ fun LayoutScope.lazyBox(modifier: Modifier = Modifier.fillParent(), block: Layou
}
}

private class LazyComponent(private val initialized: State<Boolean>) : UIContainer() {
private class LazyComponent(private val initialized: MutableState<Boolean>) : UIContainer() {
override fun draw(matrixStack: UMatrixStack) {
super.draw(matrixStack)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import gg.essential.elementa.constraints.*
import gg.essential.elementa.constraints.animation.*
import gg.essential.elementa.dsl.*
import gg.essential.gui.common.constraints.FillConstraintIncludingPadding
import gg.essential.gui.common.onSetValueAndNow
import gg.essential.gui.elementa.state.v2.State
import gg.essential.gui.elementa.state.v2.effect
import gg.essential.gui.elementa.state.v2.stateOf
import gg.essential.gui.util.hasWindow

Expand Down Expand Up @@ -106,7 +106,9 @@ private class AnimateWidthModifier(private val newWidth: State<() -> WidthConstr
}
}

val removeListenerCallback = newWidth.onSetValueAndNow(component) { animate(it()) }
val removeListenerCallback = effect(component) {
animate(newWidth()())
}

return {
removeListenerCallback()
Expand All @@ -129,7 +131,9 @@ private class AnimateHeightModifier(private val newHeight: State<() -> HeightCon
}
}

val removeListenerCallback = newHeight.onSetValueAndNow(component) { animate(it()) }
val removeListenerCallback = effect(component) {
animate(newHeight()())
}

return {
removeListenerCallback()
Expand Down
Loading

0 comments on commit 6ae6376

Please sign in to comment.