diff --git a/gradle.properties b/gradle.properties index c2f195f6..78e90595 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ org.gradle.caching = true org.gradle.daemon = true modname=TheOneSmeagle -version=1.12-Dev-6 +version=1.12-Dev-7 curse_type=release projectId=245211 github_project=strubium/TheOneSmeagle diff --git a/src/main/java/mcjty/theoneprobe/api/TextStyleClass.java b/src/main/java/mcjty/theoneprobe/api/TextStyleClass.java index 06bae51b..d7709835 100644 --- a/src/main/java/mcjty/theoneprobe/api/TextStyleClass.java +++ b/src/main/java/mcjty/theoneprobe/api/TextStyleClass.java @@ -46,6 +46,7 @@ public String getReadableName() { /** * Returns a string representation of the enum constant, * formatted as "{=code=}". + * * @return String representation of the enum constant. */ @Override diff --git a/src/main/java/mcjty/theoneprobe/network/NetworkTools.java b/src/main/java/mcjty/theoneprobe/network/NetworkTools.java index 974103c2..4d55e5a1 100644 --- a/src/main/java/mcjty/theoneprobe/network/NetworkTools.java +++ b/src/main/java/mcjty/theoneprobe/network/NetworkTools.java @@ -6,6 +6,7 @@ import net.minecraft.network.PacketBuffer; import net.minecraft.util.math.BlockPos; +import javax.annotation.Nullable; import java.io.IOException; import java.util.Collection; import java.util.Objects; @@ -126,14 +127,14 @@ public static void writeString(ByteBuf dataOut, String str) { * @return The String read from the buffer, or null if the length was -1, or an empty string if the length was 0. */ public static String readStringUTF8(ByteBuf dataIn) { - int s = dataIn.readInt(); - if (s == -1) { + int length = dataIn.readInt(); + if (length == -1) { return null; } - if (s == 0) { + if (length == 0) { return ""; } - byte[] dst = new byte[s]; + byte[] dst = new byte[length]; dataIn.readBytes(dst); return new String(dst, java.nio.charset.StandardCharsets.UTF_8); } @@ -210,7 +211,7 @@ public static > T readEnum(ByteBuf buf, T[] values) { * Writes a collection of enum values to the given ByteBuf. * * @param buf The ByteBuf to write to. - * @param collection The collection of enum values to write. + * @param collection A {@link Collection} of enum values to write. * @param The enum type. */ public static > void writeEnumCollection(ByteBuf buf, Collection collection) { @@ -224,7 +225,7 @@ public static > void writeEnumCollection(ByteBuf buf, Collecti * Reads a collection of enum values from the given ByteBuf. * * @param buf The ByteBuf to read from. - * @param collection The collection to populate with the enum values. + * @param collection A {@link Collection} to populate with the enum values. * @param values The array of possible enum values. * @param The enum type. */ @@ -240,12 +241,12 @@ public static > void readEnumCollection(ByteBuf buf, Collectio * Writes a Float value to the given ByteBuf. * * @param buf The ByteBuf to write to. - * @param f The Float value to write, or null to indicate no value. + * @param value The Float value to write, or null to indicate no value. */ - public static void writeFloat(ByteBuf buf, Float f) { - if (f != null) { + public static void writeFloat(ByteBuf buf, @Nullable Float value) { + if (value != null) { buf.writeBoolean(true); - buf.writeFloat(f); + buf.writeFloat(value); } else { buf.writeBoolean(false); } diff --git a/src/main/java/mcjty/theoneprobe/network/PacketGetEntityInfo.java b/src/main/java/mcjty/theoneprobe/network/PacketGetEntityInfo.java index cba05844..aa789f51 100644 --- a/src/main/java/mcjty/theoneprobe/network/PacketGetEntityInfo.java +++ b/src/main/java/mcjty/theoneprobe/network/PacketGetEntityInfo.java @@ -19,7 +19,6 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import java.util.List; import java.util.UUID; import static mcjty.theoneprobe.api.TextStyleClass.ERROR; @@ -50,18 +49,15 @@ public void toBytes(ByteBuf buf) { buf.writeLong(uuid.getMostSignificantBits()); buf.writeLong(uuid.getLeastSignificantBits()); buf.writeByte(mode.ordinal()); - if (hitVec == null) { - buf.writeBoolean(false); - } else { - buf.writeBoolean(true); + buf.writeBoolean(hitVec != null); + if (hitVec != null) { buf.writeDouble(hitVec.x); buf.writeDouble(hitVec.y); buf.writeDouble(hitVec.z); } } - public PacketGetEntityInfo() { - } + public PacketGetEntityInfo() {} public PacketGetEntityInfo(int dim, ProbeMode mode, RayTraceResult mouseOver, Entity entity) { this.dim = dim; @@ -91,30 +87,23 @@ private void handle(PacketGetEntityInfo message, MessageContext ctx) { private static ProbeInfo getProbeInfo(EntityPlayer player, ProbeMode mode, World world, Entity entity, Vec3d hitVec) { if (ConfigSetup.needsProbe == PROBE_NEEDEDFOREXTENDED) { - // We need a probe only for extended information - if (!ModItems.hasAProbeSomewhere(player)) { - // No probe anywhere, switch EXTENDED to NORMAL - if (mode == ProbeMode.EXTENDED) { - mode = ProbeMode.NORMAL; - } + if (!ModItems.hasAProbeSomewhere(player) && mode == ProbeMode.EXTENDED) { + mode = ProbeMode.NORMAL; } } else if (ConfigSetup.needsProbe == PROBE_NEEDEDHARD && !ModItems.hasAProbeSomewhere(player)) { - // The server says we need a probe, but we don't have one in our hands or on our head return null; } ProbeInfo probeInfo = TheOneProbe.theOneProbeImp.create(); IProbeHitEntityData data = new ProbeHitEntityData(hitVec); - IProbeConfig probeConfig = TheOneProbe.theOneProbeImp.createProbeConfig(); - List configProviders = TheOneProbe.theOneProbeImp.getConfigProviders(); - for (IProbeConfigProvider configProvider : configProviders) { + + for (IProbeConfigProvider configProvider : TheOneProbe.theOneProbeImp.getConfigProviders()) { configProvider.getProbeConfig(probeConfig, player, world, entity, data); } ConfigSetup.setRealConfig(probeConfig); - List entityProviders = TheOneProbe.theOneProbeImp.getEntityProviders(); - for (IProbeInfoEntityProvider provider : entityProviders) { + for (IProbeInfoEntityProvider provider : TheOneProbe.theOneProbeImp.getEntityProviders()) { try { provider.addProbeEntityInfo(mode, probeInfo, player, world, entity, data); } catch (Throwable e) { @@ -124,5 +113,4 @@ private static ProbeInfo getProbeInfo(EntityPlayer player, ProbeMode mode, World } return probeInfo; } - }