Directly using VirtualBox from Java #5
3 changed files with 24 additions and 22 deletions
BIN
VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.jar
Executable file → Normal file
BIN
VirtualComputer/repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.jar
Executable file → Normal file
Binary file not shown.
|
@ -97,8 +97,10 @@ public class MCFrameBuffer implements IFramebuffer {
|
||||||
* return; // Don't even try to render too large resolutions }
|
* return; // Don't even try to render too large resolutions }
|
||||||
*/
|
*/
|
||||||
tt = Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, () -> {
|
tt = Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, () -> {
|
||||||
|
try {
|
||||||
display.querySourceBitmap(0L, holder);
|
display.querySourceBitmap(0L, holder);
|
||||||
byte[] arr = PluginMain.allpixels.array();
|
//byte[] arr = PluginMain.allpixels.array();
|
||||||
|
long[] arr = new long[1];
|
||||||
long[] w = new long[1], h = new long[1], bpp = new long[1], bpl = new long[1], pf = new long[1];
|
long[] w = new long[1], h = new long[1], bpp = new long[1], bpl = new long[1], pf = new long[1];
|
||||||
holder.value.getTypedWrapped().queryBitmapInfo(arr, w, h, bpp, bpl, pf);
|
holder.value.getTypedWrapped().queryBitmapInfo(arr, w, h, bpp, bpl, pf);
|
||||||
System.out.println("Arr0:" + arr[0]);
|
System.out.println("Arr0:" + arr[0]);
|
||||||
|
@ -113,6 +115,9 @@ public class MCFrameBuffer implements IFramebuffer {
|
||||||
else if (r instanceof DirectRenderer)
|
else if (r instanceof DirectRenderer)
|
||||||
((DirectRenderer) r).render(PluginMain.allpixels, xOrigin, yOrigin, width, height);
|
((DirectRenderer) r).render(PluginMain.allpixels, xOrigin, yOrigin, width, height);
|
||||||
System.out.println("Change!");
|
System.out.println("Change!");
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
}, 5); // Wait 1/4th of a second
|
}, 5); // Wait 1/4th of a second
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +131,6 @@ public class MCFrameBuffer implements IFramebuffer {
|
||||||
((DirectRenderer) r).render(PluginMain.allpixels, x, y, width, height);
|
((DirectRenderer) r).render(PluginMain.allpixels, x, y, width, height);
|
||||||
System.out.println("Update!");
|
System.out.println("Update!");
|
||||||
}, 5);*/
|
}, 5);*/
|
||||||
throw new UnsupportedOperationException("Use UpdateImage");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,11 +139,11 @@ public class MCFrameBuffer implements IFramebuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processVHWACommand(byte arg0) {
|
public void setVisibleRegion(byte arg0, long arg1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisibleRegion(byte arg0, long arg1) {
|
public void processVHWACommand(byte b, int i, boolean b1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package sznp.virtualcomputer;
|
package sznp.virtualcomputer;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.sun.jna.Memory;
|
|
||||||
import com.sun.jna.Pointer;
|
import com.sun.jna.Pointer;
|
||||||
import jnr.ffi.LibraryLoader;
|
import jnr.ffi.LibraryLoader;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -10,7 +9,6 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.virtualbox_5_2.*;
|
import org.virtualbox_5_2.*;
|
||||||
import sun.misc.Unsafe;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
@ -115,7 +113,7 @@ public class PluginMain extends JavaPlugin {
|
||||||
screenupdatetask = Bukkit.getScheduler().runTaskTimerAsynchronously(PluginMain.this, () -> {
|
screenupdatetask = Bukkit.getScheduler().runTaskTimerAsynchronously(PluginMain.this, () -> {
|
||||||
if (session.getState().equals(SessionState.Locked) // Don't run until the machine is running
|
if (session.getState().equals(SessionState.Locked) // Don't run until the machine is running
|
||||||
&& console.getState().equals(MachineState.Running))
|
&& console.getState().equals(MachineState.Running))
|
||||||
console.getDi splay().invalidateAndUpdateScreen(0L);
|
console.getDisplay().invalidateAndUpdateScreen(0L);
|
||||||
if (session.getState().equals(SessionState.Unlocked) // Stop if the machine stopped fully
|
if (session.getState().equals(SessionState.Unlocked) // Stop if the machine stopped fully
|
||||||
|| console.getState().equals(MachineState.PoweredOff)
|
|| console.getState().equals(MachineState.PoweredOff)
|
||||||
|| console.getState().equals(MachineState.Saved)) {
|
|| console.getState().equals(MachineState.Saved)) {
|
||||||
|
|
Loading…
Reference in a new issue