Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default BlockBehaviour.Properties overloads to DeferredRegister.Blocks #1660

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -424,24 +424,56 @@ public <B extends Block> DeferredBlock<B> register(String name, Supplier<? exten
* @param func A factory for the new block. The factory should not cache the created block.
* @param props The properties for the created block.
* @return A {@link DeferredHolder} that will track updates from the registry for this block.
* @see #registerBlock(String, Function)
* @see #registerSimpleBlock(String, BlockBehaviour.Properties)
* @see #registerSimpleBlock(String)
*/
public <B extends Block> DeferredBlock<B> registerBlock(String name, Function<BlockBehaviour.Properties, ? extends B> func, BlockBehaviour.Properties props) {
return this.register(name, key -> func.apply(props.setId(ResourceKey.create(Registries.BLOCK, key))));
}

/**
* Adds a new simple {@link Block} to the list of entries to be registered and returns a {@link DeferredHolder} that will be populated with the created block automatically.
* Adds a new block to the list of entries to be registered and returns a {@link DeferredHolder} that will be populated with the created block automatically.
* This method uses the default {@link BlockBehaviour.Properties}.
*
* @param name The new block's name. It will automatically have the {@linkplain #getNamespace() namespace} prefixed.
* @param func A factory for the new block. The factory should not cache the created block.
* @return A {@link DeferredHolder} that will track updates from the registry for this block.
* @see #registerBlock(String, Function, BlockBehaviour.Properties)
* @see #registerSimpleBlock(String, BlockBehaviour.Properties)
* @see #registerSimpleBlock(String)
*/
public <B extends Block> DeferredBlock<B> registerBlock(String name, Function<BlockBehaviour.Properties, ? extends B> func) {
return this.registerBlock(name, func, BlockBehaviour.Properties.of());
}

/**
* Adds a new simple {@link Block} with the given {@link BlockBehaviour.Properties properties} to the list of entries to be registered and returns a {@link DeferredHolder} that will be populated with the created block automatically.
*
* @param name The new block's name. It will automatically have the {@linkplain #getNamespace() namespace} prefixed.
* @param props The properties for the created block.
* @return A {@link DeferredHolder} that will track updates from the registry for this block.
* @see #registerBlock(String, Function, BlockBehaviour.Properties)
* @see #registerBlock(String, Function)
* @see #registerSimpleBlock(String)
*/
public DeferredBlock<Block> registerSimpleBlock(String name, BlockBehaviour.Properties props) {
return this.registerBlock(name, Block::new, props);
}

/**
* Adds a new simple {@link Block} with the default {@link BlockBehaviour.Properties properties} to the list of entries to be registered and returns a {@link DeferredHolder} that will be populated with the created block automatically.
*
* @param name The new block's name. It will automatically have the {@linkplain #getNamespace() namespace} prefixed.
* @return A {@link DeferredHolder} that will track updates from the registry for this block.
* @see #registerBlock(String, Function, BlockBehaviour.Properties)
* @see #registerBlock(String, Function)
* @see #registerSimpleBlock(String, BlockBehaviour.Properties)
*/
public DeferredBlock<Block> registerSimpleBlock(String name) {
return this.registerSimpleBlock(name, BlockBehaviour.Properties.of());
}

@Override
protected <I extends Block> DeferredBlock<I> createHolder(ResourceKey<? extends Registry<Block>> registryKey, ResourceLocation key) {
return DeferredBlock.createBlock(ResourceKey.create(registryKey, key));
Expand Down