first commit

This commit is contained in:
robojerk 2025-06-13 12:13:32 -07:00
commit 32870ccb82

142
README.md Normal file
View file

@ -0,0 +1,142 @@
# Minecraft Windows Network Configuration
This guide provides PowerShell commands to configure Windows Firewall for Minecraft networking.
## Prerequisites
- Windows 10 or later
- PowerShell running as Administrator
- Java Runtime Environment (JRE)
## Check Installed Java Versions
First, let's check which Java versions are installed on your system:
```powershell
# List all Java installations
Get-Command java -ErrorAction SilentlyContinue | Select-Object Source
Get-ChildItem "C:\Program Files\Java" -ErrorAction SilentlyContinue
Get-ChildItem "C:\Program Files (x86)\Java" -ErrorAction SilentlyContinue
Get-ChildItem "$env:LOCALAPPDATA\Programs\Java" -ErrorAction SilentlyContinue
Get-ChildItem "$env:APPDATA\ATLauncher\jre" -ErrorAction SilentlyContinue
```
## Firewall Configuration
Open PowerShell as Administrator and run the following commands:
### 1. Allow Java through Windows Firewall (Dynamic Selection)
```powershell
# Function to create firewall rules for a specific Java path
function Add-MinecraftJavaFirewallRules {
param (
[string]$JavaPath
)
if (Test-Path $JavaPath) {
Write-Host "Adding firewall rules for Java at: $JavaPath"
New-NetFirewallRule -DisplayName "Minecraft Java" -Direction Inbound -Program $JavaPath -Action Allow
New-NetFirewallRule -DisplayName "Minecraft Java" -Direction Outbound -Program $JavaPath -Action Allow
} else {
Write-Host "Java path not found: $JavaPath"
}
}
# Get all possible Java paths
$javaPaths = @(
"C:\Users\rob\AppData\Roaming\ATLauncher\jre\bin\java.exe",
"C:\Program Files\Java\*\bin\java.exe",
"C:\Program Files (x86)\Java\*\bin\java.exe",
"$env:LOCALAPPDATA\Programs\Java\*\bin\java.exe"
)
# Find all existing Java installations
$foundJavaPaths = $javaPaths | ForEach-Object { Get-ChildItem $_ -ErrorAction SilentlyContinue } | Select-Object -ExpandProperty FullName
if ($foundJavaPaths.Count -gt 1) {
Write-Host "Multiple Java installations found:"
for ($i = 0; $i -lt $foundJavaPaths.Count; $i++) {
Write-Host "[$i] $($foundJavaPaths[$i])"
}
$selection = Read-Host "Enter the number of the Java installation to use (or 'all' for all installations)"
if ($selection -eq 'all') {
foreach ($path in $foundJavaPaths) {
Add-MinecraftJavaFirewallRules -JavaPath $path
}
} else {
$index = [int]$selection
if ($index -ge 0 -and $index -lt $foundJavaPaths.Count) {
Add-MinecraftJavaFirewallRules -JavaPath $foundJavaPaths[$index]
} else {
Write-Host "Invalid selection"
}
}
} else {
# If only one Java installation is found, use it automatically
if ($foundJavaPaths) {
Add-MinecraftJavaFirewallRules -JavaPath $foundJavaPaths[0]
} else {
Write-Host "No Java installations found"
}
}
```
### 2. Open Required Minecraft Ports
```powershell
# Allow Minecraft default port (25565)
New-NetFirewallRule -DisplayName "Minecraft TCP" -Direction Inbound -LocalPort 25565 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "Minecraft UDP" -Direction Inbound -LocalPort 25565 -Protocol UDP -Action Allow
```
### 3. Verify Rules
```powershell
# List all Minecraft-related firewall rules
Get-NetFirewallRule | Where-Object DisplayName -like "*Minecraft*" | Format-Table DisplayName, Enabled, Direction, Action
```
## Removing Rules
If you need to remove the firewall rules, use these commands:
```powershell
# Remove Minecraft firewall rules
Remove-NetFirewallRule -DisplayName "Minecraft Java"
Remove-NetFirewallRule -DisplayName "Minecraft TCP"
Remove-NetFirewallRule -DisplayName "Minecraft UDP"
```
## Notes
- Make sure to run PowerShell as Administrator
- The script will automatically detect Java installations
- Default Minecraft port is 25565, adjust if using a different port
- These rules allow both incoming and outgoing connections for Minecraft
## Troubleshooting
If you experience connection issues:
1. Verify the rules are enabled:
```powershell
Get-NetFirewallRule -DisplayName "Minecraft*" | Select-Object DisplayName, Enabled
```
2. Check if the ports are actually open:
```powershell
Test-NetConnection -ComputerName localhost -Port 25565
```
3. Ensure Java is running with proper permissions:
```powershell
Get-Process java | Select-Object Id, ProcessName, Path
```
4. Check Java version:
```powershell
java -version
```