diff --git a/Allay-API/src/main/java/org/allaymc/api/item/component/common/ItemBaseComponent.java b/Allay-API/src/main/java/org/allaymc/api/item/component/common/ItemBaseComponent.java index e9ed6f449..49d2cabc5 100644 --- a/Allay-API/src/main/java/org/allaymc/api/item/component/common/ItemBaseComponent.java +++ b/Allay-API/src/main/java/org/allaymc/api/item/component/common/ItemBaseComponent.java @@ -148,6 +148,10 @@ default NbtMap saveNBT() { void addEnchantment(EnchantmentType enchantmentType, short level); + void removeEnchantment(EnchantmentType enchantmentType); + + void removeAllEnchantments(); + /** * 获取破坏方块的加速倍数
* @param blockState 要破坏的方块 diff --git a/Allay-API/src/main/java/org/allaymc/api/world/generator/WorldGenerator.java b/Allay-API/src/main/java/org/allaymc/api/world/generator/WorldGenerator.java index 7a3c71d82..a7add7069 100644 --- a/Allay-API/src/main/java/org/allaymc/api/world/generator/WorldGenerator.java +++ b/Allay-API/src/main/java/org/allaymc/api/world/generator/WorldGenerator.java @@ -1,6 +1,7 @@ package org.allaymc.api.world.generator; import lombok.Getter; +import org.allaymc.api.world.Dimension; /** * Allay Project 2023/7/1 @@ -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); diff --git a/Allay-Server/src/main/java/org/allaymc/server/item/component/common/ItemBaseComponentImpl.java b/Allay-Server/src/main/java/org/allaymc/server/item/component/common/ItemBaseComponentImpl.java index 5c3627a5f..8341858c1 100644 --- a/Allay-Server/src/main/java/org/allaymc/server/item/component/common/ItemBaseComponentImpl.java +++ b/Allay-Server/src/main/java/org/allaymc/server/item/component/common/ItemBaseComponentImpl.java @@ -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; @@ -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 CORRECT_TOOL_SPECIAL_MAP = new EnumMap<>(VanillaBlockId.class); diff --git a/Allay-Server/src/main/java/org/allaymc/server/world/AllayDimension.java b/Allay-Server/src/main/java/org/allaymc/server/world/AllayDimension.java index 7d38c04b9..7583424a7 100644 --- a/Allay-Server/src/main/java/org/allaymc/server/world/AllayDimension.java +++ b/Allay-Server/src/main/java/org/allaymc/server/world/AllayDimension.java @@ -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); diff --git a/Allay-Server/src/main/java/org/allaymc/server/world/generator/AllayWorldGeneratorFactory.java b/Allay-Server/src/main/java/org/allaymc/server/world/generator/AllayWorldGeneratorFactory.java index 955c677e2..727122ccf 100644 --- a/Allay-Server/src/main/java/org/allaymc/server/world/generator/AllayWorldGeneratorFactory.java +++ b/Allay-Server/src/main/java/org/allaymc/server/world/generator/AllayWorldGeneratorFactory.java @@ -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)); diff --git a/Allay-Server/src/main/java/org/allaymc/server/world/generator/VoidWorldGenerator.java b/Allay-Server/src/main/java/org/allaymc/server/world/generator/VoidWorldGenerator.java index fd5176b09..c48cf341b 100644 --- a/Allay-Server/src/main/java/org/allaymc/server/world/generator/VoidWorldGenerator.java +++ b/Allay-Server/src/main/java/org/allaymc/server/world/generator/VoidWorldGenerator.java @@ -12,8 +12,8 @@ * @author daoge_cmd */ public class VoidWorldGenerator extends WorldGenerator { - public VoidWorldGenerator() { - super(""); + public VoidWorldGenerator(String preset) { + super(preset); } @Override