Some code cleanup
This commit is contained in:
parent
96a3dd8464
commit
63d2e53811
10 changed files with 7 additions and 17 deletions
|
@ -359,7 +359,7 @@ public class CommandProcessor {
|
||||||
Song currentSong = SongHandler.getInstance().currentSong;
|
Song currentSong = SongHandler.getInstance().currentSong;
|
||||||
long currentTime = Math.min(currentSong.time, currentSong.length);
|
long currentTime = Math.min(currentSong.time, currentSong.length);
|
||||||
long totalTime = 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;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -3,13 +3,11 @@ package com.github.hhhzzzsss.songplayer;
|
||||||
import com.github.hhhzzzsss.songplayer.playing.SongHandler;
|
import com.github.hhhzzzsss.songplayer.playing.SongHandler;
|
||||||
import com.github.hhhzzzsss.songplayer.playing.Stage;
|
import com.github.hhhzzzsss.songplayer.playing.Stage;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.client.RunArgs;
|
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
import net.minecraft.client.network.OtherClientPlayerEntity;
|
import net.minecraft.client.network.OtherClientPlayerEntity;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.entity.EntityPose;
|
import net.minecraft.entity.EntityPose;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.Uuids;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,7 @@ package com.github.hhhzzzsss.songplayer;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.enums.Instrument;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -12,8 +10,6 @@ import net.minecraft.text.Text;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import static net.minecraft.block.NoteBlock.*;
|
|
||||||
|
|
||||||
public class SongPlayer implements ModInitializer {
|
public class SongPlayer implements ModInitializer {
|
||||||
|
|
||||||
public static final MinecraftClient MC = MinecraftClient.getInstance();
|
public static final MinecraftClient MC = MinecraftClient.getInstance();
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class NBSConverter {
|
||||||
if (length > maxSize) {
|
if (length > maxSize) {
|
||||||
throw new IOException("String is too large");
|
throw new IOException("String is too large");
|
||||||
}
|
}
|
||||||
byte arr[] = new byte[length];
|
byte[] arr = new byte[length];
|
||||||
buffer.get(arr, 0, length);
|
buffer.get(arr, 0, length);
|
||||||
return new String(arr);
|
return new String(arr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class SPConverter {
|
||||||
if (length > maxSize) {
|
if (length > maxSize) {
|
||||||
throw new IOException("String is too large");
|
throw new IOException("String is too large");
|
||||||
}
|
}
|
||||||
byte arr[] = new byte[length];
|
byte[] arr = new byte[length];
|
||||||
buffer.get(arr, 0, length);
|
buffer.get(arr, 0, length);
|
||||||
System.out.println(new String(arr, StandardCharsets.UTF_8));
|
System.out.println(new String(arr, StandardCharsets.UTF_8));
|
||||||
return new String(arr, StandardCharsets.UTF_8);
|
return new String(arr, StandardCharsets.UTF_8);
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class SongItemConfirmationScreen extends Screen {
|
||||||
String.format("§7Max notes per second: %s%d", getNumberColor(loaderThread.maxNotesPerSecond), loaderThread.maxNotesPerSecond),
|
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),
|
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);
|
this.loadedText = MultilineText.createFromTexts(this.textRenderer, messageList);
|
||||||
|
|
||||||
int loadedTextHeight = this.loadedText.count() * this.textRenderer.fontHeight;
|
int loadedTextHeight = this.loadedText.count() * this.textRenderer.fontHeight;
|
||||||
|
|
|
@ -10,7 +10,6 @@ import net.minecraft.entity.EntityPose;
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
|
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.c2s.play.PlayerMoveC2SPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket;
|
import net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket;
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.github.hhhzzzsss.songplayer.Util;
|
||||||
import com.github.hhhzzzsss.songplayer.mixin.ClientPlayerInteractionManagerAccessor;
|
import com.github.hhhzzzsss.songplayer.mixin.ClientPlayerInteractionManagerAccessor;
|
||||||
import com.github.hhhzzzsss.songplayer.song.*;
|
import com.github.hhhzzzsss.songplayer.song.*;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.RunArgs;
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -141,7 +140,7 @@ public class SongHandler {
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
loaderThread = new SongLoaderThread(location);
|
loaderThread = new SongLoaderThread(location);
|
||||||
SongPlayer.addChatMessage("§6Loading §3" + location + "");
|
SongPlayer.addChatMessage("§6Loading §3" + location);
|
||||||
loaderThread.start();
|
loaderThread.start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SongPlayer.addChatMessage("§cFailed to load song: §4" + e.getMessage());
|
SongPlayer.addChatMessage("§cFailed to load song: §4" + e.getMessage());
|
||||||
|
@ -489,8 +488,6 @@ public class SongHandler {
|
||||||
private void getAndSaveBuildSlot() {
|
private void getAndSaveBuildSlot() {
|
||||||
buildSlot = SongPlayer.MC.player.getInventory().getSwappableHotbarSlot();
|
buildSlot = SongPlayer.MC.player.getInventory().getSwappableHotbarSlot();
|
||||||
prevHeldItem = SongPlayer.MC.player.getInventory().getStack(buildSlot);
|
prevHeldItem = SongPlayer.MC.player.getInventory().getStack(buildSlot);
|
||||||
System.out.println(buildSlot);
|
|
||||||
System.out.println(prevHeldItem.toString());
|
|
||||||
}
|
}
|
||||||
private void restoreBuildSlot() {
|
private void restoreBuildSlot() {
|
||||||
SongPlayer.MC.player.getInventory().setStack(buildSlot, prevHeldItem);
|
SongPlayer.MC.player.getInventory().setStack(buildSlot, prevHeldItem);
|
||||||
|
|
|
@ -16,7 +16,7 @@ import java.util.stream.Collectors;
|
||||||
public class Stage {
|
public class Stage {
|
||||||
private final ClientPlayerEntity player = SongPlayer.MC.player;
|
private final ClientPlayerEntity player = SongPlayer.MC.player;
|
||||||
|
|
||||||
public static enum StageType {
|
public enum StageType {
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
WIDE,
|
WIDE,
|
||||||
SPHERICAL,
|
SPHERICAL,
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class DownloadUtils {
|
||||||
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
byte buf[] = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
int n;
|
int n;
|
||||||
int tot = 0;
|
int tot = 0;
|
||||||
while ((n = downloadStream.read(buf)) > 0) {
|
while ((n = downloadStream.read(buf)) > 0) {
|
||||||
|
|
Loading…
Reference in a new issue