Minestom Latest - Update (#499)

* Bukkit Build Fix

* remove comments

* remove papermc repo from gradle settings

* add back gradle shasum

* fix formatting, update gradle hash

* 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.

* Bug Fix - Entity Type was parsing a value that was incorrect and causing issues to load the world.

EntityType.fromId(Integer.parseInt(id));
to
delegate = EntityType.fromKey(id);

* Reverted changes to comply with build version requirements and avoiding pulling functionality out of a common existing function

---------

Co-authored-by: Peter Pan <peter@never.lan>
Co-authored-by: Zoë Gidiere <duplexsys@protonmail.com>
This commit is contained in:
kyuri 2025-06-05 06:38:42 +01:00 committed by GitHub
parent 28d93d158e
commit e79ea4ab82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 40 additions and 25 deletions

View File

@ -87,6 +87,6 @@ object Versions {
}
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.world.MinestomChunkGeneratorWrapper;
import com.dfsek.terra.minestom.world.MinestomWorldHandle;
import com.dfsek.terra.registry.master.ConfigRegistry.PackLoadFailuresException;
import net.minestom.server.MinecraftServer;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
public final class MinestomPlatform extends AbstractPlatform {
@ -51,7 +55,7 @@ public final class MinestomPlatform extends AbstractPlatform {
if(world.generator() instanceof MinestomChunkGeneratorWrapper wrapper) {
getConfigRegistry().get(wrapper.getPack().getRegistryKey()).ifPresent(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());
});
}
});
@ -59,6 +63,7 @@ public final class MinestomPlatform extends AbstractPlatform {
return succeed;
}
@Override
public @NotNull WorldHandle getWorldHandle() {
return worldHandle;
@ -83,11 +88,10 @@ public final class MinestomPlatform extends AbstractPlatform {
return file;
}
public static MinestomPlatform getInstance() {
if(INSTANCE == null) {
INSTANCE = new MinestomPlatform();
}
return INSTANCE;
}
}
}

View File

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

View File

@ -24,14 +24,14 @@ public class MinestomBlockState implements BlockState {
public MinestomBlockState(String data) {
if(!data.contains("[")) {
block = Block.fromNamespaceId(data);
block = Block.fromKey(data);
return;
}
String[] split = data.split("\\[");
String namespaceId = split[0];
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<>();
for(String property : properties.split(",")) {
@ -70,7 +70,7 @@ public class MinestomBlockState implements BlockState {
@Override
public String getAsString(boolean properties) {
String name = block.namespace().asString();
String name = block.key().asString();
if(!properties || block.properties().isEmpty()) {
return name;
}
@ -95,4 +95,4 @@ public class MinestomBlockState implements BlockState {
public int hashCode() {
return Objects.hashCode(block.id());
}
}
}

View File

@ -1,18 +1,16 @@
package com.dfsek.terra.minestom.entity;
import net.minestom.server.entity.EntityType;
public class MinestomEntityType implements com.dfsek.terra.api.entity.EntityType {
private final EntityType delegate;
public MinestomEntityType(String id) {
delegate = EntityType.fromNamespaceId(id);
delegate = EntityType.fromKey(id);
}
@Override
public EntityType getHandle() {
return delegate;
}
}
}

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.item.Enchantment;
import net.kyori.adventure.key.Key;
import net.minestom.server.MinecraftServer;
import net.minestom.server.item.Material;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.registry.DynamicRegistry;
import java.util.Objects;
@ -16,11 +17,13 @@ public class MinestomEnchantment implements Enchantment {
public MinestomEnchantment(net.minestom.server.item.enchant.Enchantment 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) {
this.delegate = MinecraftServer.getEnchantmentRegistry().get(NamespaceID.from(id));
Key key = Key.key(id);
this.delegate = MinecraftServer.getEnchantmentRegistry().get(key);
this.id = id;
}
@ -31,7 +34,19 @@ public class MinestomEnchantment implements Enchantment {
@Override
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
@ -48,4 +63,4 @@ public class MinestomEnchantment implements Enchantment {
public net.minestom.server.item.enchant.Enchantment getHandle() {
return delegate;
}
}
}

View File

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