Skip to content
This repository was archived by the owner on Feb 19, 2019. It is now read-only.

Commit e88fd21

Browse files
committed
Updated build.gradle
Also added some commenting documentation
1 parent 93b8f9e commit e88fd21

4 files changed

Lines changed: 25 additions & 7 deletions

File tree

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,26 @@ buildscript {
99
name = 'SpongePowered'
1010
url = 'http://repo.spongepowered.org/maven'
1111
}
12+
maven {
13+
url 'https://plugins.gradle.org/m2/'
14+
}
1215
}
1316

1417
dependencies {
1518
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
1619
classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT'
20+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.0'
1721
}
1822
}
1923

2024
apply plugin: 'java'
2125
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
2226
apply plugin: 'org.spongepowered.mixin'
27+
apply plugin: 'com.github.johnrengelman.shadow'
2328

2429
version '1.0'
2530
group 'me.zero.api'
2631

27-
sourceCompatibility = targetCompatibility = '1.8'
2832
compileJava {
2933
sourceCompatibility = targetCompatibility = '1.8'
3034
}

src/main/java/me/zero/client/api/value/type/resolve/DefaultResolvers.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ private DefaultResolvers () {}
6363
public static final TypeResolver<MultiType> MULTI = (parent, field) -> {
6464
Label label = field.getAnnotation(Label.class);
6565
MultiValue multi = field.getAnnotation(MultiValue.class);
66+
6667
MultiType type = new MultiType(label.name(), label.id(), label.description(), parent, field, multi.value());
6768
if (type.getValue() == null)
6869
type.setValue(multi.value()[0]);
70+
6971
return type;
7072
};
7173

@@ -77,9 +79,8 @@ private DefaultResolvers () {}
7779
Label label = field.getAnnotation(Label.class);
7880
NumberValue num = field.getAnnotation(NumberValue.class);
7981

80-
NumberType type = null;
81-
8282
// This is an absolute mess, still finding some other solution
83+
NumberType type = null;
8384
if (field.getType() == Byte.class || field.getType() == Byte.TYPE) {
8485
type = new NumberType<Byte>(label.name(), label.id(), label.description(), parent, field, (byte) num.min(), (byte) num.max()) { };
8586
} else if (field.getType() == Short.class || field.getType() == Short.TYPE) {

src/main/java/me/zero/client/load/ClientTweaker.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ public void acceptOptions(List<String> args, File gameDir, File assetsDir, Strin
5353
@Override
5454
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
5555
Logger.instance.log(Level.INFO, "Injecting into ClassLoader");
56+
57+
// Initialize the Mixin Bootstrap
5658
MixinBootstrap.init();
59+
60+
// Load the ClientAPI and Wrapper mixins
5761
Mixins.addConfiguration("mixins.capi.json");
5862
Mixins.addConfiguration("mixins.wrapper.capi.json");
5963

@@ -62,6 +66,7 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
6266
if (this.getClass().getResourceAsStream("/" + mixin) != null)
6367
Mixins.addConfiguration(mixin);
6468

69+
// Ensure that the mixins are only run on client side
6570
MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
6671
}
6772

src/main/java/me/zero/client/load/mixin/MixinMinecraft.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,20 @@ public void onLoop(CallbackInfo ci) {
7373

7474
@Inject(method = "init", at = @At("RETURN"))
7575
public void init(CallbackInfo ci) {
76+
// Try and find the "client.json" config
7677
InputStream stream = this.getClass().getResourceAsStream("/client.json");
7778

7879
if (stream == null)
7980
throw new ClientInitException("Unable to locate the Client.json");
8081

81-
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
82-
ClientInfo clientInfo = new GsonBuilder().setPrettyPrinting().create().fromJson(reader, ClientInfo.class);
82+
// Construct a ClientInfo object from the client json using GSON
83+
ClientInfo clientInfo = new GsonBuilder().setPrettyPrinting().create().fromJson(new BufferedReader(new InputStreamReader(stream)), ClientInfo.class);
8384

8485
if (clientInfo == null)
8586
throw new ClientInitException("Unable to create ClientInfo from Client.json");
8687

88+
// Attempt to instantiate the specified class from the ClientInfo
8789
Client client;
88-
8990
try {
9091
Class<?> clientClass = Class.forName(clientInfo.getMain());
9192
if (clientClass != null && clientClass.getSuperclass().equals(Client.class)) {
@@ -101,10 +102,15 @@ public void init(CallbackInfo ci) {
101102
throw new ClientInitException("Unable to find client class");
102103
}
103104

105+
// Init GLUtils
104106
GlUtils.init();
105-
client.setInfo(clientInfo);
107+
106108
ClientHandler handler = new ClientHandler();
109+
110+
// Init client
111+
client.setInfo(clientInfo);
107112
client.onInit(handler);
113+
108114
ClientAPI.EVENT_BUS.subscribe(handler);
109115
}
110116

@@ -132,6 +138,7 @@ public GuiScreen displayGuiScreen(GuiScreen screen) {
132138

133139
@Inject(method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at = @At("HEAD"))
134140
public void loadWorld(@Nullable WorldClient worldClientIn, String loadingMessage, CallbackInfo ci) {
141+
// If the world is null, then it must be unloading
135142
if (worldClientIn != null)
136143
ClientAPI.EVENT_BUS.post(new WorldEvent.Load(worldClientIn));
137144
else
@@ -158,6 +165,7 @@ public void setSession(Session session) {
158165

159166
@Override
160167
public void clickMouse(ClickEvent.MouseButton button) {
168+
// IF statements are required because Mixin doesn't support SWITCH
161169
if (button == LEFT)
162170
clickMouse();
163171
if (button == RIGHT)

0 commit comments

Comments
 (0)