From 57d6a666bbb52f033f5efdcf80513be1056840da Mon Sep 17 00:00:00 2001 From: Aram Date: Sun, 6 Oct 2024 14:11:26 +0200 Subject: [PATCH] Cleaned some Comments Co-Authored-By: Justindraak1 <86565594+justindraak1@users.noreply.github.com> --- .../main/java/software/bluelib/BlueLib.java | 8 +- .../bluelib/event/ReloadEventHandler.java | 2 +- .../interfaces/logging/ILogColorProvider.java | 2 +- .../interfaces/variant/IVariantAccessor.java | 32 ++++++- .../interfaces/variant/IVariantEntity.java | 4 +- .../variant/base/IVariantEntityBase.java | 6 +- .../software/bluelib/json/JSONLoader.java | 6 +- .../software/bluelib/json/JSONMerger.java | 4 +- .../mixin/variant/LivingEntityMixin.java | 85 ++++++++++++++++++- 9 files changed, 130 insertions(+), 19 deletions(-) diff --git a/NeoForge/src/main/java/software/bluelib/BlueLib.java b/NeoForge/src/main/java/software/bluelib/BlueLib.java index a834bef5..36612b6a 100644 --- a/NeoForge/src/main/java/software/bluelib/BlueLib.java +++ b/NeoForge/src/main/java/software/bluelib/BlueLib.java @@ -44,7 +44,7 @@ public class BlueLib { /** - * A {@link ScheduledExecutorService} used to schedule tasks, such as printing messages after a delay. + * A {@code public static final} {@link ScheduledExecutorService} used to schedule tasks, such as printing messages after a delay. *

* This executor runs tasks on a single thread to ensure delayed tasks run in a separate thread from the main thread. *

@@ -54,7 +54,7 @@ public class BlueLib { private static final ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1); /** - * A {@link String} representing the Mod ID for the {@link BlueLib} mod. + * A {@code public static final} {@link String} representing the Mod ID for the {@link BlueLib} mod. *

This serves as a unique identifier for the mod.

* @Co-author MeAlam, Dan * @since 1.0.0 @@ -86,7 +86,7 @@ public BlueLib(IEventBus pModEventBus, ModContainer pModContainer) { } /** - * a {@code void} that handles the {@link FMLLoadCompleteEvent}, which occurs when the mod finishes loading. + * A {@code public void} that handles the {@link FMLLoadCompleteEvent}, which occurs when the mod finishes loading. *

* If the mod is in developer mode, it schedules a task that prints a thank-you message after a short delay. *

@@ -112,7 +112,7 @@ public void onLoadComplete(FMLLoadCompleteEvent pEvent) { } /** - * a {@code void} that checks if the mod is running in developer mode. + * A {@code static} {@link Boolean} that checks if the mod is running in developer mode. *

* Developer mode is active when the mod is not running in a production environment. *

diff --git a/NeoForge/src/main/java/software/bluelib/event/ReloadEventHandler.java b/NeoForge/src/main/java/software/bluelib/event/ReloadEventHandler.java index 6ba0a893..53c35347 100644 --- a/NeoForge/src/main/java/software/bluelib/event/ReloadEventHandler.java +++ b/NeoForge/src/main/java/software/bluelib/event/ReloadEventHandler.java @@ -30,7 +30,7 @@ public class ReloadEventHandler { /** - * A {@code void} that registers entity variants from specified locations. + * A {@code protected static void} that registers entity variants from specified locations. *

* This method attempts to load variants from both mod and datapack locations. It logs status information and * handles exceptions that occur during the loading process. diff --git a/NeoForge/src/main/java/software/bluelib/interfaces/logging/ILogColorProvider.java b/NeoForge/src/main/java/software/bluelib/interfaces/logging/ILogColorProvider.java index ba85c030..c0a48b1c 100644 --- a/NeoForge/src/main/java/software/bluelib/interfaces/logging/ILogColorProvider.java +++ b/NeoForge/src/main/java/software/bluelib/interfaces/logging/ILogColorProvider.java @@ -5,7 +5,7 @@ import java.util.logging.Level; /** - * An {@code Interface} for providing color codes based on log levels. + * A {@code public Interface} for providing color codes based on log levels. *

* This interface defines a method to retrieve color codes for various log levels. Implementations should provide * the appropriate color codes for each log level to enhance the readability of log messages. diff --git a/NeoForge/src/main/java/software/bluelib/interfaces/variant/IVariantAccessor.java b/NeoForge/src/main/java/software/bluelib/interfaces/variant/IVariantAccessor.java index bd4a4579..b688ed28 100644 --- a/NeoForge/src/main/java/software/bluelib/interfaces/variant/IVariantAccessor.java +++ b/NeoForge/src/main/java/software/bluelib/interfaces/variant/IVariantAccessor.java @@ -1,7 +1,37 @@ +// Copyright (c) BlueLib. Licensed under the MIT License. + package software.bluelib.interfaces.variant; +/** + * A {@code public Interface} interface responsible for accessing and modifying + * variant-related properties of an entity within the BlueLib framework. + *

+ * Key Methods: + *

+ * + * @author MeAlam + * @since 1.0.0 + */ public interface IVariantAccessor { + + /** + * A {@code void} method that sets the variant name for the entity. + * + * @param pVariantName {@link String} - The variant name to assign to the entity. + * @author MeAlam + * @since 1.0.0 + */ void setEntityVariantName(String pVariantName); + + /** + * A {@link String} method that retrieves the variant name of the entity. + * + * @return {@link String} - The current variant name of the entity. + * @author MeAlam + * @since 1.0.0 + */ String getEntityVariantName(); } - diff --git a/NeoForge/src/main/java/software/bluelib/interfaces/variant/IVariantEntity.java b/NeoForge/src/main/java/software/bluelib/interfaces/variant/IVariantEntity.java index 97c50daa..2b08cdac 100644 --- a/NeoForge/src/main/java/software/bluelib/interfaces/variant/IVariantEntity.java +++ b/NeoForge/src/main/java/software/bluelib/interfaces/variant/IVariantEntity.java @@ -10,7 +10,7 @@ import java.util.List; /** - * An {@code Interface} representing an entity that supports multiple variants. + * A {@code public Interface} representing an entity that supports multiple variants. *

* This interface extends {@link IVariantEntityBase} to include methods specific to handling entity variants, including * random selection of variants. @@ -35,7 +35,7 @@ public interface IVariantEntity extends IVariantEntityBase { RandomSource random = RandomSource.create(); /** - * A {@link String} that selects a random variant name from the provided list of variant names. + * A {@code default} {@link String} that selects a random variant name from the provided list of variant names. *

* This method uses the {@link RandomSource} to pick a random variant from the list. If the list is empty, the default * variant name is returned. diff --git a/NeoForge/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java b/NeoForge/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java index 46c9ca2a..d89c5499 100644 --- a/NeoForge/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java +++ b/NeoForge/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java @@ -12,7 +12,7 @@ import java.util.stream.Collectors; /** - * An {@code base Interface} providing fundamental methods for handling entity variants. + * A {@code public base Interface} providing fundamental methods for handling entity variants. *

* This interface defines methods for retrieving texture locations and variant names associated with entities. *

@@ -30,7 +30,7 @@ public interface IVariantEntityBase { /** - * A {@link ResourceLocation} that points to the texture of an entity. + * A {@code default} {@link ResourceLocation} that points to the texture of an entity. *

* This method constructs a {@link ResourceLocation} using the provided mod ID and texture path. *

@@ -47,7 +47,7 @@ default ResourceLocation getTextureLocation(String pModId, String pPath) { } /** - * A {@link List} of variant names associated with the specified entity. + * A {@code default} {@link List} of variant names associated with the specified entity. *

* This method retrieves the names of all variants for a given entity by querying the {@link VariantLoader}. *

diff --git a/NeoForge/src/main/java/software/bluelib/json/JSONLoader.java b/NeoForge/src/main/java/software/bluelib/json/JSONLoader.java index 55569689..25a6f80b 100644 --- a/NeoForge/src/main/java/software/bluelib/json/JSONLoader.java +++ b/NeoForge/src/main/java/software/bluelib/json/JSONLoader.java @@ -17,7 +17,7 @@ import java.util.Optional; /** - * A {@code class} responsible for loading and parsing JSON data from + * A {@code public class} responsible for loading and parsing JSON data from * resources defined by {@link ResourceLocation} within a Minecraft mod environment.
* It uses the {@link Gson} library to convert JSON strings into {@link JsonObject} instances. *

@@ -32,13 +32,13 @@ public class JSONLoader { /** - * A {@link Gson} instance for parsing JSON data. + * A {@code private static} {@link Gson} instance for parsing JSON data. * @Co-author MeAlam, Dan */ private static final Gson gson = new Gson(); /** - * A {@link JsonObject} that loads JSON data from a {@link ResourceLocation}.
+ * A {@code public} {@link JsonObject} that loads JSON data from a {@link ResourceLocation}.
* This method is typically used to load configuration files or other JSON-based resources * in a Minecraft mod environment. *

diff --git a/NeoForge/src/main/java/software/bluelib/json/JSONMerger.java b/NeoForge/src/main/java/software/bluelib/json/JSONMerger.java index d2518b0c..ac300db6 100644 --- a/NeoForge/src/main/java/software/bluelib/json/JSONMerger.java +++ b/NeoForge/src/main/java/software/bluelib/json/JSONMerger.java @@ -11,7 +11,7 @@ import java.util.Map; /** - * A {@code class} responsible for merging JSON data from a source {@link JsonObject} into a target {@link JsonObject}. + * A {@code public class} responsible for merging JSON data from a source {@link JsonObject} into a target {@link JsonObject}. *

* This class provides functionality to combine JSON data where overlapping keys result in merging arrays, * and non-overlapping keys are simply added to the target. @@ -30,7 +30,7 @@ public class JSONMerger { /** - * A {@code void} method that merges data from a source {@link JsonObject} into a target {@link JsonObject}. + * A {@code public void} method that merges data from a source {@link JsonObject} into a target {@link JsonObject}. *

* If the target JSON object already contains a key present in the source JSON object, the values are merged if they are arrays. * Otherwise, the source value is added to the target JSON object. diff --git a/NeoForge/src/main/java/software/bluelib/mixin/variant/LivingEntityMixin.java b/NeoForge/src/main/java/software/bluelib/mixin/variant/LivingEntityMixin.java index afb65d3c..68592587 100644 --- a/NeoForge/src/main/java/software/bluelib/mixin/variant/LivingEntityMixin.java +++ b/NeoForge/src/main/java/software/bluelib/mixin/variant/LivingEntityMixin.java @@ -1,3 +1,5 @@ +// Copyright (c) BlueLib. Licensed under the MIT License. + package software.bluelib.mixin.variant; import net.minecraft.nbt.CompoundTag; @@ -14,46 +16,125 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import software.bluelib.interfaces.variant.IVariantAccessor; +/** + * A {@code public} {@link Mixin} class that injects functionality into the {@link LivingEntity} class to + * provide variant management support within the BlueLib framework. + *

+ * This mixin adds functionality to define, save, and retrieve an entity's variant information + * using NBT (Named Binary Tag) data. It implements the {@link IVariantAccessor} interface, which + * allows setting and getting the variant name of a {@link LivingEntity}. + *

+ * Key Methods: + *

    + *
  • {@link #bluelib$setVariantName(String)} - Sets the variant name of the entity.
  • + *
  • {@link #bluelib$getVariantName()} - Retrieves the variant name of the entity.
  • + *
+ * + * @author MeAlam + * @since 1.0.0 + */ @Mixin(LivingEntity.class) public class LivingEntityMixin implements IVariantAccessor { + /** + * A {@link EntityDataAccessor} to hold the entity's variant name, which is synchronized + * across clients and servers using {@link SynchedEntityData}. + * @Co-author MeAlam + * @since 1.0.0 + */ @Unique private static final EntityDataAccessor bluelib$VARIANT = SynchedEntityData.defineId(LivingEntity.class, EntityDataSerializers.STRING); + /** + * A {@code public void} that injects into the {@code defineSynchedData} method of {@link LivingEntity} to define + * the synchronized data that will hold the entity's variant information. + * + * @param pBuilder {@link SynchedEntityData.Builder} - The builder to define entity data. + * @param pCi {@link CallbackInfo} - Callback information for the injection process. + * @author MeAlam + * @since 1.0.0 + */ @Inject(method = "defineSynchedData", at = @At("HEAD")) protected void defineSynchedData(SynchedEntityData.@NotNull Builder pBuilder, CallbackInfo pCi) { - pBuilder.define(bluelib$VARIANT, "normal"); + pBuilder.define(bluelib$VARIANT, "normal"); // Default variant is "normal" } + /** + * A {@code public void} that injects into the {@code addAdditionalSaveData} method of {@link LivingEntity} to store + * the entity's variant in NBT data when saving the entity. + * + * @param pCompound {@link CompoundTag} - The NBT tag to save the entity's variant information. + * @param pCi {@link CallbackInfo} - Callback information for the injection process. + * @author MeAlam + * @since 1.0.0 + */ @Inject(method = "addAdditionalSaveData", at = @At("HEAD")) public void addAdditionalSaveData(@NotNull CompoundTag pCompound, CallbackInfo pCi) { pCompound.putString("Variant", bluelib$getVariantName()); } + /** + * A {@code public void} that injects into the {@code readAdditionalSaveData} method of {@link LivingEntity} to read + * the entity's variant from NBT data when loading the entity. + * + * @param pCompound {@link CompoundTag} - The NBT tag containing the entity's variant information. + * @param pCi {@link CallbackInfo} - Callback information for the injection process. + * @author MeAlam + * @since 1.0.0 + */ @Inject(method = "readAdditionalSaveData", at = @At("HEAD")) public void readAdditionalSaveData(@NotNull CompoundTag pCompound, CallbackInfo pCi) { bluelib$setVariantName(pCompound.getString("Variant")); } + /** + * A {@code public void} method that sets the entity's variant name. + * + * @param pName {@link String} - The variant name to assign to the entity. + * @author MeAlam + * @since 1.0.0 + */ @Unique public void bluelib$setVariantName(String pName) { ((Entity) (Object) this).getEntityData().set(bluelib$VARIANT, pName); } + /** + * A {@code public} {@link String} method that retrieves the entity's current variant name. + * + * @return The current variant name of the entity as a {@link String}. + * @author MeAlam + * @since 1.0.0 + */ @Unique public String bluelib$getVariantName() { return ((Entity) (Object) this).getEntityData().get(bluelib$VARIANT); } + /** + * A {@code public void} method that sets the variant name of the entity. This method overrides + * the {@link IVariantAccessor#setEntityVariantName(String)} interface method. + * + * @param pVariantName {@link String} - The variant name to set for the entity. + * @author MeAlam + * @since 1.0.0 + */ @Override public void setEntityVariantName(String pVariantName) { bluelib$setVariantName(pVariantName); } + /** + * A {@code public} {@link String} method that retrieves the variant name of the entity. This method overrides + * the {@link IVariantAccessor#getEntityVariantName()} interface method. + * + * @return The current variant name of the entity as a {@link String}. + * @author MeAlam + * @since 1.0.0 + */ @Override public String getEntityVariantName() { return bluelib$getVariantName(); } } -