Skip to content
Closed
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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.2.8-beta]

* Ported to Minecraft 26.2

## [26.1.2.7-beta]

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void guiInit(Screen screen) {

public void clientTick() {
var client = Minecraft.getInstance();
var cursorType = client.screen instanceof IScreenWrapper w ? w.getGui().getCursor() : null;
var cursorType = client.gui.screen() instanceof IScreenWrapper w ? w.getGui().getCursor() : null;
if (lastCursorType != cursorType) {
lastCursorType = cursorType;
CursorType.set(cursorType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public Component getName() {
*/
public Component getTooltip() {
var t = getNameKey() + ".tooltip";
return I18n.exists(t) ? Component.translatable(t) : Component.empty();
return !I18n.get(t).isEmpty() ? Component.translatable(t) : Component.empty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public String getName() {

public String getTooltip() {
var k = getNameKey() + ".tooltip";
return I18n.exists(k) ? I18n.get(k) : "";
return !I18n.get(k).isEmpty() ? I18n.get(k) : "";
}

public EditableConfigValue<T> setOrder(int o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EntityTypes;

import java.util.OptionalLong;

public class EditableEntityFace extends EditableResource<EntityType<?>> {
// any non-living entity would be ok here
public static final EntityType<?> NONE = EntityType.AREA_EFFECT_CLOUD;
public static final EntityType<?> NONE = EntityTypes.AREA_EFFECT_CLOUD;

public EditableEntityFace() {
value = NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public ConfigGroupButton(Panel panel, EditableConfigGroup g) {
}

var infoKey = group.getPath() + ".info";
info = I18n.exists(infoKey) ? Component.translatable(infoKey) : null;
info = !I18n.get(infoKey).isEmpty() ? Component.translatable(infoKey) : null;
setCollapsed(collapsed);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ public Collection<? extends SelectableResource<FluidStack>> getAllResources() {
}
};
ResourceSearchMode<EntityType<?>> ALL_LIVING_ENTITIES = entitySearchMode(e -> e instanceof LivingEntity,
"all_entities", () -> EntityIconLoader.getIcon(EntityType.VILLAGER));
"all_entities", () -> EntityIconLoader.getIcon(EntityTypes.VILLAGER));
ResourceSearchMode<EntityType<?>> HOSTILES = entitySearchMode(e -> e instanceof Enemy && !(e instanceof NeutralMob),
"hostiles",() -> EntityIconLoader.getIcon(EntityType.ZOMBIE));
"hostiles",() -> EntityIconLoader.getIcon(EntityTypes.ZOMBIE));
ResourceSearchMode<EntityType<?>> NEUTRALS = entitySearchMode(e -> e instanceof NeutralMob,
"neutrals", () -> EntityIconLoader.getIcon(EntityType.ENDERMAN));
"neutrals", () -> EntityIconLoader.getIcon(EntityTypes.ENDERMAN));
ResourceSearchMode<EntityType<?>> ANIMALS = entitySearchMode(e -> e instanceof Animal,
"animals", () -> EntityIconLoader.getIcon(EntityType.SHEEP));
"animals", () -> EntityIconLoader.getIcon(EntityTypes.SHEEP));

ResourceSearchMode<Identifier> IMAGES = new SearchMode<>(Component.translatable("ftblibrary.select_image.all_images"), () -> Icons.ART) {
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SimpleToast implements Toast {
private Visibility visibility = Visibility.SHOW;

public static void info(Component title, Component subtitle) {
Minecraft.getInstance().getToastManager().addToast(
Minecraft.getInstance().gui.toastManager().addToast(
new SimpleToast() {
@Override
public Component getTitle() {
Expand All @@ -35,7 +35,7 @@ public Component getSubtitle() {
}

public static void error(Component title, Component subtitle) {
Minecraft.getInstance().getToastManager().addToast(
Minecraft.getInstance().gui.toastManager().addToast(
new SimpleToast() {
@Override
public Component getTitle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public BaseScreen(@Nullable Screen previousScreen) {
}

public BaseScreen() {
this(Minecraft.getInstance().screen);
this(Minecraft.getInstance().gui.screen());
}

/**
Expand Down Expand Up @@ -238,7 +238,7 @@ public final void closeGui(boolean openPrevScreen) {

if (usePreviousScreenOnBack()) {
if (openPrevScreen && getPrevScreen() != null) {
mc.setScreen(getPrevScreen());
mc.gui.setScreen(getPrevScreen());
GLFW.glfwSetCursorPos(getWindow().handle(), mx, my);
}
}
Expand Down Expand Up @@ -497,7 +497,7 @@ public void addMouseOverText(TooltipList list) {
@Override
public final void openGui() {
openContextMenu((ContextMenu) null);
getMinecraft().setScreen(new ScreenWrapper(this));
getMinecraft().gui.setScreen(new ScreenWrapper(this));
}

@Override
Expand Down Expand Up @@ -544,7 +544,7 @@ public boolean handleClick(String scheme, String path) {
}

public void openYesNoFull(Component title, Component desc, BooleanConsumer callback) {
getMinecraft().setScreen(new ConfirmScreen(result -> {
getMinecraft().gui.setScreen(new ConfirmScreen(result -> {
openGui();
callback.accept(result);
refreshWidgets();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ColorSelectorPanel extends ModalPanel {
private static final Icon<?> WHEEL = Icon.getIcon(FTBLibrary.id("textures/gui/rgbcolorwheel.png"));
private static final MutableComponent ARGB = Component.literal("ARGB");
private static final MutableComponent RGB = Component.literal("RGB");
private static final Map<ChatFormatting, Integer> COLOR_RGB = new EnumMap<>(ChatFormatting.class);
private static final Map<String, List<Integer>> PRESETS = Util.make(new LinkedHashMap<>(), ColorSelectorPanel::setupPalettes);
private static String curPalette = "chat";

Expand All @@ -44,6 +45,25 @@ public class ColorSelectorPanel extends ModalPanel {
private final float[] hsb = new float[3];
private boolean allowAlphaEdit = false;

static {
COLOR_RGB.put(ChatFormatting.BLACK, 0x000000);
COLOR_RGB.put(ChatFormatting.DARK_BLUE, 0x0000AA);
COLOR_RGB.put(ChatFormatting.DARK_GREEN, 0x00AA00);
COLOR_RGB.put(ChatFormatting.DARK_AQUA, 0x00AAAA);
COLOR_RGB.put(ChatFormatting.DARK_RED, 0xAA0000);
COLOR_RGB.put(ChatFormatting.DARK_PURPLE, 0xAA00AA);
COLOR_RGB.put(ChatFormatting.GOLD, 0xFFAA00);
COLOR_RGB.put(ChatFormatting.GRAY, 0xAAAAAA);
COLOR_RGB.put(ChatFormatting.DARK_GRAY, 0x555555);
COLOR_RGB.put(ChatFormatting.BLUE, 0x5555FF);
COLOR_RGB.put(ChatFormatting.GREEN, 0x55FF55);
COLOR_RGB.put(ChatFormatting.AQUA, 0x55FFFF);
COLOR_RGB.put(ChatFormatting.RED, 0xFF5555);
COLOR_RGB.put(ChatFormatting.LIGHT_PURPLE, 0xFF55FF);
COLOR_RGB.put(ChatFormatting.YELLOW, 0xFFFF55);
COLOR_RGB.put(ChatFormatting.WHITE, 0xFFFFFF);
}

public ColorSelectorPanel(Panel panel, EditableColor config, ConfigCallback callback) {
super(panel);

Expand Down Expand Up @@ -87,7 +107,10 @@ private static MutableComponent getPaletteName(String palette) {

private static void setupPalettes(Map<String,List<Integer>> presetMap) {
presetMap.put("chat", Util.make(new ArrayList<>(), l -> {
Arrays.stream(ChatFormatting.values()).filter(ChatFormatting::isColor).map(ChatFormatting::getColor).forEach(e -> l.add(e | 0xFF000000));
Arrays.stream(ChatFormatting.values())
.filter(COLOR_RGB::containsKey)
.map(f -> COLOR_RGB.get(f) | 0xFF000000)
.forEach(l::add);
}));

presetMap.put("dye", Util.make(new ArrayList<>(), l -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void execClientCommand(String command, boolean printChat) {
if (!command.isEmpty() && Minecraft.getInstance().player != null) {
if (AllowChatCommandEvent.TYPE.post(new AllowChatCommandEvent.Data(command))) {
if (printChat) {
Minecraft.getInstance().gui.getChat().addRecentChat(command);
Minecraft.getInstance().gui.hud.getChat().addRecentChat(command);
}
Minecraft.getInstance().player.connection.sendCommand(command.replaceFirst("/", ""));
}
Expand All @@ -61,12 +61,12 @@ public static <T> T getGuiAs(Screen gui, Class<T> clazz) {
}
}

return clazz.isAssignableFrom(gui.getClass()) ? (T) Minecraft.getInstance().screen : null;
return clazz.isAssignableFrom(gui.getClass()) ? (T) Minecraft.getInstance().gui.screen() : null;
}

@Nullable
public static <T> T getCurrentGuiAs(Class<T> clazz) {
return Minecraft.getInstance().screen == null ? null : getGuiAs(Minecraft.getInstance().screen, clazz);
return Minecraft.getInstance().gui.screen() == null ? null : getGuiAs(Minecraft.getInstance().gui.screen(), clazz);
}

public static boolean handleClick(String scheme, String path) {
Expand All @@ -76,12 +76,12 @@ public static boolean handleClick(String scheme, String path) {
try {
final var uri = new URI(uriStr);
if (Minecraft.getInstance().options.chatLinksPrompt().get()) {
final var currentScreen = Minecraft.getInstance().screen;
Minecraft.getInstance().setScreen(new ConfirmLinkScreen(accepted -> {
final var currentScreen = Minecraft.getInstance().gui.screen();
Minecraft.getInstance().gui.setScreen(new ConfirmLinkScreen(accepted -> {
if (accepted) {
Util.getPlatform().openUri(uri);
}
Minecraft.getInstance().setScreen(currentScreen);
Minecraft.getInstance().gui.setScreen(currentScreen);
}, uriStr, false));
} else {
Util.getPlatform().openUri(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void registerGuiHandlers(IGuiHandlerRegistration registration) {

@Override
public Collection<Rect2i> getGuiExtraAreas() {
var currentScreen = Minecraft.getInstance().screen;
var currentScreen = Minecraft.getInstance().gui.screen();

if (FTBLibraryClient.areButtonsVisible(currentScreen)) {
return Collections.singleton(SidebarGroupGuiButton.lastDrawnArea);
Expand All @@ -104,7 +104,7 @@ public Collection<Rect2i> getGuiExtraAreas() {

@Override
public Optional<IClickableIngredient<?>> getClickableIngredientUnderMouse(IClickableIngredientFactory builder, double mouseX, double mouseY) {
var currentScreen = Minecraft.getInstance().screen;
var currentScreen = Minecraft.getInstance().gui.screen();

if (currentScreen instanceof IScreenWrapper wrapper && wrapper.getGui().getIngredientUnderMouse().isPresent()) {
PositionedIngredient underMouse = wrapper.getGui().getIngredientUnderMouse().get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public RegisteredSidebarButton(Identifier id, SidebarButtonData data) {
this.id = id;
this.data = data;
this.langKey = Util.makeDescriptionId("sidebar_button", id);
tooltip = I18n.exists(langKey + ".tooltip") ? Component.translatable(langKey + ".tooltip") : null;
tooltip = !I18n.get(langKey + ".tooltip").isEmpty() ? Component.translatable(langKey + ".tooltip") : null;
if (data.requiresOp()) {
addVisibilityCondition(ClientUtils.IS_CLIENT_OP);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;

public class TextComponentUtils {

private static final Map<String, ChatFormatting> BY_NAME = Arrays.stream(ChatFormatting.values())
.collect(Collectors.toMap(f -> f.name().toLowerCase(Locale.ROOT).replaceAll("[^a-z]", ""), f -> f));

public static Component withLinks(String message) {
return Platform.get().misc().componentWithLinks(message);
}
Expand All @@ -25,4 +35,9 @@ public static Component translatedDimension(ResourceKey<Level> key) {
public static Component translatedDimension(Identifier dimId) {
return Component.translatableWithFallback(dimId.toLanguageKey("dimension"), dimId.toString());
}

@Nullable
public static ChatFormatting getByName(@Nullable String name) {
return name == null ? null : BY_NAME.get(name.toLowerCase(Locale.ROOT).replaceAll("[^a-z]", ""));
}
}
28 changes: 14 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ org.gradle.daemon=false
# Mod
mod_id=ftblibrary
readable_name=FTB Library
mod_version=7
mod_version=8
mod_author=FTB Team

# Maven
archives_base_name=ftb-library
maven_group=dev.ftb.mods

# MC
minecraft_version=26.1.2
supported_minecraft_versions=26.1,26.1.1,26.1.2
minecraft_version_range_maven=[26.1,27)
minecraft_version_range_semver=>=26.1.0
minecraft_version=26.2
supported_minecraft_versions=26.2,26.2.1,26.2.2
minecraft_version_range_maven=[26.2,27)
minecraft_version_range_semver=>=26.2.0

# Deps
neoforge_version=26.1.2.71
neoforge_version_range=[26.1.2.71,27)
neoforge_version=26.2.0.7-beta
neoforge_version_range=[26.2.0.7-beta,27)
neoforge_loader_version=4

fabric_loader_version=0.18.6
fabric_api_version=0.149.1+26.1.2
fabric_api_version_range=>=0.149.1+26.1.2
fabric_loader_version=0.19.3
fabric_api_version=0.154.2+26.2
fabric_api_version_range=>=0.144.0+26.2

jei_version=29.5.0.26
jei_version=30.2.0.18

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
amecs_key_modifiers_version=mc26.2.0:1.0.2
amecs_key_bundle_version=mc26.2.0:1.6.5

modmenu_version=18.0.0-alpha.8
modmenu_version=20.0.1

curseforge_id_forge=404465
curseforge_id_fabric=438495
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pluginManagement {

include "common", "fabric", "neoforge"

rootProject.name = 'FTB-Library-26.1'
rootProject.name = 'FTB-Library-26.2'