fix: adapt allay update

* feat: update mapping files to latest
This commit is contained in:
Dmitry Luk 2024-12-16 23:28:19 +04:00
parent 1d3c380784
commit 9b6a503f31
25 changed files with 148 additions and 3573 deletions

View File

@ -13,7 +13,7 @@ object Versions {
const val caffeine = "3.1.8"
const val slf4j = "2.0.16"
object Internal {
const val shadow = "8.3.3"
const val apacheText = "1.12.0"
@ -31,7 +31,7 @@ object Versions {
const val fabricAPI = "0.106.1+${Mod.minecraft}"
const val cloud = "2.0.0-beta.9"
}
//
// object Quilt {
// const val quiltLoader = "0.20.2"
// const val fabricApi = "7.3.1+0.89.3-1.20.1"
@ -46,9 +46,8 @@ object Versions {
const val architecuryLoom = "1.7.413"
const val architecturyPlugin = "3.4.159"
}
//
// object Forge {
// const val forge = "${Mod.minecraft}-48.0.13"
// const val burningwave = "12.63.0"
@ -65,20 +64,19 @@ object Versions {
const val paperWeight = "1.7.2"
const val cloud = "2.0.0-beta.10"
}
//
// object Sponge {
// const val sponge = "9.0.0-SNAPSHOT"
// const val mixin = "0.8.2"
// const val minecraft = "1.17.1"
// }
//
object CLI {
const val logback = "1.5.8"
const val picocli = "4.7.6"
}
object Allay {
const val api = "0114e0b290"
const val api = "master-SNAPSHOT"
}
}

View File

@ -2,7 +2,7 @@
## Resource files
Current mapping version: je 1.21 to be 1.21.30
Current mapping version: je 1.21.4 to be 1.21.50
- `mapping/biomes.json` obtain from GeyserMC/mappings.
- `mapping/items.json` obtain from GeyserMC/mappings.

View File

@ -21,11 +21,11 @@ import com.dfsek.terra.api.handle.ItemHandle;
import com.dfsek.terra.api.handle.WorldHandle;
import com.dfsek.terra.api.world.biome.PlatformBiome;
/**
* @author daoge_cmd
*/
public class AllayPlatform extends AbstractPlatform {
public static final Set<AllayGeneratorWrapper> GENERATOR_WRAPPERS = new HashSet<>();
protected static final AllayWorldHandle ALLAY_WORLD_HANDLE = new AllayWorldHandle();
@ -47,7 +47,7 @@ public class AllayPlatform extends AbstractPlatform {
var dimension = wrapper.getAllayWorldGenerator().getDimension();
TerraAllayPlugin.INSTANCE.getPluginLogger().info(
"Replaced pack in chunk generator for world {}",
dimension.getWorld().getWorldData().getName() + ":" + dimension.getDimensionInfo().dimensionId()
dimension.getWorld().getWorldData().getDisplayName() + ":" + dimension.getDimensionInfo().dimensionId()
);
});
});
@ -82,12 +82,14 @@ public class AllayPlatform extends AbstractPlatform {
@Override
public void register(TypeRegistry registry) {
super.register(registry);
registry.registerLoader(BlockState.class, (type, o, loader, depthTracker) -> ALLAY_WORLD_HANDLE.createBlockState((String) o))
.registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker));
registry.registerLoader(BlockState.class, ($, o, $$, $$$) -> ALLAY_WORLD_HANDLE.createBlockState((String) o));
registry.registerLoader(PlatformBiome.class, ($, o, $$, depthTracker) -> parseBiome((String) o, depthTracker));
}
protected AllayBiome parseBiome(String id, DepthTracker depthTracker) throws LoadException {
if(!id.startsWith("minecraft:")) throw new LoadException("Invalid biome identifier " + id, depthTracker);
if(!id.startsWith("minecraft:")) {
throw new LoadException("Invalid biome identifier " + id, depthTracker);
}
return new AllayBiome(BiomeId.fromId(Mapping.biomeIdJeToBe(id)));
}
}

View File

