Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit fb87b7f

Browse files
committed
Remove useless parameter javadoc, replace some overly terse names
1 parent 4677452 commit fb87b7f

5 files changed

Lines changed: 26 additions & 45 deletions

File tree

patchwork-networking/src/main/java/com/patchworkmc/mixin/networking/handler/MixinClientLoginNetworkHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public abstract class MixinClientLoginNetworkHandler {
3737
public abstract ClientConnection getConnection();
3838

3939
@Inject(method = "onQueryRequest", at = @At("HEAD"), cancellable = true)
40-
private void patchwork$hookCustomPayload(LoginQueryRequestS2CPacket packet, CallbackInfo callback) {
40+
private void patchwork$hookQueryRequest(LoginQueryRequestS2CPacket packet, CallbackInfo callback) {
4141
if (NetworkHooks.onCustomPayload((ICustomPacket<?>) packet, getConnection())) {
4242
callback.cancel();
4343
}

patchwork-networking/src/main/java/com/patchworkmc/mixin/networking/handler/MixinServerLoginNetworkHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public abstract class MixinServerLoginNetworkHandler {
3737
public abstract ClientConnection getConnection();
3838

3939
@Inject(method = "onQueryResponse", at = @At("HEAD"), cancellable = true)
40-
private void patchwork$hookCustomPayload(LoginQueryResponseC2SPacket packet, CallbackInfo callback) {
40+
private void patchwork$hookQueryResponse(LoginQueryResponseC2SPacket packet, CallbackInfo callback) {
4141
if (NetworkHooks.onCustomPayload((ICustomPacket<?>) packet, getConnection())) {
4242
callback.cancel();
4343
}

patchwork-networking/src/main/java/net/minecraftforge/fml/network/PacketDistributor.java

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public PacketTarget noArg() {
128128
return new PacketTarget(functor.apply(this, () -> null), this);
129129
}
130130

131+
// TODO: Fix Checkstyle on lambda returns
131132
// CHECKSTYLE.OFF: Indentation - lambda returns are broken
132133
private Consumer<Packet<?>> playerConsumer(final Supplier<ServerPlayerEntity> player) {
133134
return packet -> player.get().networkHandler.client.send(packet);
@@ -145,10 +146,10 @@ private Consumer<Packet<?>> clientToServer(final Supplier<Void> ignored) {
145146
return packet -> MinecraftClient.getInstance().getNetworkHandler().sendPacket(packet);
146147
}
147148

148-
private Consumer<Packet<?>> playerListPointConsumer(final Supplier<TargetPoint> point) {
149+
private Consumer<Packet<?>> playerListPointConsumer(final Supplier<TargetPoint> pointSupplier) {
149150
return packet -> {
150-
final TargetPoint tp = point.get();
151-
getServer().getPlayerManager().sendToAround(tp.excluded, tp.x, tp.y, tp.z, tp.r2, tp.dim, packet);
151+
final TargetPoint point = pointSupplier.get();
152+
getServer().getPlayerManager().sendToAround(point.excluded, point.x, point.y, point.z, point.radius, point.dim, packet);
152153
};
153154
}
154155

@@ -188,65 +189,46 @@ public static final class TargetPoint {
188189
private final double x;
189190
private final double y;
190191
private final double z;
191-
private final double r2;
192+
private final double radius;
192193
private final DimensionType dim;
193194

194195
/**
195-
* A target point with excluded entity.
196-
*
197-
* @param excluded the {@link ServerPlayerEntity} to exclude
198-
* @param x X
199-
* @param y Y
200-
* @param z Z
201-
* @param r2 Radius
202-
* @param dim DimensionType
196+
* A target point that excludes the provided player entity.
203197
*/
204-
public TargetPoint(final ServerPlayerEntity excluded, final double x, final double y, final double z, final double r2, final DimensionType dim) {
198+
public TargetPoint(final ServerPlayerEntity excluded, final double x, final double y, final double z, final double radius, final DimensionType dim) {
205199
this.excluded = excluded;
206200
this.x = x;
207201
this.y = y;
208202
this.z = z;
209-
this.r2 = r2;
203+
this.radius = radius;
210204
this.dim = dim;
211205
}
212206

213207
/**
214208
* A target point that does not exclude any entities.
215-
* @param x X
216-
* @param y Y
217-
* @param z Z
218-
* @param r2 Radius
219-
* @param dim DimensionType
220209
*/
221-
public TargetPoint(final double x, final double y, final double z, final double r2, final DimensionType dim) {
210+
public TargetPoint(final double x, final double y, final double z, final double radius, final DimensionType dim) {
222211
this.excluded = null;
223212
this.x = x;
224213
this.y = y;
225214
this.z = z;
226-
this.r2 = r2;
215+
this.radius = radius;
227216
this.dim = dim;
228217
}
229218

230219
/**
231220
* Helper to build a target point that does not exclude any entities.
232-
* @param x X
233-
* @param y Y
234-
* @param z Z
235-
* @param r2 Radius
236-
* @param dim DimensionType
237-
* @return A TargetPoint supplier
238221
*/
239-
public static Supplier<TargetPoint> p(double x, double y, double z, double r2, DimensionType dim) {
240-
TargetPoint tp = new TargetPoint(x, y, z, r2, dim);
241-
return () -> tp;
222+
public static Supplier<TargetPoint> p(double x, double y, double z, double radius, DimensionType dim) {
223+
TargetPoint point = new TargetPoint(x, y, z, radius, dim);
224+
return () -> point;
242225
}
243226
}
244227

245228
/**
246-
* A Distributor curried with a specific value instance, for actual dispatch.
229+
* A {@link PacketDistributor} curried with a specific value instance. Can be used for packet dispatch.
247230
*
248231
* @see net.minecraftforge.fml.network.simple.SimpleChannel#send(PacketTarget, Object)
249-
*
250232
*/
251233
public static class PacketTarget {
252234
private final Consumer<Packet<?>> packetConsumer;

patchwork-networking/src/main/java/net/minecraftforge/fml/network/simple/IndexedMessageCodec.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,17 @@ private static <M> int tryEncode(PacketByteBuf target, M message, MessageHandler
8181
}
8282

8383
@SuppressWarnings("unchecked")
84-
public <M> MessageHandler<M> findMessageType(final M msgToReply) {
85-
return (MessageHandler<M>) types.get(msgToReply.getClass());
84+
public <M> MessageHandler<M> findMessageType(final M message) {
85+
return (MessageHandler<M>) types.get(message.getClass());
8686
}
8787

8888
@SuppressWarnings("unchecked")
89-
<M> MessageHandler<M> findIndex(final short i) {
90-
return (MessageHandler<M>) indices.get(i);
89+
<M> MessageHandler<M> findIndex(final short index) {
90+
return (MessageHandler<M>) indices.get(index);
9191
}
9292

9393
public <M> int build(M message, PacketByteBuf target) {
94-
@SuppressWarnings("unchecked")
95-
MessageHandler<M> codec = (MessageHandler<M>) types.get(message.getClass());
94+
MessageHandler<M> codec = findMessageType(message);
9695

9796
if (codec == null) {
9897
LOGGER.error(SIMPLENET, "Received invalid message {} on channel {}", message.getClass().getName(), channelName);

patchwork-networking/src/main/java/net/minecraftforge/fml/network/simple/SimpleChannel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public <M> IndexedMessageCodec.MessageHandler<M> registerMessage(int index, Clas
8383
return this.indexedCodec.addCodecIndex(index, messageType, encoder, decoder, messageConsumer);
8484
}
8585

86-
private <M> Pair<PacketByteBuf, Integer> toBuffer(M msg) {
86+
private <M> Pair<PacketByteBuf, Integer> toBuffer(M message) {
8787
final PacketByteBuf bufIn = new PacketByteBuf(Unpooled.buffer());
88-
int index = encodeMessage(msg, bufIn);
88+
int index = encodeMessage(message, bufIn);
8989
return Pair.of(bufIn, index);
9090
}
9191

@@ -194,9 +194,9 @@ public MessageBuilder<M> consumer(BiConsumer<M, Supplier<NetworkEvent.Context>>
194194
* @return this
195195
*/
196196
public MessageBuilder<M> consumer(ToBooleanBiFunction<M, Supplier<NetworkEvent.Context>> handler) {
197-
this.consumer = (msg, ctx) -> {
198-
boolean handled = handler.applyAsBool(msg, ctx);
199-
ctx.get().setPacketHandled(handled);
197+
this.consumer = (message, context) -> {
198+
boolean handled = handler.applyAsBool(message, context);
199+
context.get().setPacketHandled(handled);
200200
};
201201
return this;
202202
}

0 commit comments

Comments
 (0)