-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0001-Implement-netease-support.patch
More file actions
664 lines (641 loc) · 39.6 KB
/
0001-Implement-netease-support.patch
File metadata and controls
664 lines (641 loc) · 39.6 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
diff --git a/app/electron/src/session.js b/app/electron/src/session.js
index b73d9ee..60feb48 100644
--- a/app/electron/src/session.js
+++ b/app/electron/src/session.js
@@ -709,6 +709,8 @@ export class Session {
customIdentifiers: !data.hasOwnProperty("customIdentifiers") || data["customIdentifiers"],
skipBlockConnections: data.hasOwnProperty("blockConnections") && !data["blockConnections"],
enableCompact: !data.hasOwnProperty("enableCompact") || data["enableCompact"],
+ preserveUnknownEntities: !data.hasOwnProperty("preserveUnknownEntities") || data["preserveUnknownEntities"],
+ preserveUnknownBlockEntities: !data.hasOwnProperty("preserveUnknownBlockEntities") || data["preserveUnknownBlockEntities"],
discardEmptyChunks: data.hasOwnProperty("discardEmptyChunks") && data["discardEmptyChunks"],
preventYBiomeBlending: data.hasOwnProperty("preventYBiomeBlending") && data["preventYBiomeBlending"]
}
diff --git a/app/ui/public/schemas/converter_settings.schema.json b/app/ui/public/schemas/converter_settings.schema.json
index 23807af..aaf1466 100644
--- a/app/ui/public/schemas/converter_settings.schema.json
+++ b/app/ui/public/schemas/converter_settings.schema.json
@@ -12,6 +12,8 @@
"lootTableConversion": true,
"mapConversion": true,
"enableCompact": false,
+ "preserveUnknownEntities": true,
+ "preserveUnknownBlockEntities": true,
"discardEmptyChunks": false,
"preventYBiomeBlending": false
}
@@ -78,6 +80,26 @@
true
]
},
+ "preserveUnknownEntities": {
+ "type": "boolean",
+ "title": "Preserve Unknown Entities",
+ "description": "Whether unknown entities should be preserved.",
+ "default": true,
+ "examples": [
+ false,
+ true
+ ]
+ },
+ "preserveUnknownBlockEntities": {
+ "type": "boolean",
+ "title": "Preserve Unknown Block Entities",
+ "description": "Whether unknown block entities should be preserved.",
+ "default": true,
+ "examples": [
+ false,
+ true
+ ]
+ },
"discardEmptyChunks": {
"type": "boolean",
"title": "Discard Empty Chunks",
diff --git a/app/ui/src/components/app.js b/app/ui/src/components/app.js
index ef3e6ef..38d0034 100644
--- a/app/ui/src/components/app.js
+++ b/app/ui/src/components/app.js
@@ -23,6 +23,8 @@ export class App extends Component {
lootTableConversion: true,
mapConversion: true,
enableCompact: true,
+ preserveUnknownEntities: true,
+ preserveUnknownBlockEntities: true,
discardEmptyChunks: false,
preventYBiomeBlending: false
};
diff --git a/app/ui/src/components/screen/settings/tab/converterSettingsTab.js b/app/ui/src/components/screen/settings/tab/converterSettingsTab.js
index 3475f3e..ebf1b5f 100644
--- a/app/ui/src/components/screen/settings/tab/converterSettingsTab.js
+++ b/app/ui/src/components/screen/settings/tab/converterSettingsTab.js
@@ -51,6 +51,18 @@ export class ConverterSettingsTab extends Component {
"description": "Whether converting in-game maps should be enabled.",
"type": "Boolean"
},
+ {
+ "display": "Preserve Unknown Entities",
+ "name": "preserveUnknownEntities",
+ "description": "Whether unknown entities should be preserved.",
+ "type": "Boolean"
+ },
+ {
+ "display": "Preserve Unknown Block Entities",
+ "name": "preserveUnknownBlockEntities",
+ "description": "Whether unknown block entities should be preserved.",
+ "type": "Boolean"
+ },
{
"display": "Discard Empty Chunks",
"name": "discardEmptyChunks",
diff --git a/cli/src/main/java/com/hivemc/chunker/cli/CLI.java b/cli/src/main/java/com/hivemc/chunker/cli/CLI.java
index a6f5680..bb22d11 100644
--- a/cli/src/main/java/com/hivemc/chunker/cli/CLI.java
+++ b/cli/src/main/java/com/hivemc/chunker/cli/CLI.java
@@ -110,6 +110,18 @@ public class CLI implements Runnable {
)
private boolean keepOriginalNBT;
+ @CommandLine.Option(
+ names = {"--preserveUnknownEntities"},
+ description = "Whether unknown entities should be preserved in the output world."
+ )
+ private boolean preserveUnknownEntities;
+
+ @CommandLine.Option(
+ names = {"--preserveUnknownBlockEntities"},
+ description = "Whether unknown block entities should be preserved in the output world."
+ )
+ private boolean preserveUnknownBlockEntities;
+
/**
* Main entry point for the CLI
*
@@ -272,6 +284,8 @@ public class CLI implements Runnable {
// Check for the original NBT option
worldConverter.setAllowNBTCopying(keepOriginalNBT);
+ worldConverter.setPreserveUnknownEntities(preserveUnknownEntities);
+ worldConverter.setPreserveUnknownBlockEntities(preserveUnknownBlockEntities);
// Create the reader / writer (note: converter settings cannot be set after this point)
Optional<? extends LevelReader> reader = EncodingType.findReader(inputDirectory, worldConverter);
diff --git a/cli/src/main/java/com/hivemc/chunker/cli/messenger/Messenger.java b/cli/src/main/java/com/hivemc/chunker/cli/messenger/Messenger.java
index f2d2dec..63e07d0 100644
--- a/cli/src/main/java/com/hivemc/chunker/cli/messenger/Messenger.java
+++ b/cli/src/main/java/com/hivemc/chunker/cli/messenger/Messenger.java
@@ -234,6 +234,8 @@ public class Messenger {
worldConverter.setProcessItems(!convertRequest.isSkipItemConversion());
worldConverter.setProcessColumnPreTransform(!convertRequest.isSkipBlockConnections());
worldConverter.setLevelDBCompaction(convertRequest.isEnableCompact());
+ worldConverter.setPreserveUnknownEntities(convertRequest.isPreserveUnknownEntities());
+ worldConverter.setPreserveUnknownBlockEntities(convertRequest.isPreserveUnknownBlockEntities());
worldConverter.setDiscardEmptyChunks(convertRequest.isDiscardEmptyChunks());
worldConverter.setPreventYBiomeBlending(convertRequest.isPreventYBiomeBlending());
worldConverter.setCustomIdentifiers(convertRequest.isCustomIdentifiers());
diff --git a/cli/src/main/java/com/hivemc/chunker/cli/messenger/messaging/request/ConvertRequest.java b/cli/src/main/java/com/hivemc/chunker/cli/messenger/messaging/request/ConvertRequest.java
index 9bc1acc..6f8a1c5 100644
--- a/cli/src/main/java/com/hivemc/chunker/cli/messenger/messaging/request/ConvertRequest.java
+++ b/cli/src/main/java/com/hivemc/chunker/cli/messenger/messaging/request/ConvertRequest.java
@@ -35,6 +35,8 @@ public class ConvertRequest extends BasicMessage implements InvokesWorldConverte
private final boolean skipItemConversion;
private final boolean skipBlockConnections;
private final boolean enableCompact;
+ private final boolean preserveUnknownEntities;
+ private final boolean preserveUnknownBlockEntities;
private final boolean discardEmptyChunks;
private final boolean preventYBiomeBlending;
private final boolean customIdentifiers;
@@ -42,27 +44,29 @@ public class ConvertRequest extends BasicMessage implements InvokesWorldConverte
/**
* Create a new conversion request.
*
- * @param anonymousId the session ID for the user.
- * @param inputPath the input path on the current machine for the world.
- * @param outputPath the output path to write the world to.
- * @param outputType the output type to use for the world in the format FORMAT_MAJOR_MINOR_PATCH.
- * @param inputToOutputDimension mapping of dimension type to output dimension type. If the dimension isn't present
- * in the map, it won't be processed.
- * @param mappings the mappings (null if not present) which are parsed as a MappingsFile.
- * @param nbtSettings NBT settings (if present) which are merged with the original settings.
- * @param maps a list of maps, null if it should use the original maps.
- * @param copyNbt true if NBT should be copied from the input world to the output.
- * @param pruningList a list of pruning rules to run for each dimension.
- * @param skipMaps whether in-game maps should be skipped.
- * @param skipLootTables whether loot tables inside containers should be skipped.
- * @param skipItemConversion whether air should be used instead of converting items.
- * @param customIdentifiers whether custom identifiers should be read/written.
- * @param skipBlockConnections whether data based on other chunks should be skipped.
- * @param enableCompact whether the world should be compacted after conversion (Bedrock).
- * @param discardEmptyChunks whether empty chunks should not be written.
- * @param preventYBiomeBlending whether biomes should be prevented from blending (Java).
+ * @param anonymousId the session ID for the user.
+ * @param inputPath the input path on the current machine for the world.
+ * @param outputPath the output path to write the world to.
+ * @param outputType the output type to use for the world in the format FORMAT_MAJOR_MINOR_PATCH.
+ * @param inputToOutputDimension mapping of dimension type to output dimension type. If the dimension isn't present
+ * in the map, it won't be processed.
+ * @param mappings the mappings (null if not present) which are parsed as a MappingsFile.
+ * @param nbtSettings NBT settings (if present) which are merged with the original settings.
+ * @param maps a list of maps, null if it should use the original maps.
+ * @param copyNbt true if NBT should be copied from the input world to the output.
+ * @param pruningList a list of pruning rules to run for each dimension.
+ * @param skipMaps whether in-game maps should be skipped.
+ * @param skipLootTables whether loot tables inside containers should be skipped.
+ * @param skipItemConversion whether air should be used instead of converting items.
+ * @param customIdentifiers whether custom identifiers should be read/written.
+ * @param skipBlockConnections whether data based on other chunks should be skipped.
+ * @param enableCompact whether the world should be compacted after conversion (Bedrock).
+ * @param preserveUnknownEntities whether unknown entities should be preserved.
+ * @param preserveUnknownBlockEntities whether unknown block entities should be preserved.
+ * @param discardEmptyChunks whether empty chunks should not be written.
+ * @param preventYBiomeBlending whether biomes should be prevented from blending (Java).
*/
- public ConvertRequest(UUID anonymousId, String inputPath, String outputPath, String outputType, @Nullable Map<Dimension, Dimension> inputToOutputDimension, @Nullable JsonObject mappings, @Nullable JsonObject nbtSettings, @Nullable JsonArray maps, boolean copyNbt, @Nullable DimensionPruningList pruningList, boolean skipMaps, boolean skipLootTables, boolean skipItemConversion, boolean customIdentifiers, boolean skipBlockConnections, boolean enableCompact, boolean discardEmptyChunks, boolean preventYBiomeBlending) {
+ public ConvertRequest(UUID anonymousId, String inputPath, String outputPath, String outputType, @Nullable Map<Dimension, Dimension> inputToOutputDimension, @Nullable JsonObject mappings, @Nullable JsonObject nbtSettings, @Nullable JsonArray maps, boolean copyNbt, @Nullable DimensionPruningList pruningList, boolean skipMaps, boolean skipLootTables, boolean skipItemConversion, boolean customIdentifiers, boolean skipBlockConnections, boolean enableCompact, boolean preserveUnknownEntities, boolean preserveUnknownBlockEntities, boolean discardEmptyChunks, boolean preventYBiomeBlending) {
this.anonymousId = anonymousId;
this.inputPath = inputPath;
this.outputPath = outputPath;
@@ -79,6 +83,8 @@ public class ConvertRequest extends BasicMessage implements InvokesWorldConverte
this.customIdentifiers = customIdentifiers;
this.skipBlockConnections = skipBlockConnections;
this.enableCompact = enableCompact;
+ this.preserveUnknownEntities = preserveUnknownEntities;
+ this.preserveUnknownBlockEntities = preserveUnknownBlockEntities;
this.discardEmptyChunks = discardEmptyChunks;
this.preventYBiomeBlending = preventYBiomeBlending;
}
@@ -86,28 +92,30 @@ public class ConvertRequest extends BasicMessage implements InvokesWorldConverte
/**
* Create a new conversion request.
*
- * @param requestId the request ID to use.
- * @param anonymousId the session ID for the user.
- * @param inputPath the input path on the current machine for the world.
- * @param outputPath the output path to write the world to.
- * @param outputType the output type to use for the world in the format FORMAT_MAJOR_MINOR_PATCH.
- * @param inputToOutputDimension mapping of dimension type to output dimension type. If the dimension isn't present
- * in the map, it won't be processed.
- * @param mappings the mappings (null if not present) which are parsed as a MappingsFile.
- * @param nbtSettings NBT settings (if present) which are merged with the original settings.
- * @param maps a list of maps, null if it should use the original maps.
- * @param copyNbt true if NBT should be copied from the input world to the output.
- * @param pruningList a list of pruning rules to run for each dimension.
- * @param skipMaps whether in-game maps should be skipped.
- * @param skipLootTables whether loot tables inside containers should be skipped.
- * @param skipItemConversion whether air should be used instead of converting items.
- * @param customIdentifiers whether custom identifiers should be read/written.
- * @param skipBlockConnections whether data based on other chunks should be skipped.
- * @param enableCompact whether the world should be compacted after conversion (Bedrock).
- * @param discardEmptyChunks whether empty chunks should not be written.
- * @param preventYBiomeBlending whether biomes should be prevented from blending (Java).
+ * @param requestId the request ID to use.
+ * @param anonymousId the session ID for the user.
+ * @param inputPath the input path on the current machine for the world.
+ * @param outputPath the output path to write the world to.
+ * @param outputType the output type to use for the world in the format FORMAT_MAJOR_MINOR_PATCH.
+ * @param inputToOutputDimension mapping of dimension type to output dimension type. If the dimension isn't present
+ * in the map, it won't be processed.
+ * @param mappings the mappings (null if not present) which are parsed as a MappingsFile.
+ * @param nbtSettings NBT settings (if present) which are merged with the original settings.
+ * @param maps a list of maps, null if it should use the original maps.
+ * @param copyNbt true if NBT should be copied from the input world to the output.
+ * @param pruningList a list of pruning rules to run for each dimension.
+ * @param skipMaps whether in-game maps should be skipped.
+ * @param skipLootTables whether loot tables inside containers should be skipped.
+ * @param skipItemConversion whether air should be used instead of converting items.
+ * @param customIdentifiers whether custom identifiers should be read/written.
+ * @param skipBlockConnections whether data based on other chunks should be skipped.
+ * @param enableCompact whether the world should be compacted after conversion (Bedrock).
+ * @param preserveUnknownEntities whether unknown entities should be preserved.
+ * @param preserveUnknownBlockEntities whether unknown block entities should be preserved.
+ * @param discardEmptyChunks whether empty chunks should not be written.
+ * @param preventYBiomeBlending whether biomes should be prevented from blending (Java).
*/
- public ConvertRequest(UUID requestId, UUID anonymousId, String inputPath, String outputPath, String outputType, @Nullable Map<Dimension, Dimension> inputToOutputDimension, @Nullable JsonObject mappings, @Nullable JsonObject nbtSettings, @Nullable JsonArray maps, boolean copyNbt, @Nullable DimensionPruningList pruningList, boolean skipMaps, boolean skipLootTables, boolean skipItemConversion, boolean customIdentifiers, boolean skipBlockConnections, boolean enableCompact, boolean discardEmptyChunks, boolean preventYBiomeBlending) {
+ public ConvertRequest(UUID requestId, UUID anonymousId, String inputPath, String outputPath, String outputType, @Nullable Map<Dimension, Dimension> inputToOutputDimension, @Nullable JsonObject mappings, @Nullable JsonObject nbtSettings, @Nullable JsonArray maps, boolean copyNbt, @Nullable DimensionPruningList pruningList, boolean skipMaps, boolean skipLootTables, boolean skipItemConversion, boolean customIdentifiers, boolean skipBlockConnections, boolean enableCompact, boolean preserveUnknownEntities, boolean preserveUnknownBlockEntities, boolean discardEmptyChunks, boolean preventYBiomeBlending) {
super(requestId);
this.anonymousId = anonymousId;
this.inputPath = inputPath;
@@ -125,6 +133,8 @@ public class ConvertRequest extends BasicMessage implements InvokesWorldConverte
this.customIdentifiers = customIdentifiers;
this.skipBlockConnections = skipBlockConnections;
this.enableCompact = enableCompact;
+ this.preserveUnknownEntities = preserveUnknownEntities;
+ this.preserveUnknownBlockEntities = preserveUnknownBlockEntities;
this.discardEmptyChunks = discardEmptyChunks;
this.preventYBiomeBlending = preventYBiomeBlending;
}
@@ -281,6 +291,24 @@ public class ConvertRequest extends BasicMessage implements InvokesWorldConverte
return enableCompact;
}
+ /**
+ * Whether unknown entities should be preserved.
+ *
+ * @return true if unknown entities should be preserved.
+ */
+ public boolean isPreserveUnknownEntities() {
+ return preserveUnknownEntities;
+ }
+
+ /**
+ * Whether unknown block entities should be preserved.
+ *
+ * @return true if unknown block entities should be preserved.
+ */
+ public boolean isPreserveUnknownBlockEntities() {
+ return preserveUnknownBlockEntities;
+ }
+
/**
* Whether empty chunks should be discarded instead of written.
*
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/WorldConverter.java b/cli/src/main/java/com/hivemc/chunker/conversion/WorldConverter.java
index dce799d..3586325 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/WorldConverter.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/WorldConverter.java
@@ -86,6 +86,8 @@ public class WorldConverter implements Converter {
private boolean processLighting = true;
private boolean processColumnPreTransform = true;
private boolean allowNBTCopying = false;
+ private boolean preserveUnknownEntities = false;
+ private boolean preserveUnknownBlockEntities = false;
private boolean discardEmptyChunks = false;
private boolean preventYBiomeBlending = false;
private boolean customIdentifiers = true;
@@ -228,6 +230,24 @@ public class WorldConverter implements Converter {
this.allowNBTCopying = allowNBTCopying;
}
+ /**
+ * Set whether unknown entities should be preserved.
+ *
+ * @param preserveUnknownEntities true if they should be preserved.
+ */
+ public void setPreserveUnknownEntities(boolean preserveUnknownEntities) {
+ this.preserveUnknownEntities = preserveUnknownEntities;
+ }
+
+ /**
+ * Set whether unknown block-entities should be preserved.
+ *
+ * @param preserveUnknownBlockEntities true if they should be preserved.
+ */
+ public void setPreserveUnknownBlockEntities(boolean preserveUnknownBlockEntities) {
+ this.preserveUnknownBlockEntities = preserveUnknownBlockEntities;
+ }
+
/**
* Set whether empty chunks should be removed.
*
@@ -401,6 +421,16 @@ public class WorldConverter implements Converter {
return allowNBTCopying;
}
+ @Override
+ public boolean shouldPreserveUnknownEntities() {
+ return preserveUnknownEntities;
+ }
+
+ @Override
+ public boolean shouldPreserveUnknownBlockEntities() {
+ return preserveUnknownBlockEntities;
+ }
+
@Override
public boolean shouldAllowCustomIdentifiers() {
return customIdentifiers;
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/base/Converter.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/base/Converter.java
index c59f1b3..0496871 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/base/Converter.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/base/Converter.java
@@ -118,6 +118,20 @@ public interface Converter {
*/
boolean shouldAllowNBTCopying();
+ /**
+ * Whether unknown entities should be preserved.
+ *
+ * @return true if unknown entities should be preserved.
+ */
+ boolean shouldPreserveUnknownEntities();
+
+ /**
+ * Whether unknown block entities should be preserved.
+ *
+ * @return true if unknown block entities should be preserved.
+ */
+ boolean shouldPreserveUnknownBlockEntities();
+
/**
* Whether custom identifiers should be processed.
*
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/blockentity/BedrockBlockEntityResolver.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/blockentity/BedrockBlockEntityResolver.java
index e53ae22..babe2d3 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/blockentity/BedrockBlockEntityResolver.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/blockentity/BedrockBlockEntityResolver.java
@@ -33,7 +33,7 @@ public class BedrockBlockEntityResolver extends BlockEntityResolver<BedrockResol
* @param resolvers the resolvers to use.
*/
public BedrockBlockEntityResolver(Version version, BedrockResolvers resolvers) {
- super(version, resolvers, resolvers.converter().shouldAllowNBTCopying());
+ super(version, resolvers, resolvers.converter().shouldAllowNBTCopying() || resolvers.converter().shouldPreserveUnknownBlockEntities());
}
@Override
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/entity/BedrockEntityResolver.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/entity/BedrockEntityResolver.java
index aea4e14..cef7306 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/entity/BedrockEntityResolver.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/entity/BedrockEntityResolver.java
@@ -26,7 +26,7 @@ public class BedrockEntityResolver extends EntityResolver<BedrockResolvers, Comp
* @param resolvers the resolvers to use.
*/
public BedrockEntityResolver(Version version, BedrockResolvers resolvers) {
- super(version, resolvers, resolvers.converter().shouldAllowNBTCopying());
+ super(version, resolvers, resolvers.converter().shouldAllowNBTCopying() || resolvers.converter().shouldPreserveUnknownEntities());
}
@Override
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/entity/handlers/BedrockEntityHandler.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/entity/handlers/BedrockEntityHandler.java
index fd10269..3cf8d4e 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/entity/handlers/BedrockEntityHandler.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/resolver/entity/handlers/BedrockEntityHandler.java
@@ -7,8 +7,10 @@ import com.hivemc.chunker.nbt.TagType;
import com.hivemc.chunker.nbt.tags.Tag;
import com.hivemc.chunker.nbt.tags.collection.CompoundTag;
import com.hivemc.chunker.nbt.tags.collection.ListTag;
+import com.hivemc.chunker.nbt.tags.primitive.DoubleTag;
import com.hivemc.chunker.nbt.tags.primitive.FloatTag;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
@@ -23,6 +25,40 @@ public class BedrockEntityHandler extends EntityHandler<BedrockResolvers, Compou
});
}
+ /**
+ * Read a list of floats from a tag, supporting both FloatTag and DoubleTag list types.
+ * NetEase Bedrock edition uses DoubleTag for entity positions while vanilla uses FloatTag.
+ *
+ * @param input the compound tag to read from
+ * @param name the name of the list tag
+ * @return list of float values, or null if not found
+ */
+ @Nullable
+ private static List<Float> readFloatList(CompoundTag input, String name) {
+ Tag<?> tag = input.get(name, Tag.class);
+ if (!(tag instanceof ListTag<?, ?> listTag)) {
+ return null;
+ }
+
+ TagType listType = listTag.getListType();
+ if (listType == TagType.FLOAT) {
+ @SuppressWarnings("unchecked")
+ ListTag<FloatTag, Float> floatList = (ListTag<FloatTag, Float>) listTag;
+ return floatList.toList();
+ } else if (listType == TagType.DOUBLE) {
+ // NetEase Bedrock uses DoubleTag for entity positions
+ @SuppressWarnings("unchecked")
+ ListTag<DoubleTag, Double> doubleList = (ListTag<DoubleTag, Double>) listTag;
+ List<Double> doubles = doubleList.toList();
+ if (doubles == null) return null;
+ return doubles.stream()
+ .map(d -> d != null ? d.floatValue() : 0f)
+ .toList();
+ }
+
+ return null;
+ }
+
@Override
public void read(@NotNull BedrockResolvers resolvers, @NotNull CompoundTag input, @NotNull Entity entity) {
// Save original NBT
@@ -30,16 +66,16 @@ public class BedrockEntityHandler extends EntityHandler<BedrockResolvers, Compou
entity.setOriginalNBT(input);
}
- // Position
- List<Float> position = input.getListValues("Pos", FloatTag.class, null);
+ // Position (supports both FloatTag and DoubleTag for NetEase compatibility)
+ List<Float> position = readFloatList(input, "Pos");
if (position != null && position.size() >= 3) {
entity.setPositionX(position.get(0));
entity.setPositionY(position.get(1));
entity.setPositionZ(position.get(2));
}
- // Motion
- List<Float> motion = input.getListValues("Motion", FloatTag.class, null);
+ // Motion (supports both FloatTag and DoubleTag for NetEase compatibility)
+ List<Float> motion = readFloatList(input, "Motion");
if (motion != null && motion.size() >= 3) {
entity.setMotionX(motion.get(0));
entity.setMotionY(motion.get(1));
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/writer/BedrockColumnWriter.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/writer/BedrockColumnWriter.java
index 08cbf9c..4ea4605 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/writer/BedrockColumnWriter.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/bedrock/base/writer/BedrockColumnWriter.java
@@ -10,6 +10,7 @@ import com.hivemc.chunker.conversion.handlers.pretransform.manager.PreTransformM
import com.hivemc.chunker.conversion.intermediate.column.ChunkerColumn;
import com.hivemc.chunker.conversion.intermediate.column.biome.ChunkerBiome;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.BlockEntity;
+import com.hivemc.chunker.conversion.intermediate.column.blockentity.UnknownBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.chunk.ChunkerChunk;
import com.hivemc.chunker.conversion.intermediate.column.chunk.identifier.ChunkerBlockIdentifier;
import com.hivemc.chunker.conversion.intermediate.column.entity.Entity;
@@ -354,7 +355,17 @@ public class BedrockColumnWriter implements ColumnWriter {
protected CompoundTag writeBlockEntity(ChunkerColumn chunkerColumn, BlockEntity blockEntity) {
Optional<CompoundTag> compoundTag = resolvers.blockEntityResolver().from(blockEntity);
if (compoundTag.isPresent()) {
- return compoundTag.get();
+ CompoundTag output = compoundTag.get();
+
+ // Write NetEase ModBlock
+ if (blockEntity instanceof UnknownBlockEntity unknownBlockEntity && !unknownBlockEntity.getType().startsWith("minecraft:")) {
+ output.put("id", "ModBlock");
+ output.put("exData", new CompoundTag());
+ output.put("_blockName", unknownBlockEntity.getType());
+ long uniqueEntityID = parent.generateUniqueEntityID();
+ output.put("_uniqueId", uniqueEntityID);
+ }
+ return output;
} else {
// Log as missing
converter.logMissingMapping(Converter.MissingMappingType.BLOCK_ENTITY, blockEntity.getClass().getSimpleName());
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/blockentity/JavaBlockEntityResolver.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/blockentity/JavaBlockEntityResolver.java
index f59ec76..7b148cf 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/blockentity/JavaBlockEntityResolver.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/blockentity/JavaBlockEntityResolver.java
@@ -30,7 +30,7 @@ public class JavaBlockEntityResolver extends BlockEntityResolver<JavaResolvers,
* @param resolvers the resolvers to use.
*/
public JavaBlockEntityResolver(Version version, JavaResolvers resolvers) {
- super(version, resolvers, resolvers.converter().shouldAllowNBTCopying());
+ super(version, resolvers, resolvers.converter().shouldAllowNBTCopying() || resolvers.converter().shouldPreserveUnknownBlockEntities());
}
@Override
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/blockentity/legacy/JavaLegacyBlockEntityResolver.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/blockentity/legacy/JavaLegacyBlockEntityResolver.java
index 4a20c29..b11d380 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/blockentity/legacy/JavaLegacyBlockEntityResolver.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/blockentity/legacy/JavaLegacyBlockEntityResolver.java
@@ -66,7 +66,7 @@ public class JavaLegacyBlockEntityResolver extends BlockEntityResolver<JavaResol
* @param resolvers the resolvers to use.
*/
public JavaLegacyBlockEntityResolver(Version version, JavaResolvers resolvers) {
- super(version, resolvers, resolvers.converter().shouldAllowNBTCopying());
+ super(version, resolvers, resolvers.converter().shouldAllowNBTCopying() || resolvers.converter().shouldPreserveUnknownBlockEntities());
}
@Override
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/entity/JavaEntityResolver.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/entity/JavaEntityResolver.java
index 7d90280..4fc68d4 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/entity/JavaEntityResolver.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/entity/JavaEntityResolver.java
@@ -26,7 +26,7 @@ public class JavaEntityResolver extends EntityResolver<JavaResolvers, CompoundTa
* @param resolvers the resolvers to use.
*/
public JavaEntityResolver(Version version, JavaResolvers resolvers) {
- super(version, resolvers, resolvers.converter().shouldAllowNBTCopying());
+ super(version, resolvers, resolvers.converter().shouldAllowNBTCopying() || resolvers.converter().shouldPreserveUnknownEntities());
}
@Override
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/entity/legacy/JavaLegacyEntityResolver.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/entity/legacy/JavaLegacyEntityResolver.java
index 5058e4f..073d258 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/entity/legacy/JavaLegacyEntityResolver.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/base/resolver/entity/legacy/JavaLegacyEntityResolver.java
@@ -23,7 +23,7 @@ public class JavaLegacyEntityResolver extends EntityResolver<JavaResolvers, Comp
* @param resolvers the resolvers to use.
*/
public JavaLegacyEntityResolver(Version version, JavaResolvers resolvers) {
- super(version, resolvers, resolvers.converter().shouldAllowNBTCopying());
+ super(version, resolvers, resolvers.converter().shouldAllowNBTCopying() || resolvers.converter().shouldPreserveUnknownEntities());
}
@Override
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/util/FontUtil.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/util/FontUtil.java
index 32cc67a..a262906 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/util/FontUtil.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/util/FontUtil.java
@@ -1,6 +1,5 @@
package com.hivemc.chunker.conversion.encoding.java.util;
-import com.google.common.io.Resources;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
@@ -19,24 +18,55 @@ import java.util.List;
* The measurements used in this class are based on Java edition.
*/
public class FontUtil {
- private static final Int2ByteMap CODE_POINT_TO_WIDTH = new Int2ByteOpenHashMap();
+ // Use lazy initialization to avoid resource loading issues during class initialization
+ // in plugin environments where ClassLoader may not be fully ready during static init
+ private static volatile Int2ByteMap CODE_POINT_TO_WIDTH;
+
+ /**
+ * Get the code point to width map, loading it lazily on first access.
+ *
+ * @return the code point to width map
+ */
+ private static Int2ByteMap getCodePointToWidth() {
+ if (CODE_POINT_TO_WIDTH == null) {
+ synchronized (FontUtil.class) {
+ if (CODE_POINT_TO_WIDTH == null) {
+ CODE_POINT_TO_WIDTH = loadCodePointToWidth();
+ }
+ }
+ }
+ return CODE_POINT_TO_WIDTH;
+ }
+
+ /**
+ * Load the code point to width map from resources.
+ * Uses "chunker/" resource path to avoid conflicts with Java's reserved "java/" package name
+ * which can cause issues with some ClassLoaders (e.g., Spigot's PluginClassLoader).
+ *
+ * @return the loaded map
+ */
+ private static Int2ByteMap loadCodePointToWidth() {
+ Int2ByteMap map = new Int2ByteOpenHashMap();
+ // Use Class.getResourceAsStream with absolute path for better compatibility with plugin classloaders
+ try (InputStream rawStream = FontUtil.class.getResourceAsStream("/chunker/default_font_width_codepoints.json");
+ InputStreamReader inputStreamReader = rawStream != null ? new InputStreamReader(rawStream) : null) {
+ if (inputStreamReader == null) {
+ throw new IOException("Resource not found: /chunker/default_font_width_codepoints.json");
+ }
- static {
- // Load the code point to width map
- try (InputStream stream = Resources.getResource("java/default_font_width_codepoints.json").openStream();
- InputStreamReader inputStreamReader = new InputStreamReader(stream)) {
JsonArray nestedCodePoints = JsonParser.parseReader(inputStreamReader).getAsJsonArray();
// Loop through each width array and add the codepoints to our lookup
for (byte width = 0; width < nestedCodePoints.size(); width++) {
JsonArray codePoints = nestedCodePoints.get(width).getAsJsonArray();
for (JsonElement element : codePoints) {
- CODE_POINT_TO_WIDTH.put(element.getAsInt(), width);
+ map.put(element.getAsInt(), width);
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
+ return map;
}
/**
@@ -46,7 +76,7 @@ public class FontUtil {
* @return the width or 0 if it wasn't found.
*/
public static int getWidth(int codePoint) {
- return CODE_POINT_TO_WIDTH.getOrDefault(codePoint, (byte) 0);
+ return getCodePointToWidth().getOrDefault(codePoint, (byte) 0);
}
/**
diff --git a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/v1_17/writer/LevelWriter.java b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/v1_17/writer/LevelWriter.java
index 33b6761..161f7df 100644
--- a/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/v1_17/writer/LevelWriter.java
+++ b/cli/src/main/java/com/hivemc/chunker/conversion/encoding/java/v1_17/writer/LevelWriter.java
@@ -33,7 +33,7 @@ public class LevelWriter extends com.hivemc.chunker.conversion.encoding.java.v1_
File outputFile = new File(directory, "CavesAndCliffsHeightPack.zip");
try {
- Resources.asByteSource(Resources.getResource("java/CavesAndCliffsHeightPack.zip")).copyTo(Files.asByteSink(outputFile));
+ Resources.asByteSource(Resources.getResource("chunker/CavesAndCliffsHeightPack.zip")).copyTo(Files.asByteSink(outputFile));
} catch (IOException e) {
converter.logNonFatalException(e);
}
diff --git a/cli/src/main/resources/java/CavesAndCliffsHeightPack.zip b/cli/src/main/resources/chunker/CavesAndCliffsHeightPack.zip
similarity index 100%
rename from cli/src/main/resources/java/CavesAndCliffsHeightPack.zip
rename to cli/src/main/resources/chunker/CavesAndCliffsHeightPack.zip
diff --git a/cli/src/main/resources/java/default_font_width_codepoints.json b/cli/src/main/resources/chunker/default_font_width_codepoints.json
similarity index 100%
rename from cli/src/main/resources/java/default_font_width_codepoints.json
rename to cli/src/main/resources/chunker/default_font_width_codepoints.json
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755