Skip to content

Commit

Permalink
Merge branch '1.18/dev' into 1.18/main
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxNeedsSnacks committed Jun 6, 2022
2 parents e319e4f + bd17148 commit 0ff915d
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 196 deletions.
114 changes: 78 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,70 +1,112 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false
id 'base'
id 'architectury-plugin' version '3.4-SNAPSHOT'
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
id "io.github.juuxel.loom-quiltflower" version "1.7.2" apply false
id "com.github.johnrengelman.shadow" version "7.0.0" apply false
id "com.matthewprenger.cursegradle" version "1.4.0" apply false
}

architectury {
minecraft = rootProject.minecraft_version
minecraft = project.minecraft_version
}

allprojects {
ext.ENV = System.getenv()

repositories {
maven {
url "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.latvian.mods"
includeGroup "dev.ftb.mods"
}
}
}
}

version = "${mod_version}-build.${ENV.GITHUB_RUN_NUMBER ?: 9999}"
group = project.maven_group
base.archivesBaseName = project.archives_base_name

subprojects {
apply plugin: "java"
apply plugin: "dev.architectury.loom"
apply plugin: 'architectury-plugin'
apply plugin: "io.github.juuxel.loom-quiltflower"
apply plugin: "maven-publish"
apply from: "https://files.latmod.com/public/markdown-git-changelog.gradle"

version = rootProject.version
group = rootProject.group
base.archivesBaseName = rootProject.base.archivesBaseName

loom {
silentMojangMappingsLicense()
}

compileJava {
options.encoding = "UTF-8"
options.release.set(17)
}

java {
sourceCompatibility = targetCompatibility = '17'
withSourcesJar()
}

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
// parchment("org.parchmentmc.data:parchment-1.17.1:2021.10.10")
}
}
}

allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
apply from: "https://files.latmod.com/public/markdown-git-changelog.gradle"