@ -14,20 +14,12 @@ public class JeBlockState {
protected final TreeMap<String, String> properties;
protected int hash = Integer.MAX_VALUE;
public static JeBlockState fromString(String data) {
return new JeBlockState(data);
}
public static JeBlockState create(String identifier, TreeMap<String, String> properties) {
return new JeBlockState(identifier, properties);
}
private JeBlockState(String data) {
String[] strings = data.replace("[", ",").replace("]", ",").replace(" ", "").split(",");
this.identifier = strings[0];
this.properties = new TreeMap<>();
if (strings.length > 1) {
for (int i = 1; i < strings.length; i++) {
if(strings.length > 1) {
for(int i = 1; i < strings.length; i++) {
final String tmp = strings[i];
final int index = tmp.indexOf("=");
properties.put(tmp.substring(0, index), tmp.substring(index + 1));
@ -36,6 +28,19 @@ public class JeBlockState {
completeMissingProperties();
}
private JeBlockState(String identifier, TreeMap<String, String> properties) {
this.identifier = identifier;
this.properties = properties;
}
public static JeBlockState fromString(String data) {
return new JeBlockState(data);
}
public static JeBlockState create(String identifier, TreeMap<String, String> properties) {
return new JeBlockState(identifier, properties);
}
public String getPropertyValue(String key) {
return properties.get(key);
}
@ -45,13 +50,9 @@ public class JeBlockState {
if(properties.size() == defaultProperties.size()) {
return;
}
defaultProperties.entrySet().stream().filter(entry -> !properties.containsKey(entry.getKey())).forEach(
entry -> properties.put(entry.getKey(), entry.getValue()));
}
private JeBlockState(String identifier, TreeMap<String, String> properties) {
this.identifier = identifier;
this.properties = properties;
defaultProperties.entrySet().stream()
.filter(entry -> !properties.containsKey(entry.getKey()))
.forEach(entry -> properties.put(entry.getKey(), entry.getValue()));
}
public String toString(boolean includeProperties) {
@ -59,14 +60,14 @@ public class JeBlockState {
StringBuilder builder = new StringBuilder(identifier).append(";");
properties.forEach((k, v) -> builder.append(k).append("=").append(v).append(";"));
String str = builder.toString();
if (hash == Integer.MAX_VALUE) {
if(hash == Integer.MAX_VALUE) {
hash = HashUtils.fnv1a_32(str.getBytes());
}
return str;
}
public int getHash() {
if (hash == Integer.MAX_VALUE) {
if(hash == Integer.MAX_VALUE) {
hash = HashUtils.fnv1a_32(toString(true).getBytes());
}
return hash;

View File

@ -25,7 +25,6 @@ import java.util.TreeMap;
* @author daoge_cmd
*/
public final class Mapping {
private static final Map<String, Map<String, String>> JE_BLOCK_DEFAULT_PROPERTIES = new Object2ObjectOpenHashMap<>();
private static final Map<BlockState, JeBlockState> BLOCK_STATE_BE_TO_JE = new Object2ObjectOpenHashMap<>();
private static final Map<Integer, BlockState> BLOCK_STATE_JE_HASH_TO_BE = new Int2ObjectOpenHashMap<>();
@ -73,7 +72,7 @@ public final class Mapping {
public static Map<String, String> getJeBlockDefaultProperties(String jeBlockIdentifier) {
Map<String, String> defaultProperties = JE_BLOCK_DEFAULT_PROPERTIES.get(jeBlockIdentifier);
if( defaultProperties == null) {
if(defaultProperties == null) {
TerraAllayPlugin.INSTANCE.getPluginLogger().warn("Failed to find default properties for {}", jeBlockIdentifier);
return Map.of();
}
@ -85,12 +84,15 @@ public final class Mapping {
}
private static boolean initBiomeMapping() {
try (InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/biomes.json")) {
if (stream == null) {
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/biomes.json")) {
if(stream == null) {
TerraAllayPlugin.INSTANCE.getPluginLogger().error("biomes mapping not found");
return false;
}
Set<Entry<String, Map<String, Integer>>> mappings = JSONUtils.from(stream, new TypeToken<Map<String, Map<String, Integer>>>(){}).entrySet();
Set<Entry<String, Map<String, Integer>>> mappings = JSONUtils.from(
stream,
new TypeToken<Map<String, Map<String, Integer>>>() {}
).entrySet();
mappings.forEach(mapping -> BIOME_ID_JE_TO_BE.put(mapping.getKey(), mapping.getValue().get("bedrock_id")));
} catch(IOException e) {
TerraAllayPlugin.INSTANCE.getPluginLogger().error("Failed to load biomes mapping", e);
@ -100,12 +102,15 @@ public final class Mapping {
}
private static boolean initItemMapping() {
try (InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/items.json")) {
if (stream == null) {
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/items.json")) {
if(stream == null) {
TerraAllayPlugin.INSTANCE.getPluginLogger().error("items mapping not found");
return false;
}
Set<Entry<String, Map<String, Object>>> mappings = JSONUtils.from(stream, new TypeToken<Map<String, Map<String, Object>>>(){}).entrySet();
Set<Entry<String, Map<String, Object>>> mappings = JSONUtils.from(
stream,
new TypeToken<Map<String, Map<String, Object>>>() {}
).entrySet();
mappings.forEach(mapping -> {
ItemType<?> item = ItemTypeSafeGetter
.name((String) mapping.getValue().get("bedrock_identifier"))
@ -121,13 +126,16 @@ public final class Mapping {
}
private static boolean initBlockStateMapping() {
try (InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/blocks.json")) {
if (stream == null) {
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/blocks.json")) {
if(stream == null) {
TerraAllayPlugin.INSTANCE.getPluginLogger().error("blocks mapping not found");
return false;
}
// noinspection unchecked
List<Map<String, Map<String, Object>>> mappings = (List<Map<String, Map<String, Object>>>) JSONUtils.from(stream, new TypeToken<Map<String, Object>>(){}).get("mappings");
List<Map<String, Map<String, Object>>> mappings = (List<Map<String, Map<String, Object>>>) JSONUtils.from(
stream,
new TypeToken<Map<String, Object>>() {}
).get("mappings");
mappings.forEach(mapping -> {
JeBlockState jeState = createJeBlockState(mapping.get("java_state"));
BlockState beState = createBeBlockState(mapping.get("bedrock_state"));
@ -141,12 +149,12 @@ public final class Mapping {
}
private static boolean initJeBlockDefaultProperties() {
try (InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("je_block_default_states.json")) {
if (stream == null) {
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("je_block_default_states.json")) {
if(stream == null) {
TerraAllayPlugin.INSTANCE.getPluginLogger().error("je_block_default_states.json not found");
return false;
}
Map<String, Map<String, String>> states = JSONUtils.from(stream, new TypeToken<Map<String, Map<String, String>>>(){});
Map<String, Map<String, String>> states = JSONUtils.from(stream, new TypeToken<>() {});
for(Entry<String, Map<String, String>> entry : states.entrySet()) {
String identifier = entry.getKey();
Map<String, String> properties = entry.getValue();
@ -159,9 +167,8 @@ public final class Mapping {
}
private static BlockState createBeBlockState(Map<String, Object> data) {
Getter getter = BlockStateSafeGetter
.name("minecraft:" + data.get("bedrock_identifier"));
if (data.containsKey("state")) {
Getter getter = BlockStateSafeGetter.name("minecraft:" + data.get("bedrock_identifier"));
if(data.containsKey("state")) {
// noinspection unchecked
convertValueType((Map<String, Object>) data.get("state")).forEach(getter::property);
}
@ -170,8 +177,8 @@ public final class Mapping {
private static Map<String, Object> convertValueType(Map<String, Object> data) {
TreeMap<String, Object> result = new TreeMap<>();
for (Entry<String, Object> entry : data.entrySet()) {
if (entry.getValue() instanceof Number number) {
for(Entry<String, Object> entry : data.entrySet()) {
if(entry.getValue() instanceof Number number) {
// Convert double to int because the number in json is double
result.put(entry.getKey(), number.intValue());
} else {
@ -183,6 +190,7 @@ public final class Mapping {
private static JeBlockState createJeBlockState(Map<String, Object> data) {
// noinspection unchecked
return JeBlockState.create((String) data.get("Name"), new TreeMap<>((Map<String, String>) data.getOrDefault("Properties", Map.of())));
return JeBlockState.create((String) data.get("Name"),
new TreeMap<>((Map<String, String>) data.getOrDefault("Properties", Map.of())));
}
}

View File

@ -40,9 +40,8 @@ public class TerraAllayPlugin extends Plugin {
AllayGeneratorWrapper wrapper = new AllayGeneratorWrapper(preset);
AllayPlatform.GENERATOR_WRAPPERS.add(wrapper);
return wrapper.getAllayWorldGenerator();
} catch (IllegalArgumentException e) {
TerraAllayPlugin.INSTANCE.getPluginLogger().error("Fail to create world generator with preset: {}", preset);
TerraAllayPlugin.INSTANCE.getPluginLogger().error("Reason: {}", e.getMessage());
} catch(IllegalArgumentException e) {
TerraAllayPlugin.INSTANCE.getPluginLogger().error("Fail to create world generator with preset: {}", preset, e);
return Registries.WORLD_GENERATOR_FACTORIES.get("FLAT").apply("");
}
});
@ -71,6 +70,8 @@ public class TerraAllayPlugin extends Plugin {
@EventHandler
private void onWorldUnload(WorldUnloadEvent event) {
AllayPlatform.GENERATOR_WRAPPERS.removeIf(wrapper -> wrapper.getAllayWorldGenerator().getDimension().getWorld() == event.getWorld());
AllayPlatform.GENERATOR_WRAPPERS.removeIf(
wrapper -> wrapper.getAllayWorldGenerator().getDimension().getWorld() == event.getWorld()
);
}
}

View File

@ -4,6 +4,7 @@ import org.allaymc.api.world.biome.BiomeType;
import com.dfsek.terra.api.world.biome.PlatformBiome;
/**
* @author daoge_cmd
*/

View File

@ -7,13 +7,15 @@ import com.dfsek.terra.allay.JeBlockState;
import com.dfsek.terra.api.block.BlockType;
import com.dfsek.terra.api.block.state.properties.Property;
/**
* @author daoge_cmd
*/
public final class AllayBlockState implements com.dfsek.terra.api.block.state.BlockState {
public static final AllayBlockState AIR = new AllayBlockState(BlockTypes.AIR.getDefaultState(),
JeBlockState.fromString("minecraft:air"));
public static final AllayBlockState AIR = new AllayBlockState(
BlockTypes.AIR.getDefaultState(),
JeBlockState.fromString("minecraft:air")
);
private final BlockState allayBlockState;
private final JeBlockState jeBlockState;
@ -66,9 +68,15 @@ public final class AllayBlockState implements com.dfsek.terra.api.block.state.Bl
return allayBlockState;
}
public BlockState allayBlockState() { return allayBlockState; }
public BlockState allayBlockState() {
return allayBlockState;
}
public boolean containsWater() { return containsWater; }
public boolean containsWater() {
return containsWater;
}
public JeBlockState jeBlockState() { return jeBlockState; }
public JeBlockState jeBlockState() {
return jeBlockState;
}
}

View File

@ -6,6 +6,7 @@ import org.allaymc.api.block.type.BlockType;
import com.dfsek.terra.allay.Mapping;
import com.dfsek.terra.api.block.state.BlockState;
/**
* @author daoge_cmd
*/
@ -17,7 +18,7 @@ public record AllayBlockType(BlockType<?> allayBlockType) implements com.dfsek.t
@Override
public boolean isSolid() {
return allayBlockType.getMaterial().isSolid();
return allayBlockType.getDefaultState().getBlockStateData().isSolid();
}
@Override

View File

@ -10,19 +10,20 @@ import com.dfsek.terra.allay.Mapping;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.world.ServerWorld;
/**
* @author daoge_cmd
*/
public record AllayChunk(ServerWorld world, Chunk allayChunk) implements com.dfsek.terra.api.world.chunk.Chunk {
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0));
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(
BlockPropertyTypes.LIQUID_DEPTH.createValue(0)
);
@Override
public void setBlock(int x, int y, int z, BlockState data, boolean physics) {
AllayBlockState allayBlockState = (AllayBlockState) data;
allayChunk.setBlockState(x, y, z, allayBlockState.allayBlockState());
boolean containsWater = allayBlockState.containsWater() || allayChunk.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER);
if (containsWater) {
if(allayBlockState.containsWater() || allayChunk.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER)) {
allayChunk.setBlockState(x, y, z, WATER, 1);
}
}

View File

@ -6,18 +6,19 @@ import com.dfsek.terra.allay.Mapping;
import com.dfsek.terra.api.inventory.ItemStack;
import com.dfsek.terra.api.inventory.item.Enchantment;
/**
* @author daoge_cmd
*/
public record AllayEnchantment(EnchantmentType allayEnchantment) implements Enchantment {
@Override
public boolean canEnchantItem(ItemStack itemStack) {
return ((AllayItemStack)itemStack).allayItemStack().checkEnchantmentCompatibility(allayEnchantment);
return ((AllayItemStack) itemStack).allayItemStack().checkEnchantmentCompatibility(allayEnchantment);
}
@Override
public boolean conflictsWith(Enchantment other) {
return ((AllayEnchantment)other).allayEnchantment.isIncompatibleWith(allayEnchantment);
return ((AllayEnchantment) other).allayEnchantment.isIncompatibleWith(allayEnchantment);
}
@Override

View File

@ -4,6 +4,7 @@ import com.dfsek.terra.api.entity.Entity;
import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.ServerWorld;
/**
* NOTICE: Entity is not supported currently, and this is a fake implementation.
*

View File

@ -10,6 +10,7 @@ import java.util.Map;
import com.dfsek.terra.api.inventory.item.Enchantment;
import com.dfsek.terra.api.inventory.item.ItemMeta;
/**
* @author daoge_cmd
*/
@ -23,7 +24,7 @@ public record AllayItemMeta(ItemStack allayItemStack) implements ItemMeta {
@Override
public Map<Enchantment, Integer> getEnchantments() {
Map<Enchantment, Integer> results = new HashMap<>();
for (EnchantmentInstance allayEnchantmentInstance : allayItemStack.getEnchantments()) {
for(EnchantmentInstance allayEnchantmentInstance : allayItemStack.getEnchantments()) {
results.put(new AllayEnchantment(allayEnchantmentInstance.getType()), allayEnchantmentInstance.getLevel());
}
return results;

View File

@ -6,10 +6,11 @@ import org.allaymc.api.item.enchantment.EnchantmentInstance;
import com.dfsek.terra.api.inventory.Item;
import com.dfsek.terra.api.inventory.item.ItemMeta;
/**
* @author daoge_cmd
*/
public record AllayItemStack(ItemStack allayItemStack) implements com.dfsek.terra.api.inventory.ItemStack{
public record AllayItemStack(ItemStack allayItemStack) implements com.dfsek.terra.api.inventory.ItemStack {
@Override
public int getAmount() {
return allayItemStack.getCount();
@ -34,7 +35,7 @@ public record AllayItemStack(ItemStack allayItemStack) implements com.dfsek.terr
public void setItemMeta(ItemMeta meta) {
ItemStack targetItem = ((AllayItemMeta) meta).allayItemStack();
allayItemStack.removeAllEnchantments();
for (EnchantmentInstance enchantment : targetItem.getEnchantments()) {
for(EnchantmentInstance enchantment : targetItem.getEnchantments()) {
allayItemStack.addEnchantment(enchantment.getType(), enchantment.getLevel());
}
allayItemStack.setLore(targetItem.getLore());

View File

@ -10,12 +10,14 @@ import com.dfsek.terra.allay.Mapping;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
/**
* @author daoge_cmd
*/
public record AllayProtoChunk(UnsafeChunk allayChunk) implements ProtoChunk {
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0));
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(
BlockPropertyTypes.LIQUID_DEPTH.createValue(0)
);
@Override
public int getMaxHeight() {
@ -26,8 +28,7 @@ public record AllayProtoChunk(UnsafeChunk allayChunk) implements ProtoChunk {
public void setBlock(int x, int y, int z, @NotNull BlockState blockState) {
AllayBlockState allayBlockState = (AllayBlockState) blockState;
allayChunk.setBlockState(x, y, z, allayBlockState.allayBlockState());
boolean containsWater = allayBlockState.containsWater() || allayChunk.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER);
if (containsWater) {
if(allayBlockState.containsWater() || allayChunk.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER)) {
allayChunk.setBlockState(x, y, z, WATER, 1);
}
}

View File

@ -17,12 +17,14 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
/**
* @author daoge_cmd
*/
public record AllayProtoWorld(AllayServerWorld allayServerWorld, OtherChunkAccessibleContext context) implements ProtoWorld {
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0));
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(
BlockPropertyTypes.LIQUID_DEPTH.createValue(0)
);
@Override
public int centerChunkX() {
@ -41,10 +43,11 @@ public record AllayProtoWorld(AllayServerWorld allayServerWorld, OtherChunkAcces
@Override
public void setBlockState(int x, int y, int z, BlockState data, boolean physics) {
AllayBlockState allayBlockState = (AllayBlockState)data;
boolean containsWater = allayBlockState.containsWater() || context.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER);
AllayBlockState allayBlockState = (AllayBlockState) data;
context.setBlockState(x, y, z, allayBlockState.allayBlockState());
if (containsWater) context.setBlockState(x, y, z, WATER, 1);
if(allayBlockState.containsWater() || context.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER)) {
context.setBlockState(x, y, z, WATER, 1);
}
}
@Override

View File

@ -1,7 +1,5 @@
package com.dfsek.terra.allay.delegate;
import org.allaymc.api.block.property.type.BlockPropertyTypes;
import org.allaymc.api.block.type.BlockTypes;
import org.allaymc.api.world.Dimension;
import com.dfsek.terra.allay.Mapping;
@ -17,16 +15,14 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import com.dfsek.terra.api.world.chunk.Chunk;
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
/**
* @author daoge_cmd
*/
public record AllayServerWorld(AllayGeneratorWrapper allayGeneratorWrapper, Dimension allayDimension) implements ServerWorld {
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0));
@Override
public Chunk getChunkAt(int x, int z) {
return new AllayChunk(this, allayDimension.getChunkService().getChunk(x ,z));
return new AllayChunk(this, allayDimension.getChunkService().getChunk(x, z));
}
@Override

View File

@ -24,11 +24,11 @@ import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
import com.dfsek.terra.api.world.chunk.generation.util.GeneratorWrapper;
import com.dfsek.terra.api.world.info.WorldProperties;
/**
* @author daoge_cmd
*/
public class AllayGeneratorWrapper implements GeneratorWrapper {
protected static final String OPTION_PACK_NAME = "pack";
protected static final String OPTION_SEED = "seed";
@ -46,6 +46,7 @@ public class AllayGeneratorWrapper implements GeneratorWrapper {
if(packName == null) {
throw new IllegalArgumentException("Missing config pack name");
}
this.seed = Long.parseLong(options.getOrDefault(OPTION_SEED, "0"));
this.configPack = getConfigPack(packName);
this.chunkGenerator = createGenerator(this.configPack);
@ -59,7 +60,6 @@ public class AllayGeneratorWrapper implements GeneratorWrapper {
.onDimensionSet(dimension -> {
this.allayServerWorld = new AllayServerWorld(this, dimension);
this.worldProperties = new WorldProperties() {
private final Object fakeHandle = new Object();
@Override
@ -82,8 +82,19 @@ public class AllayGeneratorWrapper implements GeneratorWrapper {
return fakeHandle;
}
};
})
.build();
}).build();
}
protected static ConfigPack getConfigPack(String packName) {
Optional<ConfigPack> byId = TerraAllayPlugin.PLATFORM.getConfigRegistry().getByID(packName);
return byId.orElseGet(
() -> TerraAllayPlugin.PLATFORM.getConfigRegistry().getByID(packName.toUpperCase(Locale.ENGLISH))
.orElseThrow(() -> new IllegalArgumentException("Cant find terra config pack named " + packName))
);
}
protected static ChunkGenerator createGenerator(ConfigPack configPack) {
return configPack.getGeneratorProvider().newInstance(configPack);
}
@Override
@ -112,8 +123,8 @@ public class AllayGeneratorWrapper implements GeneratorWrapper {
return this.allayWorldGenerator;
}
protected class AllayNoiser implements Noiser {
protected class AllayNoiser implements Noiser {
@Override
public boolean apply(NoiseContext context) {
UnsafeChunk chunk = context.getCurrentChunk();
@ -145,8 +156,8 @@ public class AllayGeneratorWrapper implements GeneratorWrapper {
}
}
protected class AllayPopulator implements Populator {
protected class AllayPopulator implements Populator {
@Override
public boolean apply(PopulateContext context) {
AllayProtoWorld tmp = new AllayProtoWorld(allayServerWorld, context);
@ -165,16 +176,4 @@ public class AllayGeneratorWrapper implements GeneratorWrapper {
return "TERRA_POPULATOR";
}
}
protected static ConfigPack getConfigPack(String packName) {
Optional<ConfigPack> byId = TerraAllayPlugin.PLATFORM.getConfigRegistry().getByID(packName);
return byId.orElseGet(
() -> TerraAllayPlugin.PLATFORM.getConfigRegistry().getByID(packName.toUpperCase(Locale.ENGLISH))
.orElseThrow(() -> new IllegalArgumentException("Cant find terra config pack named " + packName))
);
}
protected static ChunkGenerator createGenerator(ConfigPack configPack) {
return configPack.getGeneratorProvider().newInstance(configPack);
}
}

View File

@ -13,6 +13,7 @@ import com.dfsek.terra.api.handle.ItemHandle;
import com.dfsek.terra.api.inventory.Item;
import com.dfsek.terra.api.inventory.item.Enchantment;
/**
* @author daoge_cmd
*/

View File

@ -9,11 +9,11 @@ import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.entity.EntityType;
import com.dfsek.terra.api.handle.WorldHandle;
/**
* @author daoge_cmd
*/
public class AllayWorldHandle implements WorldHandle {
@Override
public @NotNull BlockState createBlockState(@NotNull String data) {
JeBlockState jeBlockState = JeBlockState.fromString(data);
@ -29,6 +29,7 @@ public class AllayWorldHandle implements WorldHandle {
public @NotNull EntityType getEntity(@NotNull String id) {
return new EntityType() {
private final Object fakeEntityType = new Object();
@Override
public Object getHandle() {
return fakeEntityType;

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{ "minecraft:badlands": { "bedrock_id": 37 }, "minecraft:bamboo_jungle": { "bedrock_id": 48 }, "minecraft:basalt_deltas": { "bedrock_id": 181 }, "minecraft:beach": { "bedrock_id": 16 }, "minecraft:birch_forest": { "bedrock_id": 27 }, "minecraft:cherry_grove": { "bedrock_id": 192 }, "minecraft:cold_ocean": { "bedrock_id": 44 }, "minecraft:crimson_forest": { "bedrock_id": 179 }, "minecraft:dark_forest": { "bedrock_id": 29 }, "minecraft:deep_cold_ocean": { "bedrock_id": 45 }, "minecraft:deep_dark": { "bedrock_id": 190 }, "minecraft:deep_frozen_ocean": { "bedrock_id": 47 }, "minecraft:deep_lukewarm_ocean": { "bedrock_id": 43 }, "minecraft:deep_ocean": { "bedrock_id": 24 }, "minecraft:desert": { "bedrock_id": 2 }, "minecraft:dripstone_caves": { "bedrock_id": 188 }, "minecraft:end_barrens": { "bedrock_id": 9 }, "minecraft:end_highlands": { "bedrock_id": 9 }, "minecraft:end_midlands": { "bedrock_id": 9 }, "minecraft:eroded_badlands": { "bedrock_id": 165 }, "minecraft:flower_forest": { "bedrock_id": 132 }, "minecraft:forest": { "bedrock_id": 4 }, "minecraft:frozen_ocean": { "bedrock_id": 46 }, "minecraft:frozen_peaks": { "bedrock_id": 183 }, "minecraft:frozen_river": { "bedrock_id": 11 }, "minecraft:grove": { "bedrock_id": 185 }, "minecraft:ice_spikes": { "bedrock_id": 140 }, "minecraft:jagged_peaks": { "bedrock_id": 182 }, "minecraft:jungle": { "bedrock_id": 21 }, "minecraft:lukewarm_ocean": { "bedrock_id": 42 }, "minecraft:lush_caves": { "bedrock_id": 187 }, "minecraft:mangrove_swamp": { "bedrock_id": 191 }, "minecraft:meadow": { "bedrock_id": 186 }, "minecraft:mushroom_fields": { "bedrock_id": 14 }, "minecraft:nether_wastes": { "bedrock_id": 8 }, "minecraft:ocean": { "bedrock_id": 0 }, "minecraft:old_growth_birch_forest": { "bedrock_id": 155 }, "minecraft:old_growth_pine_taiga": { "bedrock_id": 32 }, "minecraft:old_growth_spruce_taiga": { "bedrock_id": 160 }, "minecraft:plains": { "bedrock_id": 1 }, "minecraft:river": { "bedrock_id": 7 }, "minecraft:savanna": { "bedrock_id": 35 }, "minecraft:savanna_plateau": { "bedrock_id": 36 }, "minecraft:small_end_islands": { "bedrock_id": 9 }, "minecraft:snowy_beach": { "bedrock_id": 26 }, "minecraft:snowy_plains": { "bedrock_id": 12 }, "minecraft:snowy_slopes": { "bedrock_id": 184 }, "minecraft:snowy_taiga": { "bedrock_id": 30 }, "minecraft:soul_sand_valley": { "bedrock_id": 178 }, "minecraft:sparse_jungle": { "bedrock_id": 23 }, "minecraft:stony_peaks": { "bedrock_id": 189 }, "minecraft:stony_shore": { "bedrock_id": 25 }, "minecraft:sunflower_plains": { "bedrock_id": 129 }, "minecraft:swamp": { "bedrock_id": 6 }, "minecraft:taiga": { "bedrock_id": 5 }, "minecraft:the_end": { "bedrock_id": 9 }, "minecraft:the_void": { "bedrock_id": 7 }, "minecraft:warm_ocean": { "bedrock_id": 40 }, "minecraft:warped_forest": { "bedrock_id": 180 }, "minecraft:windswept_forest": { "bedrock_id": 34 }, "minecraft:windswept_gravelly_hills": { "bedrock_id": 131 }, "minecraft:windswept_hills": { "bedrock_id": 3 }, "minecraft:windswept_savanna": { "bedrock_id": 163 }, "minecraft:wooded_badlands": { "bedrock_id": 38 } }
{"minecraft:badlands":{"bedrock_id":37},"minecraft:bamboo_jungle":{"bedrock_id":48},"minecraft:basalt_deltas":{"bedrock_id":181},"minecraft:beach":{"bedrock_id":16},"minecraft:birch_forest":{"bedrock_id":27},"minecraft:cherry_grove":{"bedrock_id":192},"minecraft:cold_ocean":{"bedrock_id":44},"minecraft:crimson_forest":{"bedrock_id":179},"minecraft:dark_forest":{"bedrock_id":29},"minecraft:deep_cold_ocean":{"bedrock_id":45},"minecraft:deep_dark":{"bedrock_id":190},"minecraft:deep_frozen_ocean":{"bedrock_id":47},"minecraft:deep_lukewarm_ocean":{"bedrock_id":43},"minecraft:deep_ocean":{"bedrock_id":24},"minecraft:desert":{"bedrock_id":2},"minecraft:dripstone_caves":{"bedrock_id":188},"minecraft:end_barrens":{"bedrock_id":9},"minecraft:end_highlands":{"bedrock_id":9},"minecraft:end_midlands":{"bedrock_id":9},"minecraft:eroded_badlands":{"bedrock_id":165},"minecraft:flower_forest":{"bedrock_id":132},"minecraft:forest":{"bedrock_id":4},"minecraft:frozen_ocean":{"bedrock_id":46},"minecraft:frozen_peaks":{"bedrock_id":183},"minecraft:frozen_river":{"bedrock_id":11},"minecraft:grove":{"bedrock_id":185},"minecraft:ice_spikes":{"bedrock_id":140},"minecraft:jagged_peaks":{"bedrock_id":182},"minecraft:jungle":{"bedrock_id":21},"minecraft:lukewarm_ocean":{"bedrock_id":42},"minecraft:lush_caves":{"bedrock_id":187},"minecraft:mangrove_swamp":{"bedrock_id":191},"minecraft:meadow":{"bedrock_id":186},"minecraft:mushroom_fields":{"bedrock_id":14},"minecraft:nether_wastes":{"bedrock_id":8},"minecraft:ocean":{"bedrock_id":0},"minecraft:old_growth_birch_forest":{"bedrock_id":155},"minecraft:old_growth_pine_taiga":{"bedrock_id":32},"minecraft:old_growth_spruce_taiga":{"bedrock_id":160},"minecraft:pale_garden":{"bedrock_id":62},"minecraft:plains":{"bedrock_id":1},"minecraft:river":{"bedrock_id":7},"minecraft:savanna":{"bedrock_id":35},"minecraft:savanna_plateau":{"bedrock_id":36},"minecraft:small_end_islands":{"bedrock_id":9},"minecraft:snowy_beach":{"bedrock_id":26},"minecraft:snowy_plains":{"bedrock_id":12},"minecraft:snowy_slopes":{"bedrock_id":184},"minecraft:snowy_taiga":{"bedrock_id":30},"minecraft:soul_sand_valley":{"bedrock_id":178},"minecraft:sparse_jungle":{"bedrock_id":23},"minecraft:stony_peaks":{"bedrock_id":189},"minecraft:stony_shore":{"bedrock_id":25},"minecraft:sunflower_plains":{"bedrock_id":129},"minecraft:swamp":{"bedrock_id":6},"minecraft:taiga":{"bedrock_id":5},"minecraft:the_end":{"bedrock_id":9},"minecraft:the_void":{"bedrock_id":7},"minecraft:warm_ocean":{"bedrock_id":40},"minecraft:warped_forest":{"bedrock_id":180},"minecraft:windswept_forest":{"bedrock_id":34},"minecraft:windswept_gravelly_hills":{"bedrock_id":131},"minecraft:windswept_hills":{"bedrock_id":3},"minecraft:windswept_savanna":{"bedrock_id":163},"minecraft:wooded_badlands":{"bedrock_id":38}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,17 @@
{
"entrance": "com.dfsek.terra.allay.TerraAllayPlugin",
"name": "Terra",
"authors": ["daoge_cmd", "dfsek", "duplexsystem", "Astrash", "solonovamax", "Sancires", "Aureus", "RogueShade"],
"authors": [
"daoge_cmd",
"IWareQ",
"dfsek",
"duplexsystem",
"Astrash",
"solonovamax",
"Sancires",
"Aureus",
"RogueShade"
],
"version": "@VERSION@",
"description": "@DESCRIPTION@",
"website": "@WIKI@"