forked from AppliedEnergistics/Applied-Energistics-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix case when external storage is not slotted
- Loading branch information
Showing
17 changed files
with
87 additions
and
17 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
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
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
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
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
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
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
...ration/abstraction/IFabricBakedModel.java → ...integration/fabric/IFabricBakedModel.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,4 +1,4 @@ | ||
package appeng.integration.abstraction; | ||
package appeng.integration.fabric; | ||
|
||
import java.util.List; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...tion/abstraction/IFabricCustomEntity.java → ...tegration/fabric/IFabricCustomEntity.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
67 changes: 67 additions & 0 deletions
67
src/main/java/appeng/integration/fabric/NonSlotStorageAdapter.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,67 @@ | ||
package appeng.integration.fabric; | ||
|
||
import net.fabricmc.fabric.api.transfer.v1.storage.Storage; | ||
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage; | ||
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext; | ||
|
||
public class NonSlotStorageAdapter<T> implements SingleSlotStorage<T> { | ||
|
||
private final Storage<T> storage; | ||
|
||
public NonSlotStorageAdapter(Storage<T> storage) { | ||
this.storage = storage; | ||
} | ||
|
||
@Override | ||
public long insert( | ||
T resource, | ||
long maxAmount, | ||
TransactionContext transaction | ||
) { | ||
return storage.insert(resource, maxAmount, transaction); | ||
} | ||
|
||
@Override | ||
public long extract( | ||
T resource, | ||
long maxAmount, | ||
TransactionContext transaction | ||
) { | ||
return storage.extract(resource, maxAmount, transaction); | ||
} | ||
|
||
@Override | ||
public boolean isResourceBlank() { | ||
return !storage.nonEmptyIterator().hasNext(); | ||
} | ||
|
||
@Override | ||
public T getResource() { | ||
for (var storageView : storage) { | ||
return storageView.getResource(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public long getAmount() { | ||
var iterator = storage.nonEmptyIterator(); | ||
|
||
var count = 0L; | ||
while(iterator.hasNext()) { | ||
count += iterator.next().getAmount(); | ||
} | ||
|
||
return count; | ||
} | ||
|
||
@Override | ||
public long getCapacity() { | ||
for (var storageView : storage) { | ||
return storageView.getCapacity(); | ||
} | ||
|
||
return 0; | ||
} | ||
} |
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