Skip to content

Commit

Permalink
Merge pull request #718 from refinedmods/feat/GH-102/autocrafting-mon…
Browse files Browse the repository at this point in the history
…itor

Autocrafting monitor
  • Loading branch information
raoulvdberge authored Nov 16, 2024
2 parents 2b058ba + b74c948 commit e89b4bd
Show file tree
Hide file tree
Showing 213 changed files with 5,405 additions and 137 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Autocrafting Monitor

### Changed

- The Autocrafting Monitor now has a sidebar with all tasks instead of using tabs.

## [2.0.0-milestone.4.9] - 2024-11-01

### Added
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.refinedmods.refinedstorage.api.autocrafting;

import java.util.UUID;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.10")
public record TaskId(UUID id) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.refinedmods.refinedstorage.api.autocrafting.preview;

import java.util.List;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.9")
public record Preview(PreviewType type, List<PreviewItem> items) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.refinedmods.refinedstorage.api.autocrafting.preview;

import com.refinedmods.refinedstorage.api.resource.ResourceKey;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.9")
public record PreviewItem(ResourceKey resource, long available, long missing, long toCraft) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.refinedmods.refinedstorage.api.autocrafting.preview;

import com.refinedmods.refinedstorage.api.resource.ResourceKey;

import java.util.Optional;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.9")
public interface PreviewProvider {
Optional<Preview> getPreview(ResourceKey resource, long amount);

boolean startTask(ResourceKey resource, long amount);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.refinedmods.refinedstorage.api.autocrafting.preview;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.9")
public enum PreviewType {
SUCCESS,
MISSING_RESOURCES
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@FieldsAndMethodsAreNonnullByDefault
package com.refinedmods.refinedstorage.api.autocrafting.preview;

import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.refinedmods.refinedstorage.api.autocrafting.status;

import com.refinedmods.refinedstorage.api.autocrafting.TaskId;
import com.refinedmods.refinedstorage.api.resource.ResourceKey;

import java.util.List;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.10")
public record TaskStatus(TaskInfo info, float percentageCompleted, List<Item> items) {
public record TaskInfo(TaskId id, ResourceKey resource, long amount, long startTime) {
}

public record Item(
ItemType type,
ResourceKey resource,
long stored,
long missing,
long processing,
long scheduled,
long crafting
) {
}

public enum ItemType {
NORMAL,
MACHINE_DOES_NOT_ACCEPT_RESOURCE,
NO_MACHINE_FOUND,
AUTOCRAFTER_IS_LOCKED
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.refinedmods.refinedstorage.api.autocrafting.status;

import com.refinedmods.refinedstorage.api.autocrafting.TaskId;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.10")
public interface TaskStatusListener {
void taskStatusChanged(TaskStatus status);

void taskRemoved(TaskId id);

void taskAdded(TaskStatus status);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.refinedmods.refinedstorage.api.autocrafting.status;

import com.refinedmods.refinedstorage.api.autocrafting.TaskId;

import java.util.List;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.10")
public interface TaskStatusProvider {
List<TaskStatus> getStatuses();

void addListener(TaskStatusListener listener);

void removeListener(TaskStatusListener listener);

void cancel(TaskId taskId);

void cancelAll();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@FieldsAndMethodsAreNonnullByDefault
package com.refinedmods.refinedstorage.api.autocrafting.status;

import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.refinedmods.refinedstorage.api.resource.ResourceKey;

enum ResourceFixtures implements ResourceKey {
public enum ResourceFixtures implements ResourceKey {
A,
B,
C
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.refinedmods.refinedstorage.api.autocrafting.status;

import com.refinedmods.refinedstorage.api.autocrafting.ResourceFixtures;
import com.refinedmods.refinedstorage.api.autocrafting.TaskId;

import java.util.List;
import java.util.UUID;

import org.junit.jupiter.api.Test;

public class TaskStatusTest {
@Test
void dummyTest() {
new TaskStatus(
new TaskStatus.TaskInfo(
new TaskId(UUID.randomUUID()),
ResourceFixtures.A,
0,
0
),
0.69F,
List.of(
new TaskStatus.Item(
TaskStatus.ItemType.NORMAL,
ResourceFixtures.A,
0,
0,
0,
0,
0
)
)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@FieldsAndMethodsAreNonnullByDefault
package com.refinedmods.refinedstorage.api.autocrafting.status;

import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.common.api.grid;

import com.refinedmods.refinedstorage.api.autocrafting.AutocraftingPreviewProvider;
import com.refinedmods.refinedstorage.api.autocrafting.preview.PreviewProvider;
import com.refinedmods.refinedstorage.api.grid.operations.GridOperations;
import com.refinedmods.refinedstorage.api.grid.watcher.GridWatcher;
import com.refinedmods.refinedstorage.api.storage.Actor;
Expand All @@ -16,7 +16,7 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.0")
public interface Grid extends AutocraftingPreviewProvider {
public interface Grid extends PreviewProvider {
void addWatcher(GridWatcher watcher, Class<? extends Actor> actorType);

void removeWatcher(GridWatcher watcher);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"variants": {
"active=false,direction=down_east": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"x": 90,
"y": -90
},
"active=false,direction=down_north": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"x": 90
},
"active=false,direction=down_south": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"x": 90,
"y": 180
},
"active=false,direction=down_west": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"x": 90,
"y": 90
},
"active=false,direction=east": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"y": 90
},
"active=false,direction=north": {
"model": "refinedstorage:block/autocrafting_monitor/inactive"
},
"active=false,direction=south": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"y": 180
},
"active=false,direction=up_east": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"x": -90,
"y": -90
},
"active=false,direction=up_north": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"x": -90,
"y": 180
},
"active=false,direction=up_south": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"x": -90
},
"active=false,direction=up_west": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"x": -90,
"y": 90
},
"active=false,direction=west": {
"model": "refinedstorage:block/autocrafting_monitor/inactive",
"y": 270
},
"active=true,direction=down_east": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"x": 90,
"y": -90
},
"active=true,direction=down_north": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"x": 90
},
"active=true,direction=down_south": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"x": 90,
"y": 180
},
"active=true,direction=down_west": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"x": 90,
"y": 90
},
"active=true,direction=east": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"y": 90
},
"active=true,direction=north": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue"
},
"active=true,direction=south": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"y": 180
},
"active=true,direction=up_east": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"x": -90,
"y": -90
},
"active=true,direction=up_north": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"x": -90,
"y": 180
},
"active=true,direction=up_south": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"x": -90
},
"active=true,direction=up_west": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"x": -90,
"y": 90
},
"active=true,direction=west": {
"model": "refinedstorage:block/autocrafting_monitor/light_blue",
"y": 270
}
}
}
Loading

0 comments on commit e89b4bd

Please sign in to comment.