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

Commit 5bb77e4

Browse files
author
LeafHacker
committed
Fix mixin warnings, mostly about overwrite reasons
- Fixed warning about elevating access to onUpdateWalkingPlayer from private to public. - Added @Reason doc strings to the four overwrite methods.
1 parent f6d7986 commit 5bb77e4

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private void canCollideCheck(IBlockState state, boolean hitIfLiquid, CallbackInf
5353
}
5454

5555
/**
56+
* @reason the overwritten method is only one line, we need to overwrite to mutate the AABB and pass params into the event constructor
5657
* @author Brady
5758
*/
5859
@Overwrite

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ private void move(AbstractClientPlayer player, MoverType type, double x, double
8787
}
8888

8989
/**
90+
* @reason In addition to firing pre and post events, we also want to override some position values (prefixed with p).
9091
* @author Brady
9192
*/
9293
@Overwrite
93-
public void onUpdateWalkingPlayer() {
94+
private void onUpdateWalkingPlayer() {
9495
EntityPlayerSP _this = (EntityPlayerSP) (Object) this;
9596

9697
MotionUpdateEvent pre = new MotionUpdateEvent(EventState.PRE);
@@ -110,6 +111,8 @@ public void onUpdateWalkingPlayer() {
110111

111112
if (this.isCurrentViewEntity()) {
112113

114+
// Override vanilla defaults of _tis.posX, etc
115+
// This is why we need to overwrite the method body.
113116
double pX = pre.getX();
114117
double pY = pre.getY();
115118
double pZ = pre.getZ();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class MixinNettyPacketDecoder {
2727
@Shadow @Final private EnumPacketDirection direction;
2828

2929
/**
30+
* @reason we need to wait until the packet is built and then pass it (and the connection state) to the event constructor
3031
* @author Brady
3132
*/
3233
@Overwrite
@@ -39,6 +40,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
3940
EnumConnectionState state = ctx.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).get();
4041
Packet<?> packet = state.getPacket(this.direction, packetId);
4142

43+
// We need the packet to create our Event, so we have to overwrite the method body
4244
PacketEvent event = new PacketEvent.Decode(packet, state);
4345
ClientAPI.EVENT_BUS.post(event);
4446
packet = event.getPacket();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class MixinNettyPacketEncoder {
2626
@Shadow @Final private EnumPacketDirection direction;
2727

2828
/**
29+
* @reason mostly because we need to mutate msg, but also so that we can pass the connection state to the event constructor
2930
* @author Brady
3031
*/
3132
@Overwrite
@@ -37,6 +38,7 @@ protected void encode(ChannelHandlerContext ctx, Packet<?> msg, ByteBuf out) thr
3738
LOGGER.debug(RECEIVED_PACKET_MARKER, "OUT: [{}:{}] {}", state, packetId, msg.getClass().getName());
3839
}
3940

41+
// We need the state and we plan to mutate the msg, hence the overwrite
4042
PacketEvent event = new PacketEvent.Encode(msg, state);
4143
ClientAPI.EVENT_BUS.post(event);
4244
msg = event.getPacket();

0 commit comments

Comments
 (0)