Skip to content

Commit

Permalink
feat: autocrafting monitor from the server
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Nov 16, 2024
1 parent c59a526 commit b4a185c
Show file tree
Hide file tree
Showing 45 changed files with 924 additions and 598 deletions.
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
Expand Up @@ -5,5 +5,5 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.9")
public record AutocraftingPreview(AutocraftingPreviewType type, List<AutocraftingPreviewItem> items) {
public record Preview(PreviewType type, List<PreviewItem> items) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.9")
public record AutocraftingPreviewItem(ResourceKey resource, long available, long missing, long toCraft) {
public record PreviewItem(ResourceKey resource, long available, long missing, long toCraft) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.9")
public interface AutocraftingPreviewProvider {
Optional<AutocraftingPreview> getPreview(ResourceKey resource, long amount);
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
Expand Up @@ -3,7 +3,7 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.9")
public enum AutocraftingPreviewType {
public enum PreviewType {
SUCCESS,
MISSING_RESOURCES
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
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 java.util.UUID;

import org.apiguardian.api.API;

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

public record Element(
ElementType type,
public record Item(
ItemType type,
ResourceKey resource,
long stored,
long missing,
Expand All @@ -23,7 +23,7 @@ public record Element(
) {
}

public enum ElementType {
public enum ItemType {
NORMAL,
MACHINE_DOES_NOT_ACCEPT_RESOURCE,
NO_MACHINE_FOUND,
Expand Down
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
@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage.common.api.grid;

import com.refinedmods.refinedstorage.api.autocrafting.preview.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
Expand Up @@ -821,7 +821,7 @@ protected final void registerMenus(final RegistryCallback<MenuType<?>> callback,
Menus.INSTANCE.setAutocraftingMonitor(callback.register(
ContentIds.AUTOCRAFTING_MONITOR,
() -> extendedMenuTypeFactory.create(
(syncId, player, data) -> new AutocraftingMonitorContainerMenu(syncId, data),
AutocraftingMonitorContainerMenu::new,
AutocraftingMonitorData.STREAM_CODEC
)
));
Expand Down
Loading

0 comments on commit b4a185c

Please sign in to comment.