Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

How can I get a modded Minecraft server java arguments running smoothly on my PC?

Asked by Ishii Watanabe Oct 6, 2022 13.0K views 2 answers
Share

About this question

 I'm looking to run a modded minecraft server (1.12.2) for myself and a friend to play on. There are quite a few mods we're looking to use, and I'd like to know what I can do to make the server run more smoothly. As of right now, it lags quite a lot, even with a freshly-generated world. Looking around online, all the information I can find feels like it's at least a little bit outdated, and sometimes a lot outdated. So while this is looking to get a particular server up and running, I'd also appreciate anything about generally optimizing performance using current versions of java.

According to LagGoggles, the main culprits seem to be mobs, with one or two (which one changes each time I run it) taking ~20-30 ms per tick each time I run the profiler.

According to warm roast, something is making the game spend a significant amount of time doing pathfinding for sheep, and a significant amount of time is spent in Update Time Light And Entities, about 80% of the server thread's resources.

Is there a mod that optimizes entity calculations? Or perhaps a way to determine which mods are most adversely affecting performance, so I know which ones to focus on removing or fiddling with configs?

The server is running on a computer with a Ryzen 2200G (probably soon to be upgraded to a 3600, though--hopefully that helps) and 16 GB of DDR4-2666 RAM. It also has a GTX 1060-6GB but I'm reasonably certain the graphics card doesn't matter for this. (would be nice if I could offload some computing load onto it, though.... Is there a way to do that?)

I'm using OpenJDK 8, with the OpenJ9 JVM, starting the server with the command "C:Program FilesAdoptOpenJDKjdk-8.0.242.08-openj9binjava.exe" -server -XX:+UseG1GC -Xmx8G -Xms8G -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -jar forge-1.12.2-14.23.5.2847-universal.jar. I don't actually know what most of these flags do, but I was told they would help. And I think they did, at least a little, but there's still a lot of lag.

Your answer

2 Answers

Ranjana Admin JanBask Expert Latest answer

Answered on May 23, 2024

To get a modded Minecraft server running smoothly on your PC, you need to optimize both the server and the Java Virtual Machine (JVM) arguments. Here are some steps and tips to achieve this:


Step 1: Ensure Your PC Meets the Requirements

Modded Minecraft servers require substantial resources. Ensure your PC has:

A multi-core processor: At least a quad-core CPU.

Sufficient RAM: At least 8GB of RAM, though 16GB or more is preferable if you plan to allocate a lot of memory to the server and still run other tasks.

A solid-state drive (SSD): This significantly improves loading times and performance.

64-bit operating system: To make full use of the memory and performance.

Step 2: Install Java

Ensure you have the latest 64-bit version of Java installed. You can download it from the Oracle website or use OpenJDK from AdoptOpenJDK.

Step 3: Configure JVM Arguments

Configuring the JVM arguments correctly can vastly improve server performance. Here’s a set of JVM arguments optimized for a modded Minecraft server:

java -server -Xms4G -Xmx8G -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1HeapRegionSize=32M -Dfml.queryResult=confirm -jar forge-1.12.2-14.23.5.2854-universal.jar nogui

  • Explanation of the arguments:
  • -server: Optimizes the JVM for server performance.
  • -Xms4G -Xmx8G: Sets the initial and maximum heap size to 4GB and 8GB, respectively. Adjust these values based on your available RAM.
  • -XX:+UseG1GC: Uses the Garbage-First (G1) garbage collector, which is better for applications with large heaps.
  • -XX:MaxGCPauseMillis=50: Aims to limit the maximum GC pause time.
  • -XX:+UnlockExperimentalVMOptions: Enables experimental JVM options.
  • -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20: Sets the percentage of heap reserved for new objects and total reserve.
  • -XX:InitiatingHeapOccupancyPercent=15: Sets the percentage of heap occupancy to start a concurrent GC cycle.
  • -XX:G1HeapRegionSize=32M: Sets the size of the G1 heap region.
  • -Dfml.queryResult=confirm: Automatically confirms the server running modded content.
  • -jar forge-1.12.2-14.23.5.2854-universal.jar nogui: Specifies the server jar file and disables the GUI for better performance.

Was this helpful?

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.