Skip to content

Commit

Permalink
Update to 24w09a
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Feb 29, 2024
1 parent bc60b2f commit cfefa1d
Show file tree
Hide file tree
Showing 22 changed files with 93 additions and 49 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
- v11
- v12
- v13
- v14

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
id "maven-publish"
id "org.cadixdev.licenser" version "0.6.1" apply false
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
}

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

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@SuppressWarnings({"unused", "FieldMayBeFinal"})
@ApiStatus.Internal
@Config(name = "autoconfig1u_example")
@Config.Gui.Background("minecraft:textures/block/oak_planks.png")
@Config.Gui.Background(Config.Gui.Background.TRANSPARENT)
@Config.Gui.CategoryBackground(category = "b", background = "minecraft:textures/block/stone.png")
public class ExampleConfig extends PartitioningSerializer.GlobalData {
@ConfigEntry.Category("a")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public Screen get() {
String bg = configClass.getAnnotation(Config.Gui.Background.class).value();
ResourceLocation bgId = ResourceLocation.tryParse(bg);
if (TRANSPARENT_BACKGROUND.equals(bgId))
builder.transparentBackground();
builder.transparentBackground().setDefaultBackgroundTexture(null);
else
builder.setDefaultBackgroundTexture(bgId);
builder.solidBackground().setDefaultBackgroundTexture(bgId);
}

Map<String, ResourceLocation> categoryBackgrounds =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -84,7 +85,6 @@ enum DependencyDemoEnum {
}

ConfigBuilder builder = ConfigBuilder.create().setTitle(Component.translatable("title.cloth-config.config"));
builder.setDefaultBackgroundTexture(new ResourceLocation("minecraft:textures/block/oak_planks.png"));
builder.setGlobalized(true);
builder.setGlobalizedExpanded(false);
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
Expand Down Expand Up @@ -204,7 +204,10 @@ enum DependencyDemoEnum {

testing.addEntry(entryBuilder.startTextDescription(
Component.translatable("text.cloth-config.testing.1",
Component.literal("ClothConfig").withStyle(s -> s.withBold(true).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new HoverEvent.ItemStackInfo(Util.make(new ItemStack(Items.PINK_WOOL), stack -> stack.setHoverName(Component.literal("(\u30FB\u2200\u30FB)")).enchant(Enchantments.BLOCK_EFFICIENCY, 10)))))),
Component.literal("ClothConfig").withStyle(s -> s.withBold(true).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new HoverEvent.ItemStackInfo(Util.make(new ItemStack(Items.PINK_WOOL), stack -> {
stack.set(DataComponents.CUSTOM_NAME, Component.literal("(\u30FB\u2200\u30FB)"));
stack.enchant(Enchantments.EFFICIENCY, 10);
}))))),
Component.translatable("text.cloth-config.testing.2").withStyle(s -> s.withColor(ChatFormatting.BLUE).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("https://shedaniel.gitbook.io/cloth-config/"))).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://shedaniel.gitbook.io/cloth-config/"))),
Component.translatable("text.cloth-config.testing.3").withStyle(s -> s.withColor(ChatFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, Utils.getConfigFolder().getParent().resolve("options.txt").toString())))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@
public interface TabbedConfigScreen extends ConfigScreen {
void registerCategoryBackground(String text, ResourceLocation identifier);

void registerCategoryTransparency(String text, boolean transparent);

Component getSelectedCategory();
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void setAlwaysShowTabs(boolean alwaysShowTabs) {
}

public boolean isTransparentBackground() {
return transparentBackground && Minecraft.getInstance().level != null;
return transparentBackground;
}

@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Map;

public abstract class AbstractTabbedConfigScreen extends AbstractConfigScreen implements TabbedConfigScreen {
private final Map<String, Boolean> categoryTransparentBackground = Maps.newHashMap();
private final Map<String, ResourceLocation> categoryBackgroundLocation = Maps.newHashMap();

protected AbstractTabbedConfigScreen(Screen parent, Component title, ResourceLocation backgroundLocation) {
Expand All @@ -39,6 +40,19 @@ public final void registerCategoryBackground(String text, ResourceLocation ident
this.categoryBackgroundLocation.put(text, identifier);
}

@Override
public void registerCategoryTransparency(String text, boolean transparent) {
this.categoryTransparentBackground.put(text, transparent);
}

@Override
public boolean isTransparentBackground() {
Component selectedCategory = getSelectedCategory();
if (categoryTransparentBackground.containsKey(selectedCategory.getString()))
return categoryTransparentBackground.get(selectedCategory.getString());
return super.isTransparentBackground();
}

@Override
public ResourceLocation getBackgroundLocation() {
Component selectedCategory = getSelectedCategory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public ClothConfigScreen(Screen parent, Component title, Map<String, ConfigCateg
categorizedEntries.put(category.getCategoryKey(), entries);
if (category.getBackground() != null) {
registerCategoryBackground(category.getCategoryKey().getString(), category.getBackground());
registerCategoryTransparency(category.getCategoryKey().getString(), false);
}
});

Expand Down Expand Up @@ -227,10 +228,14 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
buttonLeftTab.active = tabsScroller.scrollAmount > 0d;
buttonRightTab.active = tabsScroller.scrollAmount < getTabsMaximumScrolled() - width + 40;
}
if (isTransparentBackground()) {
graphics.fillGradient(0, 0, this.width, this.height, -1072689136, -804253680);
if (!isTransparentBackground()) {
renderMenuBackground(graphics);
} else {
renderDirtBackground(graphics);
if (this.minecraft.level == null) {
this.renderPanorama(graphics, delta);
}
renderBlurredBackground(delta);
renderMenuBackground(graphics);
}
listWidget.render(graphics, mouseX, mouseY, delta);
ScissorsHandler.INSTANCE.scissor(new Rectangle(listWidget.left, listWidget.top, listWidget.width, listWidget.bottom - listWidget.top));
Expand Down Expand Up @@ -425,7 +430,9 @@ protected void renderBackBackground(GuiGraphics graphics, BufferBuilder buffer,
if (!screen.isTransparentBackground())
super.renderBackBackground(graphics, buffer, tessellator);
else {
graphics.fillGradient(left, top, right, bottom, 0x68000000, 0x68000000);
RenderSystem.enableBlend();
graphics.blit(new ResourceLocation("textures/gui/menu_list_background.png"), this.left, this.top, this.right, this.bottom, this.width, this.bottom - this.top, 32, 32);
RenderSystem.disableBlend();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import me.shedaniel.clothconfig2.api.*;
import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer;
import me.shedaniel.clothconfig2.gui.entries.EmptyEntry;
import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget;
import me.shedaniel.clothconfig2.gui.widget.SearchFieldEntry;
import me.shedaniel.math.Rectangle;
import net.minecraft.ChatFormatting;
Expand All @@ -43,6 +44,7 @@
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
Expand Down Expand Up @@ -213,12 +215,17 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
requestingReferenceRebuilding = false;
}
int sliderPosition = getSideSliderPosition();
ScissorsHandler.INSTANCE.scissor(new Rectangle(sliderPosition, 0, width - sliderPosition, height));
if (isTransparentBackground()) {
graphics.fillGradient(14, 0, width, height, -1072689136, -804253680);
} else {
renderDirtBackground(graphics);
if (!isTransparentBackground()) {
ScissorsHandler.INSTANCE.scissor(new Rectangle(sliderPosition, 0, width - sliderPosition, height));
renderMenuBackground(graphics);
overlayBackground(graphics, new Rectangle(14, 0, width, height), 64, 64, 64, 255, 255);
} else {
if (this.minecraft.level == null) {
this.renderPanorama(graphics, delta);
}
renderBlurredBackground(delta);
renderMenuBackground(graphics);
ScissorsHandler.INSTANCE.scissor(new Rectangle(sliderPosition, 0, width - sliderPosition, height));
}
listWidget.width = width - sliderPosition;
listWidget.setLeftPos(sliderPosition);
Expand All @@ -235,8 +242,14 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
sideSlider.updatePosition(delta);
sideScroller.updatePosition(delta);
if (isTransparentBackground()) {
graphics.fillGradient(0, 0, sliderPosition, height, -1240461296, -972025840);
graphics.fillGradient(0, 0, sliderPosition - 14, height, 1744830464, 1744830464);
RenderSystem.enableBlend();
graphics.blit(new ResourceLocation("textures/gui/menu_list_background.png"), 0, 0, sliderPosition, height, sliderPosition, height, 32, 32);
graphics.blit(new ResourceLocation("textures/gui/menu_list_background.png"), 0, 0, sliderPosition - 14, height, sliderPosition - 14, height, 32, 32);
graphics.blit(DynamicEntryListWidget.VERTICAL_HEADER_SEPARATOR, sliderPosition - 1, 0, 0.0F, 0.0F, 1, this.height, 2, 32);
if (sliderPosition - 14 - 1 > 0) {
graphics.blit(DynamicEntryListWidget.VERTICAL_HEADER_SEPARATOR, sliderPosition - 14 - 1, 0, 0.0F, 0.0F, 1, this.height, 2, 32);
}
RenderSystem.disableBlend();
} else {
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder buffer = tesselator.getBuilder();
Expand All @@ -255,14 +268,11 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
buffer.vertex(sliderPosition - 14, 0, 0.0D).uv((sliderPosition - 14) / 32.0F, sideScroller.scrollAmountInt() / 32.0F).color(32, 32, 32, 255).endVertex();
buffer.vertex(0, 0, 0.0D).uv(0, sideScroller.scrollAmountInt() / 32.0F).color(32, 32, 32, 255).endVertex();
tesselator.end();
}
{

Matrix4f matrix = graphics.pose().last().pose();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder buffer = tesselator.getBuilder();
int shadeColor = isTransparentBackground() ? 120 : 160;
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
buffer.vertex(matrix, sliderPosition + 4, 0, 100.0F).color(0, 0, 0, 0).endVertex();
Expand Down Expand Up @@ -373,6 +383,7 @@ public int getItemHeight() {
public ComponentPath nextFocusPath(FocusNavigationEvent focusNavigationEvent) {
return null;
}

@Override
public Object getValue() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import net.minecraft.client.gui.navigation.ScreenDirection;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -53,6 +54,8 @@

@Environment(EnvType.CLIENT)
public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.Entry<E>> extends AbstractContainerEventHandler implements Renderable, NarratableEntry {
public static final ResourceLocation VERTICAL_HEADER_SEPARATOR = new ResourceLocation("cloth-config2:textures/gui/vertical_header_separator.png");
public static final ResourceLocation VERTICAL_FOOTER_SEPARATOR = new ResourceLocation("cloth-config2:textures/gui/vertical_footer_separator.png");
protected static final int DRAG_OUTSIDE = -2;
protected final Minecraft client;
private final List<E> entries = new Entries();
Expand Down Expand Up @@ -308,8 +311,10 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
this.renderHoleBackground(graphics, 0, this.top, 255, 255);
this.renderHoleBackground(graphics, this.bottom, this.height, 255, 255);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
graphics.fillGradient(this.left, this.top, this.right, this.top + 4, 0xff000000, 0);
graphics.fillGradient(this.left, this.bottom - 4, this.right, this.bottom, 0, 0xff000000);
RenderSystem.enableBlend();
graphics.blit(CreateWorldScreen.HEADER_SEPARATOR, this.left, this.top - 2, 0.0F, 0.0F, this.width, 2, 32, 2);
graphics.blit(CreateWorldScreen.FOOTER_SEPARATOR, this.left, this.bottom, 0.0F, 0.0F, this.width, 2, 32, 2);
RenderSystem.disableBlend();

int maxScroll = this.getMaxScroll();
renderScrollBar(graphics, tesselator, buffer, maxScroll, scrollbarPosition, int_4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public class ConfigBuilderImpl implements ConfigBuilder {
private boolean tabsSmoothScroll = true;
private boolean listSmoothScroll = true;
private boolean doesConfirmSave = true;
private boolean transparentBackground = false;
private ResourceLocation defaultBackground = Screen.BACKGROUND_LOCATION;
private boolean transparentBackground = true;
private ResourceLocation defaultBackground = new ResourceLocation("textures/block/dirt.png");
private Consumer<Screen> afterInitConsumer = screen -> {};
private final Map<String, ConfigCategory> categoryMap = Maps.newLinkedHashMap();
private String fallbackCategory = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ public ConfigCategory addEntry(AbstractConfigListEntry entry) {

@Override
public ConfigCategory setCategoryBackground(ResourceLocation identifier) {
if (builder.hasTransparentBackground())
throw new IllegalStateException("Cannot set category background if screen is using transparent background.");
background = identifier;
return this;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ dependencies {
mappings loom.officialMojangMappings()

modApi "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modApi fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version)
modApi fabricApi.module("fabric-screen-api-v1", rootProject.fabric_api_version)
modApi fabricApi.module("fabric-key-binding-api-v1", rootProject.fabric_api_version)
modApi fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version)

modApi("me.shedaniel.cloth:basic-math:0.6.1")
include("me.shedaniel.cloth:basic-math:0.6.1")
Expand All @@ -52,9 +55,9 @@ dependencies {
modCompileOnly("com.terraformersmc:modmenu:${mod_menu_version}") {
transitive(false)
}
modLocalRuntime("com.terraformersmc:modmenu:${mod_menu_version}") {
transitive(false)
}
// modLocalRuntime("com.terraformersmc:modmenu:${mod_menu_version}") {
// transitive(false)
// }

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
Expand Down Expand Up @@ -108,7 +111,7 @@ publishing {
unifiedPublishing {
project {
displayName = "[Fabric $rootProject.supported_version] v$project.version"
releaseType = "release"
releaseType = "beta"
gameVersions = []
gameLoaders = ["fabric"]

Expand All @@ -118,7 +121,7 @@ unifiedPublishing {
curseforge {
token = project.hasProperty("curse_api_key") ? project.property("curse_api_key") : System.getenv("curse_api_key")
id = project.curseforge_id
gameVersions.addAll "1.20.4", "1.20.3", "1.20.3-Snapshot", "Java 17"
gameVersions.addAll "1.20.5-Snapshot", "Java 17"
}
}

Expand All @@ -127,7 +130,7 @@ unifiedPublishing {
token = project.hasProperty("modrinth_key") ? project.property("modrinth_key") : System.getenv("modrinth_key")
id = project.modrinth_id
version = "$project.version+$project.name"
gameVersions.addAll project.minecraft_version, "1.20.3"
gameVersions.addAll project.minecraft_version
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "cloth-config",
"name": "Cloth Config v13",
"name": "Cloth Config v14",
"description": "An API for config screens.",
"version": "${version}",
"authors": [
Expand All @@ -27,7 +27,7 @@
],
"depends": {
"fabricloader": ">=0.14.0",
"minecraft": ">=1.20-"
"minecraft": ">=1.20.5-"
},
"accessWidener": "cloth-config.accessWidener",
"custom": {
Expand Down
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "GNU LGPLv3"
[[mods]]
modId = "cloth_config"
version = "${version}"
displayName = "Cloth Config v13 API"
displayName = "Cloth Config v14 API"
description = '''
An API for config screens.
'''
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

minecraft_version=1.20.4
supported_version=1.20.4
minecraft_version=24w09a
supported_version=1.20.5 (24w09a)

archives_base_name=cloth-config
archives_base_name_snapshot=cloth-config-snapshot
base_version=13.0
base_version=14.0
maven_group=me.shedaniel.cloth

jankson_version=1.2.0
toml4j_version=0.7.2
snakeyaml_version=1.27

fabric_loader_version=0.15.1
fabric_api_version=0.91.2+1.20.4
mod_menu_version=9.0.0-pre.1
fabric_loader_version=0.15.7
fabric_api_version=0.96.4+1.20.5
mod_menu_version=9.0.0

forge_version=49.0.3
neoforge_version=20.4.3-beta
Expand Down
Loading

0 comments on commit cfefa1d

Please sign in to comment.