mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-26 14:33:46 +00:00
Introduced multi-aspect container
This commit is contained in:
1 parent
1b0148aaa4
commit
0bb9f7b909
2 files changed
+34
-1
No files matched your search
@@ -0,0 +1,19 @@
|
||||
package thaumicenergistics.api.storage;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.IAspectContainer;
|
||||
|
||||
/**
|
||||
* An aspect container that can store multiple aspects separately and doesn't share its capacity between different
|
||||
* aspects.
|
||||
*/
|
||||
public interface IMultiAspectContainer extends IAspectContainer {
|
||||
|
||||
/**
|
||||
* Returns the capacity of aspect container for particular aspect.
|
||||
*
|
||||
* @param aspect
|
||||
* @return Maximum amount of essentia of specific aspect this container can store.
|
||||
*/
|
||||
int getContainerCapacity(Aspect aspect);
|
||||
}
|
||||
+15
-1
@@ -22,6 +22,7 @@ import thaumcraft.common.tiles.TileTubeBuffer;
|
||||
import thaumicenergistics.api.IThETransportPermissions;
|
||||
import thaumicenergistics.api.ThEApi;
|
||||
import thaumicenergistics.api.storage.IAspectStack;
|
||||
import thaumicenergistics.api.storage.IMultiAspectContainer;
|
||||
import thaumicenergistics.common.fluids.GaseousEssentia;
|
||||
import thaumicenergistics.common.storage.AspectStack;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaVibrationChamber;
|
||||
@@ -271,7 +272,20 @@ public final class EssentiaTileContainerHelper {
|
||||
}
|
||||
|
||||
// Get how much the container can hold
|
||||
int containerCurrentCapacity = this.getContainerCapacity(container) - this.getContainerStoredAmount(container);
|
||||
int containerCurrentCapacity;
|
||||
if (container instanceof IMultiAspectContainer multiAspectContainer) {
|
||||
// Get total capacity of multi-aspect container
|
||||
containerCurrentCapacity = multiAspectContainer.getContainerCapacity(aspectToFill);
|
||||
AspectList storedAspects = multiAspectContainer.getAspects();
|
||||
|
||||
// Does multi-aspect container store any aspects?
|
||||
if (storedAspects != null) {
|
||||
// Calculate free space for particular aspect
|
||||
containerCurrentCapacity -= storedAspects.getAmount(aspectToFill);
|
||||
}
|
||||
} else {
|
||||
containerCurrentCapacity = this.getContainerCapacity(container) - this.getContainerStoredAmount(container);
|
||||
}
|
||||
|
||||
// Is there more to fill than the container will hold?
|
||||
if (amountToFill > containerCurrentCapacity) {
|
||||
|
||||
Reference in new issue
Block a user