def ENV = System.getenv()
version = "${mod_version}-build.${ENV.GITHUB_RUN_NUMBER ?: 9999}"
group = project.mod_package
archivesBaseName = project.mod_name

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '17'
subprojects {
if (project.path != ':common') {
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "com.matthewprenger.cursegradle"

compileJava {
options.encoding = "UTF-8"
}
configurations {
bundle {
canBeResolved(true)
canBeConsumed(false)
}
}

repositories {
maven {
url "https://maven.architectury.dev/"
jar {
archiveClassifier.set "dev"
}

maven {
url "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.ftb.mods"
includeGroup "dev.latvian.mods"
}
shadowJar {
archiveClassifier.set "dev-shadow"
configurations = [
project.configurations.bundle
]
}

maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
remapJar {
dependsOn shadowJar
inputFile.set shadowJar.archiveFile
archiveBaseName.set "${rootProject.archives_base_name}-${project.name}"
archiveClassifier.set null
}
}
}

java {
withSourcesJar()
task collectJars(type: Copy) {
subprojects {
if (project.path != ":common") {
def remapJar = project.tasks.named('remapJar')
dependsOn remapJar
from remapJar
}
}

into(buildDir.toPath().resolve("libs"))
}

task curseforgePublish
assemble {
dependsOn(collectJars)
}
8 changes: 2 additions & 6 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"

modApi "dev.architectury:architectury:${rootProject.architectury_version}"

modImplementation "dev.latvian.mods:kubejs-fabric:${rootProject.kubejs_version}"
modImplementation "dev.latvian.mods:rhino:${rootProject.rhino_version}"
modApi("dev.latvian.mods:kubejs:${rootProject.kubejs_version}")
}

def ENV = System.getenv()

architectury {
common()
common("forge", "fabric")
}

publishing {
Expand Down
12 changes: 6 additions & 6 deletions common/src/main/java/dev/latvian/kubejs/ui/widget/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import dev.latvian.mods.kubejs.text.Text;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.util.FormattedCharSequence;

/**
Expand All @@ -21,9 +21,9 @@ public Button() {
}

@Override
public void setName(Text o) {
super.setName(o);
setW(getUi().screen.getUiFont().width(cachedComponent) + 10);
public void setName(Component name) {
super.setName(name);
setW(getUi().screen.getUiFont().width(this.name) + 10);
}

@Override
Expand Down Expand Up @@ -59,10 +59,10 @@ public void renderBackground(PoseStack matrixStack, float partialTicks) {
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);

if (shadow) {
drawCenteredString(matrixStack, fontrenderer, cachedComponent, w / 2, (h - 8) / 2, j | (alpha << 24));
drawCenteredString(matrixStack, fontrenderer, name, w / 2, (h - 8) / 2, j | (alpha << 24));
} else {
// RenderSystem.enableAlphaTest();
FormattedCharSequence ireorderingprocessor = cachedComponent.getVisualOrderText();
FormattedCharSequence ireorderingprocessor = name.getVisualOrderText();
fontrenderer.draw(matrixStack, ireorderingprocessor, (w - fontrenderer.width(ireorderingprocessor)) / 2F, (h - 8) / 2F, j | (alpha << 24));
}

Expand Down
11 changes: 5 additions & 6 deletions common/src/main/java/dev/latvian/kubejs/ui/widget/Label.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import dev.latvian.mods.kubejs.text.Text;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
Expand All @@ -22,10 +21,10 @@ public Label() {
}

@Override
public void setName(Text o) {
super.setName(o);
cachedComponentUnderlined = new TextComponent("").append(cachedComponent).withStyle(ChatFormatting.UNDERLINE);
setW((int) (getUi().screen.getUiFont().width(cachedComponent) * (getH() / 10F)));
public void setName(Component name) {
super.setName(name);
cachedComponentUnderlined = new TextComponent("").append(this.name).withStyle(ChatFormatting.UNDERLINE);
setW((int) (getUi().screen.getUiFont().width(this.name) * (getH() / 10F)));
}

@Override
Expand All @@ -37,7 +36,7 @@ public void renderForeground(PoseStack matrixStack, float partialTicks) {
int h = getH();
matrixStack.scale(h / 10F, h / 10F, 1F);

Component c = (isMouseOver && getAction() != null) ? cachedComponentUnderlined : cachedComponent;
Component c = (isMouseOver && getAction() != null) ? cachedComponentUnderlined : name;
int col = (isMouseOver ? hoverColor : color) | (alpha << 24);

if (shadow) {
Expand Down
16 changes: 7 additions & 9 deletions common/src/main/java/dev/latvian/kubejs/ui/widget/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import dev.latvian.kubejs.ui.KubeJSUIOptions;
import dev.latvian.kubejs.ui.ScreenKubeJSUI;
import dev.latvian.mods.kubejs.text.Text;
import dev.latvian.mods.kubejs.bindings.ComponentWrapper;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
Expand Down Expand Up @@ -32,7 +32,7 @@ public UI(ScreenKubeJSUI s) {
mouse = new Mouse();
allWidgets = new ArrayList<>();
widgetTexture = new ResourceLocation("minecraft:textures/gui/widgets.png");
setName(Text.of(s.getTitle()));
setName(ComponentWrapper.of(s.getTitle()));
tick = 0;

long now = System.currentTimeMillis();
Expand Down Expand Up @@ -78,15 +78,13 @@ public double getScale() {
public int textWidth(@Nullable Object o) {
if (o == null) {
return 0;
} else if (o instanceof FormattedText) {
return screen.getUiFont().width((FormattedText) o);
} else if (o instanceof FormattedCharSequence) {
return screen.getUiFont().width((FormattedCharSequence) o);
} else if (o instanceof Text) {
return screen.getUiFont().width(((Text) o).component());
} else if (o instanceof FormattedText ft) {
return screen.getUiFont().width(ft);
} else if (o instanceof FormattedCharSequence fcs) {
return screen.getUiFont().width(fcs);
}

return screen.getUiFont().width(o.toString());
return screen.getUiFont().width(ComponentWrapper.of(o));
}

public boolean getUseShaders() {
Expand Down
23 changes: 8 additions & 15 deletions common/src/main/java/dev/latvian/kubejs/ui/widget/Widget.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import dev.latvian.kubejs.ui.ScreenKubeJSUI;
import dev.latvian.kubejs.ui.UIData;
import dev.latvian.kubejs.ui.UIEventJS;
import dev.latvian.mods.kubejs.bindings.ComponentWrapper;
import dev.latvian.mods.kubejs.script.ScriptType;
import dev.latvian.mods.kubejs.text.Text;
import dev.latvian.mods.kubejs.util.UtilsJS;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
Expand All @@ -32,7 +32,7 @@ public class Widget extends GuiComponent {
public Panel parent;
private int x, y, w, h;
public int z;
private Text name;
protected Component name;
private Consumer<Screen> action;
public int alpha;
public boolean enabled;
Expand All @@ -43,7 +43,6 @@ public class Widget extends GuiComponent {
public int hoverColor;
public List<Component> hoverTextComponents;

protected Component cachedComponent;
public int actualX, actualY;
public boolean isMouseOver;

Expand All @@ -53,7 +52,7 @@ public Widget() {
w = 16;
h = 16;
z = 0;
name = Text.of("");
name = TextComponent.EMPTY;
action = null;
alpha = 255;
enabled = true;
Expand All @@ -63,7 +62,6 @@ public Widget() {
color = 0xFFFFFF;
hoverColor = 0xFFFFFF;

cachedComponent = TextComponent.EMPTY;
actualX = 0;
actualY = 0;
isMouseOver = false;
Expand Down Expand Up @@ -121,13 +119,12 @@ public double getActualH() {
return getH() / getUi().getScale();
}

public Text getName() {
public Component getName() {
return name;
}

public void setName(Text o) {
name = o;
cachedComponent = name.component();
public void setName(Component name) {
this.name = name;
}

@Nullable
Expand Down Expand Up @@ -191,18 +188,14 @@ public boolean mousePressed() {
public void mouseReleased() {
}

public void setHoverText(Object[] array) {
public void setHoverComponent(Component[] array) {
hoverTextComponents = new ArrayList<>(array.length);

for (Object o : array) {
hoverTextComponents.add(Text.of(o).component());
hoverTextComponents.add(ComponentWrapper.of(o));
}
}

public void setHoverText(Object o) {
setHoverText(new Object[]{o});
}

public void appendHoverText(List<Component> list) {
if (hoverTextComponents != null && isMouseOver) {
list.addAll(hoverTextComponents);
Expand Down
Loading

0 comments on commit 0ff915d

Please sign in to comment.