mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Make many more Mekanism fluid renderers Stack aware for NBT purposes (#5360)
* Port 72251446f make many more Mekanism fluid renderers Stack aware for NBT purposes * Make it a bit easier to see osmium in the compressor * fix a missed stack color get * move osmium gas colour back to a more vibrant blue for contrast reasons
This commit is contained in:
1 parent
88eae4f314
commit
a1e0688af8
18 files changed
+160
-91
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package mekanism.client.render;
|
||||
|
||||
import it.unimi.dsi.fastutil.Hash;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
|
||||
/**
|
||||
* Map which uses FluidStacks as keys, ignoring amount. Primary use: caching FluidStack aware fluid rendering (NBT,
|
||||
* yay)
|
||||
*/
|
||||
public class FluidRenderMap<V> extends Object2ObjectOpenCustomHashMap<FluidStack, V> {
|
||||
|
||||
public FluidRenderMap() {
|
||||
super(FluidHashStrategy.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements equals & hashCode that ignore FluidStack#amount
|
||||
*/
|
||||
public static class FluidHashStrategy implements Hash.Strategy<FluidStack> {
|
||||
|
||||
public static FluidHashStrategy INSTANCE = new FluidHashStrategy();
|
||||
|
||||
@Override
|
||||
public int hashCode(FluidStack stack) {
|
||||
if (stack == null) {
|
||||
return 0;
|
||||
}
|
||||
int code = 1;
|
||||
code = 31 * code + stack.getFluid().hashCode();
|
||||
if (stack.tag != null) {
|
||||
code = 31 * code + stack.tag.hashCode();
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(FluidStack a, FluidStack b) {
|
||||
if (a == null) {
|
||||
return b == null;
|
||||
}
|
||||
return a.isFluidEqual(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user