-
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.
# Conflicts: # build.gradle.kts # settings.gradle.kts # src/main/java/gripe/_90/aecapfix/mixin/ae2/ChestBlockEntityMixin.java # src/main/java/gripe/_90/aecapfix/mixin/ae2/InitCapabilitiesMixin.java # src/main/java/gripe/_90/aecapfix/mixin/powah/ForgeEnvHandlerMixin.java
- Loading branch information
Showing
9 changed files
with
64 additions
and
39 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
34 changes: 34 additions & 0 deletions
34
src/main/java/gripe/_90/aecapfix/misc/DirectionalCapabilityCache.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,34 @@ | ||
package gripe._90.aecapfix.misc; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import net.minecraft.core.Direction; | ||
import net.minecraftforge.common.util.LazyOptional; | ||
|
||
public class DirectionalCapabilityCache<C> { | ||
private final Map<Direction, LazyOptional<C>> directional = new HashMap<>(); | ||
private LazyOptional<C> nullDirection = LazyOptional.empty(); | ||
|
||
public LazyOptional<C> getOrCache(Direction side, LazyOptional<?> toCache) { | ||
if (toCache.isPresent()) { | ||
if (side == null) { | ||
if (!nullDirection.isPresent()) { | ||
nullDirection = toCache.cast(); | ||
} | ||
|
||
return nullDirection; | ||
} else { | ||
directional.putIfAbsent(side, toCache.cast()); | ||
return directional.get(side); | ||
} | ||
} else { | ||
return LazyOptional.empty(); | ||
} | ||
} | ||
|
||
public void invalidate() { | ||
directional.forEach((direction, holder) -> holder.invalidate()); | ||
directional.clear(); | ||
nullDirection.invalidate(); | ||
} | ||
} |
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
src/main/java/gripe/_90/aecapfix/mixin/ae2/PatternProviderBlockEntityMixin.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
4 changes: 2 additions & 2 deletions
4
src/main/java/gripe/_90/aecapfix/mixin/ae2/PatternProviderLogicMixin.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
2 changes: 1 addition & 1 deletion
2
src/main/java/gripe/_90/aecapfix/mixin/ae2/PatternProviderPartMixin.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
2 changes: 1 addition & 1 deletion
2
src/main/java/gripe/_90/aecapfix/mixin/ae2/PatternProviderReturnInventoryMixin.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
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