diff --git a/refinedstorage-autocrafting-api/src/main/java/com/refinedmods/refinedstorage/api/autocrafting/status/TaskStatusProvider.java b/refinedstorage-autocrafting-api/src/main/java/com/refinedmods/refinedstorage/api/autocrafting/status/TaskStatusProvider.java index 8fbc08337..a74424707 100644 --- a/refinedstorage-autocrafting-api/src/main/java/com/refinedmods/refinedstorage/api/autocrafting/status/TaskStatusProvider.java +++ b/refinedstorage-autocrafting-api/src/main/java/com/refinedmods/refinedstorage/api/autocrafting/status/TaskStatusProvider.java @@ -17,6 +17,4 @@ public interface TaskStatusProvider { void cancel(TaskId taskId); void cancelAll(); - - void testUpdate(); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AbstractAutocraftingMonitorContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AbstractAutocraftingMonitorContainerMenu.java index 88fc8fe48..e9cec21a1 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AbstractAutocraftingMonitorContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AbstractAutocraftingMonitorContainerMenu.java @@ -74,14 +74,6 @@ public void removed(final Player removedPlayer) { } } - @Override - public void broadcastChanges() { - super.broadcastChanges(); - if (autocraftingMonitor != null) { - autocraftingMonitor.testUpdate(); - } - } - void setListener(@Nullable final AutocraftingMonitorListener listener) { this.listener = listener; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorBlockEntity.java index 402e57252..369e610d6 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorBlockEntity.java @@ -103,11 +103,6 @@ public void cancelAll() { getAutocrafting().ifPresent(AutocraftingNetworkComponent::cancelAll); } - @Override - public void testUpdate() { - getAutocrafting().ifPresent(AutocraftingNetworkComponent::testUpdate); - } - @Override public void addWatcher(final AutocraftingMonitorWatcher watcher) { watchers.add(watcher); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/TaskStatusProviderImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/TaskStatusProviderImpl.java index 76aeb33fc..a28133d41 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/TaskStatusProviderImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/TaskStatusProviderImpl.java @@ -4,33 +4,16 @@ import com.refinedmods.refinedstorage.api.autocrafting.status.TaskStatus; import com.refinedmods.refinedstorage.api.autocrafting.status.TaskStatusListener; import com.refinedmods.refinedstorage.api.autocrafting.status.TaskStatusProvider; -import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Random; import java.util.Set; -import java.util.UUID; - -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; public class TaskStatusProviderImpl implements TaskStatusProvider { - private static final Item[] ITEM_SET = new Item[] { - Items.DIRT, - Items.DIAMOND, - Items.GOLD_INGOT, - Items.ACACIA_WOOD, - Items.BEEHIVE - }; - private final List statuses = new ArrayList<>(); private final Set listeners = new HashSet<>(); - private final Random r = new Random(); - private int ticks; @Override public List getStatuses() { @@ -65,58 +48,4 @@ public void cancelAll() { statuses.clear(); copy.forEach(s -> listeners.forEach(l -> l.taskRemoved(s.info().id()))); } - - @Override - public void testUpdate() { - if (ticks++ % 10 != 0) { - return; - } - final int chance = r.nextInt(100); - if (chance < 50 && statuses.size() < 100) { - final TaskStatus status = generateTaskStatus(); - statuses.add(status); - listeners.forEach(l -> l.taskAdded(status)); - } else if (chance < 85 && !statuses.isEmpty()) { - final int idx = r.nextInt(statuses.size()); - final TaskStatus status = statuses.get(idx); - final TaskStatus updated = new TaskStatus( - status.info(), - r.nextFloat(), - generateTaskStatus().items() - ); - statuses.set(idx, updated); - listeners.forEach(l -> l.taskStatusChanged(updated)); - } else if (chance > 85 && !statuses.isEmpty()) { - final int idx = r.nextInt(statuses.size()); - final TaskStatus status = statuses.remove(idx); - listeners.forEach(l -> l.taskRemoved(status.info().id())); - } - } - - private TaskStatus generateTaskStatus() { - final TaskStatus.TaskInfo taskInfo = new TaskStatus.TaskInfo( - new TaskId(UUID.randomUUID()), - ItemResource.ofItemStack(new ItemStack(ITEM_SET[r.nextInt(ITEM_SET.length)])), - 5 + r.nextLong(32), - System.currentTimeMillis() - ); - final float pct = r.nextFloat(); - final List items = new ArrayList<>(); - for (int i = 0; i < 3 + r.nextInt(30); i++) { - final int typeIdx = r.nextInt(TaskStatus.ItemType.values().length); - final TaskStatus.ItemType type = TaskStatus.ItemType.values()[typeIdx]; - final int idx = r.nextInt(5); - final int amount = 2 + r.nextInt(20); - items.add(new TaskStatus.Item( - type, - ItemResource.ofItemStack(new ItemStack(ITEM_SET[r.nextInt(ITEM_SET.length)])), - idx == 0 ? amount : 0, - idx == 1 ? amount : 0, - idx == 2 ? amount : 0, - idx == 3 ? amount : 0, - idx == 4 ? amount : 0 - )); - } - return new TaskStatus(taskInfo, pct, items); - } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/WirelessAutocraftingMonitor.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/WirelessAutocraftingMonitor.java index 7fea8c646..d5cd17058 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/WirelessAutocraftingMonitor.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/WirelessAutocraftingMonitor.java @@ -73,9 +73,4 @@ public void cancelAll() { ); }); } - - @Override - public void testUpdate() { - getAutocrafting().ifPresent(AutocraftingNetworkComponent::testUpdate); - } } diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/autocrafting/AutocraftingNetworkComponentImpl.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/autocrafting/AutocraftingNetworkComponentImpl.java index 16033048b..d4207107e 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/autocrafting/AutocraftingNetworkComponentImpl.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/autocrafting/AutocraftingNetworkComponentImpl.java @@ -145,11 +145,6 @@ public void cancelAll() { taskStatusProvider.cancelAll(); } - @Override - public void testUpdate() { - taskStatusProvider.testUpdate(); - } - private class ParentContainerImpl implements ParentContainer { @Override public void add(final Pattern pattern, final int priority) { diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/autocrafting/AutocraftingNetworkComponentImplTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/autocrafting/AutocraftingNetworkComponentImplTest.java index 427414b5c..58b2470ca 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/autocrafting/AutocraftingNetworkComponentImplTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/autocrafting/AutocraftingNetworkComponentImplTest.java @@ -88,7 +88,6 @@ public void taskAdded(final TaskStatus status) { sut.getStatuses(); sut.cancel(new TaskId(UUID.randomUUID())); sut.cancelAll(); - sut.testUpdate(); } @Test