mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
* 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
46 lines
1.3 KiB
Java
46 lines
1.3 KiB
Java
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);
|
|
}
|
|
}
|
|
} |