mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-24 10:34:29 +00:00
Fixed the registry lag
This commit is contained in:
4 files changed
+146
-16
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package com.falsepattern.endlessids.asm;
|
||||
|
||||
import lombok.var;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class GameDataHooks {
|
||||
private static final WeakHashMap<Block, WeakReference<ItemBlock>> itemBlockCache = new WeakHashMap<>();
|
||||
|
||||
public static void cacheItemBlock(ItemBlock itemBlock) {
|
||||
itemBlockCache.put(itemBlock.field_150939_a, new WeakReference<>(itemBlock));
|
||||
}
|
||||
|
||||
public static ItemBlock fetchCachedItemBlock(Block block) {
|
||||
var weakItem = itemBlockCache.get(block);
|
||||
if (weakItem != null) {
|
||||
return weakItem.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Iterable<Item> fakeIterable() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user