From 391d543d7b8bf5fb6dbf638bc4ce5859a79451f8 Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Sun, 29 Dec 2024 14:34:07 -0500 Subject: [PATCH 01/16] Update ActiveBlock.java --- .../gtceu/api/block/ActiveBlock.java | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java index c8135ea3ac..bc4256af8e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java @@ -11,37 +11,79 @@ import javax.annotation.ParametersAreNonnullByDefault; +/** + * @implNote This class is a simple extension of AppearanceBlock that adds a property + * to track whether the block is active or not. + * This is useful for blocks that have different appearances when active. + */ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class ActiveBlock extends AppearanceBlock { - + /** + * This class is a simple extension of AppearanceBlock that adds a + * property to track whether the block is active or not. + * This is useful for blocks that have different appearances when active. + */ public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); + /** + * Constructor for ActiveBlock + * @param properties the properties of the block + */ public ActiveBlock(Properties properties) { super(properties); - registerDefaultState(defaultBlockState().setValue(ACTIVE, false)); + registerDefaultState( + defaultBlockState().setValue(ACTIVE, false) + ); } + /** + * Adds the ACTIVE property to the block state + * @param builder the block state builder + */ @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); builder.add(ACTIVE); } + /** + * Changes the active state of the block + * @param state the block state + * @param active whether the block is active or not + * @return the new block state + */ public BlockState changeActive(BlockState state, boolean active) { if (state.is(this)) { return state.setValue(ACTIVE, active); } - return state; + else { + return state; + } } + /** + * Gets the active state of the block + * @param state the block state + * @return whether the block is active or not + */ public boolean isActive(BlockState state) { return state.getValue(ACTIVE); } + /** + * Gets the block appearance based on the active state + * @param state the block state + * @param level the block and tint getter + * @param pos the block position + * @param side the direction of the block + * @param sourceState the source block state + * @param sourcePos the source block position + * @return the block state + */ @Override public BlockState getBlockAppearance(BlockState state, BlockAndTintGetter level, BlockPos pos, Direction side, BlockState sourceState, BlockPos sourcePos) { return defaultBlockState(); } -} +} \ No newline at end of file From a8082439f08187f6640cbeed0ea3e94ce06668cf Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Sun, 29 Dec 2024 14:36:16 -0500 Subject: [PATCH 02/16] Update ActiveBlock.java --- src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java index bc4256af8e..baa5f8e0c2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java @@ -12,8 +12,7 @@ import javax.annotation.ParametersAreNonnullByDefault; /** - * @implNote This class is a simple extension of AppearanceBlock that adds a property - * to track whether the block is active or not. + * @implNote ActiveBlock extends AppearanceBlock with the property ACTIVE. * This is useful for blocks that have different appearances when active. */ @ParametersAreNonnullByDefault From 2948ee38410784f1da55a4cf31dd60ae9f757293 Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Sun, 29 Dec 2024 14:45:04 -0500 Subject: [PATCH 03/16] Update ActiveBlock.java --- .../gtceu/api/block/ActiveBlock.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java index baa5f8e0c2..53ce77dfa2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java @@ -18,26 +18,23 @@ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class ActiveBlock extends AppearanceBlock { - /** - * This class is a simple extension of AppearanceBlock that adds a - * property to track whether the block is active or not. - * This is useful for blocks that have different appearances when active. - */ + + // Properties public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); /** - * Constructor for ActiveBlock + * Constructor for ActiveBlock that adds the ACTIVE property to the block state + * Also registers the default block state and properties * @param properties the properties of the block */ public ActiveBlock(Properties properties) { super(properties); - registerDefaultState( - defaultBlockState().setValue(ACTIVE, false) - ); + registerDefaultState(defaultBlockState().setValue(ACTIVE, false)); } /** * Adds the ACTIVE property to the block state + * Overrides the createBlockStateDefinition method in AppearanceBlock * @param builder the block state builder */ @Override @@ -53,12 +50,8 @@ protected void createBlockStateDefinition(StateDefinition.Builder Date: Sun, 29 Dec 2024 14:52:33 -0500 Subject: [PATCH 04/16] Update ActiveBlock.java --- src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java index 53ce77dfa2..ff3990136e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java @@ -50,7 +50,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder Date: Sun, 29 Dec 2024 14:59:33 -0500 Subject: [PATCH 05/16] Add sees and javadocs for AppearanceBlock --- .../gtceu/api/block/ActiveBlock.java | 4 ++++ .../gtceu/api/block/AppearanceBlock.java | 24 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java index ff3990136e..bf59420617 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java @@ -14,6 +14,10 @@ /** * @implNote ActiveBlock extends AppearanceBlock with the property ACTIVE. * This is useful for blocks that have different appearances when active. + * For example, a block that changes appearance when powered by redstone. + * @see AppearanceBlock + * @see Block + * @see BlockState */ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java index 3f2ea26e19..b45a92c645 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java @@ -9,16 +9,34 @@ import org.jetbrains.annotations.Nullable; /** - * @author KilaBash - * @date 2023/3/27 - * @implNote AppearanceBlock + * @implNote AppearanceBlock is an abstract class that implements IAppearance. + * This is useful for blocks that have different appearances based on context. + * For example, a block that changes appearance based on the block it is facing. + * @see IAppearance + * @see Block + * @see BlockState */ public class AppearanceBlock extends Block implements IAppearance { + /** + * Constructor for AppearanceBlock that sets the properties of the block + * @param properties the properties of the block + */ public AppearanceBlock(Properties properties) { super(properties); } + /** + * Gets the appearance of the block based on the context + * Overrides the getAppearance method in IAppearance + * @param state the block state + * @param level the block and tint getter + * @param pos the block position + * @param side the direction of the block + * @param queryState the block state of the query + * @param queryPos the block position of the query + * @return the block state of the appearance + */ @Override public BlockState getAppearance(BlockState state, BlockAndTintGetter level, BlockPos pos, Direction side, @Nullable BlockState queryState, @Nullable BlockPos queryPos) { From f442867cd5b23518f9a3ca0a1d31920c3609976c Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Sun, 29 Dec 2024 15:04:09 -0500 Subject: [PATCH 06/16] IAppearance.java --- .../gtceu/api/block/ActiveBlock.java | 1 - .../gtceu/api/block/AppearanceBlock.java | 3 +-- .../gtceu/api/block/BlockProperties.java | 11 +++++----- .../gtceu/api/block/IAppearance.java | 20 +++++++++++++------ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java index bf59420617..a92a6304ba 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java @@ -22,7 +22,6 @@ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class ActiveBlock extends AppearanceBlock { - // Properties public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java index b45a92c645..63371f4cdf 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java @@ -17,7 +17,6 @@ * @see BlockState */ public class AppearanceBlock extends Block implements IAppearance { - /** * Constructor for AppearanceBlock that sets the properties of the block * @param properties the properties of the block @@ -43,4 +42,4 @@ public BlockState getAppearance(BlockState state, BlockAndTintGetter level, Bloc var appearance = this.getBlockAppearance(state, level, pos, side, queryState, queryPos); return appearance == null ? state : appearance; } -} +} \ No newline at end of file diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java b/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java index a42ed84c3c..9f989ffc81 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java @@ -3,11 +3,12 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty; /** - * @author KilaBash - * @date 2023/3/12 - * @implNote BlockProperties + * @implNote BlockProperties is a utility class that contains custom block properties. + * This is useful for blocks that have custom properties that are not included in the default properties. + * For example, a block that has a property that determines whether the block should tick on the server. + * @see BooleanProperty */ public final class BlockProperties { - + // Properties public static final BooleanProperty SERVER_TICK = BooleanProperty.create("server_tick"); -} +} \ No newline at end of file diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/IAppearance.java b/src/main/java/com/gregtechceu/gtceu/api/block/IAppearance.java index 5224d78f02..5b81f4e1af 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/IAppearance.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/IAppearance.java @@ -8,18 +8,26 @@ import org.jetbrains.annotations.Nullable; /** - * @author KilaBash - * @date 2023/3/27 - * @implNote IAppearanceBlock + * @implNote IAppearance is an interface that provides a method to get the appearance of a block. + * This is useful for blocks that have different appearances based on context. + * For example, a block that changes appearance based on the block it is facing. + * @see BlockState */ public interface IAppearance { - /** - * get Appearance. same as IForgeBlock.getAppearance() / IFabricBlock.getAppearance() + * Gets the appearance of the block based on the context + * @see net.minecraftforge.common.extensions.IForgeBlock#getAppearance(BlockState, BlockAndTintGetter, BlockPos, Direction, BlockState, BlockPos) + * @param state the block state + * @param level the block and tint getter + * @param pos the block position + * @param side the direction of the block + * @param sourceState the block state of the source + * @param sourcePos the block position of the source + * @return the block state of the appearance */ @Nullable default BlockState getBlockAppearance(BlockState state, BlockAndTintGetter level, BlockPos pos, Direction side, BlockState sourceState, BlockPos sourcePos) { return state; } -} +} \ No newline at end of file From 91623609e33db7891cb9dc85fa8d4ba1f60e5112 Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Sun, 29 Dec 2024 15:24:02 -0500 Subject: [PATCH 07/16] ICoilType.java --- .../gtceu/api/block/ActiveBlock.java | 2 +- .../gtceu/api/block/AppearanceBlock.java | 2 +- .../gtceu/api/block/BlockProperties.java | 2 +- .../gtceu/api/block/ICoilType.java | 43 ++++++++++++++----- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java index a92a6304ba..fb1109aef6 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java @@ -12,7 +12,7 @@ import javax.annotation.ParametersAreNonnullByDefault; /** - * @implNote ActiveBlock extends AppearanceBlock with the property ACTIVE. + * ActiveBlock extends AppearanceBlock with the property ACTIVE. * This is useful for blocks that have different appearances when active. * For example, a block that changes appearance when powered by redstone. * @see AppearanceBlock diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java index 63371f4cdf..81f75c9173 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.Nullable; /** - * @implNote AppearanceBlock is an abstract class that implements IAppearance. + * AppearanceBlock is an abstract class that implements IAppearance. * This is useful for blocks that have different appearances based on context. * For example, a block that changes appearance based on the block it is facing. * @see IAppearance diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java b/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java index 9f989ffc81..a218759256 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java @@ -3,7 +3,7 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty; /** - * @implNote BlockProperties is a utility class that contains custom block properties. + * BlockProperties is a utility class that contains custom block properties. * This is useful for blocks that have custom properties that are not included in the default properties. * For example, a block that has a property that determines whether the block should tick on the server. * @see BooleanProperty diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ICoilType.java b/src/main/java/com/gregtechceu/gtceu/api/block/ICoilType.java index f4ed44974a..b14a7a0bb9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ICoilType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ICoilType.java @@ -12,55 +12,78 @@ import java.util.Arrays; import java.util.Comparator; -public interface ICoilType { +/** + * @implNote ICoilType is an interface that provides methods to get the properties of Heating Coils. + * This is useful for Heating Coils that have different properties based on the type of coil. + * For example, a Heating Coil that provides different temperatures based on the level of the coil. + * @see Material + */ +public interface ICoilType { /** - * @return The Unique Name of the Heating Coil + * TODO: Rename to getRegistryName() or getUniqueName() + * This is used for the registry name of the Heating Coil + * @implNote This should be unique for each Heating Coil + * @return the name of the Heating Coil */ @NotNull String getName(); /** - * @return the temperature the Heating Coil provides + * TODO: Rename to getTemperature() + * This is used for the temperature of the Heating Coil + * @return the temperature of the Heating Coil */ int getCoilTemperature(); /** + * TODO: Rename to getParallelizationTier() + * This is used for the parallelization tier of the Heating Coil * This is used for the amount of parallel recipes in the multi smelter - * - * @return the level of the Heating Coil + * @return the parallelization tier of the Heating Coil */ int getLevel(); /** - * This is used for the energy discount in the multi smelter - * + * This is used for the energy discount when used in the multi smelter * @return the energy discount of the Heating Coil */ int getEnergyDiscount(); /** - * This is used for the energy discount in the cracking unit and pyrolyse oven - * - * @return the tier of the coil + * TODO: Rename to getEnergyDiscountTier() + * This is used for the energy discount tier when used in the cracking unit and pyrolyse oven + * @return the energy discount tier of the Heating Coil */ int getTier(); /** + * This is used for the material of the Heating Coil + * @implNote This can be {@code null} if the Heating Coil does not have a material * @return the {@link Material} of the Heating Coil if it has one, otherwise {@code null} */ @Nullable Material getMaterial(); /** + * This is used for the texture of the Heating Coil * @return the {@link ResourceLocation} defining the base texture of the coil */ ResourceLocation getTexture(); + /** + * This is used to make a list of all Heating Coils sorted by temperature + * @implNote This is a lazy-loaded list of Heating Coils sorted by temperature + */ Lazy ALL_COILS_TEMPERATURE_SORTED = Lazy.of(() -> GTCEuAPI.HEATING_COILS.keySet().stream() .sorted(Comparator.comparing(ICoilType::getCoilTemperature)) .toArray(ICoilType[]::new)); + /** + * This is used to get the Heating Coil with the minimum-required temperature + * @param requiredTemperature the minimum-required temperature + * @return the Heating Coil with the minimum-required temperature, otherwise {@code null} + */ @Nullable static ICoilType getMinRequiredType(int requiredTemperature) { return Arrays.stream(ALL_COILS_TEMPERATURE_SORTED.get()) From 71116b6af8bae25c0f9758e0d4aa814d11afb1a4 Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Sun, 29 Dec 2024 15:25:15 -0500 Subject: [PATCH 08/16] Remove `// Properties` It's bad form and I'm eepy so I did this earlier --- src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java | 1 - .../java/com/gregtechceu/gtceu/api/block/BlockProperties.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java index fb1109aef6..80cb554a38 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java @@ -22,7 +22,6 @@ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class ActiveBlock extends AppearanceBlock { - // Properties public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); /** diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java b/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java index a218759256..313d56355c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/BlockProperties.java @@ -9,6 +9,5 @@ * @see BooleanProperty */ public final class BlockProperties { - // Properties public static final BooleanProperty SERVER_TICK = BooleanProperty.create("server_tick"); } \ No newline at end of file From 3c11c46ae6d0c1358fb03b33fa596de320d946d1 Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Sun, 29 Dec 2024 15:30:19 -0500 Subject: [PATCH 09/16] Small tweaks Remove some @see's Use InheritDoc instead of @see Remove @implNote at the beginning of the function description --- .../java/com/gregtechceu/gtceu/api/block/ActiveBlock.java | 2 -- .../java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java | 1 - .../java/com/gregtechceu/gtceu/api/block/IAppearance.java | 4 ++-- src/main/java/com/gregtechceu/gtceu/api/block/ICoilType.java | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java index 80cb554a38..0073f8605e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ActiveBlock.java @@ -16,8 +16,6 @@ * This is useful for blocks that have different appearances when active. * For example, a block that changes appearance when powered by redstone. * @see AppearanceBlock - * @see Block - * @see BlockState */ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java index 81f75c9173..9bcb21f4af 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/AppearanceBlock.java @@ -14,7 +14,6 @@ * For example, a block that changes appearance based on the block it is facing. * @see IAppearance * @see Block - * @see BlockState */ public class AppearanceBlock extends Block implements IAppearance { /** diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/IAppearance.java b/src/main/java/com/gregtechceu/gtceu/api/block/IAppearance.java index 5b81f4e1af..ea56101953 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/IAppearance.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/IAppearance.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable; /** - * @implNote IAppearance is an interface that provides a method to get the appearance of a block. + * IAppearance is an interface that provides a method to get the appearance of a block. * This is useful for blocks that have different appearances based on context. * For example, a block that changes appearance based on the block it is facing. * @see BlockState @@ -16,7 +16,7 @@ public interface IAppearance { /** * Gets the appearance of the block based on the context - * @see net.minecraftforge.common.extensions.IForgeBlock#getAppearance(BlockState, BlockAndTintGetter, BlockPos, Direction, BlockState, BlockPos) + * @inheritDoc IForgeBlock#getAppearance(BlockState, BlockAndTintGetter, BlockPos, Direction, BlockState, BlockPos) * @param state the block state * @param level the block and tint getter * @param pos the block position diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/ICoilType.java b/src/main/java/com/gregtechceu/gtceu/api/block/ICoilType.java index b14a7a0bb9..6401ac37b2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/ICoilType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/ICoilType.java @@ -14,7 +14,7 @@ /** - * @implNote ICoilType is an interface that provides methods to get the properties of Heating Coils. + * ICoilType is an interface that provides methods to get the properties of Heating Coils. * This is useful for Heating Coils that have different properties based on the type of coil. * For example, a Heating Coil that provides different temperatures based on the level of the coil. * @see Material From e0cb3257809567a36f4c345acf75ba56cb8c1896 Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Mon, 30 Dec 2024 13:10:35 -0500 Subject: [PATCH 10/16] Update IFilterType.java --- src/main/java/com/gregtechceu/gtceu/api/block/IFilterType.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/IFilterType.java b/src/main/java/com/gregtechceu/gtceu/api/block/IFilterType.java index 46ca8e04b6..513a1af307 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/IFilterType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/IFilterType.java @@ -9,8 +9,9 @@ public interface IFilterType extends StringRepresentable { /** + * Get the cleanroom type of this filter. * @return The cleanroom type of this filter. */ @NotNull CleanroomType getCleanroomType(); -} +} \ No newline at end of file From 31dc0615076cef40ae29c1844d8275269f936988 Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Mon, 30 Dec 2024 13:21:33 -0500 Subject: [PATCH 11/16] Javadocs! --- .../gtceu/api/block/IFilterType.java | 7 ++- .../gtceu/api/block/IFusionCasingType.java | 11 +++- .../gtceu/api/block/IMachineBlock.java | 54 ++++++++++++++++--- 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/IFilterType.java b/src/main/java/com/gregtechceu/gtceu/api/block/IFilterType.java index 513a1af307..9cff634767 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/IFilterType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/IFilterType.java @@ -6,8 +6,13 @@ import org.jetbrains.annotations.NotNull; +/** + * IFilterType is an interface that provides methods to get the properties of Filters. + * This is useful for Filters that have different properties based on the type of filter. + * For example, a Filter that provides different cleanroom types based on the level of the filter. + * @see CleanroomType + */ public interface IFilterType extends StringRepresentable { - /** * Get the cleanroom type of this filter. * @return The cleanroom type of this filter. diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/IFusionCasingType.java b/src/main/java/com/gregtechceu/gtceu/api/block/IFusionCasingType.java index 5e56b9e50e..777fb93cab 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/IFusionCasingType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/IFusionCasingType.java @@ -3,15 +3,22 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.util.StringRepresentable; +/** + * IFusionCasingType is an interface that provides methods to get the properties of Fusion Casings. + * This is useful for Fusion Casings that have different properties based on the type of casing. + * For example, a Fusion Casing that provides different textures based on the level of the casing. + */ public interface IFusionCasingType extends StringRepresentable { - /** - * @return the {@link ResourceLocation} defining the base texture of the coil + * Get the texture of the fusing casing. + * @return the {@link ResourceLocation} defining the base texture of the casing */ ResourceLocation getTexture(); /** + * Get the harvest level of the casing. * @return the Harvest level of this casing as an integer + * @see net.minecraft.world.item.Tier */ int getHarvestLevel(); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/IMachineBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/IMachineBlock.java index 83f3798d64..4af36a5956 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/IMachineBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/IMachineBlock.java @@ -33,24 +33,43 @@ import java.util.Optional; /** - * @author KilaBash - * @date 2023/3/31 - * @implNote IMachineBlock + * IMachineBlock is an interface that provides methods to get the properties of Machines. + * This is useful for Machines that have different properties based on the type of machine. + * For example, a Machine that provides different textures based on the level of the machine. */ public interface IMachineBlock extends IBlockRendererProvider, EntityBlock { - DirectionProperty UPWARDS_FACING_PROPERTY = DirectionProperty.create("upwards_facing", Direction.Plane.HORIZONTAL); + /** TODO: Rename to asBlock() or something similar + * The self method is used to cast the block to a Block. + */ default Block self() { return (Block) this; } + /** + * Get the definition of the machine. + * @return the {@link MachineDefinition} defining the properties of the machine + */ MachineDefinition getDefinition(); + /** + * Get the rotation state of the machine. + * @return the {@link RotationState} defining the rotation state of the machine + */ RotationState getRotationState(); + /** TODO: blockState is not used, remove it + * Get the tinted color of the machine. + * @param blockState the {@link BlockState} of the machine + * @param level the {@link BlockAndTintGetter} of the machine + * @param pos the {@link BlockPos} of the machine + * @param index the index of the tinted color + * @return the tinted color of the machine + */ static int colorTinted(BlockState blockState, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos, int index) { + // TODO: Flip conditions and return early if (level != null && pos != null) { var machine = MetaMachine.getMachine(level, pos); if (machine != null) { @@ -60,16 +79,31 @@ static int colorTinted(BlockState blockState, @Nullable BlockAndTintGetter level return -1; } + /** TODO: Rename to getBlockEntity() or something similar + * TODO: Rename parameter pos to blockPos + * Get the block entity of the machine. + * @param pos the {@link BlockPos} of the machine + * @param state the {@link BlockState} of the machine + * @return the {@link BlockEntity} of the machine + */ @Nullable @Override default BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return getDefinition().getBlockEntityType().create(pos, state); } + /** + * Get the block entity ticker of the machine. + * @param level the {@link Level} of the machine + * @param state the {@link BlockState} of the machine + * @param blockEntityType the {@link BlockEntityType} of the machine + * @return the {@link BlockEntityTicker} of the machine + */ @Nullable @Override default BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { + // TODO: Flip conditions and return early if (blockEntityType == getDefinition().getBlockEntityType()) { if (state.getValue(BlockProperties.SERVER_TICK) && !level.isClientSide) { return (pLevel, pPos, pState, pTile) -> { @@ -89,7 +123,13 @@ default BlockEntityTicker getTicker(Level level, Bloc return null; } + /** + * Set the machine owner of the machine. + * @param machine the {@link MetaMachine} of the machine + * @param player the {@link ServerPlayer} of the machine owner + */ default void setMachineOwner(MetaMachine machine, ServerPlayer player) { + // FTB Teams API if (IMachineOwner.MachineOwnerType.FTB.isAvailable()) { Optional team = FTBTeamsAPIImpl.INSTANCE.getManager().getTeamForPlayerID(player.getUUID()); if (team.isPresent()) { @@ -97,13 +137,15 @@ default void setMachineOwner(MetaMachine machine, ServerPlayer player) { return; } } - if (IMachineOwner.MachineOwnerType.ARGONAUTS.isAvailable()) { + // Argonauts API + else if (IMachineOwner.MachineOwnerType.ARGONAUTS.isAvailable()) { Guild guild = GuildHandler.read(player.server).get(player); if (guild != null) { machine.holder.setOwner(new ArgonautsOwner(guild, player.getUUID())); return; } } + // Alternatively, set the owner to the player machine.holder.setOwner(new PlayerOwner(player.getUUID())); } -} +} \ No newline at end of file From a59150623a4d30b2f6d9f547b5a13514c6f21ebd Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Mon, 30 Dec 2024 13:40:46 -0500 Subject: [PATCH 12/16] Update MaterialBlock.java This took so long I'm dying --- .../gtceu/api/block/MaterialBlock.java | 124 +++++++++++++++++- 1 file changed, 117 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java index ec684acbcb..0aa8bfaa5c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java @@ -56,17 +56,24 @@ import javax.annotation.ParametersAreNonnullByDefault; /** - * @author KilaBash - * @date 2023/2/27 - * @implNote MaterialBlock + * MaterialBlock is a class that provides methods to get the properties of Material Blocks. + * This takes care of the appearances depending on the GTCEU Material. + * @see AppearanceBlock + * @see Material */ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault public class MaterialBlock extends AppearanceBlock { - public final TagPrefix tagPrefix; public final Material material; + /** + * This is the constructor for the MaterialBlock class. + * @param properties the properties of the block + * @param tagPrefix the tag prefix of the block + * @param material the material of the block + * @param registerModel whether to register the model of the block + */ public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material material, boolean registerModel) { super(properties); this.material = material; @@ -76,12 +83,24 @@ public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material materi } } + /** + * This is the constructor for the MaterialBlock class when registerModel is ignored. + * @param properties the properties of the block + * @param tagPrefix the tag prefix of the block + * @param material the material of the block + */ public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material material) { this(properties, tagPrefix, material, true); } + /** + * This is the function that changes the color of the block. + * @implNote This is only used on the client side. + * @return the tinted color of the block + */ @OnlyIn(Dist.CLIENT) public static BlockColor tintedColor() { + // TODO: Avoid using arrow notation return (state, reader, pos, tintIndex) -> { if (state.getBlock() instanceof MaterialBlock block) { return block.material.getLayerARGB(tintIndex); @@ -90,8 +109,17 @@ public static BlockColor tintedColor() { }; } + // TODO: Rename to DEFAULT_FRAME_COLLISION_BOX public static VoxelShape FRAME_COLLISION_BOX = Shapes.box(0.05, 0.0, 0.05, 0.95, 1.0, 0.95); + /** + * This is the function that gets the collision shape of the block. + * @param state the {@link BlockState} of the block + * @param level the {@link BlockGetter} of the block + * @param pos the {@link BlockPos} of the block + * @param context the {@link CollisionContext} of the block + * @return the {@link VoxelShape} of the block + */ @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { if (this.tagPrefix == TagPrefix.frameGt) { @@ -100,7 +128,15 @@ public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPo return super.getCollisionShape(state, level, pos, context); } - /** Start falling ore stuff */ + /** + * This is the function that handles the block when placed. + * @implNote This is suppressed because the method is deprecated. + * @param state the {@link BlockState} of the block + * @param level the {@link Level} of the block + * @param pos the {@link BlockPos} of the block + * @param oldState the {@link BlockState} of the old block + * @param isMoving whether the block is moving + */ @SuppressWarnings("deprecation") @Override public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { @@ -110,10 +146,21 @@ public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldS } } + /** + * This is the function that updates the shape of the block. + * @param state the {@link BlockState} of the block + * @param direction the {@link Direction} of the block + * @param neighborState the {@link BlockState} of the neighbor block + * @param level the {@link LevelAccessor} of the block + * @param currentPos the {@link BlockPos} of the current block + * @param neighborPos the {@link BlockPos} of the neighbor block + * @return the {@link BlockState} of the block + */ @SuppressWarnings("deprecation") @Override public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor level, BlockPos currentPos, BlockPos neighborPos) { + // TODO: Simplify conditions and return early if (TagPrefix.ORES.containsKey(this.tagPrefix) && TagPrefix.ORES.get(tagPrefix).isSand() && ConfigHolder.INSTANCE.worldgen.sandOresFall) { level.scheduleTick(currentPos, this, this.getDelayAfterPlace()); @@ -121,17 +168,33 @@ public BlockState updateShape(BlockState state, Direction direction, BlockState return super.updateShape(state, direction, neighborState, level, currentPos, neighborPos); } + /** + * This is the function that updates the block with game ticks. + * @param state the {@link BlockState} of the block + * @param level the {@link ServerLevel} of the block + * @param pos the {@link BlockPos} of the block + * @param random the {@link RandomSource} of the block + */ @SuppressWarnings("deprecation") @Override public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { + // TODO: Simplify condition if (!FallingBlock.isFree(level.getBlockState(pos.below())) || pos.getY() < level.getMinBuildHeight()) { return; } FallingBlockEntity.fall(level, pos, state); } + /** + * This is the function that animates the block with game ticks. + * @param state the {@link BlockState} of the block + * @param level the {@link Level} of the block + * @param pos the {@link BlockPos} of the block + * @param random the {@link RandomSource} of the block + */ @Override public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { + // TODO: Simplify condition if (!TagPrefix.ORES.containsKey(this.tagPrefix) || !TagPrefix.ORES.get(tagPrefix).isSand() || !ConfigHolder.INSTANCE.worldgen.sandOresFall) return; @@ -145,23 +208,34 @@ public void animateTick(BlockState state, Level level, BlockPos pos, RandomSourc /** * Gets the amount of time in ticks this block will wait before attempting to start falling. + * @return the delay after the block is placed */ protected int getDelayAfterPlace() { return 2; } - /** End falling ore stuff */ - + /** + * This is the function that gets the description ID of the block. + * @return the unlocalized name of the block + */ @Override public String getDescriptionId() { return tagPrefix.getUnlocalizedName(material); } + /** + * This is the function that gets the name of the block. + * @return the localized name of the block + */ @Override public MutableComponent getName() { return tagPrefix.getLocalizedName(material); } + /** + * This is the function determines how the block is used. + * @return the result of the interaction + */ @Override public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { @@ -216,6 +290,11 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player return InteractionResult.PASS; } + /** + * TODO: Tbh I actually don't know what this does enough to describe it + * @param stack the {@link ItemStack} of the block + * @return the {@link MaterialBlock} of the item if it is a frame box, otherwise {@code null} + */ @Nullable public static MaterialBlock getFrameboxFromItem(ItemStack stack) { Item item = stack.getItem(); @@ -227,6 +306,14 @@ public static MaterialBlock getFrameboxFromItem(ItemStack stack) { return null; } + /** + * This is the function that determines if a frame block is removed from the world. + * @param level the {@link Level} of the block + * @param pos the {@link BlockPos} of the block + * @param player the {@link Player} of the block + * @param stack the {@link ItemStack} of the block + * @return whether the frame block was removed + */ public boolean removeFrame(Level level, BlockPos pos, Player player, ItemStack stack) { BlockEntity te = level.getBlockEntity(pos); if (te instanceof PipeBlockEntity pipeTile) { @@ -242,6 +329,12 @@ public boolean removeFrame(Level level, BlockPos pos, Player player, ItemStack s return false; } + /** + * This is the function that determines if a block can be replaced in-place. + * @param state the {@link BlockState} of the block + * @param useContext the {@link BlockPlaceContext} of the block + * @return whether the block can be replaced + */ @Override public boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) { if (this.tagPrefix == TagPrefix.frameGt && useContext.getItemInHand().getItem() instanceof PipeBlockItem && @@ -250,6 +343,16 @@ public boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) { return super.canBeReplaced(state, useContext); } + /** + * This is the function that determines if a block can be replaced with a framed pipe? + * @param level the {@link Level} of the block + * @param pos the {@link BlockPos} of the block + * @param state the {@link BlockState} of the block + * @param player the {@link Player} of the block + * @param stackInHand the {@link ItemStack} of the block + * @param hit the {@link BlockHitResult} of the block + * @return whether the block can be replaced with a framed pipe + */ public boolean replaceWithFramedPipe(Level level, BlockPos pos, BlockState state, Player player, ItemStack stackInHand, BlockHitResult hit) { PipeBlock pipeBlock = (PipeBlock) ((PipeBlockItem) stackInHand.getItem()).getBlock(); @@ -281,6 +384,13 @@ public boolean replaceWithFramedPipe(Level level, BlockPos pos, BlockState state return false; } + /** + * TODO: Tbh I actually don't know what this does enough to describe it + * @param state the {@link BlockState} of the block + * @param level the {@link Level} of the block + * @param pos the {@link BlockPos} of the block + * @param entity the {@link Entity} of the block + */ @Override public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { if (this.tagPrefix == TagPrefix.frameGt && entity instanceof LivingEntity livingEntity) { From d2d449bf24d5053e5ce1cb6d34546f0d425cb2eb Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Mon, 30 Dec 2024 13:46:02 -0500 Subject: [PATCH 13/16] Update MaterialPipeBlock.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are getting harder 😭 --- .../gtceu/api/block/MaterialPipeBlock.java | 76 ++++++++++++++++++- 1 file changed, 72 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialPipeBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialPipeBlock.java index 034cf09bbe..9855dc6091 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialPipeBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialPipeBlock.java @@ -21,9 +21,12 @@ import javax.annotation.ParametersAreNonnullByDefault; /** - * @author KilaBash - * @date 2023/2/28 - * @implNote MaterialPipeBlock + * MaterialPipeBlock is an abstract class that provides methods to get the properties of Material Pipes. + * This is useful for Material Pipes that have different properties based on the type of pipe. + * For example, a Material Pipe that provides different textures based on the material of the pipe. + * @param the type of pipe + * @param the type of data stored in the pipe + * @param the type of pipe network in the world */ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @@ -36,6 +39,12 @@ public abstract class MaterialPipeBlock< public final PipeBlockRenderer renderer; public final PipeModel model; + /** + * MaterialPipeBlock is a constructor that creates a Material Pipe Block. + * @param properties the properties of the block + * @param pipeType the type of pipe + * @param material the material of the pipe + */ public MaterialPipeBlock(Properties properties, PipeType pipeType, Material material) { super(properties, pipeType); this.material = material; @@ -43,8 +52,14 @@ public MaterialPipeBlock(Properties properties, PipeType pipeType, Material mate this.renderer = new PipeBlockRenderer(this.model); } + /** + * The function that returns the tinted color of the pipe. + * @implNote This is only used on the client side. + * @return the tinted color of the pipe + */ @OnlyIn(Dist.CLIENT) public static BlockColor tintedColor() { + // TODO: Avoid Arrow Notation and use Early Returns return (blockState, level, blockPos, index) -> { if (blockState.getBlock() instanceof MaterialPipeBlock block) { if (blockPos != null && level != null && @@ -66,21 +81,43 @@ public static BlockColor tintedColor() { }; } + /** + * The function that returns the tinted color of the pipe. + * @param blockState the {@link BlockState} of the pipe + * @param blockAndTintGetter the {@link BlockAndTintGetter} of the pipe + * @param blockPos the {@link BlockPos} of the pipe + * @param index the index of the tinted color + * @return the tinted color of the pipe + */ public int tinted(BlockState blockState, @Nullable BlockAndTintGetter blockAndTintGetter, @Nullable BlockPos blockPos, int index) { return index == 0 || index == 1 ? material.getMaterialRGB() : -1; } + /** + * The function that returns the model of the pipe. + * @return the model of the pipe + */ @Override protected PipeModel getPipeModel() { return model; } + /** + * TODO: The function that creates the raw data of the pipe? + * @param pState the {@link BlockState} of the pipe + * @param pStack the {@link ItemStack} of the pipe + */ @Override public final NodeDataType createRawData(BlockState pState, @Nullable ItemStack pStack) { return createMaterialData(); } + /** + * The function that creates the properties of the pipe. + * @param pipeTile the {@link IPipeNode} of the pipe + * @return the properties of the pipe + */ @Override public NodeDataType createProperties(IPipeNode pipeTile) { PipeType pipeType = pipeTile.getPipeType(); @@ -92,29 +129,60 @@ public NodeDataType createProperties(IPipeNode pipeTile) return createProperties(pipeType, material); } + /** + * The function that creates the properties of the pipe. + * @param pipeType the type of pipe + * @param material the material of the pipe + * @return the properties of the pipe + */ protected abstract NodeDataType createProperties(PipeType pipeType, Material material); + /** + * The function that returns the renderer of the pipe. + * @param state the {@link BlockState} of the pipe + * @return the renderer of the pipe + */ @Override public @Nullable PipeBlockRenderer getRenderer(BlockState state) { return renderer; } + /** + * The function that returns the fallback type of the pipe. + * @return the fallback type of the pipe + */ @Override public final NodeDataType getFallbackType() { return createMaterialData(); } + /** + * The function that creates the material data of the pipe. + * @return the material data of the pipe + */ protected abstract NodeDataType createMaterialData(); + /** + * The function that creates the pipe model of the pipe. + * @return the pipe model of the pipe + */ protected abstract PipeModel createPipeModel(); + /** + * The function that returns the description ID of the pipe. + * @return the unlocalized name of the pipe + */ @Override public String getDescriptionId() { return pipeType.getTagPrefix().getUnlocalizedName(material); } + /** + * The function that returns the name of the pipe. + * @return the localized name of the pipe + */ @Override public MutableComponent getName() { return pipeType.getTagPrefix().getLocalizedName(material); } -} +} \ No newline at end of file From 85e6356041965c142a5da2e3ec5fee588e8bdc14 Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Mon, 30 Dec 2024 13:51:08 -0500 Subject: [PATCH 14/16] Update MetaMachineBlock.java All I'm going for now. A lot of the docs are copy-paste --- .../gtceu/api/block/MetaMachineBlock.java | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/MetaMachineBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/MetaMachineBlock.java index 3c209bc0ed..dfc51272e5 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/MetaMachineBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/MetaMachineBlock.java @@ -56,9 +56,9 @@ import javax.annotation.ParametersAreNonnullByDefault; /** - * @author KilaBash - * @date 2023/2/17 - * @implNote GTBlock + * MetaMachineBlock is a class that provides methods to get the properties of Meta Machines. + * This is useful for Meta Machines that have different properties based on the type of machine. + * For example, a Meta Machine that provides different textures based on the level of the machine. */ @SuppressWarnings("deprecation") @MethodsReturnNonnullByDefault @@ -70,6 +70,11 @@ public class MetaMachineBlock extends AppearanceBlock implements IMachineBlock { @Getter public final RotationState rotationState; + /** + * MetaMachineBlock is a constructor that creates a Meta Machine Block. + * @param properties the properties of the block + * @param definition the definition of the machine + */ public MetaMachineBlock(Properties properties, MachineDefinition definition) { super(properties); this.definition = definition; @@ -84,6 +89,11 @@ public MetaMachineBlock(Properties properties, MachineDefinition definition) { } } + /** + * Get the block state definition of the machine. + * @implNote This is used to add the block state properties of the machine + * @param pBuilder the {@link StateDefinition.Builder} of the block + */ @Override protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { pBuilder.add(BlockProperties.SERVER_TICK); @@ -97,23 +107,49 @@ protected void createBlockStateDefinition(StateDefinition.Builder Date: Mon, 30 Dec 2024 16:51:47 -0500 Subject: [PATCH 15/16] Appeasing the Screret --- .../java/com/gregtechceu/gtceu/api/block/MaterialBlock.java | 4 +--- .../com/gregtechceu/gtceu/api/block/MaterialPipeBlock.java | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java index 0aa8bfaa5c..14e4c8c663 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java @@ -100,11 +100,9 @@ public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material materi */ @OnlyIn(Dist.CLIENT) public static BlockColor tintedColor() { - // TODO: Avoid using arrow notation return (state, reader, pos, tintIndex) -> { - if (state.getBlock() instanceof MaterialBlock block) { + if (state.getBlock() instanceof MaterialBlock block) return block.material.getLayerARGB(tintIndex); - } return -1; }; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialPipeBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialPipeBlock.java index 9855dc6091..c4a895a653 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialPipeBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialPipeBlock.java @@ -59,7 +59,6 @@ public MaterialPipeBlock(Properties properties, PipeType pipeType, Material mate */ @OnlyIn(Dist.CLIENT) public static BlockColor tintedColor() { - // TODO: Avoid Arrow Notation and use Early Returns return (blockState, level, blockPos, index) -> { if (blockState.getBlock() instanceof MaterialPipeBlock block) { if (blockPos != null && level != null && @@ -71,7 +70,7 @@ public static BlockColor tintedColor() { return pipe.getFrameMaterial().getMaterialSecondaryRGB(); } } - if (pipe.isPainted()) { + else if (pipe.isPainted()) { return pipe.getRealColor(); } } From 57aa0cc5cbb7d6f1ba9ec867cfbd06df01260cd8 Mon Sep 17 00:00:00 2001 From: Stanley Goodwin Date: Mon, 30 Dec 2024 17:04:34 -0500 Subject: [PATCH 16/16] Update MaterialBlock.java To appease the Tech22 --- .../java/com/gregtechceu/gtceu/api/block/MaterialBlock.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java index 14e4c8c663..62a2c7bc52 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java @@ -101,9 +101,8 @@ public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material materi @OnlyIn(Dist.CLIENT) public static BlockColor tintedColor() { return (state, reader, pos, tintIndex) -> { - if (state.getBlock() instanceof MaterialBlock block) - return block.material.getLayerARGB(tintIndex); - return -1; + if (!(state.getBlock() instanceof MaterialBlock block)) return -1; + return block.material.getLayerARGB(tintIndex); }; }