Skip to content
Merged

Dev #187

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [26.1.2.3-beta]

### Fixed
* Fixed item data component viewing/editing in the item selection screen
* Fixed sidebar buttons showing tooltip translation keys (when shift is held) when the button shouldn't have a tooltip
* Server configs are now loaded earlier on NeoForge (using `ServerAboutToStartEvent`, not `ServerStartingEvent`)
* Fixes an issues with forceloading and FTB Chunks
* Fixed a tooltip issues with some GUI button types (not showing first line of tooltip)
* Fixed keybinding registration bug on Fabric where key categories weren't properly registered

## [26.1.2.2-beta]

### Added
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

loom {
accessWidenerPath = project(":common").file("src/main/resources/${project.mod_id}.accesswidener")
accessWidenerPath = file("src/main/resources/ftblibrary.accesswidener")

mixin {
useLegacyMixinAp = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public void onClicked(MouseButton button) {

@Override
public void addMouseOverText(TooltipList list) {
super.addMouseOverText(list);

for (Component c : tooltip) {
list.add(c);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ default void addResourcePackReloadListener(String modId, Identifier id, Preparab
addResourcePackReloadListeners(modId, Map.of(id, listener));
}

KeyMapping.Category registerKeyMappingCategory(Identifier id);

void registerKeyMapping(String modId, KeyMapping... keyMappings);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import dev.ftb.mods.ftblibrary.client.gui.screens.LoadingScreen;
import dev.ftb.mods.ftblibrary.client.util.ClientUtils;
import dev.ftb.mods.ftblibrary.platform.Platform;
import net.minecraft.ChatFormatting;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.minecraft.util.Util;
Expand All @@ -21,7 +23,7 @@ public class RegisteredSidebarButton implements SidebarButton {
private final SidebarButtonData data;
private final Identifier id;
private final String langKey;
private final Component tooltip;
private @Nullable final Component tooltip;
private final List<ButtonOverlayRender> extraRenderers;
private @Nullable Supplier<List<Component>> tooltipOverride;
private BooleanSupplier visible = () -> true;
Expand All @@ -31,7 +33,7 @@ public RegisteredSidebarButton(Identifier id, SidebarButtonData data) {
this.id = id;
this.data = data;
this.langKey = Util.makeDescriptionId("sidebar_button", id);
tooltip = Component.translatable(langKey + ".tooltip");
tooltip = I18n.exists(langKey + ".tooltip") ? Component.translatable(langKey + ".tooltip") : null;
if (data.requiresOp()) {
addVisibilityCondition(ClientUtils.IS_CLIENT_OP);
}
Expand Down Expand Up @@ -65,8 +67,8 @@ public List<Component> getTooltip(boolean shift) {
} else {
List<Component> tooltips = new ArrayList<>();
tooltips.add(Component.translatable(langKey));
if (shift) {
tooltips.add(tooltip);
if (tooltip != null && shift) {
tooltips.add(tooltip.copy().withStyle(ChatFormatting.GRAY));
}
Optional<List<Component>> components = shift ? data.shiftTooltip() : data.tooltip();
components.ifPresent(tooltips::addAll);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public record SidebarButtonData(
).apply(builder, SidebarButtonData::new));

@Override
public int compareTo(@NonNull SidebarButtonData o) {
public int compareTo(SidebarButtonData o) {
return Integer.compare(sortIndex, o.sortIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
import org.joml.Matrix3x2fStack;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

import java.util.*;
import java.util.stream.Collectors;
Expand All @@ -35,9 +35,11 @@ public class SidebarGroupGuiButton extends AbstractButton {
boolean gridStartRight = false;
int yRenderStart;
int xRenderStart;
@Nullable
private SidebarGuiButton mouseOver;
@Nullable
private SidebarGuiButton selectedButton;
private GridLocation selectedLocation;
private GridLocation selectedLocation = GridLocation.OUT_OF_BOUNDS;
private int lastMouseClickButton = 0;
private boolean isEditMode;
private int currentMouseX;
Expand Down Expand Up @@ -211,10 +213,10 @@ private void extractEditMode(GuiGraphicsExtractor graphics, int mx, int my) {
graphics.pose().pushMatrix();

if (gridStartRight) {
drawHoveredGrid(graphics, addIconX, gridY, 1, disabledButtonList.size(), BUTTON_SPACING, Color4I.GRAY, Color4I.BLACK, mx, my, gridStartBottom, gridStartRight);
drawHoveredGrid(graphics, addIconX, gridY, 1, disabledButtonList.size(), BUTTON_SPACING, Color4I.GRAY, Color4I.BLACK, mx, my, gridStartBottom, true);
drawGrid(graphics, addIconX - maxWidth - 6, gridY, 1, disabledButtonList.size(), maxWidth + 6, BUTTON_SPACING, Color4I.GRAY, Color4I.BLACK);
} else {
drawHoveredGrid(graphics, gridX, gridY, 1, disabledButtonList.size(), BUTTON_SPACING, Color4I.GRAY, Color4I.BLACK, mx, my, gridStartBottom, gridStartRight);
drawHoveredGrid(graphics, gridX, gridY, 1, disabledButtonList.size(), BUTTON_SPACING, Color4I.GRAY, Color4I.BLACK, mx, my, gridStartBottom, false);
drawGrid(graphics, gridX + BUTTON_SPACING, gridY, 1, disabledButtonList.size(), maxWidth + 6, BUTTON_SPACING, Color4I.GRAY, Color4I.BLACK);
}

Expand Down Expand Up @@ -267,6 +269,8 @@ public void onRelease(MouseButtonEvent mouseButtonEvent) {
}

private void updateButtonLocations(GridLocation gLocation) {
assert selectedButton != null;

// Checks if moved from the first spot, so we can move other icons over but only as the same row

boolean isFrom0XTo1X = selectedLocation.y() == gLocation.y() && selectedLocation.x() == 0 && gLocation.x() == 1;
Expand Down Expand Up @@ -340,7 +344,7 @@ private void updateWidgetSize() {
}

if (isEditMode && addBoxOpen) {
int disabledList = SidebarButtonManager.INSTANCE.getDisabledButtonList(isEditMode).size();
int disabledList = SidebarButtonManager.INSTANCE.getDisabledButtonList(true).size();
girdAmountX += 4;
girdAmountY = Math.max(girdAmountY, disabledList);
}
Expand Down Expand Up @@ -428,7 +432,7 @@ private GridLocation getGridLocation() {
}

@Override
public void onPress(@NonNull InputWithModifiers inputWithModifiers) {
public void onPress(InputWithModifiers inputWithModifiers) {
if (lastMouseClickButton == 1) {
isEditMode = !isEditMode;
ensureGridAlignment();
Expand Down
4 changes: 0 additions & 4 deletions common/src/main/resources/ftblibrary.accesswidener
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
accessWidener v2 official

accessible class net/minecraft/client/gui/components/MultilineTextField$StringView

#transitive-extendable class net/minecraft/nbt/CompoundTag
#transitive-accessible method net/minecraft/nbt/CompoundTag <init> (Ljava/util/Map;)V

accessible method net/minecraft/client/renderer/texture/SpriteContents getFrameCount ()I

accessible field net/minecraft/client/gui/GuiGraphicsExtractor guiRenderState Lnet/minecraft/client/renderer/state/gui/GuiRenderState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public void addResourcePackReloadListeners(String modId, Map<Identifier, Prepara
ResourceLoader.get(PackType.CLIENT_RESOURCES).registerReloadListener(id, listener));
}

@Override
public KeyMapping.Category registerKeyMappingCategory(Identifier id) {
return KeyMapping.Category.register(id);
}

@Override
public void registerKeyMapping(String modId, KeyMapping... keyMappings) {
for (var k : keyMappings) {
Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.daemon=false
# Mod
mod_id=ftblibrary
readable_name=FTB Library
mod_version=2
mod_version=3
mod_author=FTB Team

# Maven
Expand All @@ -29,6 +29,10 @@ fabric_api_version_range=>=0.145.0+26.1.1
jei_version=29.5.0.26

json5_version=3.0.0
amecs_key_modifiers_version=mc26.1.0:1.0.2
amecs_key_bundle_version=mc26.1.0:1.6.5

modmenu_version=18.0.0-alpha.8

curseforge_id_forge=404465
curseforge_id_fabric=438495
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
import net.neoforged.neoforge.event.server.ServerAboutToStartEvent;
import net.neoforged.neoforge.event.server.ServerStartedEvent;
import net.neoforged.neoforge.event.server.ServerStartingEvent;
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
Expand All @@ -33,7 +34,7 @@ public FTBLibraryNeoForge(IEventBus modEventBus) {
IEventBus bus = NeoForge.EVENT_BUS;

bus.addListener(ServerStartedEvent.class, (event) -> this.library.serverStarted(event.getServer()));
bus.addListener(ServerStartingEvent.class, (event) -> ConfigManager.getInstance().onServerStarting(event.getServer()));
bus.addListener(ServerAboutToStartEvent.class, (event) -> ConfigManager.getInstance().onServerStarting(event.getServer()));
bus.addListener(ServerStoppedEvent.class, (event) -> this.library.serverStopped(event.getServer()));

bus.addListener(RegisterCommandsEvent.class, (event) -> this.library.registerCommands(event.getDispatcher(), event.getBuildContext(), event.getCommandSelection()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import net.neoforged.neoforge.client.network.ClientPacketDistributor;
import org.jspecify.annotations.NonNull;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class NeoPlatformClientImpl implements PlatformClient {
private final Set<KeyMapping.Category> registeredCategories = ConcurrentHashMap.newKeySet();

@Override
public void sendToServer(CustomPacketPayload payload) {
ClientPacketDistributor.sendToServer(payload);
Expand All @@ -29,15 +31,25 @@ public void addResourcePackReloadListeners(String modId, Map<Identifier, Prepara
listeners.forEach(event::addListener));
}

@Override
public KeyMapping.Category registerKeyMappingCategory(Identifier id) {
var category = new KeyMapping.Category(id);
if (!registeredCategories.add(category)) {
throw new IllegalStateException("Key mapping category " + id + " is already registered");
}

return category;
}

@Override
public void registerKeyMapping(String modId, KeyMapping... keyMappings) {
getModBusOrThrow(modId).addListener(RegisterKeyMappingsEvent.class, event -> {
Set<KeyMapping.Category> cats = new HashSet<>();
for (var k : keyMappings) {
cats.add(k.getCategory());
event.register(k);
}
cats.forEach(event::registerCategory);

registeredCategories.forEach(event::registerCategory);
registeredCategories.clear();
});
}

Expand Down
Loading