public void DoubleStoreTest(double num) { long storedDouble = JavaHelper.DoubleToStoredDouble(num); double decodedDouble = JavaHelper.StoredDoubleToDouble(storedDouble); Assert.Equal(num, decodedDouble); }
public void FloatStoreTest(float num) { int storedFloat = JavaHelper.FloatToStoredFloat(num); float decodedFloat = JavaHelper.StoredFloatToFloat(storedFloat); Assert.Equal(num, decodedFloat); }
public ClippingHelper() { Frustum = JavaHelper.ReturnRectangularArray <float>(16, 16); ProjectionMatrix = new float[16]; ModelviewMatrix = new float[16]; ClippingMatrix = new float[16]; }
public ChunkCache(World par1World, int par2, int par3, int par4, int par5, int par6, int par7) { WorldObj = par1World; ChunkX = par2 >> 4; ChunkZ = par4 >> 4; int i = par5 >> 4; int j = par7 >> 4; ChunkArray = JavaHelper.ReturnRectangularArray <Chunk>((i - ChunkX) + 1, (j - ChunkZ) + 1); Field_48467_d = true; for (int k = ChunkX; k <= i; k++) { for (int l = ChunkZ; l <= j; l++) { Chunk chunk = par1World.GetChunkFromChunkCoords(k, l); if (chunk == null) { continue; } ChunkArray[k - ChunkX][l - ChunkZ] = chunk; if (!chunk.GetAreLevelsEmpty(par3, par6)) { Field_48467_d = false; } } } }
/// <summary> /// Updates all fields of the Timer using the current time /// </summary> public virtual void UpdateTimer() { long l = JavaHelper.CurrentTimeMillis(); long l1 = l - LastSyncSysClock; long l2 = JavaHelper.NanoTime() / 0xf4240L; double d = (double)l2 / 1000D; if (l1 > 1000L) { LastHRTime = d; } else if (l1 < 0L) { LastHRTime = d; } else { Field_28132_i += l1; if (Field_28132_i > 1000L) { long l3 = l2 - LastSyncHRClock; double d2 = (double)Field_28132_i / (double)l3; TimeSyncAdjustment += (d2 - TimeSyncAdjustment) * 0.20000000298023224D; LastSyncHRClock = l2; Field_28132_i = 0L; } if (Field_28132_i < 0L) { LastSyncHRClock = l2; } } LastSyncSysClock = l; double d1 = (d - LastHRTime) * TimeSyncAdjustment; LastHRTime = d; if (d1 < 0.0F) { d1 = 0.0F; } if (d1 > 1.0D) { d1 = 1.0D; } ElapsedPartialTicks += (float)d1 * TimerSpeed * TicksPerSecond; ElapsedTicks = (int)ElapsedPartialTicks; ElapsedPartialTicks -= ElapsedTicks; if (ElapsedTicks > 10) { ElapsedTicks = 10; } RenderPartialTicks = ElapsedPartialTicks; }
public Timer(float par1) { TimerSpeed = 1.0F; ElapsedPartialTicks = 0.0F; TimeSyncAdjustment = 1.0D; TicksPerSecond = par1; LastSyncSysClock = JavaHelper.CurrentTimeMillis(); LastSyncHRClock = JavaHelper.NanoTime() / 0xf4240L; }
public static string GetServerIDHash(byte[] publicKey, byte[] secretKey, string serverID) { var hashlist = new List <byte>(); hashlist.AddRange(Encoding.ASCII.GetBytes(serverID)); hashlist.AddRange(secretKey); hashlist.AddRange(publicKey); return(JavaHelper.JavaHexDigest(hashlist.ToArray())); }
public void FloatStackTest(float num) { int[] stack = new int[2]; int sp = 1; Utility.Push(ref stack, ref sp, num); Assert.Equal(num, JavaHelper.StoredFloatToFloat(stack[1])); float popped = Utility.PopFloat(stack, ref sp); Assert.Equal(num, popped); }
public async Task <Process> Start() { string javaPath = JavaHelper.FindJavaExecutableAbsolutePath(); if (javaPath.Length == 0) { Error = "Java is not installed"; return(null); } string workingDir = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID); string serverJarPath = Path.Combine(workingDir, "server.jar"); if (!File.Exists(serverJarPath)) { Error = $"server.jar not found ({serverJarPath})"; return(null); } string configPath = Path.Combine(workingDir, "server.properties"); if (!File.Exists(configPath)) { Notice = $"server.properties not found ({configPath}). Generated a new one."; } WindowsFirewall firewall = new WindowsFirewall("java.exe", javaPath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p; if (!AllowsEmbedConsole) { p = new Process { StartInfo = { WorkingDirectory = workingDir, FileName = javaPath, Arguments = $"{_serverData.ServerParam} -jar server.jar nogui", WindowStyle = ProcessWindowStyle.Minimized, UseShellExecute = false }, EnableRaisingEvents = true }; p.Start(); } else { p = new Process { StartInfo = { WorkingDirectory = workingDir, FileName = javaPath, Arguments = $"{_serverData.ServerParam} -jar server.jar nogui", WindowStyle = ProcessWindowStyle.Minimized, CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }, EnableRaisingEvents = true }; var serverConsole = new Functions.ServerConsole(_serverData.ServerID); p.OutputDataReceived += serverConsole.AddOutput; p.ErrorDataReceived += serverConsole.AddOutput; p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); } return(p); }
public async Task <bool> Update() { //Install JAVA if not installed if (!JavaHelper.IsJREInstalled()) { JavaHelper.JREDownloadTaskResult taskResult = await JavaHelper.DownloadJREToServer(_serverData.ServerID); if (!taskResult.installed) { Error = taskResult.error; return(false); } } string serverJarPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, "server.jar"); if (File.Exists(serverJarPath)) { try { File.Delete(serverJarPath); } catch { Error = "Fail to delete server.jar"; return(false); } } try { using (WebClient webClient = new WebClient()) { const string manifestUrl = "https://launchermeta.mojang.com/mc/game/version_manifest.json"; string versionJson = webClient.DownloadString(manifestUrl); string latesetVersion = JObject.Parse(versionJson)["latest"]["release"].ToString(); var versionObject = JObject.Parse(versionJson)["versions"]; string packageUrl = null; foreach (var obj in versionObject) { if (obj["id"].ToString() == latesetVersion) { packageUrl = obj["url"].ToString(); break; } } if (packageUrl == null) { Error = $"Fail to fetch packageUrl from {manifestUrl}"; return(false); } //packageUrl example: https://launchermeta.mojang.com/v1/packages/6876d19c096de56d1aa2cf434ec6b0e66e0aba00/1.15.json var packageJson = webClient.DownloadString(packageUrl); //serverJarUrl example: https://launcher.mojang.com/v1/objects/e9f105b3c5c7e85c7b445249a93362a22f62442d/server.jar string serverJarUrl = JObject.Parse(packageJson)["downloads"]["server"]["url"].ToString(); await webClient.DownloadFileTaskAsync(serverJarUrl, Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, "server.jar")); //Create eula.txt string eulaPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, "eula.txt"); File.Create(eulaPath).Dispose(); using (TextWriter textwriter = new StreamWriter(eulaPath)) { textwriter.WriteLine("#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula)."); textwriter.WriteLine("#Generated by WindowsGSM.exe"); textwriter.WriteLine("eula=true"); } } } catch { Error = $"Fail to install {FullName}"; return(false); } return(true); }