Skip to content

Commit

Permalink
feat: storage blocks gametest
Browse files Browse the repository at this point in the history
  • Loading branch information
starforcraft committed Dec 14, 2024
1 parent 6ad6d0d commit 365f3c6
Show file tree
Hide file tree
Showing 9 changed files with 716 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.refinedmods.refinedstorage.api.network.impl.node.AbstractStorageContainerNetworkNode;
import com.refinedmods.refinedstorage.api.network.impl.node.storage.StorageNetworkNode;
import com.refinedmods.refinedstorage.api.resource.ResourceKey;
import com.refinedmods.refinedstorage.api.resource.filter.FilterMode;
import com.refinedmods.refinedstorage.api.storage.AccessMode;
import com.refinedmods.refinedstorage.api.storage.Storage;
import com.refinedmods.refinedstorage.common.api.RefinedStorageApi;
import com.refinedmods.refinedstorage.common.api.storage.SerializableStorage;
Expand All @@ -18,6 +21,7 @@
import com.refinedmods.refinedstorage.common.support.resource.ResourceContainerImpl;

import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -57,7 +61,7 @@ public StorageBlockBlockEntity(final BlockPos pos,
this.filter = FilterWithFuzzyMode.createAndListenForUniqueFilters(
ResourceContainerImpl.createForFilter(provider.getResourceFactory()),
this::setChanged,
mainNetworkNode.getStorageConfiguration()::setFilters
this::setFilters
);
this.configContainer = new StorageConfigurationContainerImpl(
mainNetworkNode.getStorageConfiguration(),
Expand Down Expand Up @@ -144,6 +148,27 @@ private void tryRemoveCurrentStorage(final UUID newStorageId) {
);
}

void setFilters(final Set<ResourceKey> filters) {
mainNetworkNode.getStorageConfiguration().setFilters(filters);
}

void setFilterMode(final FilterMode mode) {
mainNetworkNode.getStorageConfiguration().setFilterMode(mode);
setChanged();
}

void setFuzzyMode(final boolean fuzzyMode) {
filter.setFuzzyMode(fuzzyMode);
}

void setAccessMode(final AccessMode accessMode) {
mainNetworkNode.getStorageConfiguration().setAccessMode(accessMode);
}

void setVoidExcess(final boolean voidExcess) {
mainNetworkNode.getStorageConfiguration().setVoidExcess(voidExcess);
}

@Override
@Nullable
public UUID getStorageId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static com.refinedmods.refinedstorage.common.GameTestUtil.insert;
import static com.refinedmods.refinedstorage.common.GameTestUtil.networkIsAvailable;
import static com.refinedmods.refinedstorage.common.GameTestUtil.storageContainsExactly;
import static com.refinedmods.refinedstorage.common.constructordestructor.ConstructorTestPlots.preparePlot;
import static net.minecraft.world.item.Items.DIRT;
import static net.minecraft.world.item.Items.FIREWORK_ROCKET;
import static net.minecraft.world.item.Items.STONE;
Expand All @@ -35,7 +36,7 @@ private ConstructorTest() {

@GameTest(template = "empty_15x15")
public static void shouldPlaceBlock(final GameTestHelper helper) {
ConstructorTestPlots.preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand All @@ -60,7 +61,7 @@ public static void shouldPlaceBlock(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldPlaceWater(final GameTestHelper helper) {
ConstructorTestPlots.preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand All @@ -87,7 +88,7 @@ public static void shouldPlaceWater(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldDropItem(final GameTestHelper helper) {
ConstructorTestPlots.preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down Expand Up @@ -119,7 +120,7 @@ public static void shouldDropItem(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldDropItemWithStackUpgrade(final GameTestHelper helper) {
ConstructorTestPlots.preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 65);
Expand Down Expand Up @@ -159,7 +160,7 @@ public static void shouldDropItemWithStackUpgrade(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldPlaceFireworks(final GameTestHelper helper) {
ConstructorTestPlots.preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.refinedmods.refinedstorage.common.GameTestUtil.insert;
import static com.refinedmods.refinedstorage.common.GameTestUtil.networkIsAvailable;
import static com.refinedmods.refinedstorage.common.GameTestUtil.storageContainsExactly;
import static com.refinedmods.refinedstorage.common.constructordestructor.DestructorTestPlots.preparePlot;
import static net.minecraft.world.item.Items.DIAMOND;
import static net.minecraft.world.item.Items.DIAMOND_ORE;
import static net.minecraft.world.item.Items.DIRT;
Expand All @@ -34,7 +35,7 @@ private DestructorTest() {

@GameTest(template = "empty_15x15")
public static void shouldBreakBlock(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down Expand Up @@ -68,7 +69,7 @@ public static void shouldBreakBlock(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldBreakBlockAllowlist(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down Expand Up @@ -99,7 +100,7 @@ public static void shouldBreakBlockAllowlist(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldBreakBlockBlocklist(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down Expand Up @@ -130,7 +131,7 @@ public static void shouldBreakBlockBlocklist(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldBreakBlockWithSilkTouchUpgrade(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand All @@ -157,7 +158,7 @@ public static void shouldBreakBlockWithSilkTouchUpgrade(final GameTestHelper hel

@GameTest(template = "empty_15x15")
public static void shouldPickupItemAllowlist(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down Expand Up @@ -189,7 +190,7 @@ public static void shouldPickupItemAllowlist(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldPickupItemBlocklist(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down Expand Up @@ -221,7 +222,7 @@ public static void shouldPickupItemBlocklist(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldDrainFluidAllowlist(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down Expand Up @@ -253,7 +254,7 @@ public static void shouldDrainFluidAllowlist(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldDrainFluidBlocklist(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static com.refinedmods.refinedstorage.common.GameTestUtil.RSBLOCKS;
import static com.refinedmods.refinedstorage.common.GameTestUtil.energyStoredExactly;
import static com.refinedmods.refinedstorage.common.GameTestUtil.networkIsAvailable;
import static com.refinedmods.refinedstorage.common.controller.ControllerTestPlots.preparePlot;

@GameTestHolder(IdentifierUtil.MOD_ID)
@PrefixGameTestTemplate(false)
Expand All @@ -22,7 +23,7 @@ private ControllerTest() {

@GameTest(template = "empty_15x15")
public static void shouldConsumeEnergy(final GameTestHelper helper) {
ControllerTestPlots.preparePlot(helper, false, (controller, pos, sequence) -> {
preparePlot(helper, false, (controller, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
}));
Expand Down Expand Up @@ -52,7 +53,7 @@ public static void shouldConsumeEnergy(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldNotConsumeEnergy(final GameTestHelper helper) {
ControllerTestPlots.preparePlot(helper, true, (controller, pos, sequence) -> {
preparePlot(helper, true, (controller, pos, sequence) -> {
// Arrange
final EnergyStorage energyStorage = controller.getEnergyStorage();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static com.refinedmods.refinedstorage.common.GameTestUtil.interfaceContainsExactly;
import static com.refinedmods.refinedstorage.common.GameTestUtil.networkIsAvailable;
import static com.refinedmods.refinedstorage.common.GameTestUtil.storageContainsExactly;
import static com.refinedmods.refinedstorage.common.exporter.ExporterTestPlots.preparePlot;
import static net.minecraft.world.item.Items.DIAMOND_CHESTPLATE;
import static net.minecraft.world.item.Items.DIRT;
import static net.minecraft.world.item.Items.STONE;
Expand All @@ -38,7 +39,7 @@ private ExporterTest() {

@GameTest(template = "empty_15x15")
public static void shouldExportItem(final GameTestHelper helper) {
ExporterTestPlots.preparePlot(helper, Blocks.CHEST, Direction.EAST, (exporter, pos, sequence) -> {
preparePlot(helper, Blocks.CHEST, Direction.EAST, (exporter, pos, sequence) -> {
// Arrange
final ItemStack damagedDiamondChestplate = getItemAsDamaged(DIAMOND_CHESTPLATE.getDefaultInstance(), 500);

Expand Down Expand Up @@ -71,7 +72,7 @@ public static void shouldExportItem(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldExportItemWithStackUpgrade(final GameTestHelper helper) {
ExporterTestPlots.preparePlot(helper, Blocks.CHEST, Direction.EAST, (exporter, pos, sequence) -> {
preparePlot(helper, Blocks.CHEST, Direction.EAST, (exporter, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 65);
Expand Down Expand Up @@ -115,7 +116,7 @@ public static void shouldExportItemWithStackUpgrade(final GameTestHelper helper)

@GameTest(template = "empty_15x15")
public static void shouldExportItemWithRegulatorUpgrade(final GameTestHelper helper) {
ExporterTestPlots.preparePlot(helper, Blocks.CHEST, Direction.EAST, (exporter, pos, sequence) -> {
preparePlot(helper, Blocks.CHEST, Direction.EAST, (exporter, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 15);
Expand Down Expand Up @@ -151,7 +152,7 @@ public static void shouldExportItemWithRegulatorUpgrade(final GameTestHelper hel

@GameTest(template = "empty_15x15")
public static void shouldExportItemFuzzy(final GameTestHelper helper) {
ExporterTestPlots.preparePlot(helper, Blocks.CHEST, Direction.EAST, (exporter, pos, sequence) -> {
preparePlot(helper, Blocks.CHEST, Direction.EAST, (exporter, pos, sequence) -> {
// Arrange
final ItemStack damagedDiamondChestplate = getItemAsDamaged(DIAMOND_CHESTPLATE.getDefaultInstance(), 500);

Expand Down Expand Up @@ -186,7 +187,7 @@ public static void shouldExportItemFuzzy(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldExportFluid(final GameTestHelper helper) {
ExporterTestPlots.preparePlot(helper, Blocks.CAULDRON, Direction.EAST, (exporter, pos, sequence) -> {
preparePlot(helper, Blocks.CAULDRON, Direction.EAST, (exporter, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down Expand Up @@ -214,7 +215,7 @@ public static void shouldExportFluid(final GameTestHelper helper) {

@GameTest(template = "empty_15x15")
public static void shouldExportFluidWithStackUpgrade(final GameTestHelper helper) {
ExporterTestPlots.preparePlot(helper, RSBLOCKS.getInterface(), Direction.EAST, (exporter, pos, sequence) -> {
preparePlot(helper, RSBLOCKS.getInterface(), Direction.EAST, (exporter, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
Expand Down
Loading

0 comments on commit 365f3c6

Please sign in to comment.