Skip to content

Commit

Permalink
somehow or other get lombok and mixin working alongside each other
Browse files Browse the repository at this point in the history
  • Loading branch information
DaMatrix committed Jul 15, 2019
1 parent c83d61d commit 38cb636
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 5 deletions.
15 changes: 12 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand All @@ -112,8 +119,8 @@ processResources {
}

mixin {
defaultObfuscationEnv notch
add sourceSets.main, "mixins.pepsimod.refmap.json"
defaultObfuscationEnv srg
add("main", "mixins.pepsimod.refmap.json")
}

jar {
Expand All @@ -127,6 +134,8 @@ jar {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
exclude "LICENSE.txt"
exclude "dummyThing"
}
manifest {
attributes(
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion src/main/java/net/daporkchop/pepsimod/Pepsimod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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",
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/net/daporkchop/pepsimod/mixin/MixinGuiMainMenu.java
Original file line number Diff line number Diff line change
@@ -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";
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.pepsimod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"package": "net.daporkchop.pepsimod.mixin",
"refmap": "mixins.pepsimod.refmap.json",
"client": [
"MixinGuiMainMenu"
]
}

6 comments on commit 38cb636

@0-x-2-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cringe 📸

@DaMatrix
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imagine NOT using lombok

@0-x-2-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imagine using pozzok

@DaMatrix
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imagine writing accessors by hand

@0-x-2-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cringe

@DaMatrix
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯\_(ツ)_/¯

Please sign in to comment.