Some code cleanup

This commit is contained in:
hhhzzzsss 2023-06-18 16:29:57 -05:00
parent 96a3dd8464
commit 63d2e53811
10 changed files with 7 additions and 17 deletions

View file

@ -359,7 +359,7 @@ public class CommandProcessor {
Song currentSong = SongHandler.getInstance().currentSong;
long currentTime = Math.min(currentSong.time, currentSong.length);
long totalTime = currentSong.length;
SongPlayer.addChatMessage(String.format("§6Currently playing %s §3(%s/%s)", Util.formatTime(currentTime), Util.formatTime(totalTime)));
SongPlayer.addChatMessage(String.format("§6Currently playing %s §3(%s/%s)", currentSong.name, Util.formatTime(currentTime), Util.formatTime(totalTime)));
return true;
}
else {

View file

@ -3,13 +3,11 @@ package com.github.hhhzzzsss.songplayer;
import com.github.hhhzzzsss.songplayer.playing.SongHandler;
import com.github.hhhzzzsss.songplayer.playing.Stage;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.RunArgs;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.OtherClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.EntityPose;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Uuids;
import java.util.UUID;

View file

@ -2,9 +2,7 @@ package com.github.hhhzzzsss.songplayer;
import net.fabricmc.api.ModInitializer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.enums.Instrument;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.Entity;
import net.minecraft.text.Text;
@ -12,8 +10,6 @@ import net.minecraft.text.Text;
import java.nio.file.Files;
import java.nio.file.Path;
import static net.minecraft.block.NoteBlock.*;
public class SongPlayer implements ModInitializer {
public static final MinecraftClient MC = MinecraftClient.getInstance();

View file

@ -171,7 +171,7 @@ public class NBSConverter {
if (length > maxSize) {
throw new IOException("String is too large");
}
byte arr[] = new byte[length];
byte[] arr = new byte[length];
buffer.get(arr, 0, length);
return new String(arr);
}

View file

@ -96,7 +96,7 @@ public class SPConverter {
if (length > maxSize) {
throw new IOException("String is too large");
}
byte arr[] = new byte[length];
byte[] arr = new byte[length];
buffer.get(arr, 0, length);
System.out.println(new String(arr, StandardCharsets.UTF_8));
return new String(arr, StandardCharsets.UTF_8);

View file

@ -69,7 +69,7 @@ public class SongItemConfirmationScreen extends Screen {
String.format("§7Max notes per second: %s%d", getNumberColor(loaderThread.maxNotesPerSecond), loaderThread.maxNotesPerSecond),
String.format("§7Avg notes per second: %s%.2f", getNumberColor(loaderThread.avgNotesPerSecond), loaderThread.avgNotesPerSecond),
};
List<Text> messageList = Arrays.stream(loadedMessages).map(Text::literal).collect(Collectors.toList());;
List<Text> messageList = Arrays.stream(loadedMessages).map(Text::literal).collect(Collectors.toList());
this.loadedText = MultilineText.createFromTexts(this.textRenderer, messageList);
int loadedTextHeight = this.loadedText.count() * this.textRenderer.fontHeight;

View file

@ -10,7 +10,6 @@ import net.minecraft.entity.EntityPose;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
import net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket;

View file

@ -7,7 +7,6 @@ import com.github.hhhzzzsss.songplayer.Util;
import com.github.hhhzzzsss.songplayer.mixin.ClientPlayerInteractionManagerAccessor;
import com.github.hhhzzzsss.songplayer.song.*;
import net.minecraft.block.Block;
import net.minecraft.client.RunArgs;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
@ -141,7 +140,7 @@ public class SongHandler {
else {
try {
loaderThread = new SongLoaderThread(location);
SongPlayer.addChatMessage("§6Loading §3" + location + "");
SongPlayer.addChatMessage("§6Loading §3" + location);
loaderThread.start();
} catch (IOException e) {
SongPlayer.addChatMessage("§cFailed to load song: §4" + e.getMessage());
@ -489,8 +488,6 @@ public class SongHandler {
private void getAndSaveBuildSlot() {
buildSlot = SongPlayer.MC.player.getInventory().getSwappableHotbarSlot();
prevHeldItem = SongPlayer.MC.player.getInventory().getStack(buildSlot);
System.out.println(buildSlot);
System.out.println(prevHeldItem.toString());
}
private void restoreBuildSlot() {
SongPlayer.MC.player.getInventory().setStack(buildSlot, prevHeldItem);

View file

@ -16,7 +16,7 @@ import java.util.stream.Collectors;
public class Stage {
private final ClientPlayerEntity player = SongPlayer.MC.player;
public static enum StageType {
public enum StageType {
DEFAULT,
WIDE,
SPHERICAL,

View file

@ -41,7 +41,7 @@ public class DownloadUtils {
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
try {
byte buf[] = new byte[1024];
byte[] buf = new byte[1024];
int n;
int tot = 0;
while ((n = downloadStream.read(buf)) > 0) {