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.Consumer; 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 @@ public class AutoPlaceEnvironment { } 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 class AutoPlaceEnvironment { /** * 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 class AutoPlaceEnvironment { } } + /** + * 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, } }