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/.gitignore | 6 +- forge/build.gradle | 24 ++--- forge/gradle.properties | 2 +- .../nochatreports/forge/NoChatReports.java | 42 -------- .../nochatreports/forge/NoChatReportsClient.java | 115 --------------------- .../forge/mixins/client/MixinClientConnection.java | 32 ------ .../MixinClientHandshakePacketListenerImpl.java | 22 ---- .../mixins/client/MixinClientPacketListener.java | 22 ---- forge/src/forge/java/net/fabricmc/api/EnvType.java | 48 --------- .../forge/java/net/fabricmc/api/Environment.java | 48 --------- forge/src/forge/resources/META-INF/MANIFEST.MF | 1 - .../forge/resources/META-INF/accesstransformer.cfg | 23 ----- forge/src/forge/resources/META-INF/mods.toml | 12 --- .../resources/nochatreports-forge.mixins.json | 18 ---- forge/src/forge/resources/pack.mcmeta | 6 -- .../nochatreports/forge/NoChatReports.java | 84 +++++++++++++++ .../forge/mixins/client/MixinClientConnection.java | 32 ++++++ .../MixinClientHandshakePacketListenerImpl.java | 22 ++++ .../mixins/client/MixinClientPacketListener.java | 22 ++++ forge/src/main/java/net/fabricmc/api/EnvType.java | 48 +++++++++ .../main/java/net/fabricmc/api/Environment.java | 48 +++++++++ .../main/resources/META-INF/accesstransformer.cfg | 23 +++++ forge/src/main/resources/META-INF/mods.toml | 12 +++ .../mixins/forge/nochatreports-forge.mixins.json | 18 ++++ forge/src/main/resources/pack.mcmeta | 6 ++ 25 files changed, 327 insertions(+), 409 deletions(-) delete mode 100644 forge/src/forge/java/com/aizistral/nochatreports/forge/NoChatReports.java delete mode 100644 forge/src/forge/java/com/aizistral/nochatreports/forge/NoChatReportsClient.java delete mode 100644 forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientConnection.java delete mode 100644 forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientHandshakePacketListenerImpl.java delete mode 100644 forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientPacketListener.java delete mode 100644 forge/src/forge/java/net/fabricmc/api/EnvType.java delete mode 100644 forge/src/forge/java/net/fabricmc/api/Environment.java delete mode 100644 forge/src/forge/resources/META-INF/MANIFEST.MF delete mode 100644 forge/src/forge/resources/META-INF/accesstransformer.cfg delete mode 100644 forge/src/forge/resources/META-INF/mods.toml delete mode 100644 forge/src/forge/resources/nochatreports-forge.mixins.json delete mode 100644 forge/src/forge/resources/pack.mcmeta create mode 100644 forge/src/main/java/com/aizistral/nochatreports/forge/NoChatReports.java create mode 100644 forge/src/main/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientConnection.java create mode 100644 forge/src/main/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientHandshakePacketListenerImpl.java create mode 100644 forge/src/main/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientPacketListener.java create mode 100644 forge/src/main/java/net/fabricmc/api/EnvType.java create mode 100644 forge/src/main/java/net/fabricmc/api/Environment.java create mode 100644 forge/src/main/resources/META-INF/accesstransformer.cfg create mode 100644 forge/src/main/resources/META-INF/mods.toml create mode 100644 forge/src/main/resources/mixins/forge/nochatreports-forge.mixins.json create mode 100644 forge/src/main/resources/pack.mcmeta (limited to 'forge') diff --git a/forge/.gitignore b/forge/.gitignore index 41f9d62..61ca1e8 100644 --- a/forge/.gitignore +++ b/forge/.gitignore @@ -33,4 +33,8 @@ multiuser_args.txt old_enigmatic_desc.txt **/TestEventHandler* /.apt_generated_tests/ -src/main \ No newline at end of file + +# Symlink directories +src/main/java/com/aizistral/nochatreports/common +src/main/resources/assets +src/main/resources/mixins/common \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle index ab5ff70..f00115b 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -47,7 +47,6 @@ archivesBaseName = "${mod_archives_name}" println("Specifying Java compatibility...") java.toolchain.languageVersion = JavaLanguageVersion.of(17) -compileJava.options.encoding = "UTF-8" println("Java Installation Data:") println(" - Java Version: " + System.getProperty('java.version')) @@ -55,31 +54,21 @@ println(" - JVM Version: " + System.getProperty('java.vm.version')) println(" - Vendor: " + System.getProperty('java.vendor')) println(" - OS Archetype: " + System.getProperty('os.arch')) -sourceSets { - forge { - java { - compileClasspath += main.output - runtimeClasspath += main.output - } - } -} - -configurations { - forgeCompile.extendsFrom mainCompile - forgeRuntime.extendsFrom mainRuntime -} +compileJava.options.encoding = "UTF-8" mixin { println("Specifying refmaps for Mixin...") - add sourceSets.main, "nochatreports.refmap.json" - add sourceSets.forge, "nochatreports-forge.refmap.json" + add sourceSets.main, "nochatreports-forge.refmap.json" + config "mixins/common/nochatreports.mixins.json" + config "mixins/forge/nochatreports-forge.mixins.json" + defaultObfuscationEnv "searge" } minecraft { println("Specifying MCP mappings...") mappings channel: 'official', version: project.version_mc println("Specifying Access Transformer configuration...") - accessTransformer = file('src/forge/resources/META-INF/accesstransformer.cfg') + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') runs { client { @@ -138,7 +127,6 @@ dependencies { jar { - from sourceSets.forge.output println("Processing manifest...") manifest { diff --git a/forge/gradle.properties b/forge/gradle.properties index 0cc420c..51d7f1d 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx4G org.gradle.daemon=false # Mod -mod_version=1.19.3-v1.6.0 +mod_version=1.19.3-v2.0.0 mod_group=com.aizistral.nochatreports mod_id=nochatreports mod_name=No Chat Reports diff --git a/forge/src/forge/java/com/aizistral/nochatreports/forge/NoChatReports.java b/forge/src/forge/java/com/aizistral/nochatreports/forge/NoChatReports.java deleted file mode 100644 index 65bac6e..0000000 --- a/forge/src/forge/java/com/aizistral/nochatreports/forge/NoChatReports.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.aizistral.nochatreports.forge; - -import java.nio.charset.Charset; -import java.util.function.Predicate; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.aizistral.nochatreports.config.NCRConfig; - -import net.minecraft.network.protocol.login.ServerboundHelloPacket; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.network.ServerGamePacketListenerImpl; -import net.minecraft.server.network.ServerLoginPacketListenerImpl; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; -import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.network.NetworkRegistry; -import net.minecraftforge.network.event.EventNetworkChannel; -import net.minecraftforge.network.simple.SimpleChannel; -import net.minecraftforge.server.ServerLifecycleHooks; - -@Mod("nochatreports") -public class NoChatReports { - public static final Logger LOGGER = LogManager.getLogger(); - - public NoChatReports() { - LOGGER.info("KONNICHIWA ZA WARUDO!"); - LOGGER.info("Default JVM text encoding is: " + Charset.defaultCharset().displayName()); - - NCRConfig.load(); - } -} diff --git a/forge/src/forge/java/com/aizistral/nochatreports/forge/NoChatReportsClient.java b/forge/src/forge/java/com/aizistral/nochatreports/forge/NoChatReportsClient.java deleted file mode 100644 index 4181a77..0000000 --- a/forge/src/forge/java/com/aizistral/nochatreports/forge/NoChatReportsClient.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.aizistral.nochatreports.forge; - -import java.util.List; - -import com.aizistral.nochatreports.NoChatReports; -import com.aizistral.nochatreports.config.NCRConfig; -import com.aizistral.nochatreports.core.ServerDataExtension; -import com.aizistral.nochatreports.core.ServerSafetyLevel; -import com.aizistral.nochatreports.core.ServerSafetyState; -import com.aizistral.nochatreports.core.SigningMode; -import com.aizistral.nochatreports.gui.UnsafeServerScreen; -import com.google.common.collect.ImmutableList; - -import net.minecraft.Util; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.ChatScreen; -import net.minecraft.client.gui.screens.ConnectScreen; -import net.minecraft.client.gui.screens.DisconnectedScreen; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.TitleScreen; -import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; -import net.minecraft.client.multiplayer.ClientPacketListener; -import net.minecraft.network.chat.CommonComponents; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.contents.TranslatableContents; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.ClientPlayerNetworkEvent; -import net.minecraftforge.client.event.ScreenEvent; -import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; - -@EventBusSubscriber(modid = "nochatreports", bus = Bus.FORGE) -public class NoChatReportsClient { - private static boolean signingKeysPresent = false; - - private NoChatReportsClient() { - throw new IllegalStateException("Can't touch this"); - } - - @OnlyIn(Dist.CLIENT) - public static void onDisconnect(Minecraft client) { - if (!NCRConfig.getClient().enableMod()) - return; - - if (NCRConfig.getCommon().enableDebugLog()) { - NoChatReports.LOGGER.info("Disconnected from server, resetting safety state!"); - } - - ServerSafetyState.reset(); - } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public static void onPlayReady(ClientPlayerNetworkEvent.LoggingIn event) { - Minecraft client = Minecraft.getInstance(); - ClientPacketListener handler = client.getConnection(); - - if (!NCRConfig.getClient().enableMod()) - return; - - client.execute(() -> { - if (!client.isLocalServer()) { - if (ServerSafetyState.isOnRealms()) { - // NO-OP - } else if (!handler.getConnection().isEncrypted()) { - ServerSafetyState.updateCurrent(ServerSafetyLevel.SECURE); - } else if (client.getCurrentServer() instanceof ServerDataExtension ext && - ext.preventsChatReports()) { - ServerSafetyState.updateCurrent(ServerSafetyLevel.SECURE); - } else if (NCRConfig.getServerPreferences().hasMode(ServerSafetyState.getLastServer(), - SigningMode.ALWAYS)) { - ServerSafetyState.updateCurrent(ServerSafetyLevel.INSECURE); - ServerSafetyState.setAllowChatSigning(true); - } else { - ServerSafetyState.updateCurrent(ServerSafetyLevel.UNKNOWN); - } - } else { - ServerSafetyState.updateCurrent(ServerSafetyLevel.SINGLEPLAYER); - } - - if (NCRConfig.getCommon().enableDebugLog()) { - NoChatReports.LOGGER.info("Sucessfully connected to server, safety state: {}", ServerSafetyState.getCurrent()); - } - - if (NCRConfig.getClient().demandOnServer() && !ServerSafetyState.getCurrent().isSecure()) { - handler.getConnection().disconnect(Component.translatable("disconnect.nochatreports.client")); - } - }); - } - - public static boolean areSigningKeysPresent() { - return signingKeysPresent; - } - - public static void setSigningKeysPresent(boolean present) { - signingKeysPresent = present; - } - - public static void resendLastChatMessage() { - var mc = Minecraft.getInstance(); - var chatScr = mc.screen instanceof ChatScreen chat ? chat : null; - - if (chatScr == null) { - chatScr = new ChatScreen(""); - chatScr.init(mc, mc.getWindow().getGuiScaledWidth(), mc.getWindow().getGuiScaledHeight()); - } - - chatScr.handleChatInput(NCRConfig.getEncryption().getLastMessage(), false); - } - - -} diff --git a/forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientConnection.java b/forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientConnection.java deleted file mode 100644 index 74f1220..0000000 --- a/forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientConnection.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.aizistral.nochatreports.forge.mixins.client; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.aizistral.nochatreports.forge.NoChatReportsClient; - -import io.netty.channel.ChannelHandlerContext; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientHandshakePacketListenerImpl; -import net.minecraft.client.multiplayer.ClientPacketListener; -import net.minecraft.network.Connection; -import net.minecraft.network.PacketListener; - -@Mixin(Connection.class) -public class MixinClientConnection { - @Shadow - private PacketListener packetListener; - - @Inject(method = "channelInactive", at = @At("HEAD")) - private void handleDisconnect(ChannelHandlerContext context, CallbackInfo info) { - // not the case for client/server query - if (this.packetListener instanceof ClientHandshakePacketListenerImpl - || this.packetListener instanceof ClientPacketListener) { - NoChatReportsClient.onDisconnect(Minecraft.getInstance()); - } - } - -} diff --git a/forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientHandshakePacketListenerImpl.java b/forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientHandshakePacketListenerImpl.java deleted file mode 100644 index e128c3e..0000000 --- a/forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientHandshakePacketListenerImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.aizistral.nochatreports.forge.mixins.client; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.aizistral.nochatreports.forge.NoChatReportsClient; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientHandshakePacketListenerImpl; -import net.minecraft.network.chat.Component; - -@Mixin(ClientHandshakePacketListenerImpl.class) -public class MixinClientHandshakePacketListenerImpl { - - @Inject(method = "onDisconnect", at = @At("HEAD")) - private void invokeLoginDisconnectEvent(Component reason, CallbackInfo info) { - NoChatReportsClient.onDisconnect(Minecraft.getInstance()); - } - -} diff --git a/forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientPacketListener.java b/forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientPacketListener.java deleted file mode 100644 index 817cea3..0000000 --- a/forge/src/forge/java/com/aizistral/nochatreports/forge/mixins/client/MixinClientPacketListener.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.aizistral.nochatreports.forge.mixins.client; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.aizistral.nochatreports.forge.NoChatReportsClient; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientPacketListener; -import net.minecraft.network.chat.Component; - -@Mixin(value = ClientPacketListener.class) -public class MixinClientPacketListener { - - @Inject(method = "onDisconnect", at = @At("HEAD")) - private void handleDisconnection(Component reason, CallbackInfo info) { - NoChatReportsClient.onDisconnect(Minecraft.getInstance()); - } - -} diff --git a/forge/src/forge/java/net/fabricmc/api/EnvType.java b/forge/src/forge/java/net/fabricmc/api/EnvType.java deleted file mode 100644 index 253b6e8..0000000 --- a/forge/src/forge/java/net/fabricmc/api/EnvType.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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/forge/java/net/fabricmc/api/Environment.java b/forge/src/forge/java/net/fabricmc/api/Environment.java deleted file mode 100644 index 1db59da..0000000 --- a/forge/src/forge/java/net/fabricmc/api/Environment.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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(); -} diff --git a/forge/src/forge/resources/META-INF/MANIFEST.MF b/forge/src/forge/resources/META-INF/MANIFEST.MF deleted file mode 100644 index b4613f2..0000000 --- a/forge/src/forge/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1 +0,0 @@ -MixinConfigs: nochatreports.mixins.json, nochatreports-forge.mixins.json \ No newline at end of file diff --git a/forge/src/forge/resources/META-INF/accesstransformer.cfg b/forge/src/forge/resources/META-INF/accesstransformer.cfg deleted file mode 100644 index 390e8b0..0000000 --- a/forge/src/forge/resources/META-INF/accesstransformer.cfg +++ /dev/null @@ -1,23 +0,0 @@ -public net.minecraft.client.gui.screens.SimpleOptionsSubScreen f_96668_ #list -public-f net.minecraft.client.gui.components.ImageButton f_94224_ #xTexStart -public-f net.minecraft.client.gui.components.ImageButton f_94225_ #yTexStart -public-f net.minecraft.network.chat.MutableComponent f_237194_ #contents -public-f net.minecraft.network.chat.contents.TranslatableContents f_237498_ #args -public-f net.minecraft.network.chat.MutableComponent f_237194_ #contents -public net.minecraft.client.gui.screens.multiplayer.WarningScreen f_210915_ #message -public net.minecraft.client.multiplayer.ClientPacketListener f_240902_ #signedMessageEncoder -public net.minecraft.client.multiplayer.ClientPacketListener f_252517_ #chatSession -public net.minecraft.client.gui.components.Tooltip f_257026_ #MAX_WIDTH -public net.minecraft.client.gui.components.Tooltip f_256850_ #message -public net.minecraft.client.gui.components.Tooltip f_257004_ #narration -public net.minecraft.client.gui.components.Tooltip f_256766_ #cachedTooltip -public net.minecraft.client.gui.screens.Screen f_96541_ #minecraft -public net.minecraft.client.gui.screens.Screen f_96542_ #itemRenderer -public net.minecraft.client.gui.screens.Screen f_96547_ #font -public net.minecraft.client.gui.components.AbstractWidget f_256816_ #tooltip -public net.minecraft.client.gui.components.AbstractWidget f_256936_ #tooltipMsDelay -public net.minecraft.client.gui.screens.OptionsScreen f_260594_ #TELEMETRY - -public net.minecraft.client.gui.components.TooltipA 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(); +} diff --git a/forge/src/main/resources/META-INF/accesstransformer.cfg b/forge/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..390e8b0 --- /dev/null +++ b/forge/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,23 @@ +public net.minecraft.client.gui.screens.SimpleOptionsSubScreen f_96668_ #list +public-f net.minecraft.client.gui.components.ImageButton f_94224_ #xTexStart +public-f net.minecraft.client.gui.components.ImageButton f_94225_ #yTexStart +public-f net.minecraft.network.chat.MutableComponent f_237194_ #contents +public-f net.minecraft.network.chat.contents.TranslatableContents f_237498_ #args +public-f net.minecraft.network.chat.MutableComponent f_237194_ #contents +public net.minecraft.client.gui.screens.multiplayer.WarningScreen f_210915_ #message +public net.minecraft.client.multiplayer.ClientPacketListener f_240902_ #signedMessageEncoder +public net.minecraft.client.multiplayer.ClientPacketListener f_252517_ #chatSession +public net.minecraft.client.gui.components.Tooltip f_257026_ #MAX_WIDTH +public net.minecraft.client.gui.components.Tooltip f_256850_ #message +public net.minecraft.client.gui.components.Tooltip f_257004_ #narration +public net.minecraft.client.gui.components.Tooltip f_256766_ #cachedTooltip +public net.minecraft.client.gui.screens.Screen f_96541_ #minecraft +public net.minecraft.client.gui.screens.Screen f_96542_ #itemRenderer +public net.minecraft.client.gui.screens.Screen f_96547_ #font +public net.minecraft.client.gui.components.AbstractWidget f_256816_ #tooltip +public net.minecraft.client.gui.components.AbstractWidget f_256936_ #tooltipMsDelay +public net.minecraft.client.gui.screens.OptionsScreen f_260594_ #TELEMETRY + +public net.minecraft.client.gui.components.Tooltip