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

Commit 433c8dc

Browse files
author
LeafHacker
committed
Use Accessors in IMinecraft
1 parent 84bd805 commit 433c8dc

File tree

3 files changed

+20
-38
lines changed

3 files changed

+20
-38
lines changed

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

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@
2828
import net.minecraft.client.Minecraft;
2929
import net.minecraft.client.gui.GuiScreen;
3030
import net.minecraft.client.multiplayer.WorldClient;
31-
import net.minecraft.util.Session;
32-
import net.minecraft.util.Timer;
33-
import org.spongepowered.asm.mixin.Final;
3431
import org.spongepowered.asm.mixin.Mixin;
35-
import org.spongepowered.asm.mixin.Mutable;
36-
import org.spongepowered.asm.mixin.Shadow;
3732
import org.spongepowered.asm.mixin.injection.At;
3833
import org.spongepowered.asm.mixin.injection.Inject;
3934
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@@ -51,15 +46,7 @@
5146
* @since 4/27/2017 12:00 PM
5247
*/
5348
@Mixin(Minecraft.class)
54-
public class MixinMinecraft implements IMinecraft {
55-
56-
@Shadow @Final private Timer timer;
57-
@Shadow @Final @Mutable private Session session;
58-
@Shadow private int rightClickDelayTimer;
59-
60-
@Shadow private void clickMouse() {}
61-
@Shadow private void rightClickMouse() {}
62-
@Shadow private void middleClickMouse() {}
49+
public abstract class MixinMinecraft implements IMinecraft {
6350

6451
@Inject(method = "runTick", at = @At("HEAD"))
6552
public void onTick(CallbackInfo ci) {
@@ -153,29 +140,14 @@ public void shutdown(CallbackInfo ci) {
153140
ci.cancel();
154141
}
155142

156-
@Override
157-
public Timer getTimer() {
158-
return this.timer;
159-
}
160-
161-
@Override
162-
public void setSession(Session session) {
163-
this.session = session;
164-
}
165-
166143
@Override
167144
public void clickMouse(ClickEvent.MouseButton button) {
168145
// IF statements are required because Mixin doesn't support SWITCH
169146
if (button == LEFT)
170-
clickMouse();
147+
leftClickMouse();
171148
if (button == RIGHT)
172149
rightClickMouse();
173150
if (button == MIDDLE)
174151
middleClickMouse();
175152
}
176-
177-
@Override
178-
public void setRightClickDelayTimer(int delay) {
179-
this.rightClickDelayTimer = delay;
180-
}
181153
}

src/main/java/me/zero/client/load/mixin/wrapper/IMinecraft.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,47 @@
1717
package me.zero.client.load.mixin.wrapper;
1818

1919
import me.zero.client.api.event.defaults.ClickEvent;
20+
import net.minecraft.client.Minecraft;
2021
import net.minecraft.util.Session;
2122
import net.minecraft.util.Timer;
23+
import org.spongepowered.asm.mixin.Mixin;
24+
import org.spongepowered.asm.mixin.gen.Accessor;
25+
import org.spongepowered.asm.mixin.gen.Invoker;
2226

2327
/**
2428
* @author Brady
2529
* @since 2/20/2017 12:00 PM
2630
*/
31+
@Mixin(Minecraft.class)
2732
public interface IMinecraft {
2833

2934
/**
3035
* @return Returns the Game's Timer
3136
*/
32-
Timer getTimer();
37+
@Accessor Timer getTimer();
3338

3439
/**
3540
* Sets the game's session
3641
*
3742
* @param session The new Session
3843
*/
39-
void setSession(Session session);
44+
@Accessor void setSession(Session session);
4045

4146
/**
42-
* Clicks a mouse button
47+
* Sets the right click delay timer
4348
*
44-
* @param button The button
49+
* @param delay The new right click delay
4550
*/
46-
void clickMouse(ClickEvent.MouseButton button);
51+
@Accessor void setRightClickDelayTimer(int delay);
52+
53+
@Invoker("clickMouse") void leftClickMouse();
54+
@Invoker("rightClickMouse") void rightClickMouse();
55+
@Invoker("middleClickMouse") void middleClickMouse();
4756

4857
/**
49-
* Sets the right click delay timer
58+
* Clicks a mouse button
5059
*
51-
* @param delay The new right click delay
60+
* @param button The button
5261
*/
53-
void setRightClickDelayTimer(int delay);
62+
void clickMouse(ClickEvent.MouseButton button);
5463
}

src/main/resources/mixins.wrapper.capi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"IGameType",
1010
"IItemRenderer",
1111
"IKeyBinding",
12+
"IMinecraft",
1213
"IPlayerControllerMP",
1314
"IRenderManager",
1415
"IShaderGroup",

0 commit comments

Comments
 (0)