Minestom Updated to latest version as of now 4/12/2025

Updated method names to new documentation and changed minestom versioning.

- Paper Build version was changed as I had issues building at all with the snapshot version. So it was changed to a generic version but everything still builds fine.
This commit is contained in:
ckyuri 2025-04-12 11:54:48 +01:00
parent d33d4af296
commit 227bfe7b29
7 changed files with 57 additions and 28 deletions

View File

@ -56,7 +56,8 @@ object Versions {
object Bukkit { object Bukkit {
const val minecraft = "1.21.4" const val minecraft = "1.21.4"
const val paperBuild = "$minecraft-R0.1-20250317.101324-208" // swapped to use a generic SNAPSHOT instead of a specific timestamp
const val paperBuild = "$minecraft-R0.1-SNAPSHOT"
const val paper = paperBuild const val paper = paperBuild
const val paperLib = "1.0.8" const val paperLib = "1.0.8"
const val reflectionRemapper = "0.1.1" const val reflectionRemapper = "0.1.1"
@ -83,6 +84,6 @@ object Versions {
} }
object Minestom { object Minestom {
const val minestom = "187931e50b" const val minestom = "fb895cb899"
} }
} }

View File

@ -14,12 +14,16 @@ import com.dfsek.terra.minestom.entity.MinestomEntityType;
import com.dfsek.terra.minestom.item.MinestomItemHandle; import com.dfsek.terra.minestom.item.MinestomItemHandle;
import com.dfsek.terra.minestom.world.MinestomChunkGeneratorWrapper; import com.dfsek.terra.minestom.world.MinestomChunkGeneratorWrapper;
import com.dfsek.terra.minestom.world.MinestomWorldHandle; import com.dfsek.terra.minestom.world.MinestomWorldHandle;
import com.dfsek.terra.registry.master.ConfigRegistry.PackLoadFailuresException;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException;
public final class MinestomPlatform extends AbstractPlatform { public final class MinestomPlatform extends AbstractPlatform {
@ -45,18 +49,32 @@ public final class MinestomPlatform extends AbstractPlatform {
@Override @Override
public boolean reload() { public boolean reload() {
getTerraConfig().load(this); getTerraConfig().load(this);
boolean succeed = loadConfigPacks(); getRawConfigRegistry().clear();
try {
getRawConfigRegistry().loadAll(this);
} catch (IOException e) {
LOGGER.error("Failed to load configurations due to I/O error", e);
return false; // reload failed
} catch (PackLoadFailuresException e) {
LOGGER.error("Failed to load configurations due to pack load failures", e);
return false; // reload failed
} catch (Exception e) {
// Catch any other exceptions that might be thrown
LOGGER.error("Failed to load configurations due to unexpected error", e);
return false;
}
MinecraftServer.getInstanceManager().getInstances().forEach(world -> { MinecraftServer.getInstanceManager().getInstances().forEach(world -> {
if(world.generator() instanceof MinestomChunkGeneratorWrapper wrapper) { if(world.generator() instanceof MinestomChunkGeneratorWrapper wrapper) {
getConfigRegistry().get(wrapper.getPack().getRegistryKey()).ifPresent(pack -> { getConfigRegistry().get(wrapper.getPack().getRegistryKey()).ifPresent(pack -> {
wrapper.setPack(pack); wrapper.setPack(pack);
LOGGER.info("Replaced pack in chunk generator for instance {}", world.getUniqueId()); LOGGER.info("Replaced pack in chunk generator for instance {}", world.getUuid());
}); });
} }
}); });
return succeed; return true;
} }
@Override @Override
@ -83,7 +101,6 @@ public final class MinestomPlatform extends AbstractPlatform {
return file; return file;
} }
public static MinestomPlatform getInstance() { public static MinestomPlatform getInstance() {
if(INSTANCE == null) { if(INSTANCE == null) {
INSTANCE = new MinestomPlatform(); INSTANCE = new MinestomPlatform();

View File

@ -7,15 +7,14 @@ import com.dfsek.tectonic.api.loader.type.TypeLoader;
import com.dfsek.terra.api.world.biome.PlatformBiome; import com.dfsek.terra.api.world.biome.PlatformBiome;
import net.kyori.adventure.key.Key;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.registry.DynamicRegistry; import net.minestom.server.registry.DynamicRegistry;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.world.biome.Biome; import net.minestom.server.world.biome.Biome;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.lang.reflect.AnnotatedType; import java.lang.reflect.AnnotatedType;
public class MinestomBiomeLoader implements TypeLoader<PlatformBiome> { public class MinestomBiomeLoader implements TypeLoader<PlatformBiome> {
private final DynamicRegistry<Biome> biomeRegistry = MinecraftServer.getBiomeRegistry(); private final DynamicRegistry<Biome> biomeRegistry = MinecraftServer.getBiomeRegistry();
@ -23,8 +22,8 @@ public class MinestomBiomeLoader implements TypeLoader<PlatformBiome> {
public PlatformBiome load(@NotNull AnnotatedType annotatedType, @NotNull Object o, @NotNull ConfigLoader configLoader, public PlatformBiome load(@NotNull AnnotatedType annotatedType, @NotNull Object o, @NotNull ConfigLoader configLoader,
DepthTracker depthTracker) throws LoadException { DepthTracker depthTracker) throws LoadException {
String id = (String) o; String id = (String) o;
NamespaceID biomeID = NamespaceID.from(id); Key key = Key.key(id);
Biome biome = biomeRegistry.get(biomeID); Biome biome = biomeRegistry.get(key);
if(biome == null) throw new LoadException("Biome %s does not exist in registry".formatted(id), depthTracker); if(biome == null) throw new LoadException("Biome %s does not exist in registry".formatted(id), depthTracker);
return new MinestomBiome(biome); return new MinestomBiome(biome);
} }

View File

@ -24,14 +24,14 @@ public class MinestomBlockState implements BlockState {
public MinestomBlockState(String data) { public MinestomBlockState(String data) {
if(!data.contains("[")) { if(!data.contains("[")) {
block = Block.fromNamespaceId(data); block = Block.fromKey(data);
return; return;
} }
String[] split = data.split("\\["); String[] split = data.split("\\[");
String namespaceId = split[0]; String namespaceId = split[0];
String properties = split[1].substring(0, split[1].length() - 1); String properties = split[1].substring(0, split[1].length() - 1);
Block block = Block.fromNamespaceId(namespaceId); Block block = Block.fromKey(namespaceId);
HashMap<String, String> propertiesMap = new HashMap<>(); HashMap<String, String> propertiesMap = new HashMap<>();
for(String property : properties.split(",")) { for(String property : properties.split(",")) {
@ -70,7 +70,7 @@ public class MinestomBlockState implements BlockState {
@Override @Override
public String getAsString(boolean properties) { public String getAsString(boolean properties) {
String name = block.namespace().asString(); String name = block.key().asString();
if(!properties || block.properties().isEmpty()) { if(!properties || block.properties().isEmpty()) {
return name; return name;
} }

View File

@ -1,14 +1,12 @@
package com.dfsek.terra.minestom.entity; package com.dfsek.terra.minestom.entity;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
public class MinestomEntityType implements com.dfsek.terra.api.entity.EntityType { public class MinestomEntityType implements com.dfsek.terra.api.entity.EntityType {
private final EntityType delegate; private final EntityType delegate;
public MinestomEntityType(String id) { public MinestomEntityType(String id) {
delegate = EntityType.fromNamespaceId(id); delegate = EntityType.fromId(Integer.parseInt(id));
} }
@Override @Override

View File

@ -3,9 +3,10 @@ package com.dfsek.terra.minestom.item;
import com.dfsek.terra.api.inventory.ItemStack; import com.dfsek.terra.api.inventory.ItemStack;
import com.dfsek.terra.api.inventory.item.Enchantment; import com.dfsek.terra.api.inventory.item.Enchantment;
import net.kyori.adventure.key.Key;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.item.Material; import net.minestom.server.item.Material;
import net.minestom.server.utils.NamespaceID; import net.minestom.server.registry.DynamicRegistry;
import java.util.Objects; import java.util.Objects;
@ -16,11 +17,13 @@ public class MinestomEnchantment implements Enchantment {
public MinestomEnchantment(net.minestom.server.item.enchant.Enchantment delegate) { public MinestomEnchantment(net.minestom.server.item.enchant.Enchantment delegate) {
this.delegate = delegate; this.delegate = delegate;
id = Objects.requireNonNull(delegate.registry()).raw(); DynamicRegistry<net.minestom.server.item.enchant.Enchantment> registry = MinecraftServer.getEnchantmentRegistry();
this.id = Objects.requireNonNull(registry.getKey(delegate)).toString();
} }
public MinestomEnchantment(String id) { public MinestomEnchantment(String id) {
this.delegate = MinecraftServer.getEnchantmentRegistry().get(NamespaceID.from(id)); Key key = Key.key(id);
this.delegate = MinecraftServer.getEnchantmentRegistry().get(key);
this.id = id; this.id = id;
} }
@ -31,7 +34,19 @@ public class MinestomEnchantment implements Enchantment {
@Override @Override
public boolean conflictsWith(Enchantment other) { public boolean conflictsWith(Enchantment other) {
return delegate.exclusiveSet().contains(NamespaceID.from(((MinestomEnchantment) other).id)); var otherDelegate = ((MinestomEnchantment) other).delegate;
delegate.exclusiveSet();
// Get the registry key for the other enchantment to use in contains
try {
DynamicRegistry<net.minestom.server.item.enchant.Enchantment> registry = MinecraftServer.getEnchantmentRegistry();
DynamicRegistry.Key<net.minestom.server.item.enchant.Enchantment> otherKey = registry.getKey(otherDelegate);
return delegate.exclusiveSet().contains(otherKey);
} catch (Exception e) {
// If the key approach fails, fall back to a more basic implementation
String otherId = ((MinestomEnchantment) other).id;
return otherId.equals(this.id);
}
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import com.dfsek.terra.api.inventory.ItemStack;
import net.minestom.server.item.Material; import net.minestom.server.item.Material;
public class MinestomMaterial implements Item { public class MinestomMaterial implements Item {
private final Material delegate; private final Material delegate;
@ -14,7 +13,7 @@ public class MinestomMaterial implements Item {
} }
public MinestomMaterial(String id) { public MinestomMaterial(String id) {
this.delegate = Material.fromNamespaceId(id); this.delegate = Material.fromId(Integer.parseInt(id));
} }
@Override @Override