feat: fetch allay's changes

This commit is contained in:
daoge_cmd
2024-07-24 20:30:24 +08:00
parent 2443fff0a4
commit 4acd0de6fa
5 changed files with 10 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
repositories {
mavenLocal()
maven("https://www.jitpack.io/")
}
dependencies {

View File

@@ -6,9 +6,9 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.extern.slf4j.Slf4j;
import org.allaymc.api.block.property.type.BlockPropertyType.BlockPropertyValue;
import org.allaymc.api.block.registry.BlockTypeRegistry;
import org.allaymc.api.block.type.BlockState;
import org.allaymc.api.block.type.BlockTypes;
import org.allaymc.api.registry.Registries;
import org.allaymc.api.utils.Identifier;
import org.allaymc.api.utils.JSONUtils;
@@ -117,7 +117,7 @@ public final class Mapping {
private static BlockState createBeBlockState(Map<String, Object> data) {
var identifier = new Identifier((String) data.get("bedrock_identifier"));
// 方块类型
var blockType = BlockTypeRegistry.getRegistry().get(identifier);
var blockType = Registries.BLOCKS.get(identifier);
// 方块属性
Map<String, Object> state = (Map<String, Object>) data.get("state");
if (state == null) return blockType.getDefaultState();

View File

@@ -2,7 +2,7 @@ package org.allaymc.terra.allay;
import lombok.extern.slf4j.Slf4j;
import org.allaymc.api.plugin.Plugin;
import org.allaymc.api.world.generator.WorldGeneratorFactory;
import org.allaymc.api.registry.Registries;
import org.allaymc.terra.allay.generator.AllayGeneratorWrapper;
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
@@ -36,7 +36,7 @@ public class TerraAllayPlugin extends Plugin {
PLATFORM.getEventManager().callEvent(new PlatformInitializationEvent());
log.info("Registering generator...");
WorldGeneratorFactory.getFactory().register("TERRA", preset -> new AllayGeneratorWrapper(preset).getAllayWorldGenerator());
Registries.WORLD_GENERATOR_FACTORIES.register("TERRA", preset -> new AllayGeneratorWrapper(preset).getAllayWorldGenerator());
log.info("Terra started");
}

View File

@@ -43,6 +43,6 @@ public final class AllayFakeEntity implements Entity {
@Override
public Object getHandle() {
return null;
return fakeHandle;
}
}

View File

@@ -1,7 +1,6 @@
package org.allaymc.terra.allay.handle;
import org.allaymc.api.item.enchantment.EnchantmentRegistry;
import org.allaymc.api.item.registry.ItemTypeRegistry;
import org.allaymc.api.registry.Registries;
import org.allaymc.api.utils.Identifier;
import org.allaymc.terra.allay.Mapping;
import org.allaymc.terra.allay.delegate.AllayEnchantment;
@@ -23,17 +22,17 @@ import com.dfsek.terra.api.inventory.item.Enchantment;
public class AllayItemHandle implements ItemHandle {
@Override
public Item createItem(String data) {
return new AllayItemType(ItemTypeRegistry.getRegistry().get(new Identifier(Mapping.itemIdJeToBe(data))));
return new AllayItemType(Registries.ITEMS.get(new Identifier(Mapping.itemIdJeToBe(data))));
}
@Override
public Enchantment getEnchantment(String id) {
return new AllayEnchantment(EnchantmentRegistry.getRegistry().getByK2(new Identifier(Mapping.enchantmentIdJeToBe(id))));
return new AllayEnchantment(Registries.ENCHANTMENTS.getByK2(new Identifier(Mapping.enchantmentIdJeToBe(id))));
}
@Override
public Set<Enchantment> getEnchantments() {
return EnchantmentRegistry.getRegistry().getContent().m1().values().stream()
return Registries.ENCHANTMENTS.getContent().m1().values().stream()
.map(AllayEnchantment::new)
.collect(Collectors.toSet());
}