package info.u_team.u_team_core.util.registry;

import java.util.function.Supplier;

import org.apache.commons.lang3.tuple.Pair;

import info.u_team.u_team_core.api.registry.IUBlockRegistryType;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.*;

public class BlockDeferredRegister {
	
	public final DeferredRegister<Block> blocks;
	public final DeferredRegister<Item> items;
	
	public BlockDeferredRegister(String modid) {
		blocks = DeferredRegister.create(ForgeRegistries.BLOCKS, modid);
		items = DeferredRegister.create(ForgeRegistries.ITEMS, modid);
	}
	
	public <I extends Block> RegistryObject<I> registerCommon(String name, Supplier<? extends I> supplier) {
		return blocks.register(name, supplier);
	}
	
	public <I extends Block & IUBlockRegistryType> Pair<RegistryObject<I>, RegistryObject<? extends Item>> register(String name, Supplier<? extends I> supplier) {
		return Pair.of(blocks.register(name, supplier), items.register(name, () -> supplier.get().getBlockItem()));
	}
	
	public void register(IEventBus bus) {
		blocks.register(bus);
		items.register(bus);
	}
	
}

@@ -82,53 +82,8 @@
 r;%0A%0A
-import org.apache.commons.lang3.tuple.Pair;%0A%0A
 impo
@@ -203,20 +203,61 @@
 ft.item.
-Item
+*;%0Aimport net.minecraft.util.ResourceLocation
 ;%0Aimport
@@ -702,32 +702,71 @@
 ;%0A%09%7D%0A%09%0A%09public %3C
+B extends Block & IUBlockRegistryType, 
 I extends Block%3E
@@ -764,18 +764,27 @@
 ds Block
-%3E 
+Item%3E Block
 Registry
@@ -790,16 +790,19 @@
 yObject%3C
+B, 
 I%3E regis
@@ -808,14 +808,8 @@
 ster
-Common
 (Str
@@ -829,33 +829,33 @@
 plier%3C? extends 
-I
+B
 %3E supplier) %7B%0A%09%09
@@ -854,22 +854,47 @@
 er) %7B%0A%09%09
-return
+final RegistryObject%3CB%3E block =
  blocks.
@@ -924,65 +924,15 @@
 );%0A%09
-%7D%0A%09%0A%09public %3CI extends Block & IUBlockRegistryType%3E Pair%3C
+%09final 
 Regi
@@ -944,17 +944,23 @@
 bject%3CI%3E
-,
+ item =
  Registr
@@ -970,81 +970,66 @@
 ject
-%3C? extends Item%3E%3E register(String 
+.of(new ResourceLocation(
 name
+)
 , 
-Supplier%3C? extends I%3E supplier) %7B
+ForgeRegistries.ITEMS);%0A%09%09
 %0A%09%09r
@@ -1038,106 +1038,49 @@
 urn 
-Pair.of(b
+new B
 lock
-s.r
+R
 egist
-er(name, supplier), items.register(name, () -%3E supplier.get().getBlockItem())
+ryObject%3CB, I%3E(block, item
 );%0A%09

Add register method for the block (wip, as the item is not registered yet)