Skip to content
Draft
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
14 changes: 5 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import red.jackf.UpdateDependenciesTask

plugins {
id("maven-publish")
id("fabric-loom") version "1.7-SNAPSHOT"
id("fabric-loom") version "1.6-SNAPSHOT"
id("com.github.breadmoirai.github-release") version "2.4.1"
id("org.ajoberstar.grgit") version "5.2.1"
id("me.modmuss50.mod-publish-plugin") version "0.3.3"
Expand Down Expand Up @@ -275,18 +275,14 @@ if (canPublish) {
val addonProp: String = properties["changelogHeaderAddon"]!!.toString()

if (addonProp.isNotBlank()) {
addonProp
addonProp + "\n\n"
} else {
null
""
}
} else {
null
""
}

val changelogFileText = rootProject.file("changelogs/${properties["mod_version"]}.md")
.takeIf { it.exists() }
?.readText()

generateChangelogTask = tasks.register<GenerateChangelogTask>("generateChangelog") {
this.lastTag.set(lastTag)
this.newTag.set(newTag)
Expand All @@ -307,7 +303,7 @@ if (canPublish) {
}

// Add a bundled block for each module version
prologue.set(listOfNotNull(changelogHeader, changelogFileText, bundledText).joinToString(separator = "\n\n"))
prologue.set(changelogHeader + bundledText)
}
}

Expand Down
17 changes: 0 additions & 17 deletions changelogs/2.5.0.md

This file was deleted.

14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ parchment_version=1.20.6:2024.05.01
loader_version=0.15.11

# Mod Properties
mod_version=2.5.3
mod_version=2.4.14
maven_group=red.jackf
archives_base_name=chesttracker

# Dependencies
bundle_searchables=true
searchables_version=1.21.1:1.0.1
bundle_searchables=false
searchables_version=1.21:1.0.5

# Mod Compat
clothconfig_version=15.0.127
Expand All @@ -26,10 +26,10 @@ jade_version=VQc9njMw
yacl_version=3.5.0+1.21-fabric

# JF_AUTO_UPDATE_BLOCK
fabric-api_version=0.103.0+1.21.1
modmenu_version=11.0.2
where-is-it_version=2.6.2+1.21.1
emi_version=1.1.12+1.21
fabric-api_version=0.102.1+1.21.1
modmenu_version=11.0.0-beta.1
where-is-it_version=2.5.0+1.21
emi_version=1.1.6+1.20.6
# JF_END_AUTO_UPDATE_BLOCK

