fix (also remove thread because apparently bad boo bad bad blablabla
threads are now worse
This commit is contained in:
parent
eeb90a315a
commit
d0c582c524
39341
javascript/classes.js
39341
javascript/classes.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -54,27 +54,26 @@ public class GuiScreenModules extends GuiScreen {
|
||||||
NoteblockPlayer.thr=null;
|
NoteblockPlayer.thr=null;
|
||||||
mc.thePlayer.sendChatToPlayer("Stopped notebot!");
|
mc.thePlayer.sendChatToPlayer("Stopped notebot!");
|
||||||
}else {
|
}else {
|
||||||
NoteblockPlayer.thr = new Thread(new Runnable() {
|
EaglerAdapter.openFileChooser("nbs", ".nbs,.mid,.midi");
|
||||||
@Override
|
NoteblockPlayer.zleep(1000);
|
||||||
public void run() {
|
while(!EaglerAdapter.isFocused()){
|
||||||
EaglerAdapter.openFileChooser("nbs", ".nbs,.mid,.midi");
|
NoteblockPlayer.zleep(100);
|
||||||
try {
|
}
|
||||||
Thread.sleep(1000);
|
NoteblockPlayer.zleep(500);
|
||||||
while(!EaglerAdapter.isFocused()){
|
byte[] b;
|
||||||
Thread.sleep(100);
|
if ((b = EaglerAdapter.getFileChooserResult()) != null && b.length > 0) {
|
||||||
}
|
String name = EaglerAdapter.getFileChooserResultName();
|
||||||
Thread.sleep(500);
|
NoteblockPlayer.songdata = b;
|
||||||
} catch (InterruptedException e) {}
|
mc.thePlayer.sendChatToPlayer("Playing \""+name+"\" on notebot!");
|
||||||
byte[] b;
|
String[] songLines=(name.toLowerCase().endsWith(".nbs")?NoteblockPlayer.loadSong():MidiConverter.midiToTxt()).split("\n");
|
||||||
if ((b = EaglerAdapter.getFileChooserResult()) != null && b.length > 0) {
|
NoteblockPlayer.thr = new Thread(new Runnable() {
|
||||||
String name = EaglerAdapter.getFileChooserResultName();
|
@Override
|
||||||
NoteblockPlayer.songdata = b;
|
public void run() {
|
||||||
mc.thePlayer.sendChatToPlayer("Playing \""+name+"\" on notebot!");
|
NoteblockPlayer.play(songLines);
|
||||||
NoteblockPlayer.play((name.toLowerCase().endsWith(".nbs")?NoteblockPlayer.loadSong():MidiConverter.midiToTxt()).split("\n"));
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
NoteblockPlayer.thr.start();
|
||||||
NoteblockPlayer.thr.start();
|
}
|
||||||
}
|
}
|
||||||
}else if(par1GuiButton.id == 3){
|
}else if(par1GuiButton.id == 3){
|
||||||
NoteblockPlayer.legit=!NoteblockPlayer.legit;
|
NoteblockPlayer.legit=!NoteblockPlayer.legit;
|
||||||
|
|
|
@ -116,13 +116,20 @@ public class NoteblockPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void zleep(int ms){
|
||||||
|
long startTime=System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
while(System.currentTimeMillis()-startTime<ms){
|
||||||
|
Thread.sleep(0);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean building=false;
|
public static boolean building=false;
|
||||||
public static void placeAndTuneNoteblocks(HashMap<Integer, HashMap<Integer, Vec3>> instrNoteToBlock){
|
public static void placeAndTuneNoteblocks(HashMap<Integer, HashMap<Integer, Vec3>> instrNoteToBlock){
|
||||||
if(!playing)return;
|
if(!playing)return;
|
||||||
building=true;
|
building=true;
|
||||||
try {
|
zleep(100);
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
for(Map.Entry<Integer, HashMap<Integer, Vec3>> entry : instrNoteToBlock.entrySet()) {
|
for(Map.Entry<Integer, HashMap<Integer, Vec3>> entry : instrNoteToBlock.entrySet()) {
|
||||||
Integer instr = entry.getKey();
|
Integer instr = entry.getKey();
|
||||||
HashMap<Integer, Vec3> noteBlockPos = entry.getValue();
|
HashMap<Integer, Vec3> noteBlockPos = entry.getValue();
|
||||||
|
@ -154,9 +161,7 @@ public class NoteblockPlayer {
|
||||||
mc.thePlayer.inventory.mainInventory[0] = item;
|
mc.thePlayer.inventory.mainInventory[0] = item;
|
||||||
mc.playerController.sendSlotPacket(item, mc.thePlayer.inventoryContainer.inventorySlots.size() - 9);
|
mc.playerController.sendSlotPacket(item, mc.thePlayer.inventoryContainer.inventorySlots.size() - 9);
|
||||||
mc.getNetHandler().addToSendQueue(new Packet16BlockItemSwitch(0));
|
mc.getNetHandler().addToSendQueue(new Packet16BlockItemSwitch(0));
|
||||||
try{
|
zleep(50);
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
}
|
}
|
||||||
rotateToBlock(blockPos.addVector(0,-1,0));
|
rotateToBlock(blockPos.addVector(0,-1,0));
|
||||||
if(id1!=0) {
|
if(id1!=0) {
|
||||||
|
@ -165,9 +170,7 @@ public class NoteblockPlayer {
|
||||||
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(1, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1));
|
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(1, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1));
|
||||||
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(2, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1));
|
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(2, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1));
|
||||||
PlayerControllerMP.clickBlockCreative(mc, mc.playerController, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1);
|
PlayerControllerMP.clickBlockCreative(mc, mc.playerController, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1);
|
||||||
try{
|
zleep(50);
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
//attempt to place
|
//attempt to place
|
||||||
|
@ -182,9 +185,7 @@ public class NoteblockPlayer {
|
||||||
mc.thePlayer.inventory.mainInventory[0] = item;
|
mc.thePlayer.inventory.mainInventory[0] = item;
|
||||||
mc.playerController.sendSlotPacket(item, mc.thePlayer.inventoryContainer.inventorySlots.size() - 9);
|
mc.playerController.sendSlotPacket(item, mc.thePlayer.inventoryContainer.inventorySlots.size() - 9);
|
||||||
mc.getNetHandler().addToSendQueue(new Packet16BlockItemSwitch(0));
|
mc.getNetHandler().addToSendQueue(new Packet16BlockItemSwitch(0));
|
||||||
try{
|
zleep(50);
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
}
|
}
|
||||||
rotateToBlock(blockPos.addVector(0,-2,0));
|
rotateToBlock(blockPos.addVector(0,-2,0));
|
||||||
if(id1!=0) {
|
if(id1!=0) {
|
||||||
|
@ -193,9 +194,7 @@ public class NoteblockPlayer {
|
||||||
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(1, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1));
|
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(1, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1));
|
||||||
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(2, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1));
|
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(2, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1));
|
||||||
PlayerControllerMP.clickBlockCreative(mc, mc.playerController, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1);
|
PlayerControllerMP.clickBlockCreative(mc, mc.playerController, (int) blockPos.xCoord, (int) (blockPos.yCoord - 1), (int) blockPos.zCoord, 1);
|
||||||
try{
|
zleep(50);
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
}
|
}
|
||||||
if(id2!=0) {
|
if(id2!=0) {
|
||||||
//attempt to break
|
//attempt to break
|
||||||
|
@ -203,9 +202,7 @@ public class NoteblockPlayer {
|
||||||
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(1, (int) blockPos.xCoord, (int) (blockPos.yCoord - 2), (int) blockPos.zCoord, 1));
|
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(1, (int) blockPos.xCoord, (int) (blockPos.yCoord - 2), (int) blockPos.zCoord, 1));
|
||||||
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(2, (int) blockPos.xCoord, (int) (blockPos.yCoord - 2), (int) blockPos.zCoord, 1));
|
mc.getNetHandler().addToSendQueue(new Packet14BlockDig(2, (int) blockPos.xCoord, (int) (blockPos.yCoord - 2), (int) blockPos.zCoord, 1));
|
||||||
PlayerControllerMP.clickBlockCreative(mc, mc.playerController, (int) blockPos.xCoord, (int) (blockPos.yCoord - 2), (int) blockPos.zCoord, 1);
|
PlayerControllerMP.clickBlockCreative(mc, mc.playerController, (int) blockPos.xCoord, (int) (blockPos.yCoord - 2), (int) blockPos.zCoord, 1);
|
||||||
try{
|
zleep(50);
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
//attempt to place
|
//attempt to place
|
||||||
|
@ -237,9 +234,7 @@ public class NoteblockPlayer {
|
||||||
currentNote=-1;
|
currentNote=-1;
|
||||||
hasBeenPlaced=false;
|
hasBeenPlaced=false;
|
||||||
}
|
}
|
||||||
try {
|
zleep(50);
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
currPos=mc.thePlayer.getPosition(1);
|
currPos=mc.thePlayer.getPosition(1);
|
||||||
//rangeBlockDist=currPos.addVector(0,mc.thePlayer.getEyeHeight(),0).distanceTo(blockPosVec3d);
|
//rangeBlockDist=currPos.addVector(0,mc.thePlayer.getEyeHeight(),0).distanceTo(blockPosVec3d);
|
||||||
blockDist=currPos.distanceTo(blockPos);
|
blockDist=currPos.distanceTo(blockPos);
|
||||||
|
@ -250,9 +245,7 @@ public class NoteblockPlayer {
|
||||||
}
|
}
|
||||||
if(playing) {
|
if(playing) {
|
||||||
mc.thePlayer.sendChatMessage("/gamemode 0");
|
mc.thePlayer.sendChatMessage("/gamemode 0");
|
||||||
try {
|
zleep(500);
|
||||||
Thread.sleep(500);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
}
|
}
|
||||||
building = false;
|
building = false;
|
||||||
}
|
}
|
||||||
|
@ -358,9 +351,11 @@ public class NoteblockPlayer {
|
||||||
//keep notes within 2-octave range
|
//keep notes within 2-octave range
|
||||||
Integer notePitch=Math.max(33,Math.min(57,noteInfo.getPitch()))-33;
|
Integer notePitch=Math.max(33,Math.min(57,noteInfo.getPitch()))-33;
|
||||||
int instrId=noteInfo.getInstrument().getID();
|
int instrId=noteInfo.getInstrument().getID();
|
||||||
if(instrId!=-1)instrId=in2old[nb2in[instrId]];
|
if(instrId!=-1){
|
||||||
tickLines.add(noteKey + ":" + notePitch + ":" + instrId + "\n");
|
instrId=in2old[nb2in[instrId]];
|
||||||
songLines.put(noteKey,tickLines);
|
tickLines.add(noteKey + ":" + notePitch + ":" + instrId + "\n");
|
||||||
|
songLines.put(noteKey,tickLines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SortedSet<Integer> ticks = new TreeSet<>(songLines.keySet());
|
SortedSet<Integer> ticks = new TreeSet<>(songLines.keySet());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user