Skip to content

Commit

Permalink
feat: relay gametest
Browse files Browse the repository at this point in the history
  • Loading branch information
starforcraft committed Dec 11, 2024
1 parent 102ae60 commit 070ff51
Show file tree
Hide file tree
Showing 5 changed files with 511 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public RelayBlockEntity(final BlockPos pos, final BlockState state) {
this.filter = FilterWithFuzzyMode.createAndListenForUniqueFilters(
ResourceContainerImpl.createForFilter(),
this::setChanged,
this::filterContainerChanged
this::setFilters
);
this.mainNetworkNode.setFilterNormalizer(filter.createNormalizer());
this.containers.addContainer(
Expand All @@ -98,7 +98,7 @@ void setFuzzyMode(final boolean fuzzyMode) {
mainNetworkNode.setActive(wasActive);
}

private void filterContainerChanged(final Set<ResourceKey> filters) {
void setFilters(final Set<ResourceKey> filters) {
mainNetworkNode.setFilters(filters);
setChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected InWorldNetworkNodeContainer createMainContainer(final T networkNode) {
.build();
}

protected boolean calculateActive() {
public boolean calculateActive() {
final long energyUsage = mainNetworkNode.getEnergyUsage();
final boolean hasLevel = level != null && level.isLoaded(worldPosition);
final boolean redstoneModeActive = !hasRedstoneMode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.refinedmods.refinedstorage.common.content.Items;
import com.refinedmods.refinedstorage.common.iface.ExportedResourcesContainer;
import com.refinedmods.refinedstorage.common.iface.InterfaceBlockEntity;
import com.refinedmods.refinedstorage.common.support.network.AbstractBaseNetworkNodeContainerBlockEntity;
import com.refinedmods.refinedstorage.common.support.resource.FluidResource;
import com.refinedmods.refinedstorage.common.support.resource.ItemResource;

Expand Down Expand Up @@ -70,6 +71,19 @@ public static Runnable networkIsAvailable(final GameTestHelper helper,
};
}

public static void checkBlockEntityActiveness(final GameTestHelper helper,
final BlockPos pos,
final boolean expectedActive) {
final var blockEntity = requireBlockEntity(
helper,
pos,
AbstractBaseNetworkNodeContainerBlockEntity.class
);
final boolean actualActive = blockEntity.calculateActive();
helper.assertTrue(actualActive == expectedActive, "Activeness of Block Entity should be " + expectedActive
+ " but is " + actualActive);
}

public static void insert(final GameTestHelper helper,
final Network network,
final Item resource,
Expand Down
Loading

0 comments on commit 070ff51

Please sign in to comment.