Skip to content

Commit

Permalink
Add default BlockBehaviour.Properties overloads to DeferredRegister.B…
Browse files Browse the repository at this point in the history
…locks
  • Loading branch information
PlatinPython committed Nov 2, 2024
1 parent 2027bc7 commit c88ecde
Showing 1 changed file with 33 additions and 1 deletion.
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

0 comments on commit c88ecde

Please sign in to comment.