generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
868 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
id("java") | ||
} | ||
|
||
java { | ||
withSourcesJar() | ||
|
||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(16) | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile> { | ||
options.encoding = "UTF-8" | ||
|
||
javaCompiler = javaToolchains.compilerFor { | ||
languageVersion = JavaLanguageVersion.of(16) | ||
} | ||
} |
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
Binary file added
BIN
+1.66 KB
...unes/src/main/resources/assets/kit_tunes/textures/gui/sprites/widget/button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
kit-tunes/src/main/resources/assets/kit_tunes/textures/gui/sprites/widget/button.png.mcmeta
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,10 @@ | ||
{ | ||
"gui": { | ||
"scaling": { | ||
"type": "nine_slice", | ||
"width": 200, | ||
"height": 20, | ||
"border": 3 | ||
} | ||
} | ||
} |
Binary file added
BIN
+1.13 KB
...main/resources/assets/kit_tunes/textures/gui/sprites/widget/button_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
...rc/main/resources/assets/kit_tunes/textures/gui/sprites/widget/button_disabled.png.mcmeta
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,10 @@ | ||
{ | ||
"gui": { | ||
"scaling": { | ||
"type": "nine_slice", | ||
"width": 200, | ||
"height": 20, | ||
"border": 1 | ||
} | ||
} | ||
} |
Binary file added
BIN
+1.66 KB
...n/resources/assets/kit_tunes/textures/gui/sprites/widget/button_highlighted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
...main/resources/assets/kit_tunes/textures/gui/sprites/widget/button_highlighted.png.mcmeta
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,10 @@ | ||
{ | ||
"gui": { | ||
"scaling": { | ||
"type": "nine_slice", | ||
"width": 200, | ||
"height": 20, | ||
"border": 3 | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
plugins { | ||
id("kit_tunes.java.16") | ||
id("kit_tunes.module") | ||
} | ||
|
||
repositories { | ||
maven { | ||
name = "Terraformers" | ||
url = uri("https://maven.terraformersmc.com/") | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(project(":kit-tunes-api")) | ||
implementation(project(":kitten-heart")) | ||
|
||
modImplementation(libs.qsl.resource.loader) | ||
|
||
modImplementation("com.terraformersmc:modmenu:${project.property("modmenu_version")}") | ||
modImplementation(fabricApi.module("fabric-resource-loader-v0", project.property("fabric_api_version").toString())) | ||
} |
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,8 @@ | ||
# Mod properties | ||
sub_mod_name = ui | ||
minecraft_version_min = 1.17.0 | ||
|
||
minecraft_version = 1.17 | ||
|
||
modmenu_version=2.0.17 | ||
fabric_api_version=0.36.0+1.17 |
22 changes: 22 additions & 0 deletions
22
kitten-square/r1.17.0/src/main/java/net/pixaurora/kitten_square/impl/FakeComponent.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,22 @@ | ||
package net.pixaurora.kitten_square.impl; | ||
|
||
import net.minecraft.network.chat.MutableComponent; | ||
import net.pixaurora.kitten_cube.impl.text.Component; | ||
import net.pixaurora.kitten_square.impl.service.UICompatImpl; | ||
|
||
public class FakeComponent implements Component { | ||
private final MutableComponent parent; | ||
|
||
public FakeComponent(MutableComponent component) { | ||
this.parent = component; | ||
} | ||
|
||
public MutableComponent gameVer() { | ||
return this.parent; | ||
} | ||
|
||
@Override | ||
public Component concat(Component component) { | ||
return new FakeComponent(this.parent.copy().append(UICompatImpl.internalToMinecraftType(component))); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
kitten-square/r1.17.0/src/main/java/net/pixaurora/kitten_square/impl/SoundUtil.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 net.pixaurora.kitten_square.impl; | ||
|
||
import net.minecraft.client.resources.sounds.SimpleSoundInstance; | ||
import net.minecraft.client.resources.sounds.SoundInstance; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.pixaurora.kitten_cube.impl.ui.sound.Sound; | ||
|
||
public class SoundUtil { | ||
public static SoundInstance soundFromInternalID(Sound sound) { | ||
switch (sound) { | ||
case BUTTON_CLICK: | ||
return SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F); | ||
default: | ||
throw new RuntimeException("Sound " + sound.name() + " was not mapped!"); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...are/r1.17.0/src/main/java/net/pixaurora/kitten_square/impl/compat/ModMenuIntegration.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,23 @@ | ||
package net.pixaurora.kitten_square.impl.compat; | ||
|
||
import java.util.Map; | ||
|
||
import com.terraformersmc.modmenu.api.ConfigScreenFactory; | ||
import com.terraformersmc.modmenu.api.ModMenuApi; | ||
|
||
import net.minecraft.client.gui.screens.Screen; | ||
import net.pixaurora.kitten_heart.impl.Constants; | ||
import net.pixaurora.kitten_heart.impl.ui.screen.KitTunesHomeScreen; | ||
import net.pixaurora.kitten_square.impl.ui.screen.MinecraftScreen; | ||
import net.pixaurora.kitten_square.impl.ui.screen.ScreenImpl; | ||
|
||
public class ModMenuIntegration implements ModMenuApi { | ||
public ScreenImpl modHomeScreen(Screen parent) { | ||
return new ScreenImpl(new KitTunesHomeScreen(new MinecraftScreen(parent))); | ||
} | ||
|
||
@Override | ||
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() { | ||
return Map.of(Constants.MOD_ID, this::modHomeScreen); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
kitten-square/r1.17.0/src/main/java/net/pixaurora/kitten_square/impl/mixin/GuiMixin.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,19 @@ | ||
package net.pixaurora.kitten_square.impl.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import net.minecraft.client.gui.Gui; | ||
import net.minecraft.network.chat.Component; | ||
|
||
@Mixin(Gui.class) | ||
public class GuiMixin { | ||
// Because we want to show our own notification, we cancel this one so it | ||
// doesn't show twice. | ||
@Inject(method = "setNowPlaying", at = @At("HEAD"), cancellable = true) | ||
private void cancelNowPlayingNotification(Component description, CallbackInfo cInfo) { | ||
cInfo.cancel(); | ||
} | ||
} |
124 changes: 124 additions & 0 deletions
124
...n-square/r1.17.0/src/main/java/net/pixaurora/kitten_square/impl/service/UICompatImpl.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,124 @@ | ||
package net.pixaurora.kitten_square.impl.service; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.Util; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.screens.ConfirmLinkScreen; | ||
import net.minecraft.network.chat.MutableComponent; | ||
import net.minecraft.network.chat.TextComponent; | ||
import net.minecraft.network.chat.TranslatableComponent; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.FormattedCharSequence; | ||
import net.pixaurora.kit_tunes.api.resource.ResourcePath; | ||
import net.pixaurora.kitten_cube.impl.math.Point; | ||
import net.pixaurora.kitten_cube.impl.text.Color; | ||
import net.pixaurora.kitten_cube.impl.text.Component; | ||
import net.pixaurora.kitten_cube.impl.ui.screen.Screen; | ||
import net.pixaurora.kitten_cube.impl.ui.sound.Sound; | ||
import net.pixaurora.kitten_cube.impl.ui.widget.text.TextBox; | ||
import net.pixaurora.kitten_heart.impl.resource.ResourcePathImpl; | ||
import net.pixaurora.kitten_heart.impl.resource.ResourcePathUtils; | ||
import net.pixaurora.kitten_heart.impl.service.MinecraftUICompat; | ||
import net.pixaurora.kitten_square.impl.FakeComponent; | ||
import net.pixaurora.kitten_square.impl.SoundUtil; | ||
import net.pixaurora.kitten_square.impl.ui.screen.MinecraftScreen; | ||
import net.pixaurora.kitten_square.impl.ui.screen.ScreenImpl; | ||
import net.pixaurora.kitten_square.impl.ui.toast.ToastImpl; | ||
import net.pixaurora.kitten_square.impl.ui.widget.TextBoxImpl; | ||
|
||
public class UICompatImpl implements MinecraftUICompat { | ||
private final Minecraft client = Minecraft.getInstance(); | ||
|
||
public static ResourceLocation internalToMinecraftType(ResourcePath path) { | ||
return new ResourceLocation(path.namespace(), path.path()); | ||
} | ||
|
||
public static MutableComponent internalToMinecraftType(Component component) { | ||
if (component instanceof FakeComponent) { | ||
return ((FakeComponent) component).gameVer(); | ||
} else { | ||
throw new RuntimeException( | ||
"Internal component is of an unconvertable type `" + component.getClass().getName() + "`!"); | ||
} | ||
} | ||
|
||
@Override | ||
public void sendToast(net.pixaurora.kitten_cube.impl.ui.toast.Toast toast) { | ||
this.client.getToasts().addToast(new ToastImpl(toast)); | ||
} | ||
|
||
@Override | ||
public ResourcePath convertToRegularAsset(ResourcePath path) { | ||
return path; | ||
} | ||
|
||
@Override | ||
public ResourcePath convertToGuiAsset(ResourcePath path) { | ||
return path; | ||
} | ||
|
||
@Override | ||
public Component translatable(String key) { | ||
return new FakeComponent(new TranslatableComponent(key)); | ||
} | ||
|
||
@Override | ||
public Component translatableWithFallback(String key, String defaultText) { | ||
return new FakeComponent(new TranslatableComponent(key)); | ||
} | ||
|
||
@Override | ||
public Component literal(String text) { | ||
return new FakeComponent(new TextComponent(text)); | ||
} | ||
|
||
@Override | ||
public int textHeight() { | ||
return this.client.font.lineHeight; | ||
} | ||
|
||
@Override | ||
public int textWidth(Component text) { | ||
return this.client.font.width(internalToMinecraftType(text)); | ||
} | ||
|
||
@Override | ||
public void playSound(Sound sound) { | ||
this.client.getSoundManager().play(SoundUtil.soundFromInternalID(sound)); | ||
} | ||
|
||
@Override | ||
public void setScreen(Screen screen) { | ||
net.minecraft.client.gui.screens.Screen mcScreen; | ||
if (screen instanceof MinecraftScreen) { | ||
mcScreen = ((MinecraftScreen) screen).parent(); | ||
} else { | ||
mcScreen = new ScreenImpl(screen); | ||
} | ||
this.client.setScreen(mcScreen); | ||
} | ||
|
||
@Override | ||
public void confirmURL(String url) { | ||
confirmLinkNow(this.client.screen, url); | ||
} | ||
|
||
private void confirmLinkNow(net.minecraft.client.gui.screens.Screen screen, String url) { | ||
this.client.setScreen(new ConfirmLinkScreen((result) -> { | ||
if (result) { | ||
Util.getPlatform().openUri(url); | ||
} | ||
|
||
this.client.setScreen(screen); | ||
}, url, true)); | ||
} | ||
|
||
@Override | ||
public TextBox createTextbox(List<Component> lines, Color color, int maxLineLength, Point pos) { | ||
List<FormattedCharSequence> text = lines.stream().map(UICompatImpl::internalToMinecraftType) | ||
.flatMap(line -> this.client.font.split(line, maxLineLength).stream()).toList(); | ||
|
||
return new TextBoxImpl(text, color, pos); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...square/r1.17.0/src/main/java/net/pixaurora/kitten_square/impl/ui/ConversionCacheImpl.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,20 @@ | ||
package net.pixaurora.kitten_square.impl.ui; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
import net.pixaurora.kit_tunes.api.resource.ResourcePath; | ||
import net.pixaurora.kitten_cube.impl.ConversionCache; | ||
import net.pixaurora.kitten_square.impl.service.UICompatImpl; | ||
|
||
public class ConversionCacheImpl extends ConversionCache<ResourceLocation, net.minecraft.network.chat.Component> { | ||
@Override | ||
protected ResourceLocation resourceToMinecraftType(ResourcePath path) { | ||
return UICompatImpl.internalToMinecraftType(path); | ||
} | ||
|
||
@Override | ||
protected net.minecraft.network.chat.Component componentToMinecraftType( | ||
net.pixaurora.kitten_cube.impl.text.Component component) { | ||
return UICompatImpl.internalToMinecraftType(component); | ||
} | ||
|
||
} |
Oops, something went wrong.