# Publishing
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
Binary file removed images/inline example.png
Binary file not shown.
20 changes: 7 additions & 13 deletions src/client/java/red/jackf/chesttracker/api/memory/Memory.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public final class Memory {

public static final Codec<Memory> CODEC = RecordCodecBuilder.create(instance ->
instance.group(
ItemStack.OPTIONAL_CODEC.listOf().fieldOf("items")
.forGetter(Memory::fullItems),
ItemStack.CODEC.listOf().fieldOf("items")
.forGetter(Memory::items),
ComponentSerialization.CODEC.optionalFieldOf("name")
.forGetter(m -> Optional.ofNullable(m.name)),
ModCodecs.BLOCK_POS_STRING.listOf().optionalFieldOf("otherPositions", Collections.emptyList())
Expand All @@ -61,7 +61,6 @@ public final class Memory {
)));


private final List<ItemStack> fullItems;
private final List<ItemStack> items;
private final @Nullable Component name;
private final List<BlockPos> otherPositions;
Expand Down Expand Up @@ -89,10 +88,6 @@ public List<ItemStack> items() {
return items;
}

public List<ItemStack> fullItems() {
return fullItems;
}

/**
* <p>The display name for this memory. This is usually obtained from renaming in an anvil, but can also be manually
* edited by the user. This method should be used if the user is seeing this name, as it considers the user-supplied
Expand Down Expand Up @@ -147,12 +142,13 @@ public List<BlockPos> otherPositions() {
}

/**
* Helper method for returning the center position of a memory, factoring in it's other positions.
* Helper method for returning the center position of a memory, including it's other positions.
*
* @param origin Central position of this memory.
* @return A position in the world regarded as the 'center'.
*/
public Vec3 getCenterPosition() {
return Misc.getAverageOffsetFrom(this.position, this.otherPositions()).add(this.position.getCenter());
public Vec3 getCenterPosition(BlockPos origin) {
return Misc.getAverageOffsetFrom(origin, this.otherPositions()).add(origin.getCenter());
}

/**
Expand Down Expand Up @@ -200,7 +196,6 @@ public Instant realTimestamp() {

@ApiStatus.Internal
private MemoryKeyImpl memoryKey = null;
@ApiStatus.Internal
private BlockPos position = null;

@ApiStatus.Internal
Expand All @@ -212,8 +207,7 @@ public Memory(
long loadedTimestamp,
long inGameTimestamp,
Instant realTimestamp) {
this.fullItems = ImmutableList.copyOf(items);
this.items = this.fullItems.stream().filter(stack -> !stack.isEmpty()).toList();
this.items = ImmutableList.copyOf(items);
this.name = name;
this.otherPositions = ImmutableList.copyOf(otherPositions);
this.loadedTimestamp = loadedTimestamp;
Expand Down
24 changes: 5 additions & 19 deletions src/client/java/red/jackf/chesttracker/api/memory/MemoryBank.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import red.jackf.chesttracker.api.providers.ProviderUtils;
import red.jackf.chesttracker.impl.util.CachedClientBlockSource;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.*;

/**
* Interface for working with a loaded memory bank.
Expand Down Expand Up @@ -116,30 +113,19 @@ default Optional<MemoryKey> getKey(Optional<ResourceLocation> keyId) {
}

/**
* <p>Helper method for getting a count of items in a given memory key matching a given predicate.</p>
*
* <p>This version does not unpack nested items.</p>
* Helper method for getting a count of items in a given memory key matching a given predicate.
*
* @param keyId Memory key to look in; if non-existent an empty list will be returned.
* @param predicate Predicate to filter each memory against.
* @param stackMergeMode How to merge stacks in the returned list - for more details, see {@link StackMergeMode}
* @return A list of stacks from all memories in the given key matching the predicate, merged according to <code>stackMergeMode</code>.
*/
default List<ItemStack> getCounts(ResourceLocation keyId, CountingPredicate predicate, StackMergeMode stackMergeMode) {
return getCounts(keyId, predicate, stackMergeMode, false);
Optional<MemoryKey> key = this.getKey(keyId);
if (key.isEmpty()) return Collections.emptyList();
return key.get().getCounts(predicate, stackMergeMode);
}

/**
* Helper method for getting a count of items in a given memory key matching a given predicate.
*
* @param keyId Memory key to look in; if non-existent an empty list will be returned.
* @param predicate Predicate to filter each memory against.
* @param stackMergeMode How to merge stacks in the returned list - for more details, see {@link StackMergeMode}
* @param unpackNested Whether to unpack nested items from within Shulker Boxes or bundles.
* @return A list of stacks from all memories in the given key matching the predicate, merged according to <code>stackMergeMode</code>.
*/
List<ItemStack> getCounts(ResourceLocation keyId, CountingPredicate predicate, StackMergeMode stackMergeMode, boolean unpackNested);

/**
* Adds or updates a memory in this memory bank.
*
Expand Down
18 changes: 1 addition & 17 deletions src/client/java/red/jackf/chesttracker/api/memory/MemoryKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,14 @@ public interface MemoryKey {
*/
Optional<Memory> get(BlockPos position);

/**
* <p>Returns a list of all memories in this key that match the given predicate.</p>
*
* <p>This overload defaults to not unpacking nested items.</p>
*
* @see CountingPredicate
* @see StackMergeMode
* @param predicate Predicate to test each memory against - this tests the in-key block position and memory itself.
* @param stackMergeMode How to merge stacks that pass the predicate - for more details, see {@link StackMergeMode}.
* @return A list of ItemStacks that pass the predicate in this memory key, merged according to stackMergeMode.
*/
default List<ItemStack> getCounts(CountingPredicate predicate, StackMergeMode stackMergeMode) {
return getCounts(predicate, stackMergeMode, false);
}

/**
* Returns a list of all memories in this key that match the given predicate.
*
* @see CountingPredicate
* @see StackMergeMode
* @param predicate Predicate to test each memory against - this tests the in-key block position and memory itself.
* @param stackMergeMode How to merge stacks that pass the predicate - for more details, see {@link StackMergeMode}.
* @param unpackNested Whether to unpack any nested items, such as within shulker boxes.
* @return A list of ItemStacks that pass the predicate in this memory key, merged according to stackMergeMode.
*/
List<ItemStack> getCounts(CountingPredicate predicate, StackMergeMode stackMergeMode, boolean unpackNested);
List<ItemStack> getCounts(CountingPredicate predicate, StackMergeMode stackMergeMode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface MemoryBuilder {
* @return A new MemoryBuilder, containing the given items.
*/
static MemoryBuilder create(List<ItemStack> items) {
return new MemoryBuilderImpl(items.stream().toList());
return new MemoryBuilderImpl(items.stream().filter(stack -> !stack.isEmpty()).toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ public interface ScreenCloseContext {
*/
List<ItemStack> getItems();

/**
* <p>Returns all item stacks, including {@link ItemStack#isEmpty()} stacks. You should generally prefer other methods
* unless a full representation of the empty slots are useful, i.e. with ender chests.</p>
*
* <p>The list of items gets trimmed after the last non-empty slot in order to save space.</p>
* @return All ItemStacks in this screen, including empty ones.
*/
List<ItemStack> getItemsWithEmpty();

/**
* Returns all non-{@link ItemStack#isEmpty()}, non-player inventory stacks in the slots of this screen matching the given predicate.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public boolean appliesTo(Coordinate coordinate) {

@Override
public void onScreenOpen(ScreenOpenContext context) {
if (DefaultProviderScreenOpen.EVENT.invoker().handleScreenOpen(this, context)) return;

InteractionTracker.INSTANCE.getLastBlockSource()
.flatMap(this::getMemoryLocation)
.ifPresent(context::setMemoryLocation);
InteractionTracker.INSTANCE.getLastBlockSource().flatMap(this::getMemoryLocation).ifPresent(context::setMemoryLocation);
}

@Override
Expand All @@ -67,11 +63,6 @@ public void onScreenClose(ScreenCloseContext context) {
});
}

@Override
public void onCommandSent(String command) {
DefaultProviderCommandSent.EVENT.invoker().onDefaultCommandSend(this, command);
}

@Override
public void onBlockPlaced(BlockPlacedContext context) {
// if the block has an alternate mapping (i.e. ender chest) don't run
Expand Down

This file was deleted.

This file was deleted.

Loading