From 38cb636b66ee0078bff1e3fc27a201313fc5932e Mon Sep 17 00:00:00 2001 From: DaMatrix Date: Mon, 15 Jul 2019 14:25:20 +0200 Subject: [PATCH] somehow or other get lombok and mixin working alongside each other --- build.gradle | 15 ++++- gradle/wrapper/gradle-wrapper.properties | 2 +- .../net/daporkchop/pepsimod/Pepsimod.java | 9 ++- .../pepsimod/mixin/MixinGuiMainMenu.java | 56 +++++++++++++++++++ src/main/resources/mixins.pepsimod.json | 1 + 5 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 src/main/java/net/daporkchop/pepsimod/mixin/MixinGuiMainMenu.java diff --git a/build.gradle b/build.gradle index 8af0e9d..9b20b09 100644 --- a/build.gradle +++ b/build.gradle @@ -28,10 +28,14 @@ buildscript { } dependencies { classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT" - classpath "org.spongepowered:mixingradle:0.4-SNAPSHOT" + classpath "org.spongepowered:mixingradle:0.6-SNAPSHOT" } } +plugins { + id "io.franzbecker.gradle-lombok" version "1.14" +} + apply plugin: "net.minecraftforge.gradle.forge" apply plugin: "org.spongepowered.mixin" @@ -101,6 +105,9 @@ dependencies { } processResources { + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + from(sourceSets.main.resources.srcDirs) { include "mcmod.info" expand "version": "$pepsimodVersion-$minecraftVersion", "mcversion": "$minecraftVersion" @@ -112,8 +119,8 @@ processResources { } mixin { - defaultObfuscationEnv notch - add sourceSets.main, "mixins.pepsimod.refmap.json" + defaultObfuscationEnv srg + add("main", "mixins.pepsimod.refmap.json") } jar { @@ -127,6 +134,8 @@ jar { exclude "META-INF/*.SF" exclude "META-INF/*.DSA" exclude "META-INF/*.RSA" + exclude "LICENSE.txt" + exclude "dummyThing" } manifest { attributes( diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6e2b9ba..bb6c710 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -17,4 +17,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip diff --git a/src/main/java/net/daporkchop/pepsimod/Pepsimod.java b/src/main/java/net/daporkchop/pepsimod/Pepsimod.java index d0c96f5..b27bb18 100644 --- a/src/main/java/net/daporkchop/pepsimod/Pepsimod.java +++ b/src/main/java/net/daporkchop/pepsimod/Pepsimod.java @@ -16,6 +16,7 @@ package net.daporkchop.pepsimod; +import lombok.Getter; import net.daporkchop.pepsimod.util.PepsiConstants; import net.minecraft.client.Minecraft; import net.minecraftforge.common.MinecraftForge; @@ -37,6 +38,13 @@ public class Pepsimod extends PepsiConstants { public static final String CHAT_PREFIX = "\u00A70\u00A7l[\u00A7c\u00A7lpepsi\u00A79\u00A7lmod\u00A70\u00A7l]\u00A7r"; + @Getter + private static final Pepsimod INSTANCE = new Pepsimod(); + + public String getVersion() { + return VERSION_FULL; + } + @Mod.EventHandler public void construction(FMLConstructionEvent event) { mc = Minecraft.getMinecraft(); @@ -60,7 +68,6 @@ public void construction(FMLConstructionEvent event) { } System.out.printf("Loading pepsimod %s...\n", VERSION_FULL); - System.exit(1); /*this.data = new DataLoader( "https://raw.githubusercontent.com/Team-Pepsi/pepsimod/master/resources/resources.json", diff --git a/src/main/java/net/daporkchop/pepsimod/mixin/MixinGuiMainMenu.java b/src/main/java/net/daporkchop/pepsimod/mixin/MixinGuiMainMenu.java new file mode 100644 index 0000000..4135783 --- /dev/null +++ b/src/main/java/net/daporkchop/pepsimod/mixin/MixinGuiMainMenu.java @@ -0,0 +1,56 @@ +/* + * Adapted from the Wizardry License + * + * Copyright (c) 2017-2019 DaPorkchop_ + * + * Permission is hereby granted to any persons and/or organizations using this software to copy, modify, merge, publish, and distribute it. + * Said persons and/or organizations are not allowed to use the software or any derivatives of the work for commercial use or any other means to generate income, nor are they allowed to claim this software as their own. + * + * The persons and/or organizations are also disallowed from sub-licensing and/or trademarking this software without explicit permission from DaPorkchop_. + * + * Any persons and/or organizations using this software must disclose their source code and have it publicly available, include this license, provide sufficient credit to the original author of the project (IE: DaPorkchop_), as well as provide a link to the original project. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +package net.daporkchop.pepsimod.mixin; + +import lombok.NonNull; +import net.daporkchop.pepsimod.Pepsimod; +import net.daporkchop.pepsimod.util.PepsiConstants; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.GuiScreen; +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.Constant; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyConstant; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +/** + * @author DaPorkchop_ + */ +@Mixin(GuiMainMenu.class) +public abstract class MixinGuiMainMenu extends GuiScreen { + @Shadow + private String splashText; + + @ModifyConstant( + method = "Lnet/minecraft/client/gui/GuiMainMenu;drawScreen(IIF)V", + constant = @Constant(stringValue = "Copyright Mojang AB. Do not distribute!") + ) + public String changeMinecraftVersionText(@NonNull String orig) { + return String.format("pepsimod %s", Pepsimod.getINSTANCE().getVersion()); + //return String.format("pepsimod %s", PepsiConstants.VERSION_FULL); + } + + @Inject( + method = "Lnet/minecraft/client/gui/GuiMainMenu;initGui()V", + at = @At("RETURN") + ) + public void postInitGui(CallbackInfo ci) { + this.splashText = "pepsimod xd"; + } +} diff --git a/src/main/resources/mixins.pepsimod.json b/src/main/resources/mixins.pepsimod.json index 307e639..e703de0 100644 --- a/src/main/resources/mixins.pepsimod.json +++ b/src/main/resources/mixins.pepsimod.json @@ -4,5 +4,6 @@ "package": "net.daporkchop.pepsimod.mixin", "refmap": "mixins.pepsimod.refmap.json", "client": [ + "MixinGuiMainMenu" ] }