Skip to content

Commit

Permalink
feat: various changes for terra support
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jun 15, 2024
1 parent ea28683 commit f6a2fb2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ default NbtMap saveNBT() {

void addEnchantment(EnchantmentType enchantmentType, short level);

void removeEnchantment(EnchantmentType enchantmentType);

void removeAllEnchantments();

/**
* 获取破坏方块的加速倍数 <br>
* @param blockState 要破坏的方块
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.allaymc.api.world.generator;

import lombok.Getter;
import org.allaymc.api.world.Dimension;

/**
* Allay Project 2023/7/1
Expand All @@ -11,11 +12,16 @@
public abstract class WorldGenerator {

protected String preset;
protected Dimension dimension;

public WorldGenerator(String preset) {
this.preset = preset;
}

public void setDimension(Dimension dimension) {
this.dimension = dimension;
}

//empty chunk -> 各种 noise-> biome -> calc height map -> generate -> carvers
//feature -> structure place-> calc light -> spawn entity -> full
public abstract void generate(ChunkGenerateContext context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import org.allaymc.api.data.VanillaBlockId;
import org.allaymc.api.data.VanillaItemId;
import org.allaymc.api.data.VanillaMaterialTypes;
import org.allaymc.api.item.ItemHelper;
import org.allaymc.api.item.enchantment.SimpleEnchantmentInstance;
import org.allaymc.api.utils.AllayStringUtils;
import org.allaymc.api.utils.Identifier;
import org.allaymc.api.component.annotation.ComponentIdentifier;
import org.allaymc.api.component.annotation.ComponentedObject;
Expand Down Expand Up @@ -348,6 +346,16 @@ public void addEnchantment(EnchantmentType enchantmentType, short level) {
enchantments.put(enchantmentType, new SimpleEnchantmentInstance(enchantmentType, level));
}

@Override
public void removeEnchantment(EnchantmentType enchantmentType) {
enchantments.remove(enchantmentType);
}

@Override
public void removeAllEnchantments() {
enchantments.clear();
}

// 记录那些对工具品质有要求的方块的正确工具集合
private static final EnumMap<VanillaBlockId, VanillaItemId[]> CORRECT_TOOL_SPECIAL_MAP = new EnumMap<>(VanillaBlockId.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public AllayDimension(World world, WorldGenerator worldGenerator, DimensionInfo
this.world = world;
this.dimensionInfo = dimensionInfo;
this.worldGenerator = worldGenerator;
this.worldGenerator.setDimension(this);
this.chunkService = new AllayChunkService(this, world.getWorldStorage());
this.entityPhysicsService = new AllayEntityPhysicsService(this);
this.entityService = new AllayEntityService(entityPhysicsService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AllayWorldGeneratorFactory() {
}

protected void init() {
register("VOID", unused -> new VoidWorldGenerator());
register("VOID", VoidWorldGenerator::new);
register("FLAT", FlatWorldGenerator::new);
// TODO: Pass preset to je generator loader
register("JEGEN_OVERWORLD", preset -> JeGeneratorLoader.getJeGenerator(DimensionInfo.OVERWORLD));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* @author daoge_cmd
*/
public class VoidWorldGenerator extends WorldGenerator {
public VoidWorldGenerator() {
super("");
public VoidWorldGenerator(String preset) {
super(preset);
}

@Override
Expand Down

0 comments on commit f6a2fb2

Please sign in to comment.