diff --git a/CHANGELOG.md b/CHANGELOG.md index 50d7f0f8e..f4382ce1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Custom disk models. Fluid disks now have a different model. - Portable Grid +### Changed + +- The Portable Grid now shows an energy bar in the UI. + ## [2.0.0-milestone.3.2] - 2023-11-03 ### Added diff --git a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/configurationcard/ConfigurationCardTarget.java b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/configurationcard/ConfigurationCardTarget.java index 16500540f..e3f8c79d0 100644 --- a/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/configurationcard/ConfigurationCardTarget.java +++ b/refinedstorage2-platform-api/src/main/java/com/refinedmods/refinedstorage2/platform/api/configurationcard/ConfigurationCardTarget.java @@ -1,5 +1,6 @@ package com.refinedmods.refinedstorage2.platform.api.configurationcard; +import java.util.Collections; import java.util.List; import net.minecraft.nbt.CompoundTag; @@ -15,7 +16,11 @@ public interface ConfigurationCardTarget { void readConfiguration(CompoundTag tag); - List getUpgradeItems(); + default List getUpgradeItems() { + return Collections.emptyList(); + } - boolean addUpgradeItem(Item upgradeItem); + default boolean addUpgradeItem(Item upgradeItem) { + return false; + } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/controller/ControllerContainerMenu.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/controller/ControllerContainerMenu.java index dd6f8497a..9e2e29515 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/controller/ControllerContainerMenu.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/controller/ControllerContainerMenu.java @@ -1,56 +1,39 @@ package com.refinedmods.refinedstorage2.platform.common.controller; -import com.refinedmods.refinedstorage2.platform.common.Platform; import com.refinedmods.refinedstorage2.platform.common.content.Menus; import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseContainerMenu; import com.refinedmods.refinedstorage2.platform.common.support.RedstoneMode; import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ClientProperty; import com.refinedmods.refinedstorage2.platform.common.support.containermenu.PropertyTypes; import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ServerProperty; +import com.refinedmods.refinedstorage2.platform.common.support.energy.EnergyContainerMenu; +import com.refinedmods.refinedstorage2.platform.common.support.energy.EnergyInfo; -import javax.annotation.Nullable; - -import com.google.common.util.concurrent.RateLimiter; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; -public class ControllerContainerMenu extends AbstractBaseContainerMenu { - private final Player player; - private final RateLimiter energyUpdateRateLimiter = RateLimiter.create(4); - - private long stored; - private long capacity; - - @Nullable - private ControllerBlockEntity controller; +public class ControllerContainerMenu extends AbstractBaseContainerMenu implements EnergyContainerMenu { + private final EnergyInfo energyInfo; public ControllerContainerMenu(final int syncId, final Inventory playerInventory, final FriendlyByteBuf buf) { super(Menus.INSTANCE.getController(), syncId); - addPlayerInventory(playerInventory, 8, 107); - - this.stored = buf.readLong(); - this.capacity = buf.readLong(); - this.player = playerInventory.player; - + this.energyInfo = EnergyInfo.forClient(playerInventory.player, buf.readLong(), buf.readLong()); registerProperty(new ClientProperty<>(PropertyTypes.REDSTONE_MODE, RedstoneMode.IGNORE)); } ControllerContainerMenu(final int syncId, final Inventory playerInventory, final ControllerBlockEntity controller, - final Player playerEntity) { + final Player player) { super(Menus.INSTANCE.getController(), syncId); - - this.controller = controller; - this.stored = controller.getActualStored(); - this.capacity = controller.getActualCapacity(); - this.player = playerEntity; - + this.energyInfo = EnergyInfo.forServer( + player, + controller::getActualStored, + controller::getActualCapacity + ); addPlayerInventory(playerInventory, 8, 107); - registerProperty(new ServerProperty<>( PropertyTypes.REDSTONE_MODE, controller::getRedstoneMode, @@ -61,30 +44,11 @@ public ControllerContainerMenu(final int syncId, final Inventory playerInventory @Override public void broadcastChanges() { super.broadcastChanges(); - if (controller == null) { - return; - } - final boolean changed = stored != controller.getActualStored() || capacity != controller.getActualCapacity(); - if (changed && energyUpdateRateLimiter.tryAcquire()) { - setEnergyInfo(controller.getActualStored(), controller.getActualCapacity()); - Platform.INSTANCE.getServerToClientCommunications().sendControllerEnergyInfo( - (ServerPlayer) player, - stored, - capacity - ); - } - } - - public void setEnergyInfo(final long newStored, final long newCapacity) { - this.stored = newStored; - this.capacity = newCapacity; + energyInfo.detectChanges(); } - long getStored() { - return stored; - } - - long getCapacity() { - return capacity; + @Override + public EnergyInfo getEnergyInfo() { + return energyInfo; } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/controller/ControllerScreen.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/controller/ControllerScreen.java index 424a3624c..3bffb46c5 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/controller/ControllerScreen.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/controller/ControllerScreen.java @@ -5,39 +5,26 @@ import com.refinedmods.refinedstorage2.platform.common.support.widget.ProgressWidget; import com.refinedmods.refinedstorage2.platform.common.support.widget.RedstoneModeSideButtonWidget; -import java.util.Collections; -import java.util.List; +import javax.annotation.Nullable; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier; -import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createStoredWithCapacityTranslation; import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation; public class ControllerScreen extends AbstractBaseScreen { private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/controller.png"); - private final ProgressWidget progressWidget; + @Nullable + private ProgressWidget progressWidget; public ControllerScreen(final ControllerContainerMenu menu, final Inventory playerInventory, final Component text) { super(menu, playerInventory, text); - this.inventoryLabelY = 94; this.imageWidth = 176; this.imageHeight = 189; - - this.progressWidget = new ProgressWidget( - 80, - 20, - 16, - 70, - this::getPercentageFull, - this::createTooltip - ); - addRenderableWidget(progressWidget); } @Override @@ -47,28 +34,24 @@ protected void init() { getMenu().getProperty(PropertyTypes.REDSTONE_MODE), createTranslation("gui", "controller.redstone_mode_help") )); + if (progressWidget == null) { + progressWidget = new ProgressWidget( + leftPos + 80, + topPos + 20, + 16, + 70, + getMenu().getEnergyInfo()::getPercentageFull, + getMenu().getEnergyInfo()::createTooltip + ); + } else { + progressWidget.setX(leftPos + 80); + progressWidget.setY(topPos + 20); + } + addRenderableWidget(progressWidget); } @Override protected ResourceLocation getTexture() { return TEXTURE; } - - private double getPercentageFull() { - return (double) getMenu().getStored() / (double) getMenu().getCapacity(); - } - - private List createTooltip() { - return Collections.singletonList(createStoredWithCapacityTranslation( - getMenu().getStored(), - getMenu().getCapacity(), - getPercentageFull() - )); - } - - @Override - protected void renderLabels(final GuiGraphics graphics, final int mouseX, final int mouseY) { - super.renderLabels(graphics, mouseX, mouseY); - progressWidget.render(graphics, mouseX - leftPos, mouseY - topPos, 0); - } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/grid/GridExtendedMenuProvider.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/grid/GridExtendedMenuProvider.java index d4d1d9bc3..39d08e945 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/grid/GridExtendedMenuProvider.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/grid/GridExtendedMenuProvider.java @@ -39,6 +39,9 @@ public void writeScreenOpeningData(final ServerPlayer player, final FriendlyByte final List> types = storageChannelTypeRegistry.getAll(); buf.writeInt(types.size()); types.forEach(type -> writeStorageChannel(type, buf)); + if (menuProvider instanceof ExtendedMenuProvider extendedMenuProvider) { + extendedMenuProvider.writeScreenOpeningData(player, buf); + } } private void writeStorageChannel(final PlatformStorageChannelType storageChannelType, diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/AbstractPortableGridBlockEntity.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/AbstractPortableGridBlockEntity.java index b2da70424..455f2b0a6 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/AbstractPortableGridBlockEntity.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/AbstractPortableGridBlockEntity.java @@ -1,9 +1,11 @@ package com.refinedmods.refinedstorage2.platform.common.storage.portablegrid; +import com.refinedmods.refinedstorage2.api.core.Action; import com.refinedmods.refinedstorage2.api.grid.GridWatcher; import com.refinedmods.refinedstorage2.api.grid.operations.GridExtractMode; import com.refinedmods.refinedstorage2.api.grid.operations.GridInsertMode; import com.refinedmods.refinedstorage2.api.grid.operations.GridOperations; +import com.refinedmods.refinedstorage2.api.network.energy.EnergyStorage; import com.refinedmods.refinedstorage2.api.storage.Actor; import com.refinedmods.refinedstorage2.api.storage.ExtractableStorage; import com.refinedmods.refinedstorage2.api.storage.InMemoryStorageImpl; @@ -15,29 +17,39 @@ import com.refinedmods.refinedstorage2.api.storage.TypedStorage; import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannelType; import com.refinedmods.refinedstorage2.platform.api.PlatformApi; +import com.refinedmods.refinedstorage2.platform.api.configurationcard.ConfigurationCardTarget; import com.refinedmods.refinedstorage2.platform.api.grid.Grid; import com.refinedmods.refinedstorage2.platform.api.storage.channel.PlatformStorageChannelType; +import com.refinedmods.refinedstorage2.platform.api.support.energy.EnergyBlockEntity; import com.refinedmods.refinedstorage2.platform.api.support.resource.ItemResource; +import com.refinedmods.refinedstorage2.platform.common.Platform; import com.refinedmods.refinedstorage2.platform.common.content.BlockEntities; import com.refinedmods.refinedstorage2.platform.common.content.ContentNames; import com.refinedmods.refinedstorage2.platform.common.grid.AbstractGridContainerMenu; import com.refinedmods.refinedstorage2.platform.common.storage.Disk; import com.refinedmods.refinedstorage2.platform.common.storage.DiskInventory; import com.refinedmods.refinedstorage2.platform.common.storage.DiskStateChangeListener; +import com.refinedmods.refinedstorage2.platform.common.support.RedstoneMode; +import com.refinedmods.refinedstorage2.platform.common.support.RedstoneModeSettings; +import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ExtendedMenuProvider; +import com.refinedmods.refinedstorage2.platform.common.support.energy.BlockEntityEnergyStorage; +import com.refinedmods.refinedstorage2.platform.common.support.energy.CreativeEnergyStorage; import com.refinedmods.refinedstorage2.platform.common.util.ContainerUtil; import java.util.Collections; import java.util.List; import javax.annotation.Nullable; +import com.google.common.util.concurrent.RateLimiter; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; +import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -import net.minecraft.world.MenuProvider; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -45,26 +57,65 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class AbstractPortableGridBlockEntity extends BlockEntity implements Grid, ExtendedMenuProvider, + EnergyBlockEntity, ConfigurationCardTarget { + private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPortableGridBlockEntity.class); -public abstract class AbstractPortableGridBlockEntity extends BlockEntity implements Grid, MenuProvider { private static final String TAG_DISK_INVENTORY = "inv"; private static final String TAG_DISKS = "disks"; + private static final String TAG_STORED = "stored"; + private static final String TAG_REDSTONE_MODE = "rm"; @Nullable protected Disk disk; private final DiskInventory diskInventory; private final DiskStateChangeListener diskStateListener = new DiskStateChangeListener(this); + private final EnergyStorage energyStorage; + private final RateLimiter activenessChangeRateLimiter = RateLimiter.create(1); + + private RedstoneMode redstoneMode = RedstoneMode.IGNORE; @Nullable private TypedStorage> storage; protected AbstractPortableGridBlockEntity(final PortableGridType type, final BlockPos pos, final BlockState state) { super(getBlockEntityType(type), pos, state); this.diskInventory = new DiskInventory(this::onDiskChanged, 1); + this.energyStorage = createEnergyStorage(type, this); + } + + private static EnergyStorage createEnergyStorage(final PortableGridType type, final BlockEntity blockEntity) { + if (type == PortableGridType.CREATIVE) { + return CreativeEnergyStorage.INSTANCE; + } + return new BlockEntityEnergyStorage( + Platform.INSTANCE.getConfig().getController().getEnergyCapacity(), // TODO + blockEntity + ); } - void updateDiskStateIfNecessaryInLevel() { + void update(final BlockState state) { diskStateListener.updateIfNecessary(); + final boolean newActive = isGridActive(); + final boolean activenessNeedsUpdate = state.getValue(PortableGridBlock.ACTIVE) != newActive; + if (activenessNeedsUpdate && activenessChangeRateLimiter.tryAcquire()) { + updateActivenessBlockState(state, newActive); + } + } + + private void updateActivenessBlockState(final BlockState state, final boolean active) { + if (level != null) { + LOGGER.debug( + "Sending block update at {} due to activeness change: {} -> {}", + getBlockPos(), + state.getValue(PortableGridBlock.ACTIVE), + active + ); + level.setBlockAndUpdate(getBlockPos(), state.setValue(PortableGridBlock.ACTIVE, active)); + } } private void onDiskChanged(final int slot) { @@ -111,9 +162,20 @@ public void load(final CompoundTag tag) { if (tag.contains(TAG_DISK_INVENTORY)) { ContainerUtil.read(tag.getCompound(TAG_DISK_INVENTORY), diskInventory); } + if (tag.contains(TAG_STORED)) { + energyStorage.receive(tag.getLong(TAG_STORED), Action.EXECUTE); + } + readConfiguration(tag); super.load(tag); } + @Override + public void readConfiguration(final CompoundTag tag) { + if (tag.contains(TAG_REDSTONE_MODE)) { + redstoneMode = RedstoneModeSettings.getRedstoneMode(tag.getInt(TAG_REDSTONE_MODE)); + } + } + private void fromClientTag(final CompoundTag tag) { if (!tag.contains(TAG_DISKS)) { return; @@ -130,6 +192,13 @@ protected void onClientDriveStateUpdated() { public void saveAdditional(final CompoundTag tag) { super.saveAdditional(tag); tag.put(TAG_DISK_INVENTORY, ContainerUtil.write(diskInventory)); + tag.putLong(TAG_STORED, energyStorage.getStored()); + writeConfiguration(tag); + } + + @Override + public void writeConfiguration(final CompoundTag tag) { + tag.putInt(TAG_REDSTONE_MODE, RedstoneModeSettings.getRedstoneMode(redstoneMode)); } @Override @@ -140,12 +209,27 @@ public Packet getUpdatePacket() { @Override public CompoundTag getUpdateTag() { final CompoundTag tag = new CompoundTag(); - tag.put(TAG_DISKS, diskInventory.toSyncTag(idx -> getState())); + tag.put(TAG_DISKS, diskInventory.toSyncTag(idx -> getStorageState())); return tag; } - private StorageState getState() { - return storage != null ? storage.storage().getState() : StorageState.NONE; + public RedstoneMode getRedstoneMode() { + return redstoneMode; + } + + public void setRedstoneMode(final RedstoneMode redstoneMode) { + this.redstoneMode = redstoneMode; + setChanged(); + } + + private StorageState getStorageState() { + if (storage == null) { + return StorageState.NONE; + } + if (!isGridActive()) { + return StorageState.INACTIVE; + } + return storage.storage().getState(); } @Override @@ -165,10 +249,12 @@ public Storage getItemStorage() { @Override public boolean isGridActive() { + return energyStorage.getStored() > 0 + && level != null + && redstoneMode.isActive(level.hasNeighborSignal(worldPosition)); // TODO: add energy component // TODO: sync activeness to block state // TODO: energy level in GUI - return true; } @Override @@ -208,10 +294,21 @@ public AbstractGridContainerMenu createMenu(final int syncId, final Inventory in return new PortableGridContainerMenu(syncId, inventory, this); } + @Override + public void writeScreenOpeningData(final ServerPlayer player, final FriendlyByteBuf buf) { + buf.writeLong(energyStorage.getStored()); + buf.writeLong(energyStorage.getCapacity()); + } + public SimpleContainer getDiskInventory() { return diskInventory; } + @Override + public EnergyStorage getEnergyStorage() { + return energyStorage; + } + private static BlockEntityType getBlockEntityType(final PortableGridType type) { return type == PortableGridType.CREATIVE ? BlockEntities.INSTANCE.getCreativePortableGrid() diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridBlock.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridBlock.java index cfe7a58bc..fc82fc6c6 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridBlock.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridBlock.java @@ -15,15 +15,20 @@ import net.minecraft.world.MenuProvider; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; public class PortableGridBlock extends AbstractDirectionalBlock implements EntityBlock { + public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); + private static final VoxelShape SHAPE_HORIZONTAL = box(0, 0, 0, 16, 13.2, 16); private static final VoxelShape SHAPE_VERTICAL_SOUTH = box(0, 0, 0, 16, 16, 13.2); private static final VoxelShape SHAPE_VERTICAL_NORTH = box(0, 0, 16 - 13.2, 16, 16, 16); @@ -42,6 +47,17 @@ public PortableGridBlock(final PortableGridType type, this.blockEntityFactory = factory; } + @Override + protected BlockState getDefaultState() { + return super.getDefaultState().setValue(ACTIVE, false); + } + + @Override + protected void createBlockStateDefinition(final StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); + builder.add(ACTIVE); + } + @Override protected DirectionType getDirectionType() { return BiDirectionType.INSTANCE; @@ -78,6 +94,7 @@ public BlockEntityTicker getTicker(final Level level, return ticker.get(level, type); } + // TODO: can we make everything extended menu provider instead of wrapping it this way? @Override @SuppressWarnings("deprecation") // Forge deprecates this public MenuProvider getMenuProvider(final BlockState state, final Level level, final BlockPos pos) { diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridBlockEntityTicker.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridBlockEntityTicker.java index d7e29d843..c0b0b1390 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridBlockEntityTicker.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridBlockEntityTicker.java @@ -21,6 +21,6 @@ public void tick(final Level level, final BlockPos pos, final BlockState state, final AbstractPortableGridBlockEntity blockEntity) { - blockEntity.updateDiskStateIfNecessaryInLevel(); + blockEntity.update(state); } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridContainerMenu.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridContainerMenu.java index 0e17a7086..4ba36f4d6 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridContainerMenu.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridContainerMenu.java @@ -3,19 +3,28 @@ import com.refinedmods.refinedstorage2.platform.api.storage.StorageContainerItem; import com.refinedmods.refinedstorage2.platform.common.content.Menus; import com.refinedmods.refinedstorage2.platform.common.grid.AbstractGridContainerMenu; +import com.refinedmods.refinedstorage2.platform.common.support.RedstoneMode; +import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ClientProperty; +import com.refinedmods.refinedstorage2.platform.common.support.containermenu.PropertyTypes; +import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ServerProperty; import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ValidatedSlot; +import com.refinedmods.refinedstorage2.platform.common.support.energy.EnergyContainerMenu; +import com.refinedmods.refinedstorage2.platform.common.support.energy.EnergyInfo; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.player.Inventory; -public class PortableGridContainerMenu extends AbstractGridContainerMenu { +public class PortableGridContainerMenu extends AbstractGridContainerMenu implements EnergyContainerMenu { private final SimpleContainer diskInventory; + private final EnergyInfo energyInfo; public PortableGridContainerMenu(final int syncId, final Inventory playerInventory, final FriendlyByteBuf buf) { super(Menus.INSTANCE.getPortableGrid(), syncId, playerInventory, buf); this.diskInventory = new SimpleContainer(1); + this.energyInfo = EnergyInfo.forClient(playerInventory.player, buf.readLong(), buf.readLong()); addSlots(0); + registerProperty(new ClientProperty<>(PropertyTypes.REDSTONE_MODE, RedstoneMode.IGNORE)); } PortableGridContainerMenu(final int syncId, @@ -23,7 +32,23 @@ public PortableGridContainerMenu(final int syncId, final Inventory playerInvento final AbstractPortableGridBlockEntity portableGrid) { super(Menus.INSTANCE.getPortableGrid(), syncId, playerInventory, portableGrid); this.diskInventory = portableGrid.getDiskInventory(); + this.energyInfo = EnergyInfo.forServer( + playerInventory.player, + portableGrid.getEnergyStorage()::getStored, + portableGrid.getEnergyStorage()::getCapacity + ); addSlots(0); + registerProperty(new ServerProperty<>( + PropertyTypes.REDSTONE_MODE, + portableGrid::getRedstoneMode, + portableGrid::setRedstoneMode + )); + } + + @Override + public void broadcastChanges() { + super.broadcastChanges(); + energyInfo.detectChanges(); } @Override @@ -32,4 +57,9 @@ public void addSlots(final int playerInventoryY) { addSlot(new ValidatedSlot(diskInventory, 0, -19, 8, stack -> stack.getItem() instanceof StorageContainerItem)); transferManager.addBiTransfer(playerInventory, diskInventory); } + + @Override + public EnergyInfo getEnergyInfo() { + return energyInfo; + } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridScreen.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridScreen.java index 753e0f6dd..d3b0787a8 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridScreen.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridScreen.java @@ -1,6 +1,9 @@ package com.refinedmods.refinedstorage2.platform.common.storage.portablegrid; import com.refinedmods.refinedstorage2.platform.common.grid.screen.AbstractGridScreen; +import com.refinedmods.refinedstorage2.platform.common.support.widget.ProgressWidget; + +import javax.annotation.Nullable; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.Rect2i; @@ -16,6 +19,9 @@ public class PortableGridScreen extends AbstractGridScreen 0L; + this.capacitySupplier = () -> 0L; + this.stored = stored; + this.capacity = capacity; + } + + public void detectChanges() { + final long newStored = storedSupplier.getAsLong(); + final long newCapacity = capacitySupplier.getAsLong(); + final boolean changed = stored != newStored || capacity != newCapacity; + if (changed && rateLimiter.tryAcquire()) { + setEnergy(newStored, newCapacity); + Platform.INSTANCE.getServerToClientCommunications().sendEnergyInfo( + (ServerPlayer) player, + newStored, + newCapacity + ); + } + } + + public void setEnergy(final long newStored, final long newCapacity) { + this.stored = newStored; + this.capacity = newCapacity; + } + + public List createTooltip() { + return Collections.singletonList(createStoredWithCapacityTranslation( + stored, + capacity, + getPercentageFull() + )); + } + + public double getPercentageFull() { + return (double) stored / (double) capacity; + } + + public static EnergyInfo forServer(final Player player, + final LongSupplier storedSupplier, + final LongSupplier capacitySupplier) { + return new EnergyInfo((ServerPlayer) player, storedSupplier, capacitySupplier); + } + + public static EnergyInfo forClient(final Player player, final long stored, final long capacity) { + return new EnergyInfo(player, stored, capacity); + } +} diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/network/AbstractRedstoneModeNetworkNodeContainerBlockEntity.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/network/AbstractRedstoneModeNetworkNodeContainerBlockEntity.java index 49787cd0e..68a1f934f 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/network/AbstractRedstoneModeNetworkNodeContainerBlockEntity.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/network/AbstractRedstoneModeNetworkNodeContainerBlockEntity.java @@ -7,8 +7,6 @@ import com.refinedmods.refinedstorage2.platform.common.support.RedstoneMode; import com.refinedmods.refinedstorage2.platform.common.support.RedstoneModeSettings; -import java.util.Collections; -import java.util.List; import java.util.UUID; import javax.annotation.Nullable; @@ -16,7 +14,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -71,16 +68,6 @@ public void readConfiguration(final CompoundTag tag) { } } - @Override - public List getUpgradeItems() { - return Collections.emptyList(); - } - - @Override - public boolean addUpgradeItem(final Item upgradeItem) { - return false; - } - public RedstoneMode getRedstoneMode() { return redstoneMode; } diff --git a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/gui/portable_grid.png b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/gui/portable_grid.png index 6c8a7b404..5e9695c55 100644 Binary files a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/gui/portable_grid.png and b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/textures/gui/portable_grid.png differ diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java index 9ca328ff4..15a13e0d4 100644 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java +++ b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ClientModInitializerImpl.java @@ -22,7 +22,7 @@ import com.refinedmods.refinedstorage2.platform.common.upgrade.UpgradeDestinationClientTooltipComponent; import com.refinedmods.refinedstorage2.platform.fabric.mixin.ItemPropertiesAccessor; import com.refinedmods.refinedstorage2.platform.fabric.packet.PacketIds; -import com.refinedmods.refinedstorage2.platform.fabric.packet.s2c.ControllerEnergyInfoPacket; +import com.refinedmods.refinedstorage2.platform.fabric.packet.s2c.EnergyInfoPacket; import com.refinedmods.refinedstorage2.platform.fabric.packet.s2c.GridActivePacket; import com.refinedmods.refinedstorage2.platform.fabric.packet.s2c.GridClearPacket; import com.refinedmods.refinedstorage2.platform.fabric.packet.s2c.GridUpdatePacket; @@ -273,7 +273,7 @@ private void registerPackets() { ClientPlayNetworking.registerGlobalReceiver(PacketIds.GRID_UPDATE, new GridUpdatePacket()); ClientPlayNetworking.registerGlobalReceiver(PacketIds.GRID_CLEAR, new GridClearPacket()); ClientPlayNetworking.registerGlobalReceiver(PacketIds.GRID_ACTIVE, new GridActivePacket()); - ClientPlayNetworking.registerGlobalReceiver(PacketIds.CONTROLLER_ENERGY_INFO, new ControllerEnergyInfoPacket()); + ClientPlayNetworking.registerGlobalReceiver(PacketIds.ENERGY_INFO, new EnergyInfoPacket()); ClientPlayNetworking.registerGlobalReceiver( PacketIds.WIRELESS_TRANSMITTER_RANGE, new WirelessTransmitterRangePacket() diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/PacketIds.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/PacketIds.java index 0484186f9..bb84ba954 100644 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/PacketIds.java +++ b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/PacketIds.java @@ -7,7 +7,7 @@ public final class PacketIds { public static final ResourceLocation STORAGE_INFO_RESPONSE = createIdentifier("storage_info_response"); public static final ResourceLocation STORAGE_INFO_REQUEST = createIdentifier("storage_info_request"); - public static final ResourceLocation CONTROLLER_ENERGY_INFO = createIdentifier("controller_energy"); + public static final ResourceLocation ENERGY_INFO = createIdentifier("controller_energy"); public static final ResourceLocation WIRELESS_TRANSMITTER_RANGE = createIdentifier("wireless_transmitter_range"); public static final ResourceLocation GRID_ACTIVE = createIdentifier("grid_active"); public static final ResourceLocation GRID_UPDATE = createIdentifier("grid_update"); diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/ControllerEnergyInfoPacket.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/EnergyInfoPacket.java similarity index 68% rename from refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/ControllerEnergyInfoPacket.java rename to refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/EnergyInfoPacket.java index 5ea8ef168..f7e890587 100644 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/ControllerEnergyInfoPacket.java +++ b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/EnergyInfoPacket.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage2.platform.fabric.packet.s2c; -import com.refinedmods.refinedstorage2.platform.common.controller.ControllerContainerMenu; +import com.refinedmods.refinedstorage2.platform.common.support.energy.EnergyContainerMenu; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.PacketSender; @@ -8,7 +8,7 @@ import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.network.FriendlyByteBuf; -public class ControllerEnergyInfoPacket implements ClientPlayNetworking.PlayChannelHandler { +public class EnergyInfoPacket implements ClientPlayNetworking.PlayChannelHandler { @Override public void receive(final Minecraft client, final ClientPacketListener handler, @@ -18,8 +18,8 @@ public void receive(final Minecraft client, final long capacity = buf.readLong(); client.execute(() -> { - if (client.player.containerMenu instanceof ControllerContainerMenu controller) { - controller.setEnergyInfo(stored, capacity); + if (client.player.containerMenu instanceof EnergyContainerMenu energyContainer) { + energyContainer.getEnergyInfo().setEnergy(stored, capacity); } }); } diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/ServerToClientCommunicationsImpl.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/ServerToClientCommunicationsImpl.java index e0769e543..dcc73b274 100644 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/ServerToClientCommunicationsImpl.java +++ b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/packet/s2c/ServerToClientCommunicationsImpl.java @@ -22,8 +22,8 @@ public class ServerToClientCommunicationsImpl implements ServerToClientCommunications { @Override - public void sendControllerEnergyInfo(final ServerPlayer player, final long stored, final long capacity) { - sendToPlayer(player, PacketIds.CONTROLLER_ENERGY_INFO, buf -> { + public void sendEnergyInfo(final ServerPlayer player, final long stored, final long capacity) { + sendToPlayer(player, PacketIds.ENERGY_INFO, buf -> { buf.writeLong(stored); buf.writeLong(capacity); }); diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/storage/portablegrid/PortableGridBakedModel.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/storage/portablegrid/PortableGridBakedModel.java index f0e660c6a..1fab9829e 100644 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/storage/portablegrid/PortableGridBakedModel.java +++ b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/storage/portablegrid/PortableGridBakedModel.java @@ -71,7 +71,8 @@ public void emitBlockQuads(final BlockAndTintGetter blockView, emitDiskQuads(blockView, state, pos, randomSupplier, context, disk); } } - inactiveModel.emitBlockQuads(blockView, state, pos, randomSupplier, context); + final boolean active = state.getValue(PortableGridBlock.ACTIVE); + (active ? activeModel : inactiveModel).emitBlockQuads(blockView, state, pos, randomSupplier, context); context.popTransform(); } diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/NetworkManager.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/NetworkManager.java index 90d63b97d..c6aa77220 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/NetworkManager.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/NetworkManager.java @@ -12,7 +12,7 @@ import com.refinedmods.refinedstorage2.platform.forge.packet.c2s.SingleAmountChangePacket; import com.refinedmods.refinedstorage2.platform.forge.packet.c2s.StorageInfoRequestPacket; import com.refinedmods.refinedstorage2.platform.forge.packet.c2s.UseNetworkBoundItemPacket; -import com.refinedmods.refinedstorage2.platform.forge.packet.s2c.ControllerEnergyInfoPacket; +import com.refinedmods.refinedstorage2.platform.forge.packet.s2c.EnergyInfoPacket; import com.refinedmods.refinedstorage2.platform.forge.packet.s2c.GridActivePacket; import com.refinedmods.refinedstorage2.platform.forge.packet.s2c.GridClearPacket; import com.refinedmods.refinedstorage2.platform.forge.packet.s2c.GridUpdatePacket; @@ -44,10 +44,10 @@ public NetworkManager() { int id = 0; handler.registerMessage( id++, - ControllerEnergyInfoPacket.class, - ControllerEnergyInfoPacket::encode, - ControllerEnergyInfoPacket::decode, - ControllerEnergyInfoPacket::handle + EnergyInfoPacket.class, + EnergyInfoPacket::encode, + EnergyInfoPacket::decode, + EnergyInfoPacket::handle ); handler.registerMessage( id++, diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/ControllerEnergyInfoPacket.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/ControllerEnergyInfoPacket.java deleted file mode 100644 index 4dd6e0bce..000000000 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/ControllerEnergyInfoPacket.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.refinedmods.refinedstorage2.platform.forge.packet.s2c; - -import com.refinedmods.refinedstorage2.platform.common.controller.ControllerContainerMenu; - -import java.util.function.Supplier; - -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraftforge.network.NetworkEvent; - -public class ControllerEnergyInfoPacket { - private final long stored; - private final long capacity; - - public ControllerEnergyInfoPacket(final long stored, final long capacity) { - this.stored = stored; - this.capacity = capacity; - } - - public static ControllerEnergyInfoPacket decode(final FriendlyByteBuf buf) { - return new ControllerEnergyInfoPacket(buf.readLong(), buf.readLong()); - } - - public static void encode(final ControllerEnergyInfoPacket packet, final FriendlyByteBuf buf) { - buf.writeLong(packet.stored); - buf.writeLong(packet.capacity); - } - - public static void handle(final ControllerEnergyInfoPacket packet, final Supplier ctx) { - ctx.get().enqueueWork(() -> ClientProxy.getPlayer().ifPresent(player -> handle(player, packet))); - ctx.get().setPacketHandled(true); - } - - private static void handle(final Player player, final ControllerEnergyInfoPacket packet) { - final AbstractContainerMenu menu = player.containerMenu; - if (menu instanceof ControllerContainerMenu controller) { - controller.setEnergyInfo(packet.stored, packet.capacity); - } - } -} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/EnergyInfoPacket.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/EnergyInfoPacket.java new file mode 100644 index 000000000..f51476e95 --- /dev/null +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/EnergyInfoPacket.java @@ -0,0 +1,41 @@ +package com.refinedmods.refinedstorage2.platform.forge.packet.s2c; + +import com.refinedmods.refinedstorage2.platform.common.support.energy.EnergyContainerMenu; + +import java.util.function.Supplier; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraftforge.network.NetworkEvent; + +public class EnergyInfoPacket { + private final long stored; + private final long capacity; + + public EnergyInfoPacket(final long stored, final long capacity) { + this.stored = stored; + this.capacity = capacity; + } + + public static EnergyInfoPacket decode(final FriendlyByteBuf buf) { + return new EnergyInfoPacket(buf.readLong(), buf.readLong()); + } + + public static void encode(final EnergyInfoPacket packet, final FriendlyByteBuf buf) { + buf.writeLong(packet.stored); + buf.writeLong(packet.capacity); + } + + public static void handle(final EnergyInfoPacket packet, final Supplier ctx) { + ctx.get().enqueueWork(() -> ClientProxy.getPlayer().ifPresent(player -> handle(player, packet))); + ctx.get().setPacketHandled(true); + } + + private static void handle(final Player player, final EnergyInfoPacket packet) { + final AbstractContainerMenu menu = player.containerMenu; + if (menu instanceof EnergyContainerMenu energy) { + energy.getEnergyInfo().setEnergy(packet.stored, packet.capacity); + } + } +} diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/ServerToClientCommunicationsImpl.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/ServerToClientCommunicationsImpl.java index 6c05e45f3..66a23a460 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/ServerToClientCommunicationsImpl.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/packet/s2c/ServerToClientCommunicationsImpl.java @@ -22,8 +22,8 @@ public ServerToClientCommunicationsImpl(final NetworkManager networkManager) { } @Override - public void sendControllerEnergyInfo(final ServerPlayer player, final long stored, final long capacity) { - networkManager.send(player, new ControllerEnergyInfoPacket(stored, capacity)); + public void sendEnergyInfo(final ServerPlayer player, final long stored, final long capacity) { + networkManager.send(player, new EnergyInfoPacket(stored, capacity)); } @Override diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridBakedModel.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridBakedModel.java index 64b328653..acdb86400 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridBakedModel.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/storage/portablegrid/PortableGridBakedModel.java @@ -83,7 +83,8 @@ public List getQuads(@Nullable final BlockState state, if (disk == null) { return super.getQuads(state, side, randomSource); } - return cache.getUnchecked(new CacheKey(side, direction, true, disk)); + final boolean active = state.getValue(PortableGridBlock.ACTIVE); + return cache.getUnchecked(new CacheKey(side, direction, active, disk)); } @Override diff --git a/refinedstorage2-storage-api/src/main/java/com/refinedmods/refinedstorage2/api/storage/StateTrackedStorage.java b/refinedstorage2-storage-api/src/main/java/com/refinedmods/refinedstorage2/api/storage/StateTrackedStorage.java index 980d7dd4d..6bda55a9a 100644 --- a/refinedstorage2-storage-api/src/main/java/com/refinedmods/refinedstorage2/api/storage/StateTrackedStorage.java +++ b/refinedstorage2-storage-api/src/main/java/com/refinedmods/refinedstorage2/api/storage/StateTrackedStorage.java @@ -62,6 +62,9 @@ private void notifyListener() { @Override public long extract(final T resource, final long amount, final Action action, final Actor actor) { final long extracted = delegate.extract(resource, amount, action, actor); + // TODO: https://sonarcloud.io/component_measures?metric=new_coverage&selected=refinedmods_refinedstorage2%3 + // Arefinedstorage2-storage-api%2Fsrc%2Fmain%2Fjava%2Fcom%2Frefinedmods%2Frefinedstorage2%2Fapi%2 + // Fstorage%2FStateTrackedStorage.java&view=list&pullRequest=465&id=refinedmods_refinedstorage2 if (extracted > 0 && action == Action.EXECUTE) { checkStateChanged(); }