public static boolean removeReaction(ItemStack reactant, Fluid fluid) { return reactionMap.remove(asList(new ComparableItemStack(reactant).hashCode(), fluid.getName().hashCode())) != null; }
public static Reaction getReaction(ItemStack reactant, Fluid fluid) { return reactant.isEmpty() || fluid == null ? null : reactionMap.get(asList(new ComparableItemStack(reactant).hashCode(), fluid.getName().hashCode())); }
public static void refresh() { Map<List<Integer>, Reaction> tempReactionMap = new Object2ObjectOpenHashMap<>(reactionMap.size()); Set<ComparableItemStack> tempSet = new ObjectOpenHashSet<>(); Set<ComparableItemStack> tempSet2 = new ObjectOpenHashSet<>(); Reaction tempReaction; for (Entry<List<Integer>, Reaction> entry : reactionMap.entrySet()) { tempReaction = entry.getValue(); ComparableItemStack reactant = new ComparableItemStack(tempReaction.reactant); tempReactionMap.put(asList(reactant.hashCode(), tempReaction.getFluidName().hashCode()), tempReaction); tempSet.add(reactant); if (validFluidsElemental.contains(tempReaction.getFluidName())) { tempSet2.add(reactant); } } reactionMap.clear(); reactionMap = tempReactionMap; validReactants.clear(); validReactants = tempSet; validReactantsElemental.clear(); validReactantsElemental = tempSet2; }
public static Reaction getReaction(ItemStack reactant, FluidStack fluid) { return reactant.isEmpty() || fluid == null ? null : reactionMap.get(asList(new ComparableItemStack(reactant).hashCode(), fluid.getFluid().getName().hashCode())); }
public static boolean addReaction(ItemStack reactant, Fluid fluid, int energy) { if (reactant.isEmpty() || fluid == null || energy < 10000 || energy > 200000000) { return false; } if (reactionExists(reactant, fluid)) { return false; } Reaction reaction = new Reaction(reactant, fluid, energy); reactionMap.put(asList(new ComparableItemStack(reactant).hashCode(), fluid.getName().hashCode()), reaction); validReactants.add(new ComparableItemStack(reactant)); validFluids.add(fluid.getName()); return true; }