Skip to content

Commit

Permalink
Merge pull request #743 from FTBTeam/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
desht authored Jul 5, 2024
2 parents e151139 + 4a4ab53 commit 00bd6f2
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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).

# [2100.1.3]

### Fixed
* Fixed adding tasks to existing quests sometimes losing the task type (leading to a '?' button appearing)
* Fixed images in the quest book not sync'ing to the client
* Fixed issue where using FTB Filter System filters would sometimes fail to find matching items for GUI display

# [2100.1.2]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ publishMods {

// TODO: Migrate to something else
def tag = providers.environmentVariable("TAG").getOrElse("release")
type = tag == "beta" ? BETA : (tag == "alpha" ? ALPHA : STABLE)
type = tag.endsWith("-beta") ? BETA : (tag.endsWith("-alpha") ? ALPHA : STABLE)

def createOptions = (String projectName) -> {
publishOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.ftb.mods.ftbquests.FTBQuests;
import net.minecraft.world.item.ItemStack;

import java.util.Collection;
import java.util.function.Consumer;

/**
* This event is fired on the client to allow mods to register custom items to be displayed when filters (such as the
* Smart Filter from FTB Filter System) look for matching items for their filter. By default, only items in the creative
* search tab are checked for, so this event is useful for adding items with custom data components.
* <br>
* KubeJS integration for this event is provided via FTB XMod Compat, and is the typical way for modpack makers to
* add custom display items for any filters they create. An example KubeJS snippet (to be placed in
* kubejs/client_scripts) to register an item:
* <pre>
* FTBQuestsEvents.customFilterItem(event => {
* event.addStack('minecraft:iron_axe {display:{Name:{text:\"Test Axe!\"}}, Damage: 50}')
* event.addStack('minecraft:diamond_axe {display:{Name:{text:\"Test Axe 2!\"}}, Damage: 300}')
* })
* </pre>
*/
public class CustomFilterDisplayItemsEvent {
private final Consumer<ItemStack> callback;

Expand All @@ -21,6 +37,6 @@ public void add(ItemStack stack) {
}

public void add(Collection<ItemStack> stacks) {
stacks.forEach(callback::accept);
stacks.forEach(callback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,12 @@ public static void rebuildCreativeTabs() {
}
}

public static Optional<RegistryAccess> registryAccess() {
return Minecraft.getInstance().level == null ? Optional.empty() : Optional.of(Minecraft.getInstance().level.registryAccess());
public static Optional<CreativeModeTab.ItemDisplayParameters> creativeTabDisplayParams() {
LocalPlayer player = Minecraft.getInstance().player;
if (player != null) {
return Optional.of(new CreativeModeTab.ItemDisplayParameters(player.connection.enabledFeatures(), Minecraft.getInstance().options.operatorItemsTab().get(), player.clientLevel.registryAccess()));
}
return Optional.empty();
}

public static void copyToClipboard(QuestObjectBase qo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private static void openSetupGui(Runnable gui, BiConsumer<Task, CompoundTag> cal
ConfigGroup group = new ConfigGroup(FTBQuestsAPI.MOD_ID, accepted -> {
gui.run();
if (accepted) {
callback.accept(task, new CompoundTag());
callback.accept(task, task.getType().makeExtraNBT());
}
});
task.fillConfigGroup(task.createSubGroup(group));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dev.ftb.mods.ftbquests.integration.item_filtering;

import com.google.common.collect.ImmutableList;
import dev.ftb.mods.ftbquests.FTBQuests;
import dev.ftb.mods.ftbquests.api.ItemFilterAdapter;
import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent;
import dev.ftb.mods.ftbquests.client.FTBQuestsClient;
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -34,9 +34,11 @@ public static List<ItemStack> getCachedDisplayStacks(ItemStack filterStack, Item
}

private static List<ItemStack> computeMatchingStacks(ItemFilterAdapter.Matcher matcher) {
if (CreativeModeTabs.searchTab().getSearchTabDisplayItems().isEmpty()) {
FTBQuestsClient.registryAccess().ifPresent(ra -> CreativeModeTabs.tryRebuildTabContents(FeatureFlags.DEFAULT_FLAGS, true, ra));
}
FTBQuestsClient.creativeTabDisplayParams().ifPresent(params -> {
if (CreativeModeTabs.tryRebuildTabContents(params.enabledFeatures(), params.hasPermissions(), params.holders())) {
FTBQuests.LOGGER.debug("creative tabs rebuilt, search tab now has {} items", CreativeModeTabs.searchTab().getSearchTabDisplayItems().size());
}
});

ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,8 @@ public final void writeNetData(RegistryFriendlyByteBuf buffer) {
public final void readNetData(RegistryFriendlyByteBuf buffer) {
super.readNetData(buffer);

emergencyItems.retainAll(ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs.list()).decode(buffer));
emergencyItems.clear();
emergencyItems.addAll(ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs.list()).decode(buffer));
emergencyItemsCooldown = buffer.readVarInt();
defaultPerTeamReward = buffer.readBoolean();
defaultTeamConsumeItems = buffer.readBoolean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public static <T> void write(FriendlyByteBuf buffer, Collection<T> list, BiConsu
}

public static <T> void read(FriendlyByteBuf buffer, Collection<T> list, Function<FriendlyByteBuf, T> reader) {
list.retainAll(buffer.readList(reader::apply));
list.clear();
list.addAll(buffer.readList(reader::apply));
}

public static void writeStrings(FriendlyByteBuf buffer, Collection<String> list) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ maven_group=dev.ftb.mods
mod_author=FTB Team

# Build time
mod_version=2100.1.2
mod_version=2100.1.3
minecraft_version=1.21


Expand Down

0 comments on commit 00bd6f2

Please sign in to comment.