Skip to content

Commit

Permalink
LazyOptional fucking sucks
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Jun 2, 2024
1 parent 06e8dfb commit ff1ccbe
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class EMCInterfaceLogic implements IActionHost, IGridTickable, IUpgradeab
private final IActionSource source = IActionSource.ofMachine(this);

private final LazyOptional<IItemHandler> storageHolder;
private final LazyOptional<MEStorage> localInvHolder;

@Nullable
private WrappedEMCStorage emcStorage;
Expand Down Expand Up @@ -85,7 +84,6 @@ public EMCInterfaceLogic(IManagedGridNode node, EMCInterfaceLogicHost host, Item
storage.useRegisteredCapacities();

storageHolder = LazyOptional.of(() -> storage).lazyMap(GenericStackItemStorage::new);
localInvHolder = LazyOptional.of(this::getInventory);
}

public ConfigInventory getConfig() {
Expand Down Expand Up @@ -298,8 +296,8 @@ private void readConfig() {
}

private void onConfigRowChanged() {
readConfig();
host.saveChanges();
readConfig();
}

private void onStorageChanged() {
Expand Down Expand Up @@ -354,15 +352,14 @@ public <T> LazyOptional<T> getCapability(Capability<T> cap) {
if (cap == ForgeCapabilities.ITEM_HANDLER) {
return storageHolder.cast();
} else if (cap == Capabilities.STORAGE) {
return localInvHolder.cast();
return LazyOptional.of(this::getInventory).cast();
} else {
return LazyOptional.empty();
}
}

public void invalidateCaps() {
storageHolder.invalidate();
localInvHolder.invalidate();
}

private class WrappedEMCStorage implements MEStorage {
Expand Down

0 comments on commit ff1ccbe

Please sign in to comment.