Skip to content

Commit

Permalink
feat: resume work converter
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolLoong committed Aug 8, 2023
1 parent ee0221b commit 846e325
Show file tree
Hide file tree
Showing 17 changed files with 323 additions and 226 deletions.
179 changes: 90 additions & 89 deletions Allay-API/src/main/java/cn/allay/api/data/VanillaBiomeId.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.allay.api.data;

import cn.allay.api.identifier.Identifier;
import cn.allay.api.world.biome.BiomeType;
import lombok.Getter;

Expand All @@ -10,186 +11,186 @@
*/
@Getter
public enum VanillaBiomeId implements BiomeType {
OCEAN("ocean", 0, "OCEAN"),
OCEAN(new Identifier("minecraft", "ocean"), 0, "OCEAN"),

PLAINS("plains", 1, "PLAIN"),
PLAINS(new Identifier("minecraft", "plains"), 1, "PLAIN"),

DESERT("desert", 2, "DESERT"),
DESERT(new Identifier("minecraft", "desert"), 2, "DESERT"),

EXTREME_HILLS("extreme_hills", 3, "EXTREME_HILLS"),
EXTREME_HILLS(new Identifier("minecraft", "extreme_hills"), 3, "EXTREME_HILLS"),

FOREST("forest", 4, "FOREST"),
FOREST(new Identifier("minecraft", "forest"), 4, "FOREST"),

TAIGA("taiga", 5, "TAIGA"),
TAIGA(new Identifier("minecraft", "taiga"), 5, "TAIGA"),

SWAMPLAND("swampland", 6, "SWAMP"),
SWAMPLAND(new Identifier("minecraft", "swampland"), 6, "SWAMP"),

RIVER("river", 7, "RIVER"),
RIVER(new Identifier("minecraft", "river"), 7, "RIVER"),

HELL("hell", 8, "HELL"),
HELL(new Identifier("minecraft", "hell"), 8, "HELL"),

THE_END("the_end", 9, "THE_END"),
THE_END(new Identifier("minecraft", "the_end"), 9, "THE_END"),

LEGACY_FROZEN_OCEAN("legacy_frozen_ocean", 10, "OCEAN"),
LEGACY_FROZEN_OCEAN(new Identifier("minecraft", "legacy_frozen_ocean"), 10, "OCEAN"),

FROZEN_RIVER("frozen_river", 11, "RIVER"),
FROZEN_RIVER(new Identifier("minecraft", "frozen_river"), 11, "RIVER"),

ICE_PLAINS("ice_plains", 12, "ICE"),
ICE_PLAINS(new Identifier("minecraft", "ice_plains"), 12, "ICE"),

ICE_MOUNTAINS("ice_mountains", 13, "ICE"),
ICE_MOUNTAINS(new Identifier("minecraft", "ice_mountains"), 13, "ICE"),

MUSHROOM_ISLAND("mushroom_island", 14, "MUSHROOM_ISLAND"),
MUSHROOM_ISLAND(new Identifier("minecraft", "mushroom_island"), 14, "MUSHROOM_ISLAND"),

MUSHROOM_ISLAND_SHORE("mushroom_island_shore", 15, "MUSHROOM_ISLAND"),
MUSHROOM_ISLAND_SHORE(new Identifier("minecraft", "mushroom_island_shore"), 15, "MUSHROOM_ISLAND"),

BEACH("beach", 16, "BEACH"),
BEACH(new Identifier("minecraft", "beach"), 16, "BEACH"),

DESERT_HILLS("desert_hills", 17, "DESERT"),
DESERT_HILLS(new Identifier("minecraft", "desert_hills"), 17, "DESERT"),

FOREST_HILLS("forest_hills", 18, "FOREST"),
FOREST_HILLS(new Identifier("minecraft", "forest_hills"), 18, "FOREST"),

TAIGA_HILLS("taiga_hills", 19, "TAIGA"),
TAIGA_HILLS(new Identifier("minecraft", "taiga_hills"), 19, "TAIGA"),

EXTREME_HILLS_EDGE("extreme_hills_edge", 20, "EXTREME_HILLS"),
EXTREME_HILLS_EDGE(new Identifier("minecraft", "extreme_hills_edge"), 20, "EXTREME_HILLS"),

JUNGLE("jungle", 21, "JUNGLE"),
JUNGLE(new Identifier("minecraft", "jungle"), 21, "JUNGLE"),

JUNGLE_HILLS("jungle_hills", 22, "JUNGLE"),
JUNGLE_HILLS(new Identifier("minecraft", "jungle_hills"), 22, "JUNGLE"),

JUNGLE_EDGE("jungle_edge", 23, "JUNGLE"),
JUNGLE_EDGE(new Identifier("minecraft", "jungle_edge"), 23, "JUNGLE"),

DEEP_OCEAN("deep_ocean", 24, "OCEAN"),
DEEP_OCEAN(new Identifier("minecraft", "deep_ocean"), 24, "OCEAN"),

STONE_BEACH("stone_beach", 25, "STONE_BEACH"),
STONE_BEACH(new Identifier("minecraft", "stone_beach"), 25, "STONE_BEACH"),

COLD_BEACH("cold_beach", 26, "BEACH"),
COLD_BEACH(new Identifier("minecraft", "cold_beach"), 26, "BEACH"),

BIRCH_FOREST("birch_forest", 27, "FOREST"),
BIRCH_FOREST(new Identifier("minecraft", "birch_forest"), 27, "FOREST"),

BIRCH_FOREST_HILLS("birch_forest_hills", 28, "FOREST"),
BIRCH_FOREST_HILLS(new Identifier("minecraft", "birch_forest_hills"), 28, "FOREST"),

ROOFED_FOREST("roofed_forest", 29, "FOREST"),
ROOFED_FOREST(new Identifier("minecraft", "roofed_forest"), 29, "FOREST"),

COLD_TAIGA("cold_taiga", 30, "TAIGA"),
COLD_TAIGA(new Identifier("minecraft", "cold_taiga"), 30, "TAIGA"),

COLD_TAIGA_HILLS("cold_taiga_hills", 31, "TAIGA"),
COLD_TAIGA_HILLS(new Identifier("minecraft", "cold_taiga_hills"), 31, "TAIGA"),

MEGA_TAIGA("mega_taiga", 32, "TAIGA"),
MEGA_TAIGA(new Identifier("minecraft", "mega_taiga"), 32, "TAIGA"),

MEGA_TAIGA_HILLS("mega_taiga_hills", 33, "TAIGA"),
MEGA_TAIGA_HILLS(new Identifier("minecraft", "mega_taiga_hills"), 33, "TAIGA"),

EXTREME_HILLS_PLUS_TREES("extreme_hills_plus_trees", 34, "EXTREME_HILLS"),
EXTREME_HILLS_PLUS_TREES(new Identifier("minecraft", "extreme_hills_plus_trees"), 34, "EXTREME_HILLS"),

SAVANNA("savanna", 35, "SAVANNA"),
SAVANNA(new Identifier("minecraft", "savanna"), 35, "SAVANNA"),

SAVANNA_PLATEAU("savanna_plateau", 36, "SAVANNA"),
SAVANNA_PLATEAU(new Identifier("minecraft", "savanna_plateau"), 36, "SAVANNA"),

MESA("mesa", 37, "MESA"),
MESA(new Identifier("minecraft", "mesa"), 37, "MESA"),

MESA_PLATEAU_STONE("mesa_plateau_stone", 38, "MESA"),
MESA_PLATEAU_STONE(new Identifier("minecraft", "mesa_plateau_stone"), 38, "MESA"),

MESA_PLATEAU("mesa_plateau", 39, "MESA"),
MESA_PLATEAU(new Identifier("minecraft", "mesa_plateau"), 39, "MESA"),

WARM_OCEAN("warm_ocean", 40, "OCEAN"),
WARM_OCEAN(new Identifier("minecraft", "warm_ocean"), 40, "OCEAN"),

DEEP_WARM_OCEAN("deep_warm_ocean", 41, "OCEAN"),
DEEP_WARM_OCEAN(new Identifier("minecraft", "deep_warm_ocean"), 41, "OCEAN"),

LUKEWARM_OCEAN("lukewarm_ocean", 42, "OCEAN"),
LUKEWARM_OCEAN(new Identifier("minecraft", "lukewarm_ocean"), 42, "OCEAN"),

DEEP_LUKEWARM_OCEAN("deep_lukewarm_ocean", 43, "OCEAN"),
DEEP_LUKEWARM_OCEAN(new Identifier("minecraft", "deep_lukewarm_ocean"), 43, "OCEAN"),

COLD_OCEAN("cold_ocean", 44, "OCEAN"),
COLD_OCEAN(new Identifier("minecraft", "cold_ocean"), 44, "OCEAN"),

DEEP_COLD_OCEAN("deep_cold_ocean", 45, "OCEAN"),
DEEP_COLD_OCEAN(new Identifier("minecraft", "deep_cold_ocean"), 45, "OCEAN"),

FROZEN_OCEAN("frozen_ocean", 46, "OCEAN"),
FROZEN_OCEAN(new Identifier("minecraft", "frozen_ocean"), 46, "OCEAN"),

DEEP_FROZEN_OCEAN("deep_frozen_ocean", 47, "OCEAN"),
DEEP_FROZEN_OCEAN(new Identifier("minecraft", "deep_frozen_ocean"), 47, "OCEAN"),

BAMBOO_JUNGLE("bamboo_jungle", 48, "JUNGLE"),
BAMBOO_JUNGLE(new Identifier("minecraft", "bamboo_jungle"), 48, "JUNGLE"),

BAMBOO_JUNGLE_HILLS("bamboo_jungle_hills", 49, "JUNGLE"),
BAMBOO_JUNGLE_HILLS(new Identifier("minecraft", "bamboo_jungle_hills"), 49, "JUNGLE"),

SUNFLOWER_PLAINS("sunflower_plains", 129, "PLAIN"),
SUNFLOWER_PLAINS(new Identifier("minecraft", "sunflower_plains"), 129, "PLAIN"),

DESERT_MUTATED("desert_mutated", 130, "DESERT"),
DESERT_MUTATED(new Identifier("minecraft", "desert_mutated"), 130, "DESERT"),

EXTREME_HILLS_MUTATED("extreme_hills_mutated", 131, "EXTREME_HILLS"),
EXTREME_HILLS_MUTATED(new Identifier("minecraft", "extreme_hills_mutated"), 131, "EXTREME_HILLS"),

FLOWER_FOREST("flower_forest", 132, "FOREST"),
FLOWER_FOREST(new Identifier("minecraft", "flower_forest"), 132, "FOREST"),

TAIGA_MUTATED("taiga_mutated", 133, "TAIGA"),
TAIGA_MUTATED(new Identifier("minecraft", "taiga_mutated"), 133, "TAIGA"),

SWAMPLAND_MUTATED("swampland_mutated", 134, "SWAMP"),
SWAMPLAND_MUTATED(new Identifier("minecraft", "swampland_mutated"), 134, "SWAMP"),

ICE_PLAINS_SPIKES("ice_plains_spikes", 140, "ICE"),
ICE_PLAINS_SPIKES(new Identifier("minecraft", "ice_plains_spikes"), 140, "ICE"),

JUNGLE_MUTATED("jungle_mutated", 149, "JUNGLE"),
JUNGLE_MUTATED(new Identifier("minecraft", "jungle_mutated"), 149, "JUNGLE"),

JUNGLE_EDGE_MUTATED("jungle_edge_mutated", 151, "JUNGLE"),
JUNGLE_EDGE_MUTATED(new Identifier("minecraft", "jungle_edge_mutated"), 151, "JUNGLE"),

BIRCH_FOREST_MUTATED("birch_forest_mutated", 155, "FOREST"),
BIRCH_FOREST_MUTATED(new Identifier("minecraft", "birch_forest_mutated"), 155, "FOREST"),

BIRCH_FOREST_HILLS_MUTATED("birch_forest_hills_mutated", 156, "FOREST"),
BIRCH_FOREST_HILLS_MUTATED(new Identifier("minecraft", "birch_forest_hills_mutated"), 156, "FOREST"),

ROOFED_FOREST_MUTATED("roofed_forest_mutated", 157, "FOREST"),
ROOFED_FOREST_MUTATED(new Identifier("minecraft", "roofed_forest_mutated"), 157, "FOREST"),

COLD_TAIGA_MUTATED("cold_taiga_mutated", 158, "TAIGA"),
COLD_TAIGA_MUTATED(new Identifier("minecraft", "cold_taiga_mutated"), 158, "TAIGA"),

REDWOOD_TAIGA_MUTATED("redwood_taiga_mutated", 160, "TAIGA"),
REDWOOD_TAIGA_MUTATED(new Identifier("minecraft", "redwood_taiga_mutated"), 160, "TAIGA"),

REDWOOD_TAIGA_HILLS_MUTATED("redwood_taiga_hills_mutated", 161, "TAIGA"),
REDWOOD_TAIGA_HILLS_MUTATED(new Identifier("minecraft", "redwood_taiga_hills_mutated"), 161, "TAIGA"),

EXTREME_HILLS_PLUS_TREES_MUTATED("extreme_hills_plus_trees_mutated", 162, "EXTREME_HILLS"),
EXTREME_HILLS_PLUS_TREES_MUTATED(new Identifier("minecraft", "extreme_hills_plus_trees_mutated"), 162, "EXTREME_HILLS"),

SAVANNA_MUTATED("savanna_mutated", 163, "SAVANNA"),
SAVANNA_MUTATED(new Identifier("minecraft", "savanna_mutated"), 163, "SAVANNA"),

SAVANNA_PLATEAU_MUTATED("savanna_plateau_mutated", 164, "SAVANNA"),
SAVANNA_PLATEAU_MUTATED(new Identifier("minecraft", "savanna_plateau_mutated"), 164, "SAVANNA"),

MESA_BRYCE("mesa_bryce", 165, "MESA"),
MESA_BRYCE(new Identifier("minecraft", "mesa_bryce"), 165, "MESA"),

MESA_PLATEAU_STONE_MUTATED("mesa_plateau_stone_mutated", 166, "MESA"),
MESA_PLATEAU_STONE_MUTATED(new Identifier("minecraft", "mesa_plateau_stone_mutated"), 166, "MESA"),

MESA_PLATEAU_MUTATED("mesa_plateau_mutated", 167, "MESA"),
MESA_PLATEAU_MUTATED(new Identifier("minecraft", "mesa_plateau_mutated"), 167, "MESA"),

SOULSAND_VALLEY("soulsand_valley", 178, "DataDriven"),
SOULSAND_VALLEY(new Identifier("minecraft", "soulsand_valley"), 178, "DataDriven"),

CRIMSON_FOREST("crimson_forest", 179, "DataDriven"),
CRIMSON_FOREST(new Identifier("minecraft", "crimson_forest"), 179, "DataDriven"),

WARPED_FOREST("warped_forest", 180, "DataDriven"),
WARPED_FOREST(new Identifier("minecraft", "warped_forest"), 180, "DataDriven"),

BASALT_DELTAS("basalt_deltas", 181, "DataDriven"),
BASALT_DELTAS(new Identifier("minecraft", "basalt_deltas"), 181, "DataDriven"),

JAGGED_PEAKS("jagged_peaks", 182, "DataDriven"),
JAGGED_PEAKS(new Identifier("minecraft", "jagged_peaks"), 182, "DataDriven"),

FROZEN_PEAKS("frozen_peaks", 183, "DataDriven"),
FROZEN_PEAKS(new Identifier("minecraft", "frozen_peaks"), 183, "DataDriven"),

SNOWY_SLOPES("snowy_slopes", 184, "DataDriven"),
SNOWY_SLOPES(new Identifier("minecraft", "snowy_slopes"), 184, "DataDriven"),

GROVE("grove", 185, "DataDriven"),
GROVE(new Identifier("minecraft", "grove"), 185, "DataDriven"),

MEADOW("meadow", 186, "DataDriven"),
MEADOW(new Identifier("minecraft", "meadow"), 186, "DataDriven"),

LUSH_CAVES("lush_caves", 187, "DataDriven"),
LUSH_CAVES(new Identifier("minecraft", "lush_caves"), 187, "DataDriven"),

DRIPSTONE_CAVES("dripstone_caves", 188, "DataDriven"),
DRIPSTONE_CAVES(new Identifier("minecraft", "dripstone_caves"), 188, "DataDriven"),

STONY_PEAKS("stony_peaks", 189, "DataDriven"),
STONY_PEAKS(new Identifier("minecraft", "stony_peaks"), 189, "DataDriven"),

DEEP_DARK("deep_dark", 190, "DataDriven"),
DEEP_DARK(new Identifier("minecraft", "deep_dark"), 190, "DataDriven"),

MANGROVE_SWAMP("mangrove_swamp", 191, "DataDriven"),
MANGROVE_SWAMP(new Identifier("minecraft", "mangrove_swamp"), 191, "DataDriven"),

CHERRY_GROVE("cherry_grove", 192, "DataDriven");
CHERRY_GROVE(new Identifier("minecraft", "cherry_grove"), 192, "DataDriven");

private final String name;
private final Identifier identifier;

private final int id;

private final String type;

VanillaBiomeId(String name, int id, String type) {
this.name = name;
VanillaBiomeId(Identifier identifier, int id, String type) {
this.identifier = identifier;
this.id = id;
this.type = type;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cn.allay.api.datastruct;

import com.google.common.base.Preconditions;
import lombok.Getter;

import java.util.Arrays;

Expand All @@ -15,7 +14,6 @@
*/
public final class NibbleArray implements Cloneable {
private final int size;
@Getter
private final byte[] data;

public NibbleArray(int size) {
Expand Down Expand Up @@ -68,6 +66,10 @@ public void copyFrom(NibbleArray array) {
copyFrom(array.data);
}

public byte[] getData() {
return Arrays.copyOf(this.data, this.data.length);
}

@Override
protected NibbleArray clone() throws CloneNotSupportedException {
NibbleArray clone = (NibbleArray) super.clone();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cn.allay.api.world.biome;

import cn.allay.api.identifier.Identifier;

/**
* Allay Project 2023/6/3
*
* @author daoge_cmd
*/
public interface BiomeType {
String getName();
Identifier getIdentifier();

int getId();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.allay.api.world.chunk;

import cn.allay.api.world.heightmap.HeightMapType;
import org.jetbrains.annotations.Range;

/**
Expand All @@ -8,7 +9,7 @@
* @author Cool_Loong
*/
public interface HeightOperate {
void setHeight(@Range(from = 0, to = 15) int x, @Range(from = 0, to = 15) int z, int height);
void setHeight(HeightMapType type, @Range(from = 0, to = 15) int x, @Range(from = 0, to = 15) int z, int height);

int getHeight(@Range(from = 0, to = 15) int x, @Range(from = 0, to = 15) int z);
int getHeight(HeightMapType type, @Range(from = 0, to = 15) int x, @Range(from = 0, to = 15) int z);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.allay.server.world.chunk;
package cn.allay.api.world.heightmap;

/**
* Allay Project 2023/5/30
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cn.allay.api.world.heightmap;

/**
* Allay Project 2023/8/8
*
* @author Cool_Loong
*/
public enum HeightMapType {
WORLD_SURFACE;
}
11 changes: 8 additions & 3 deletions Allay-API/src/main/java/cn/allay/api/world/palette/Palette.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,16 @@ public void readFromStorageRuntime(ByteBuf byteBuf, RuntimeDataDeserializer<V> d
}

//仅Anvil使用
@SuppressWarnings("unchecked")
public <R> NbtMap toNBT(Function<V, R> converter) {
NbtMapBuilder builder = NbtMap.builder().putIntArray("data", this.bitArray.words());
List<R> list = this.palette.stream().map(converter).toList();
builder.putList("palette", (NbtType<R>) NbtType.byClass(list.get(0).getClass()), list);
return builder.build();
if (this.isEmpty()) {
return NbtMap.builder().putList("palette", (NbtType<R>) NbtType.byClass(list.get(0).getClass()), list).build();
} else {
NbtMapBuilder builder = NbtMap.builder().putIntArray("data", this.bitArray.words());
builder.putList("palette", (NbtType<R>) NbtType.byClass(list.get(0).getClass()), list);
return builder.build();
}
}


Expand Down
Loading

0 comments on commit 846e325

Please sign in to comment.