package info.u_team.u_team_core.block;

import java.util.function.Supplier;

import info.u_team.u_team_core.api.block.BlockItemProvider;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

public class UBlock extends Block implements BlockItemProvider {
	
	protected final Supplier<Item> blockItem;
	
	public UBlock(Properties properties) {
		this(null, properties);
	}
	
	public UBlock(CreativeModeTab creativeTab, Properties properties) {
		this(creativeTab, properties, null);
	}
	
	public UBlock(Properties properties, Item.Properties blockItemProperties) {
		this(null, properties, blockItemProperties);
	}
	
	public UBlock(CreativeModeTab creativeTab, Properties properties, Item.Properties blockItemProperties) {
		super(properties);
		blockItem = () -> createBlockItem(blockItemProperties == null ? new Item.Properties().tab(creativeTab) : creativeTab == null ? blockItemProperties : blockItemProperties.tab(creativeTab));
	}
	
	protected Item createBlockItem(Item.Properties blockItemProperties) {
		return new BlockItem(this, blockItemProperties);
	}
	
	@Override
	public Item blockItem() {
		return blockItem.get();
	}
}

@@ -70,16 +70,58 @@
 plier;%0A%0A
+import com.google.common.base.Suppliers;%0A%0A
 import i
@@ -915,16 +915,34 @@
 kItem = 
+Suppliers.memoize(
 () -%3E cr
@@ -1107,16 +1107,17 @@
 iveTab))
+)
 ;%0A%09%7D%0A%09%0A%09

Fix contract of block item provider by memoize the supplier for the block item.