-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: autocrafting monitor now delegates to network
- Loading branch information
1 parent
3a5b99b
commit 6818308
Showing
15 changed files
with
190 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,6 @@ public interface TaskStatusProvider { | |
void cancel(TaskId taskId); | ||
|
||
void cancelAll(); | ||
|
||
void testUpdate(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
.../java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.refinedmods.refinedstorage.common.autocrafting.monitor; | ||
|
||
import com.refinedmods.refinedstorage.api.autocrafting.status.TaskStatusProvider; | ||
|
||
interface AutocraftingMonitor extends TaskStatusProvider { | ||
void addWatcher(AutocraftingMonitorWatcher watcher); | ||
|
||
void removeWatcher(AutocraftingMonitorWatcher watcher); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 1 addition & 19 deletions
20
...inedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorContainerMenu.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,30 @@ | ||
package com.refinedmods.refinedstorage.common.autocrafting.monitor; | ||
|
||
import com.refinedmods.refinedstorage.api.autocrafting.status.TaskStatusProvider; | ||
import com.refinedmods.refinedstorage.common.content.Menus; | ||
import com.refinedmods.refinedstorage.common.support.RedstoneMode; | ||
import com.refinedmods.refinedstorage.common.support.containermenu.ClientProperty; | ||
import com.refinedmods.refinedstorage.common.support.containermenu.PropertyTypes; | ||
import com.refinedmods.refinedstorage.common.support.containermenu.ServerProperty; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class AutocraftingMonitorContainerMenu extends AbstractAutocraftingMonitorContainerMenu { | ||
@Nullable | ||
private final AutocraftingMonitorBlockEntity autocraftingMonitor; | ||
|
||
public AutocraftingMonitorContainerMenu(final int syncId, | ||
final Inventory playerInventory, | ||
final AutocraftingMonitorData data) { | ||
super(Menus.INSTANCE.getAutocraftingMonitor(), syncId, playerInventory, data); | ||
registerProperty(new ClientProperty<>(PropertyTypes.REDSTONE_MODE, RedstoneMode.IGNORE)); | ||
this.autocraftingMonitor = null; | ||
} | ||
|
||
AutocraftingMonitorContainerMenu(final int syncId, | ||
final Player player, | ||
final TaskStatusProvider taskStatusProvider, | ||
final AutocraftingMonitorBlockEntity autocraftingMonitor) { | ||
super(Menus.INSTANCE.getAutocraftingMonitor(), syncId, player, taskStatusProvider); | ||
super(Menus.INSTANCE.getAutocraftingMonitor(), syncId, player, autocraftingMonitor); | ||
registerProperty(new ServerProperty<>( | ||
PropertyTypes.REDSTONE_MODE, | ||
autocraftingMonitor::getRedstoneMode, | ||
autocraftingMonitor::setRedstoneMode | ||
)); | ||
this.autocraftingMonitor = autocraftingMonitor; | ||
autocraftingMonitor.addWatcher(this); | ||
} | ||
|
||
@Override | ||
public void removed(final Player removedPlayer) { | ||
super.removed(removedPlayer); | ||
if (autocraftingMonitor != null) { | ||
autocraftingMonitor.removeWatcher(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...om/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorWatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.refinedmods.refinedstorage.common.autocrafting.monitor; | ||
|
||
@FunctionalInterface | ||
interface AutocraftingMonitorWatcher { | ||
public interface AutocraftingMonitorWatcher { | ||
void activeChanged(boolean active); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.