Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Additional javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealEmissions committed Mar 28, 2024
1 parent 0e38ecc commit 3f58295
Show file tree
Hide file tree
Showing 2 changed files with 648 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import net.dumbcode.projectnublar.core.blocks.elements.TestBlock;
import net.dumbcode.projectnublar.core.blocks.elements.TestOreBlock;
import net.dumbcode.projectnublar.core.blocks.entity.DumbBlockEntities;
import net.dumbcode.projectnublar.core.data.DataGenerator;
import net.dumbcode.projectnublar.core.data.ModBlockStateProvider;
import net.dumbcode.projectnublar.core.data.ModRecipeProvider;
import net.dumbcode.projectnublar.core.data.loot.ModBlockLootTables;
import net.dumbcode.projectnublar.core.exceptions.UtilityClassException;
Expand Down Expand Up @@ -83,6 +85,7 @@ public enum Blocks {
*/
TEST_BLOCK(
TestBlock::new,
ModBlockStateProvider.Generator::simpleWithItem,
metadata -> metadata
.tags(tags -> tags.blocks(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.NEEDS_IRON_TOOL))
.lootTable(ModBlockLootTables.Builder::dropSelf)
Expand All @@ -100,6 +103,7 @@ public enum Blocks {
*/
TEST_ORE_BLOCK(
TestOreBlock::new,
ModBlockStateProvider.Generator::simpleWithItem,
metadata -> metadata
.tags(tags -> tags
.dumbBlocks(DumbTags.Blocks.OVERWORLD_ORES)
Expand All @@ -113,6 +117,7 @@ public enum Blocks {
*/
SOUND_BLOCK(
SoundBlock::new,
ModBlockStateProvider.Generator::simpleWithItem,
metadata -> metadata
.tags(tags -> tags.blocks(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.NEEDS_DIAMOND_TOOL))
.lootTable(ModBlockLootTables.Builder::dropSelf)
Expand All @@ -132,6 +137,13 @@ public enum Blocks {
RegistryObject.create(new ResourceLocation(MOD_ID, getRegisterName()), Registrar.BLOCKS.getRegistryKey(), MOD_ID),
RegistryObject.create(new ResourceLocation(MOD_ID, getRegisterName()), Registrar.ITEMS.getRegistryKey(), MOD_ID)
);
/**
* It is used to define the block state generator for the block, which is responsible for generating the block state.
* The block state defines the properties of the block, such as its model, texture, and other visual properties.
* The data is then handled by the data generation system of this mod, {@link DataGenerator}
* The {@link UnaryOperator} allows for the state generator to be modified in a functional manner.
*/
private final UnaryOperator<ModBlockStateProvider.Generator> stateGeneratorOperator;
/**
* The metadata of the block.
* This contains information about the block's tags, loot table, recipes, and associated entity.
Expand Down Expand Up @@ -164,10 +176,12 @@ public enum Blocks {
* Constructor for blocks without an associated block entity.
*
* @param blockConstructor a supplier that provides an instance of the block
* @param stateBuilder a unary operator of {@link ModBlockStateProvider.Generator} that configures the block state generator.
* @param metadata a unary operator of {@link Metadata.Builder} that configures the properties of the block.
*/
Blocks(Supplier<IDumbBlock> blockConstructor, @NotNull UnaryOperator<Metadata.Builder> metadata) {
Blocks(Supplier<IDumbBlock> blockConstructor, @NotNull UnaryOperator<ModBlockStateProvider.Generator> stateBuilder, @NotNull UnaryOperator<Metadata.Builder> metadata) {
this.blockConstructor = blockConstructor;
this.stateGeneratorOperator = stateBuilder;
this.metadata = metadata.apply(new Metadata.Builder()).build();
}

Expand All @@ -176,13 +190,15 @@ public enum Blocks {
* This constructor requires an associated entity to be set in the metadata with {@link Metadata.Builder#associatedEntity(DumbBlockEntities.Entities)}.
*
* @param blockConstructor a function that provides an instance of the block with an associated entity, taking {@link DumbBlockEntities.Entities} as a parameter.
* @param stateBuilder a unary operator of {@link ModBlockStateProvider.Generator} that configures the block state generator.
* @param metadata a unary operator of {@link Metadata.Builder} that configures the properties of the block.
*/
Blocks(Function<DumbBlockEntities.Entities, IDumbBlock> blockConstructor, @NotNull UnaryOperator<Metadata.Builder> metadata) {
Blocks(Function<DumbBlockEntities.Entities, IDumbBlock> blockConstructor, @NotNull UnaryOperator<ModBlockStateProvider.Generator> stateBuilder, @NotNull UnaryOperator<Metadata.Builder> metadata) {
this.metadata = metadata.apply(new Metadata.Builder()).build();
if (this.metadata.associatedEntity == null) {
throw new IllegalStateException("Associated entity is required when using this constructor. Call it with Metadata#associatedEntity method.");
}
this.stateGeneratorOperator = stateBuilder;
this.blockConstructor = () -> blockConstructor.apply(this.metadata.associatedEntity);
}

Expand All @@ -196,6 +212,17 @@ public enum Blocks {
return registry;
}

/**
* Returns the {@link UnaryOperator} for the state generator of the block.
* The state generator is responsible for generating the block state, which defines the visual properties of the block.
* The {@link UnaryOperator} allows for the state generator to be modified in a functional manner.
*
* @return the {@link UnaryOperator} for the state generator of the block.
*/
public @NotNull UnaryOperator<ModBlockStateProvider.Generator> getStateGeneratorOperator() {
return stateGeneratorOperator;
}

/**
* Returns the {@link Metadata} object associated with this block.
* The {@link Metadata} object contains information about the block's tags, loot table, recipes, and associated entity.
Expand Down
Loading

0 comments on commit 3f58295

Please sign in to comment.