From 978938d450b63b220b68a44dbb309619f4301dc2 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 15 Sep 2022 18:16:28 +0800 Subject: [PATCH] more documentation efforts --- .../structure/AutoPlaceEnvironment.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gtnewhorizon/structurelib/structure/AutoPlaceEnvironment.java b/src/main/java/com/gtnewhorizon/structurelib/structure/AutoPlaceEnvironment.java index eb98eaa9..f6902628 100644 --- a/src/main/java/com/gtnewhorizon/structurelib/structure/AutoPlaceEnvironment.java +++ b/src/main/java/com/gtnewhorizon/structurelib/structure/AutoPlaceEnvironment.java @@ -6,6 +6,7 @@ import java.util.function.Predicate; import javax.annotation.Nonnull; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.util.IChatComponent; @@ -96,7 +97,9 @@ void setSource(IItemSource source) { } public APILevel getAPILevel() { - return definition == null ? APILevel.Legacy : APILevel.V2; + return definition == null + ? actor instanceof EntityPlayerMP ? APILevel.Legacy : APILevel.LegacyRelaxed + : APILevel.V2; } /** @@ -126,6 +129,7 @@ public Consumer getChatter() { /** * Test if given location is contained within the current piece. + * * @param offsetA offset in A direction relative to current element * @param offsetB offset in B direction relative to current element * @param offsetC offset in C direction relative to current element @@ -210,8 +214,25 @@ public boolean takeAll(ItemStack stack, boolean simulate) { } } + /** + * Defines the various API level an {@link AutoPlaceEnvironment} has implemented. + *

+ * Enum constants are defined in chronological order. + */ public enum APILevel { + /** + * Implements {@link #getChatter()}, {@link #getActor()} and {@link #getSource()}. + * {@link #getActor()} is guaranteed to be an {@link net.minecraft.entity.player.EntityPlayerMP} + */ Legacy, + /** + * Implements {@link #getChatter()}, {@link #getActor()} and {@link #getSource()}. + * {@link #getActor()} is NOT guaranteed to be an {@link net.minecraft.entity.player.EntityPlayerMP} + */ + LegacyRelaxed, + /** + * Implements everything so far we have defined. + */ V2, } }