-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
172 lines (141 loc) · 3.59 KB
/
index.html
File metadata and controls
172 lines (141 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html>
<html>
<head>
<title>Minecraft Java Seed Viewer</title>
<style>
body {
margin: 0;
background: #1e1e1e;
color: white;
font-family: Arial;
overflow: hidden;
}
#ui {
position: fixed;
top: 10px;
left: 10px;
background: #2a2a2a;
padding: 15px;
border-radius: 10px;
box-shadow: 0 0 10px black;
z-index: 10;
}
input, button, select {
padding: 6px;
margin: 4px 0;
width: 100%;
border-radius: 5px;
border: none;
}
button {
cursor: pointer;
background: #4CAF50;
color: white;
}
button:hover {
background: #45a049;
}
#coords {
margin-top: 8px;
font-size: 14px;
opacity: 0.8;
}
canvas {
display: block;
}
</style>
</head>
<body>
<div id="ui">
<h3>Minecraft Java Seed Viewer</h3>
<input id="seedInput" placeholder="Enter seed..." />
<select id="version">
<option value="1.20">1.20+</option>
<option value="1.21">1.21+</option>
</select>
<button onclick="generate()">Generate</button>
<div id="coords">X: 0 Z: 0</div>
</div>
<canvas id="map"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/simplex-noise/2.4.0/simplex-noise.min.js"></script>
<script>
const canvas = document.getElementById("map");
const ctx = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let scale = 150;
let offsetX = 0;
let offsetY = 0;
let simplex;
function generate() {
const seed = document.getElementById("seedInput").value || "0";
simplex = new SimplexNoise(seed);
draw();
}
function getBiomeColor(value) {
if (value < -0.35) return "#0b3d91"; // deep ocean
if (value < -0.2) return "#1565c0"; // ocean
if (value < -0.05) return "#d9d592"; // beach
if (value < 0.2) return "#3ba635"; // plains
if (value < 0.4) return "#2e7d32"; // forest
if (value < 0.6) return "#888888"; // hills
return "#ffffff"; // mountains/snow
}
function draw() {
if (!simplex) return;
const img = ctx.createImageData(canvas.width, canvas.height);
for (let x = 0; x < canvas.width; x++) {
for (let y = 0; y < canvas.height; y++) {
let worldX = (x + offsetX) / scale;
let worldY = (y + offsetY) / scale;
let elevation = simplex.noise2D(worldX, worldY);
let color = getBiomeColor(elevation);
let rgb = hexToRgb(color);
let i = (x + y * canvas.width) * 4;
img.data[i] = rgb.r;
img.data[i+1] = rgb.g;
img.data[i+2] = rgb.b;
img.data[i+3] = 255;
}
}
ctx.putImageData(img, 0, 0);
}
function hexToRgb(hex) {
const bigint = parseInt(hex.slice(1), 16);
return {
r: (bigint >> 16) & 255,
g: (bigint >> 8) & 255,
b: bigint & 255
};
}
// PAN
let dragging = false;
let lastX, lastY;
canvas.addEventListener("mousedown", e => {
dragging = true;
lastX = e.clientX;
lastY = e.clientY;
});
canvas.addEventListener("mouseup", () => dragging = false);
canvas.addEventListener("mousemove", e => {
if (dragging) {
offsetX -= (e.clientX - lastX);
offsetY -= (e.clientY - lastY);
lastX = e.clientX;
lastY = e.clientY;
draw();
}
let worldX = Math.floor((e.clientX + offsetX) / scale * 16);
let worldZ = Math.floor((e.clientY + offsetY) / scale * 16);
document.getElementById("coords").innerText = `X: ${worldX} Z: ${worldZ}`;
});
// ZOOM
canvas.addEventListener("wheel", e => {
e.preventDefault();
scale *= e.deltaY > 0 ? 1.1 : 0.9;
draw();
});
generate();
</script>
</body>
</html>