ChunkBiomeFix.java
net.minecraft.util.datafix.fixes.ChunkBiomeFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.ChunkBiomeFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/ChunkBiomeFix.java
- 起始行号:L13
- 继承:DataFix
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
public ChunkBiomeFix(Schema outputSchema, boolean changesType) @ L14
- 构造器名:ChunkBiomeFix
- 源码定位:L14
- 修饰符:public
参数:
- outputSchema: Schema
- changesType: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected TypeRewriteRule makeRule() @ L18
- 方法名:makeRule
- 源码定位:L18
- 返回类型:TypeRewriteRule
- 修饰符:protected
参数:
- 无
说明:
TODO
代码
public class ChunkBiomeFix extends DataFix {
public ChunkBiomeFix(Schema outputSchema, boolean changesType) {
super(outputSchema, changesType);
}
@Override
protected TypeRewriteRule makeRule() {
Type<?> chunkType = this.getInputSchema().getType(References.CHUNK);
OpticFinder<?> levelFinder = chunkType.findField("Level");
return this.fixTypeEverywhereTyped(
"Leaves fix", chunkType, chunk -> chunk.updateTyped(levelFinder, level -> level.update(DSL.remainderFinder(), tag -> {
Optional<IntStream> biomes = tag.get("Biomes").asIntStreamOpt().result();
if (biomes.isEmpty()) {
return tag;
} else {
int[] oldBiomes = biomes.get().toArray();
if (oldBiomes.length != 256) {
return tag;
} else {
int[] newBiomes = new int[1024];
for (int z = 0; z < 4; z++) {
for (int x = 0; x < 4; x++) {
int oldX = (x << 2) + 2;
int oldZ = (z << 2) + 2;
int index = oldZ << 4 | oldX;
newBiomes[z << 2 | x] = oldBiomes[index];
}
}
for (int ySlice = 1; ySlice < 64; ySlice++) {
System.arraycopy(newBiomes, 0, newBiomes, ySlice * 16, 16);
}
return tag.set("Biomes", tag.createIntList(Arrays.stream(newBiomes)));
}
}
}))
);
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
System.arraycopy()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: