Skip to content

Commit

Permalink
Update 1.21.1, closes #94
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightenom committed Aug 10, 2024
1 parent 3c7443e commit 776eb40
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 7 deletions.
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ javaVersion=21
useJavaToolChains=true

#The currently running forge.
forgeVersion=21.0.157
forgeVersion=21.1.4
#The minimal needed forge, as marked in metadata and curseforge.
forgeMinVersion=21.0.157
forgeMinVersion=21.0.143

fml_range=[4,)
forge_range=[21.0.157,)
forge_range=[21.0.143,)
minecraft_range=[1.21, 1.22)

#The version for forge (dependency)
exactMinecraftVersion=1.21
exactMinecraftVersion=1.21.1
#The main version on curseforge
minecraftVersion=1.21
minecraftVersion=1.21.1
#Semicolon seperated list of mc versions, which are marked as compatible on curseforge
additionalMinecraftVersions=
additionalMinecraftVersions=1.21

githubUrl=https://github.com/ldtteam/BlockUI
gitUrl=https://github.com/ldtteam/BlockUI.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ public R newLine()
return thiz;
}

/**
* Appends 1 empty line.
* Ends current line if there is any.
*/
public R emptyLine()
{
return emptyLines(1);
}

/**
* Appends <code>count</code> new line symbols.
* Ends current line if there is any.
Expand Down Expand Up @@ -149,7 +158,12 @@ public R paragraphBreak(final boolean forceStyle)
{
newLine();

final Style style = new Style(Color.toVanilla(color), bold, italic, underlined, strikeThrough, obfuscated, clickEvent, null, insertionEvent, null);
Style style = new Style(Color.toVanilla(color), bold, italic, underlined, strikeThrough, obfuscated, clickEvent, null, insertionEvent, null);
if (style.equals(Style.EMPTY))
{
style = Style.EMPTY;
}

for (int i = lastParagraphStart; i < text.size(); i++)
{
if (forceStyle || text.get(i).getStyle().equals(Style.EMPTY))
Expand Down Expand Up @@ -381,6 +395,41 @@ public List<MutableComponent> getText()
return new ArrayList<>(text); // copy, so different elements are not backed by the same list
}

/**
* Finishes current paragraph and replaces text of given pane.
*
* @see #paragraphBreak()
*/
public R applyToPane(final AbstractTextElement textPane)
{
paragraphBreak();

textPane.setText(getText());

return thiz;
}

/**
* Finishes current paragraph and appends to current text of given pane.
*
* @see #paragraphBreak()
*/
public R appendToPane(final AbstractTextElement textPane)
{
if (textPane.getTextAsList() == null)
{
return applyToPane(textPane);
}

paragraphBreak();

final List<MutableComponent> newText = getText();
newText.addAll(textPane.getTextAsList());
textPane.setText(newText);

return thiz;
}

public static class AutomaticTooltipBuilder extends TooltipBuilder
{
public AutomaticTooltipBuilder()
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/ldtteam/blockui/mod/ClientEventSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import com.ldtteam.blockui.AtlasManager;
import com.ldtteam.blockui.BOScreen;
import com.ldtteam.blockui.PaneBuilders;
import com.ldtteam.blockui.controls.Button;
import com.ldtteam.blockui.controls.ButtonImage;
import com.ldtteam.blockui.controls.Image;
import com.ldtteam.blockui.controls.Text;
import com.ldtteam.blockui.hooks.HookManager;
import com.ldtteam.blockui.hooks.HookRegistries;
import com.ldtteam.blockui.mod.container.ContainerHook;
Expand All @@ -15,9 +17,11 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModList;
import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent;
import net.neoforged.neoforge.client.event.ClientTickEvent;
import net.neoforged.neoforge.client.event.RenderGuiLayerEvent;
Expand Down Expand Up @@ -63,20 +67,43 @@ public static void onClientTickStart(final ClientTickEvent.Pre event)
{
final BOWindow window = new BOWindow();
int id = 0;

final Button dumpAtlases = createTestGuiButton(id++, "Dump mod atlases to run folder", null);
dumpAtlases.setHandler(b -> {
final Path dumpingFolder = Path.of("atlas_dump").toAbsolutePath().normalize();
Minecraft.getInstance().player.sendSystemMessage(Component.literal("Dumping atlases into: " + dumpingFolder.toString()));
AtlasManager.INSTANCE.dumpAtlases(dumpingFolder);
});
window.addChild(dumpAtlases);

window.addChild(createTestGuiButton(id++, "General All-in-one", ResourceLocation.fromNamespaceAndPath(BlockUI.MOD_ID, "gui/test.xml"), parent -> {
parent.findPaneOfTypeByID("missing_out_of_jar", Image.class).setImage(OutOfJarResourceLocation.ofMinecraftFolder(BlockUI.MOD_ID, "missing_out_of_jar.png"), false);
parent.findPaneOfTypeByID("working_out_of_jar", Image.class).setImage(OutOfJarResourceLocation.of(BlockUI.MOD_ID, Path.of("../../src/test/resources/button.png")), false);
}));
window.addChild(createTestGuiButton(id++, "Tooltip Positioning", ResourceLocation.fromNamespaceAndPath(BlockUI.MOD_ID, "gui/test2.xml")));
window.addChild(createTestGuiButton(id++, "ItemIcon To BlockState", ResourceLocation.fromNamespaceAndPath(BlockUI.MOD_ID, "gui/test3.xml"), BlockStateTestGui::setup));
window.addChild(createTestGuiButton(id++, "Scrolling Lists", ResourceLocation.fromNamespaceAndPath(BlockUI.MOD_ID, "gui/test4.xml"), ScrollingListsGui::setup));

final Text builderTest = new Text();
builderTest.setSize(ButtonImage.DEFAULT_BUTTON_WIDTH * 2 + 20, ButtonImage.DEFAULT_BUTTON_HEIGHT);
builderTest.setPosition(0, ((id + 1) / 2) * (builderTest.getHeight() + 10));
PaneBuilders.textBuilder()
.append(Component.literal(BlockUI.MOD_ID))
.append(Component.literal(" - "))
.append(Component.literal(ModList.get().getModFileById(BlockUI.MOD_ID).versionString()))
.paragraphBreak()
.colorName("red")
.underlined()
.append(Component.translatable("blockui.tooltip.item_additional_info",
Component.translatable("key.keyboard.left.control")
.append(" + ")
.append(Component.translatable("key.keyboard.left.shift"))
.append(" + ")
.append(Component.translatable("key.keyboard.left.alt"))
.setStyle(Style.EMPTY.withItalic(true))))
.applyToPane(builderTest);
window.addChild(builderTest);

window.open();
}
}
Expand Down

0 comments on commit 776eb40

Please sign in to comment.