-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/com/glodblock/github/common/item/fake/DropLookup.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,23 @@ | ||
package com.glodblock.github.common.item.fake; | ||
|
||
import appeng.api.storage.data.IAEItemStack; | ||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; | ||
import net.minecraftforge.fluids.FluidStack; | ||
|
||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
public final class DropLookup { | ||
|
||
private final static Map<FluidStack, IAEItemStack> FLUID_CACHE_A = new Object2ObjectLinkedOpenHashMap<>(); | ||
|
||
public static IAEItemStack lookup(FluidStack fluid, Function<FluidStack, IAEItemStack> fallback) { | ||
IAEItemStack cache = FLUID_CACHE_A.get(fluid); | ||
if (cache == null) { | ||
cache = fallback.apply(fluid); | ||
FLUID_CACHE_A.put(fluid, cache); | ||
} | ||
return cache == null ? null : cache.copy(); | ||
} | ||
|
||
} |
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