-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from enjarai/1.21
Backport two funny features to 1.21(.1)
- Loading branch information
Showing
15 changed files
with
237 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/io/wispforest/lavender/book/ClientNewEntriesUnlockedCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.wispforest.lavender.book; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.client.MinecraftClient; | ||
|
||
@FunctionalInterface | ||
public interface ClientNewEntriesUnlockedCallback { | ||
|
||
Event<ClientNewEntriesUnlockedCallback> EVENT = EventFactory.createArrayBacked(ClientNewEntriesUnlockedCallback.class, callbacks -> (client, book, newEntryCount) -> { | ||
for (var callback : callbacks) { | ||
callback.newEntriesUnlocked(client, book, newEntryCount); | ||
} | ||
}); | ||
|
||
void newEntriesUnlocked(MinecraftClient client, Book book, int newEntryCount); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/io/wispforest/lavender/client/NewEntriesToast.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.wispforest.lavender.client; | ||
|
||
import io.wispforest.lavender.Lavender; | ||
import io.wispforest.lavender.book.Book; | ||
import io.wispforest.owo.ui.base.BaseOwoToast; | ||
import io.wispforest.owo.ui.component.Components; | ||
import io.wispforest.owo.ui.container.Containers; | ||
import io.wispforest.owo.ui.container.StackLayout; | ||
import io.wispforest.owo.ui.core.Insets; | ||
import io.wispforest.owo.ui.core.Sizing; | ||
import io.wispforest.owo.ui.core.VerticalAlignment; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
public class NewEntriesToast extends BaseOwoToast<StackLayout> { | ||
|
||
public static final Identifier TEXTURE = Lavender.id("new_entries_toast"); | ||
|
||
public NewEntriesToast(Book.ToastSettings settings) { | ||
super( | ||
() -> Containers.stack(Sizing.content(), Sizing.content()).configure(component -> component | ||
.child(Components.sprite(MinecraftClient.getInstance().getGuiAtlasManager().getSprite(settings.backgroundSprite() != null ? settings.backgroundSprite() : TEXTURE))) | ||
.child(Containers.horizontalFlow(Sizing.content(), Sizing.content()) | ||
.child(Components.item(settings.iconStack()).margins(Insets.of(0, 0, 8, 6))) | ||
.child(Components.label(Text.translatable("text.lavender.toast.new_entries", settings.bookName()))) | ||
.verticalAlignment(VerticalAlignment.CENTER)) | ||
.verticalAlignment(VerticalAlignment.CENTER)), | ||
(baseOwoToast, time) -> time <= 5000 ? Visibility.SHOW : Visibility.HIDE | ||
); | ||
} | ||
} |
Oops, something went wrong.