From 0de301bfd62f3bb2f816dcaa292c494cae807af1 Mon Sep 17 00:00:00 2001 From: Aizistral Date: Mon, 2 Jan 2023 20:28:03 +0100 Subject: Figure this shit out, more or less --- forge/src/main/java/net/fabricmc/api/EnvType.java | 48 ++++++++++++++++++++++ .../main/java/net/fabricmc/api/Environment.java | 48 ++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 forge/src/main/java/net/fabricmc/api/EnvType.java create mode 100644 forge/src/main/java/net/fabricmc/api/Environment.java (limited to 'forge/src/main/java/net') diff --git a/forge/src/main/java/net/fabricmc/api/EnvType.java b/forge/src/main/java/net/fabricmc/api/EnvType.java new file mode 100644 index 0000000..253b6e8 --- /dev/null +++ b/forge/src/main/java/net/fabricmc/api/EnvType.java @@ -0,0 +1,48 @@ +/* + * Copyright 2016 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.fabricmc.api; + +/** + * Represents a type of environment. + * + *

A type of environment is a jar file in a Minecraft version's json file's {@code download} + * subsection, including the {@code client.jar} and the {@code server.jar}.

+ * + * @see Environment + * @see EnvironmentInterface + */ +public enum EnvType { + /** + * Represents the client environment type, in which the {@code client.jar} for a + * Minecraft version is the main game jar. + * + *

A client environment type has all client logic (client rendering and integrated + * server logic), the data generator logic, and dedicated server logic. It encompasses + * everything that is available on the {@linkplain #SERVER server environment type}.

+ */ + CLIENT, + /** + * Represents the server environment type, in which the {@code server.jar} for a + * Minecraft version is the main game jar. + * + *

A server environment type has the dedicated server logic and data generator + * logic, which are all included in the {@linkplain #CLIENT client environment type}. + * However, the server environment type has its libraries embedded compared to the + * client.

+ */ + SERVER +} diff --git a/forge/src/main/java/net/fabricmc/api/Environment.java b/forge/src/main/java/net/fabricmc/api/Environment.java new file mode 100644 index 0000000..1db59da --- /dev/null +++ b/forge/src/main/java/net/fabricmc/api/Environment.java @@ -0,0 +1,48 @@ +/* + * Copyright 2016 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.fabricmc.api; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Applied to declare that the annotated element is present only in the specified environment. + * + *

Use with caution, as Fabric-loader will remove the annotated element in a mismatched environment!

+ * + *

When the annotated element is removed, bytecode associated with the element will not be removed. + * For example, if a field is removed, its initializer code will not, and will cause an error on execution.

+ * + *

If an overriding method has this annotation and its overridden method doesn't, + * unexpected behavior may happen. If an overridden method has this annotation + * while the overriding method doesn't, it is safe, but the method can be used from + * the overridden class only in the specified environment.

+ * + * @see EnvironmentInterface + */ +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PACKAGE}) +@Documented +public @interface Environment { + /** + * Returns the environment type that the annotated element is only present in. + */ + EnvType value(); +} -- cgit v1.2.3