Skip to content

Commit

Permalink
Fix quirk with QSL to maintain current semantics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ampflower committed Dec 10, 2022
1 parent 54a27a3 commit 590368b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/net/kjp12/ddc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import it.unimi.dsi.fastutil.objects.Object2FloatArrayMap;
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
import it.unimi.dsi.fastutil.objects.Object2FloatMaps;
import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.block.ComposterBlock;
Expand Down Expand Up @@ -93,6 +94,18 @@ public static void hotLoad() {
logger.info("[DDC] Evoking {} as `disableDatapackRegistry` for the composter is enabled.",
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.clear();
} else {
logger.info("[DDC] Evoking vanilla registry entries manually to account for other mods.");
// Capture a working map to avoid spamming the logs when our logger is enabled.
var intermediary = new Object2FloatOpenHashMap<>(ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.clear();

// Manually clear out all *exact* entries from the intermediate step.
Object2FloatMaps.fastForEach(vanillaCompostableItems,
e -> intermediary.remove(e.getKey(), e.getFloatValue()));

// Set the intermediate step back into working.
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.putAll(intermediary);
}
} else {
// Same as above, but redeploys the vanilla registry.
Expand Down

0 comments on commit 590368b

Please sign in to comment.