Untitled

mail@pastecode.io avatar
unknown
java
2 months ago
3.0 kB
9
Indexable
Never
```public class EasyRegistry {
    public EasyRegistry(String modid) {
       ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, modid);
       BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, modid);
       FLUIDS = DeferredRegister.create(ForgeRegistries.FLUIDS, modid);
       FLUID_TYPES = DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, modid);
       MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, modid);
       BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, modid);
    }
    public final DeferredRegister<Item> ITEMS;
    public final DeferredRegister<Block>  BLOCKS;
    public final DeferredRegister<Fluid> FLUIDS;
    public final DeferredRegister<FluidType> FLUID_TYPES;
    public final DeferredRegister<MenuType<?>> MENU_TYPES;
    public final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES;


    public RegistryObject<Item> createItem(String name, Supplier<Item> item) {
        return ITEMS.register(name, item);
    }

    public RegistryObject<Block> createBlock(String name, Supplier<Block> block) {
        return BLOCKS.register(name, block);
    }

    public <T extends Block> RegistryObject<T> createFluidBlock(String name, Supplier<T> block) {
        return BLOCKS.register(name, block);
    }

    public RegistryObject<Block> createBlockWithItem(String name, Supplier<Block> block) {
        RegistryObject<Block> blockRegistryObject = BLOCKS.register(name, block);
        ITEMS.register(name, () -> new BlockItem(blockRegistryObject.get(), new Item.Properties()));
        return blockRegistryObject;
    }

    public RegistryObject<FlowingFluid> createFluid(String name, Supplier<FlowingFluid> flowingFluid) {
        return FLUIDS.register(name, flowingFluid);
    }

    public RegistryObject<FluidType> createFluidType(String name, Supplier<FluidType> fluidType) {
        return FLUID_TYPES.register(name, fluidType);
    }
    public <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> createMenu(String name, Supplier<MenuType<T>> menu) {
        return MENU_TYPES.register(name, menu);
    }

    public <T extends BlockEntity> RegistryObject<BlockEntityType<T>> createBlockEntity(String name, Supplier<BlockEntityType<T>> blockEntity) {
        return BLOCK_ENTITY_TYPES.register(name, blockEntity);
    }

    public ForgeFlowingFluid.Properties createFluidProperties(Supplier<? extends FluidType> fluidType, Supplier<? extends Fluid> flowing, Supplier<? extends Fluid> still, Supplier<? extends Item> bucket, Supplier<? extends LiquidBlock> block) {
        return new ForgeFlowingFluid.Properties(fluidType, flowing, still).bucket(bucket).block(block);
    }

    public void register(IEventBus modEventBus) {
        ITEMS.register(modEventBus);
        BLOCKS.register(modEventBus);
        MENU_TYPES.register(modEventBus);
        BLOCK_ENTITY_TYPES.register(modEventBus);
        FLUID_TYPES.register(modEventBus);
        FLUIDS.register(modEventBus);
    }
}```
Leave a Comment